/* Shared product modal — storefront + admin.
   Equal-height columns; whole card scales to fit viewport (no scroll).
   Visual language matches /css/common/theme.css */

#productDialog {
  width: max-content;
  max-width: none;
  max-height: none;
  margin: auto;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--text-primary, #000000);
  overflow: hidden;
}

#productDialog::backdrop {
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.product-dialog-scale {
  display: block;
  overflow: hidden;
  width: max-content;
  height: auto;
}

/* Fixed desktop card — content scrolls inside; outer size stays stable */
.product-dialog-shell {
  display: block;
  box-sizing: border-box;
  width: 960px;
  height: 640px;
  max-width: none;
  overflow: hidden;
  transform-origin: top left;
  background: var(--panel-bg, #FFFFFF);
  border: 1px solid var(--border, #000000);
  color: var(--text-primary, #000000);
  box-shadow: none;
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.product-dialog-grid {
  display: flex;
  align-items: stretch;
  width: 100%;
  height: 100%;
}

/* Left media plane — fixed column, fills card height */
.product-dialog-media {
  position: relative;
  display: flex;
  flex: 0 0 540px;
  flex-direction: column;
  width: 540px;
  min-width: 0;
  min-height: 0;
  align-self: stretch;
  background: #E5E5E5;
  border-right: 1px solid var(--border, #000000);
}

.product-dialog-media-frame {
  position: relative;
  flex: 1 1 auto;
  width: 100%;
  min-height: 0;
  overflow: hidden;
  background: #E5E5E5;
}

.product-dialog-media-frame > img,
.product-dialog-photo {
  position: absolute;
  inset: 0;
  display: block;
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
}

.product-dialog-placeholder {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted, #4A4A4A);
  font-size: 0.8rem;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

/* Right content column — desktop: pinned tools + CTA, middle scrolls */
.product-dialog-body {
  display: flex;
  flex: 0 0 420px;
  flex-direction: column;
  width: 420px;
  min-width: 0;
  min-height: 0;
  height: 100%;
  overflow: hidden;
  padding: 1.35rem 1.6rem 1.5rem;
  box-sizing: border-box;
  gap: 0;
}

.product-dialog-tools {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
  position: relative;
  z-index: 2;
  margin: 0 0 0.25rem;
  background: var(--panel-bg, #FFFFFF);
}

.product-dialog-scroll {
  flex: 1 1 auto;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
}

.product-dialog-body > .product-dialog-cta,
.product-dialog-body > #saveProduct,
.product-dialog-body > #addToCartButton {
  position: static;
  z-index: 2;
  margin-top: 1rem;
  flex-shrink: 0;
}

.product-dialog-tools button,
#shareProduct,
#closeDialog {
  border: 1px solid var(--border, #000000);
  background: var(--panel-bg, #FFFFFF);
  color: var(--text-primary, #000000);
  padding: 0.4rem 0.75rem;
  font: inherit;
  font-size: 0.75rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: none;
}

.product-dialog-tools button:hover {
  background: var(--hover-bg, #F8F8F8);
}

.product-dialog-kicker {
  margin: 1.5rem 0 0;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.16em;
  text-transform: uppercase;
  color: var(--muted, #4A4A4A);
}

.product-dialog-cta {
  flex-shrink: 0;
  box-sizing: border-box;
  width: 100%;
  padding: 0.85rem 1.1rem;
  border: 1px solid var(--cta-bg, #000000);
  background: var(--cta-bg, #000000);
  color: var(--cta-text, #FFFFFF);
  font: inherit;
  font-size: 0.92rem;
  font-weight: 500;
  cursor: pointer;
}

.product-dialog-cta:hover {
  background: #1A1A1A;
}

@media (max-width: 767px) {
  /* Match storefront mobile: near full viewport width, stacked */
  #productDialog {
    width: min(920px, calc(100vw - 1.25rem));
    max-width: min(920px, calc(100vw - 1.25rem));
    margin: max(0.5rem, env(safe-area-inset-top, 0px)) auto
      max(0.5rem, env(safe-area-inset-bottom, 0px));
  }

  .product-dialog-scale {
    width: 100% !important;
    height: auto !important;
    max-height: calc(var(--vv-height, 100svh) - 1.5rem - env(safe-area-inset-top, 0px) - env(safe-area-inset-bottom, 0px));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
  }

  .product-dialog-shell {
    flex-direction: column;
    width: 100%;
    height: auto;
    max-width: none;
    transform: none !important;
  }

  .product-dialog-grid {
    flex-direction: column;
    width: 100%;
    height: auto;
  }

  .product-dialog-media,
  .product-dialog-body {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    height: auto;
  }

  .product-dialog-media {
    min-height: 0;
    background: #E5E5E5;
    border-right: 0;
    border-bottom: 1px solid var(--border, #000000);
  }

  .product-dialog-media-frame {
    flex: 0 0 auto;
    aspect-ratio: 1 / 1;
    min-height: 0;
    background: #E5E5E5;
  }

  .product-dialog-body {
    padding: 1.15rem 1.25rem 1.35rem;
    overflow: visible;
    height: auto;
  }

  /* Mobile keeps a single flowing column; scale wrapper scrolls the whole card. */
  .product-dialog-scroll {
    flex: none;
    min-height: 0;
    overflow: visible;
  }

  .product-dialog-body > .product-dialog-cta,
  .product-dialog-body > #saveProduct,
  .product-dialog-body > #addToCartButton {
    position: static;
    margin-top: 1.5rem;
  }
}

body[data-theme="dark"] .product-dialog-tools {
  background: #000000;
}

body[data-theme="dark"] .product-dialog-shell {
  background: #000000;
  border-color: #E5E5E5;
  color: #FFFFFF;
}

body[data-theme="dark"] .product-dialog-media,
body[data-theme="dark"] .product-dialog-media-frame {
  background: #1A1A1A;
  border-color: #E5E5E5;
}

body[data-theme="dark"] .product-dialog-placeholder,
body[data-theme="dark"] .product-dialog-kicker {
  color: #A0A0A0;
}

body[data-theme="dark"] .product-dialog-tools button {
  background: #000000;
  border-color: #E5E5E5;
  color: #FFFFFF;
}

body[data-theme="dark"] .product-dialog-tools button:hover {
  background: #1A1A1A;
}

body[data-theme="dark"] .product-dialog-cta {
  background: #FFFFFF;
  border-color: #FFFFFF;
  color: #000000;
}

body[data-theme="dark"] .product-dialog-cta:hover {
  background: #E5E5E5;
}
