/* =============== BASE (DESKTOP FIRST) =============== */

body {
  font-family: 'Segoe UI', sans-serif;
  margin: 0;
  padding: 0;
  background: #f4f4f9;
}

.container {
  width: 90%;
  max-width: 1200px;
  margin: 40px auto;
  padding: 40px 20px;
  background: #fff;
  box-shadow: 0 4px 20px rgba(0,0,0,0.05);
  border-radius: 12px;
}

.product-details {
  display: flex;
  flex-wrap: wrap;
  gap: 40px;
  margin-bottom: 30px;
}

/* Desktop gallery layout: thumbnails on the side */
.product-images {
  flex: 1;
  display: flex;
  flex-direction: row-reverse;
  gap: 20px;
  align-items: flex-start;
}

.zoom-container {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-product-image {
  width: 420px;
  height: 483px;
  object-fit: cover;
  border-radius: 10px;
  box-shadow: 0 6px 18px rgba(0,0,0,0.1);
}

/* Thumbnails (desktop column) */
.thumbnail-gallery {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.thumbnail-gallery img {
  width: 60px;
  height: auto;
  cursor: pointer;
  border-radius: 6px;
  border: 1px solid #ccc;
  transition: transform 0.3s ease;
}
.thumbnail-gallery img:hover { transform: scale(1.1); }
.thumbnail.active { border: 2px solid #6a1b9a; }

/* Desktop zoom bits (hidden by default; enabled via JS if you want) */
#zoom-lens {
  position: absolute;
  width: 120px; height: 120px;
  pointer-events: none;
  display: none;
  z-index: 10;
  border: 1px solid #333;
  background-color: rgba(255,255,255,0.2);
  box-shadow: 0 0 3px rgba(0,0,0,0.4);
}
#zoom-viewer {
  display: none;
  position: absolute;
  top: 0; left: 100%;
  width: 520px; height: 483px;
  margin-left: 20px;
  background-repeat: no-repeat;
  background-size: 1200px auto;
  border: 1px solid #ccc;
  border-radius: 10px;
  z-index: 100;
  box-shadow: 0 0 10px rgba(0,0,0,0.25);
}

/* Product info (shared) */
.product-info { flex: 1; }
.product-info p { font-size: 1rem; color: #555; margin: 8px 0; }
.product-info h2 { font-size: 2.2rem; color: #222; font-weight: 700; margin: 5px 0 10px; }

.rating { font-size: 14px; color: #ffb400; margin-bottom: 10px; }

.price { font-size: 1.5rem; margin-top: 5px; }
.old-price { font-size: 1rem; color: #999; text-decoration: line-through; margin-right: 8px; }
.new-price { font-size: 1.4rem; color: #6a1b9a; font-weight: 700; }
.stock-status {
  font-size: 13px; background: #28a745; color: #fff;
  padding: 3px 10px; border-radius: 999px; margin-left: 10px;
}

.color-options, .size-options { margin: 20px 0; }
.color-box {
  width: 30px; height: 30px; display: inline-block; border-radius: 50%;
  cursor: pointer; margin-right: 10px; border: 2px solid transparent; transition: transform 0.2s;
}
.color-box:hover, .color-box.selected { border-color: #7209b7; transform: scale(1.1); }

.size-btn {
  padding: 10px 16px; margin-right: 10px;
  border: 1px solid #888; border-radius: 6px; background: #fff;
  cursor: pointer; font-weight: 500; transition: .2s;
}
.size-btn:hover, .size-btn.selected { border-color: #7209b7; background: #f1e8fc; }

.cart-actions { display: flex; gap: 15px; align-items: center; margin: 20px 0; }
#quantity-select {
  padding: 6px 10px; border-radius: 6px; border: 1px solid #ccc; font-size: 14px;
}

.add-to-cart {
  display: flex; align-items: center; gap: 8px;
  background: #6a1b9a; color: #fff; padding: 10px 18px;
  font-weight: 600; border-radius: 8px; border: none; font-size: 15px;
  box-shadow: 0 4px 14px rgba(106,27,154,.2); transition: .3s;
}
.add-to-cart:hover { background: #560bad; box-shadow: 0 6px 20px rgba(86,11,173,.3); }

/* Inline wishlist button (desktop) */
.wishlist-btn2 { background: transparent; border: none; cursor: pointer; padding: 8px; }
.wishlist-btn2 i { font-size: 20px; color: #000; transition: color .3s; }
.wishlist-btn2:hover i { color: red; }

/* Social share */
.social-share { display: flex; align-items: center; gap: 14px; margin-top: 15px; }
.social-share p { margin: 0; font-weight: 600; color: #333; }
.social-share a { font-size: 20px; color: #6a1b9a; transition: .3s; }
.social-share a:hover { color: #d63384; transform: scale(1.15); }


/* Tabs */
.product-tabs { display: flex; margin-top: 30px; border-bottom: 2px solid #ccc; }
.tab {
  background: none; border: none; padding: 12px 20px;
  font-size: 16px; color: #555; cursor: pointer; transition: color .3s;
}
.tab:hover { color: #7209b7; }
.tab.active { color: #7209b7; font-weight: 700; border-bottom: 3px solid #7209b7; }

.tab-content { display: none; padding: 20px; font-size: 15px; color: #333; background: #fafafa; border-radius: 8px; margin-top: -1px; border: 1px solid #eee; }
.tab-content.active { display: block; }

.tab-section { padding: 20px; font-size: 15px; color: #333; background: #fafafa; border-radius: 8px; margin-top: 20px; border: 1px solid #eee; }

/* Related products */
.related-products-wrapper {
  width: 90%; max-width: 1200px; margin: 40px auto; padding: 30px;
  background: #fff; border-radius: 12px; box-shadow: 0 4px 20px rgba(0,0,0,.06);
}
.related-title {
  font-size: 24px; font-weight: 700; color: #222;
  margin-bottom: 20px; border-bottom: 2px solid #7209b7; padding-bottom: 8px;
}
.related-products { display: flex; flex-wrap: wrap; gap: 20px; }
.product-card {
  background: #fff; padding: 15px; border-radius: 10px; width: 220px;
  box-shadow: 0 3px 12px rgba(0,0,0,.05); transition: transform .3s;
}
.product-card:hover { transform: translateY(-5px); }
.product-card img { width: 100%; border-radius: 6px; }

/* Floating wishlist (hidden on desktop; shown on mobile) */
.wishlist-fab { display: none; }

/* =============== MOBILE (≤768px) =============== */

@media (max-width: 768px) {
  .container {
    width: 100%;
    max-width: 100%;
    margin: 12px auto;
    padding: 12px;
    box-shadow: none;
    border-radius: 0;
  }

  .product-details { flex-direction: column; gap: 14px; }

  /* Stack image first; keep heart inside the rounded image */
  .product-images {
    flex-direction: column;
    align-items: center;
    gap: 10px;
  }
  .main-image {
    order: 1;
    width: 100%;
    max-width: 430px;
    margin: 6px auto 8px;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
  }
  .main-image .main-product-image {
    width: 100% !important;
    height: auto !important;
    aspect-ratio: 4 / 5;
    max-height: 340px;
    object-fit: cover;
    border-radius: 12px;
    box-shadow: 0 6px 18px rgba(0,0,0,.08);
  }

  /* No desktop zoom on phones */
  #zoom-viewer, #zoom-lens { display: none !important; }

  .thumbnail-gallery {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;       /* stay in one row */
  gap: 8px;
  overflow-x: auto;        /* scroll only inside the strip */
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x proximity;
  width: 100%;
  max-width: 420px;
  margin: 8px auto 0;
  padding: 0 2px 6px;
    order: 2;  /* put thumbnails after the main image */
}
.thumbnail-gallery img {
  flex: 0 0 auto;          /* don't shrink */
  width: 62px;
  height: 62px;
  object-fit: cover;
  border-radius: 8px;
  scroll-snap-align: center;
}
/* optional: hide scrollbar */
.thumbnail-gallery::-webkit-scrollbar { display: none; }
.thumbnail-gallery { scrollbar-width: none; }
  /* Info card and subtle right shift as requested */
  .product-info {
    background: #fff;
    border-radius: 14px;
    padding: 14px;
    box-shadow: 0 4px 14px rgba(0,0,0,.06);
    padding-left: 22px !important;
    padding-right: 14px !important;
  }
  .product-info h2 { font-size: 1.28rem; line-height: 1.25; margin: 4px 0 8px; font-weight: 800; }
  .rating { display: inline-flex; align-items: center; gap: 6px; font-size: 12px; color: #f39c12; margin-bottom: 4px; }

  .price-wrap { display: flex; align-items: baseline; gap: 10px; margin: 6px 0 8px; }
  .price, .new-price { font-size: 1.2rem; font-weight: 800; color: #6a0dad; }
  .old-price { font-size: .95rem; color: #9aa0a6; text-decoration: line-through; }
  .stock-status {
    display: inline-flex; align-items: center;
    padding: 3px 8px; border-radius: 999px;
    background: #e8fff0; color: #1e8e3e; font-size: 12px; font-weight: 700;
    margin-left: 4px;
  }

  .description { margin: 8px 0 10px; color: #444; font-size: .95rem; }
  .color-options, .size-options { margin: 10px 0 6px; }
  .size-btn { padding: 8px 12px; border-radius: 8px; }

  /* Quantity + actions stacked */
  #quantity-select { width: 100%; height: 42px; border-radius: 10px; border: 1px solid #ddd; padding: 0 10px; font-size: 15px; }
  .cart-actions { display: grid; grid-template-columns: 1fr; gap: 10px; margin-top: 12px; }
  .add-to-cart { width: 100%; height: 44px; border-radius: 10px; justify-content: center; font-weight: 700; }

  /* Hide inline wishlist button on mobile; use floating heart instead */
  .wishlist-btn2 { display: none !important; }
/* Floating wishlist heart (mobile) */
.wishlist-fab { color:#fff; text-shadow:0 1px 3px rgba(0,0,0,.35); }

/* When tapped/liked -> solid black */
.wishlist-fab.liked       { color:#000; text-shadow:none; }
.wishlist-fab.liked i     { color:#000; }   /* ensure the <i> is black */

  /* Floating heart: plain heart (no circle), stays inside image corner */
  .wishlist-fab {
    display: inline-flex;
    position: absolute;
    top: 8px;
    right: 8px;        /* adjust these to reposition */
    padding: 6px;
    border: none;
    background: none;  /* ← no circle background */
    color: #ffffff;
    cursor: pointer;
    z-index: 5;
    /* help legibility on busy photos without a box */
    text-shadow: 0 1px 3px rgba(0,0,0,.35);
  }
  .wishlist-fab i { font-size: 22px; line-height: 1; }
  .wishlist-fab:hover { color: #ff4d4d; }

  /* Share & tabs */
  .social-share { gap: 12px; margin-top: 12px; }
  .social-share a {
    width: 36px; height: 36px;
    display: inline-flex; align-items: center; justify-content: center;
    border: 1px solid #e7e7e7; border-radius: 50%;
    font-size: 18px;
  }

  .product-tabs { display: grid; grid-template-columns: 1fr; gap: 8px; border-bottom: 0; margin-top: 14px; }
  .product-tabs .tab { border: 1px solid #eee; border-radius: 10px; padding: 10px 12px; }
  .tab-section { padding: 14px; font-size: 14px; margin-top: 12px; }

  .related-products-wrapper { margin: 16px auto; padding: 12px; border-radius: 12px; }
  .related-products { display: grid; grid-template-columns: repeat(2, minmax(0,1fr)); gap: 12px; }
  .product-card { width: 100%; padding: 12px; border-radius: 10px; }
  .product-card .imgb img { width: 100%; aspect-ratio: 3/4; object-fit: cover; border-radius: 8px; }
}

/* Very small phones */
@media (max-width: 380px) {
  .main-image .main-product-image { max-height: 300px; }
  .thumbnail-gallery img { width: 56px !important; height: 56px !important; }
  .related-products { grid-template-columns: 1fr; }
}

/* Desktop/laptop ONLY: keep floating heart hidden (use inline wishlist button) */
@media (min-width: 769px) {
  .wishlist-fab { display: none !important; }
}

.share-toast {
  position: fixed; left: 50%; bottom: 24px;
  transform: translateX(-50%) translateY(20px);
  background: rgba(0,0,0,.85); color: #fff;
  padding: 8px 12px; border-radius: 999px;
  font-size: 14px; opacity: 0; pointer-events: none;
  transition: all .25s ease; z-index: 9999;
}
.share-toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
/* For mobile: push thumbnails below main image */
/* For mobile: push thumbnails below main image */
@media (max-width: 768px) {
  .product-images {
    display: flex;
    flex-direction: column;  /* stack vertically */
    align-items: center;
  }

  .main-image {
    order: 1;   /* show first */
  }

  .thumbnail-gallery {
    order: 2;   /* show after main image */
    margin-top: 10px;
  }
}

/* Never allow horizontal overflow on the page */
html, body { overflow-x: hidden; }

/* Keep the product area from bleeding */
.container, .product-images { overflow-x: hidden; }

/* Stop images from being draggable/pannable horizontally */
/* Keep main product image from dragging horizontally */
.main-product-image {
  -webkit-user-drag: none;
  user-select: none;
  touch-action: pan-y;   /* vertical scroll only */
  display: block;
}

/* Thumbnails: allow horizontal scrolling */
.thumbnail-gallery {
  overflow-x: auto;
  overflow-y: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-x: contain;
  touch-action: pan-x;   /* ← allow horizontal swipes */
}

.thumbnail-gallery img {
  -webkit-user-drag: none;
  user-select: none;
  touch-action: auto;    /* don’t block horizontal scroll */
  flex: 0 0 auto;
  display: block;
}


/* MOBILE ONLY — keep main image stable and let thumbs scroll fully */
@media (max-width: 768px) {
  /* Do NOT let the thumbnail area grow taller when more thumbs exist */
  .thumbnail-gallery {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;           /* single row */
    gap: 8px;

    /* scrolling inside the strip only */
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;

    /* keep a fixed, slim height so main image size never changes */
    height: 72px;                /* lock the strip height */
    max-height: 72px;

    /* make sure it doesn’t steal width */
    width: 100%;
    max-width: 420px;
    margin: 8px auto 0;
    padding: 0 8px 6px;

    /* optional: smoother scroll-to-edge with a small end spacer */
    scroll-snap-type: x proximity;
  }

  .thumbnail-gallery img {
    flex: 0 0 62px;              /* fixed thumb width; don't shrink */
    width: 62px;
    height: 62px;
    object-fit: cover;
    border-radius: 8px;
    scroll-snap-align: center;
  }

  /* allow the last thumbnail to be fully reachable/visible */
  .thumbnail-gallery::after {
    content: "";
    flex: 0 0 8px;               /* small spacer so last item isn’t clipped */
  }

  /* hide scrollbar (visual only; still scrolls) */
  .thumbnail-gallery::-webkit-scrollbar { display: none; }
  .thumbnail-gallery { scrollbar-width: none; }

  /* make sure the gallery sits BELOW the main image on mobile */
  .product-images { flex-direction: column; align-items: center; }
  .main-image { order: 1; }
  .thumbnail-gallery { order: 2; }
}
/* ===== MOBILE-ONLY FINAL TWEAKS (gallery only) ===== */
@media (max-width: 768px) {
  /* 1) Keep the main image safely inside the viewport */
  .product-images { width: 100%; align-items: center; min-width: 0; }
  .main-image {
    width: min(100%, 430px);
    margin: 6px auto 8px;
    position: relative;
    overflow: hidden;
    border-radius: 12px;
  }
  .main-image .main-product-image {
    display: block;
    max-width: 100%;
    width: 100%;
    height: auto;
    object-fit: cover;
    /* prevent horizontal drag causing page nudge */
    -webkit-user-drag: none;
    user-select: none;
    touch-action: pan-y;
  }

  /* 2) Thumbnails: keep a slim row, fully scroll to the last item */
  .thumbnail-gallery {
    justify-content: flex-start;     /* never recenter during scroll */
    padding: 0 12px 6px 12px;        /* a bit more end padding */
  }
  .thumbnail-gallery::after {
    content: "";
    flex: 0 0 16px;                  /* larger spacer so last thumb is fully visible */
  }

  /* If snap is making the final thumb stick, disable strict snapping */
  .thumbnail-gallery { scroll-snap-type: x proximity; } /* or change to 'none' if you prefer */
}
