/*=========================================
  PRODUCT GALLERY
  Loaded last on single-product so these
  rules win over products-listing / responsive.
=========================================*/

.product-container {
  gap: 40px;
}

@media (min-width: 992px) {
  .product-container > .product-section,
  .product-container > .product-info {
    flex: 1 1 0;
    min-width: 0;
    max-width: none;
  }
}

.product-section {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  min-width: 0;
  width: 100%;
}

.product-thumbnails {
  box-sizing: border-box;
  flex: 0 0 80px;
  width: 80px;
  min-width: 80px;
  max-width: 80px;
  max-height: min(72vw, 760px);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: #d0d0d0 transparent;
  padding: 0;
}

.product-thumb {
  appearance: none;
  -webkit-appearance: none;
  box-sizing: border-box;
  font: inherit;
  color: inherit;
  flex: 0 0 80px;
  width: 80px;
  min-width: 80px;
  max-width: 80px;
  height: 80px;
  min-height: 80px;
  aspect-ratio: 1 / 1;
  padding: 0;
  border: 1px solid var(--gray-200, #e5e5e5);
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--white, #fff);
  transition: border-color 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
}

.product-thumb img {
  width: 100%;
  height: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  display: block;
  pointer-events: none;
}

.product-thumb:hover {
  border-color: #111;
}

.product-thumb.active {
  border: 2px solid var(--primary, #f5ca27);
  box-shadow: 0 0 0 2px rgba(245, 202, 39, 0.28);
}

.product-thumb:focus-visible {
  outline: 2px solid var(--primary, #f5ca27);
  outline-offset: 2px;
}

.see-all {
  box-sizing: border-box;
  flex: 0 0 80px;
  width: 80px;
  min-width: 80px;
  max-width: 80px;
  height: 80px;
  min-height: 80px;
  aspect-ratio: 1 / 1;
  border: 1px solid #c3c3c3;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  background: #111;
  color: #fff;
}

.see-all span {
  font-size: 20px;
  font-weight: 700;
  line-height: 1;
}

.main-image {
  position: relative;
  flex: 1 1 auto;
  width: auto;
  max-width: none;
  min-width: 0;
  height: auto;
  aspect-ratio: 1 / 1;
  border: 1px solid var(--gray-200, #e5e5e5);
  border-radius: 10px;
  overflow: hidden;
  background: var(--white, #fff);
}

.main-image .productMainSwiper,
.main-image .swiper {
  width: 100%;
  height: 100%;
}

.main-image .swiper-slide {
  display: flex;
  align-items: center;
  justify-content: center;
}

.main-image img,
.main-image .product-main-slide,
.product-section .main-image img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  cursor: zoom-in;
  display: block;
  user-select: none;
  -webkit-user-drag: none;
}

.product-main-slide {
  opacity: 0;
}

.product-main-slide.loaded,
.product-main-slide.is-featured {
  opacity: 1;
}

@media (hover: hover) and (min-width: 992px) {
  .main-image .swiper-slide img {
    transition: transform 0.45s ease;
  }

  .main-image:hover .swiper-slide-active img {
    transform: scale(1.05);
  }
}

.product-gallery-pager {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 3;
  padding: 6px 12px;
  background: rgba(0, 0, 0, 0.78);
  color: #fff;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.02em;
  pointer-events: none;
}

.product-gallery-zoom-hint {
  position: absolute;
  right: 12px;
  top: 12px;
  z-index: 3;
  width: 44px;
  height: 44px;
  border: 0;
  border-radius: 50%;
  background: #111;
  color: var(--primary, #f5ca27);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.18);
}

.product-gallery-zoom-hint:hover,
.product-gallery-zoom-hint:focus-visible {
  background: var(--primary, #f5ca27);
  color: #111;
  outline: none;
}

/*=========================================
  LIGHTBOX
=========================================*/

#product-gallery-popup.product-gallery-popup {
  position: fixed;
  inset: 0;
  box-sizing: border-box;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 28px;
  background: rgba(0, 0, 0, 0.88);
  visibility: hidden;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease, visibility 0.28s ease;
  z-index: 100200;
}

#product-gallery-popup.product-gallery-popup.is-open {
  visibility: visible;
  opacity: 1;
  pointer-events: auto;
}

.product-gallery-popup .gallery-overlay {
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse at center, rgba(20, 20, 20, 0.2) 0%, rgba(0, 0, 0, 0.55) 70%),
    rgba(0, 0, 0, 0.72);
}

.product-gallery-popup .gallery-modal {
  position: relative;
  z-index: 5;
  box-sizing: border-box;
  width: min(1120px, 100%);
  max-width: 100%;
  height: min(92vh, 920px);
  height: min(92dvh, 920px);
  background: #111;
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.08);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  color: #fff;
  box-shadow: 0 28px 80px rgba(0, 0, 0, 0.55);
}

.gallery-toolbar {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: max(16px, env(safe-area-inset-top, 0px)) 20px 0;
  pointer-events: none;
}

.product-gallery-popup .gallery-counter {
  pointer-events: none;
  padding: 8px 14px;
  background: rgba(0, 0, 0, 0.7);
  color: #fff;
  border: 1px solid rgba(245, 202, 39, 0.45);
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.product-gallery-popup .gallery-close {
  pointer-events: auto;
  position: absolute;
  top: max(16px, env(safe-area-inset-top, 0px));
  right: 16px;
  left: auto;
  width: 48px;
  height: 48px;
  min-width: 48px;
  min-height: 48px;
  border: 0;
  border-radius: 50%;
  background: var(--primary, #f5ca27);
  color: #111;
  cursor: pointer;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 60;
}

.product-gallery-popup .gallery-close:hover,
.product-gallery-popup .gallery-close:focus-visible {
  background: #fff;
  color: #111;
  outline: 2px solid var(--primary, #f5ca27);
  outline-offset: 2px;
}

.product-gallery-popup .gallerySwiper {
  flex: 1;
  width: 100%;
  height: auto;
  min-height: 0;
}

.product-gallery-popup .gallerySwiper .swiper-slide {
  display: flex;
  justify-content: center;
  align-items: center;
}

.gallery-zoom-container {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: hidden;
  cursor: zoom-in;
}

.product-gallery-popup .panzoom {
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: grab;
}

.product-gallery-popup .panzoom:active {
  cursor: grabbing;
}

.product-gallery-popup .gallery-image {
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  user-select: none;
  -webkit-user-drag: none;
  pointer-events: none;
  background: transparent;
}

.product-gallery-popup .gallery-image.loaded {
  opacity: 1;
}

.product-gallery-popup .gallery-bottom {
  height: auto;
  min-height: 96px;
  padding: 12px 20px calc(16px + env(safe-area-inset-bottom, 0px));
  background: #0a0a0a;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

.product-gallery-popup .galleryThumbs {
  width: 100%;
  height: 72px;
}

.product-gallery-popup .galleryThumbs .swiper-slide {
  width: 72px;
  height: 72px;
  border: 2px solid transparent;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  opacity: 0.45;
  transition: opacity 0.2s ease, border-color 0.2s ease, box-shadow 0.2s ease;
  background: #1a1a1a;
}

.product-gallery-popup .galleryThumbs .swiper-slide:hover {
  opacity: 0.85;
}

.product-gallery-popup .galleryThumbs .swiper-slide-thumb-active,
.product-gallery-popup .galleryThumbs .swiper-thumb-active {
  opacity: 1;
  border-color: var(--primary, #f5ca27);
  box-shadow: 0 0 0 2px rgba(245, 202, 39, 0.35);
}

.product-gallery-popup .galleryThumbs img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
  border-radius: 0;
}

.product-gallery-popup .gallery-prev,
.product-gallery-popup .gallery-next {
  width: 48px !important;
  height: 48px !important;
  margin-top: 0 !important;
  padding: 0;
  top: 50%;
  transform: translateY(-50%);
  background: #fff;
  border: 0;
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.28);
  color: #111;
}

.product-gallery-popup .gallery-prev {
  left: 16px;
}

.product-gallery-popup .gallery-next {
  right: 16px;
}

.product-gallery-popup .gallery-prev:hover,
.product-gallery-popup .gallery-next:hover,
.product-gallery-popup .gallery-prev:focus-visible,
.product-gallery-popup .gallery-next:focus-visible {
  background: var(--primary, #f5ca27);
}

.product-gallery-popup .gallery-prev::after,
.product-gallery-popup .gallery-next::after {
  color: #111;
  font-size: 16px;
  font-weight: 700;
}

body.gallery-open {
  overflow: hidden;
}

body.gallery-open .mobile-header-actions {
  visibility: hidden !important;
  pointer-events: none !important;
}

/*=========================================
  TABLET / MOBILE
=========================================*/

@media (max-width: 991px) {
  .product-section {
    flex-direction: column;
    width: 100%;
    gap: 12px;
  }

  .product-thumbnails {
    flex: 0 0 auto;
    width: 100%;
    min-width: 0;
    max-width: none;
    max-height: none;
    flex-direction: row;
    order: 2;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 8px;
    padding: 4px 2px 8px;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scrollbar-width: none;
  }

  .product-thumbnails::-webkit-scrollbar {
    display: none;
  }

  .product-thumb,
  .see-all {
    flex: 0 0 64px;
    width: 64px;
    min-width: 64px;
    max-width: 64px;
    height: 64px;
    min-height: 64px;
    scroll-snap-align: start;
  }

  .main-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    aspect-ratio: 1;
    order: 1;
  }
}

/*=========================================
  MOBILE — full-bleed + 44px targets
=========================================*/

@media (max-width: 767px) {
  #product-gallery-popup.product-gallery-popup {
    padding: 0;
    align-items: stretch;
  }

  .product-gallery-popup .gallery-modal {
    width: 100%;
    height: 100%;
    height: 100dvh;
    max-height: none;
    border-radius: 0;
    border: 0;
    box-shadow: none;
  }

  .product-container > .product-section {
    margin-left: -15px;
    margin-right: -15px;
    width: calc(100% + 30px);
    gap: 0;
  }

  .main-image {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    width: 100%;
    max-width: none;
    height: auto;
    aspect-ratio: 1;
  }

  .main-image img,
  .main-image .product-main-slide,
  .product-section .main-image img {
    width: 100%;
    height: 100%;
  }

  .product-thumbnails {
    padding: 12px 15px 8px;
  }

  .product-thumb,
  .see-all {
    flex: 0 0 56px;
    width: 56px;
    min-width: 56px;
    max-width: 56px;
    height: 56px;
    min-height: 56px;
  }

  .product-gallery-pager {
    left: 12px;
    bottom: 12px;
  }

  .product-gallery-zoom-hint {
    right: 10px;
    top: 10px;
  }

  .gallery-toolbar {
    padding: max(12px, env(safe-area-inset-top, 0px)) 12px 0;
  }

  .product-gallery-popup .gallery-counter {
    font-size: 12px;
    padding: 6px 12px;
  }

  .product-gallery-popup .gallery-close {
    top: max(12px, env(safe-area-inset-top, 0px));
    right: 12px;
    width: 48px;
    height: 48px;
  }

  .product-gallery-popup .gallery-bottom {
    min-height: 88px;
    padding: 10px 12px calc(18px + env(safe-area-inset-bottom, 0px));
  }

  .product-gallery-popup .galleryThumbs {
    height: 64px;
  }

  .product-gallery-popup .galleryThumbs .swiper-slide {
    width: 64px;
    height: 64px;
  }

  .product-gallery-popup .gallery-prev,
  .product-gallery-popup .gallery-next {
    width: 44px !important;
    height: 44px !important;
  }

  .product-gallery-popup .gallery-prev {
    left: 8px;
  }

  .product-gallery-popup .gallery-next {
    right: 8px;
  }
}

@media (max-width: 480px) {
  .product-container > .product-section {
    margin-left: -15px;
    margin-right: -15px;
    width: calc(100% + 30px);
  }
}
