/*
 * ════════════════════════════════════════════════════════════
 *  PRODUCT DETAIL PAGE — LAYOUT FIX
 *  File: assets/css/product-fix.css
 *  Include AFTER main.css in header.php
 *  Pure CSS override — zero PHP / JS changes.
 * ════════════════════════════════════════════════════════════
 *
 *  PROBLEMS FIXED
 *  1. .pd-layout used hard minmax() floors (300 + 360 = 660 min)
 *     → overflowed on 700-1100 px viewports.
 *  2. 14 thumbnails in a single non-wrapping flex row
 *     → scrolled / overflowed outside the card.
 *  3. object-fit: cover distorted tall product images.
 *  4. align-items: start caused mismatched column heights.
 *  5. .pd-info-panel gap:12px created uneven internal spacing.
 *  6. No responsive rules between 768-1200 px for product page.
 *  7. Mobile stacking lacked max-width / centering for gallery.
 * ════════════════════════════════════════════════════════════
 */


/* ──────────────────────────────────────────────────────────
   1. TWO-COLUMN GRID  — use fraction units so it can shrink
   ────────────────────────────────────────────────────────── */
.pd-layout {
  display: grid;
  grid-template-columns: minmax(0, 45fr) minmax(0, 55fr);
  gap: 40px;
  padding: 32px 0 60px;
  align-items: start;          /* info panel stays top-anchored */
}


/* ──────────────────────────────────────────────────────────
   2. MAIN IMAGE CONTAINER
   — square aspect-ratio keeps it compact; contain prevents
     tall/narrow product images from being cropped.
   ────────────────────────────────────────────────────────── */
.pd-gallery-main {
  width: 100%;
  aspect-ratio: 1 / 1;           /* square: looks great for soaps */
  border-radius: 20px;
  overflow: hidden;
  background: linear-gradient(160deg, #fdf8ef 0%, #f6ede4 100%);
  margin-bottom: 14px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.09);
  border: 1px solid rgba(122, 85, 48, 0.08);
  position: relative;
}

.pd-gallery-main img {
  width: 100%;
  height: 100%;
  object-fit: contain;           /* CHANGED: cover → contain (no crop) */
  display: block;
  transition: opacity 0.3s ease;
}


/* ──────────────────────────────────────────────────────────
   3. THUMBNAIL STRIP
   — wrap so 14 thumbs never overflow; two-row scrollable
     area (max-height ≈ 2 rows).
   ────────────────────────────────────────────────────────── */
.pd-thumbs {
  display: flex;
  flex-wrap: wrap;               /* CHANGED: was not wrapping */
  gap: 8px;
  margin-top: 10px;
  max-height: 156px;             /* fits ~2 rows (66px + 8px gap) */
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: rgba(122,85,48,0.25) transparent;
}

.pd-thumbs::-webkit-scrollbar          { width: 4px; }
.pd-thumbs::-webkit-scrollbar-thumb    { background: rgba(122,85,48,0.25); border-radius: 4px; }
.pd-thumbs::-webkit-scrollbar-track    { background: transparent; }

.pd-thumb {
  width: 66px;
  height: 66px;
  border-radius: 10px;
  overflow: hidden;
  border: 2px solid transparent;
  cursor: pointer;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
  background: var(--cream);
  flex-shrink: 0;
}

.pd-thumb:hover  { border-color: var(--brown-light); box-shadow: 0 2px 8px rgba(0,0,0,0.10); }
.pd-thumb.active { border-color: var(--brown-dark);  box-shadow: 0 2px 8px rgba(0,0,0,0.14); }

.pd-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}


/* ──────────────────────────────────────────────────────────
   4. INFO PANEL
   — sticky while scrolling through product details;
     padding and spacing tuned for visual balance.
   ────────────────────────────────────────────────────────── */
.pd-info-panel {
  background: #fff;
  padding: 28px 30px 30px;
  border-radius: 24px;
  border: 1px solid rgba(122, 85, 48, 0.12);
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.07);
  display: flex;
  flex-direction: column;
  gap: 0;                         /* CHANGED: individual margins control spacing */
  position: sticky;
  top: calc(var(--header-h, 70px) + 20px);
  height: fit-content;
}


/* ──────────────────────────────────────────────────────────
   5. INDIVIDUAL SPACING INSIDE INFO PANEL
   — precise margins replacing the blanket gap: 12px
   ────────────────────────────────────────────────────────── */
.pd-cat-label    { margin-bottom: 6px; }
.pd-title        {
  font-size: clamp(1.55rem, 2.4vw, 2.4rem);
  line-height: 1.2;
  margin-bottom: 6px;
}
.pd-tagline      { margin-bottom: 12px; }
.pd-rating-row   { margin-bottom: 14px; }
.pd-price-row    { margin-bottom: 4px; }
.pd-price-note   { margin-top: -2px; margin-bottom: 16px; }
.pd-desc         { margin-bottom: 18px; }
.pd-benefits     { margin-bottom: 18px; }
.pd-qty          { margin-bottom: 16px; }
.pd-actions      { margin-bottom: 22px; }


/* ──────────────────────────────────────────────────────────
   6. RESPONSIVE — 900–1200 px  (small laptop / tablet land.)
   — keep two columns but let them breathe
   ────────────────────────────────────────────────────────── */
@media (max-width: 1200px) and (min-width: 769px) {
  .pd-layout {
    grid-template-columns: 1fr 1fr;   /* equal columns */
    gap: 28px;
    padding: 24px 0 48px;
  }
  .pd-info-panel {
    padding: 22px 22px 24px;
  }
}


/* ──────────────────────────────────────────────────────────
   7. RESPONSIVE — ≤ 768 px  (tablet portrait / phone)
   — stack layout; centre gallery; un-stick panel
   ────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .pd-layout {
    grid-template-columns: 1fr;
    gap: 22px;
    padding: 18px 0 36px;
  }

  .pd-gallery-main {
    max-width: 440px;              /* don't let it fill a wide phone */
    margin-left: auto;
    margin-right: auto;
    border-radius: 16px;
  }

  .pd-thumbs {
    max-width: 440px;
    margin-left: auto;
    margin-right: auto;
    justify-content: center;
    max-height: none;              /* let thumbs expand freely on mobile */
    overflow-y: visible;
  }

  .pd-info-panel {
    position: static;              /* no sticky on mobile */
    padding: 20px;
    border-radius: 18px;
  }

  .pd-title {
    font-size: clamp(1.3rem, 5vw, 1.8rem);
  }
}


/* ──────────────────────────────────────────────────────────
   8. RESPONSIVE — ≤ 480 px  (small phones)
   ────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .pd-layout { padding: 14px 0 28px; gap: 16px; }

  .pd-gallery-main {
    border-radius: 12px;
    max-width: 100%;
  }

  .pd-thumb {
    width: 56px;
    height: 56px;
    border-radius: 8px;
  }

  .pd-info-panel {
    padding: 16px;
    border-radius: 14px;
  }

  .pd-title { font-size: 1.3rem; }

  .pd-price-now { font-size: clamp(1.4rem, 6vw, 1.8rem); }

  .pd-actions { gap: 10px; }

  .pd-actions .btn-lg {
    padding: 12px 18px;
    font-size: 14px;
  }

  .pd-meta {
    grid-template-columns: 1fr;   /* stack meta rows on tiny screens */
  }

  .pd-qty button { width: 32px; height: 32px; font-size: 18px; }
}


/* ──────────────────────────────────────────────────────────
   9. RESPONSIVE — ≤ 360 px  (very small phones)
   ────────────────────────────────────────────────────────── */
@media (max-width: 360px) {
  .pd-thumb { width: 48px; height: 48px; }
  .pd-info-panel { padding: 14px; }
  .pd-title  { font-size: 1.2rem; }
}
