/* ==========================================================================
   ALBUM ẢNH KHUNG CHI TIẾT TRANH (đi kèm public/js/product-gallery.js)
   ========================================================================== */

/* Ảnh lớn bấm được để mở khung xem ảnh */
#publicProductDetailModal .public-image-frame.pg-zoomable {
  cursor: zoom-in;
  touch-action: pan-y;
}

/* ---------- Dải ảnh nhỏ: hiện 4 ảnh, còn lại xem bằng mũi tên ---------- */
.pg-thumbs-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  max-width: 380px;
  margin: 0 auto;
}

#publicProductDetailModal .pg-thumbs-viewport {
  --pg-gap: 10px;
  flex: 1 1 auto;
  min-width: 0;
  width: auto;
  display: flex;
  flex-wrap: nowrap;
  justify-content: center;
  gap: var(--pg-gap);
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x mandatory;
  scroll-padding-inline: 2px;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

#publicProductDetailModal .pg-thumbs-viewport::-webkit-scrollbar {
  display: none;
}

/* Có hơn 4 ảnh: xếp từ trái để cuộn được về đầu dải */
.pg-thumbs-strip.has-more #publicThumbsContainer {
  justify-content: flex-start;
}

#publicProductDetailModal .pg-thumbs-viewport .public-thumb-item {
  flex: 0 0 calc((100% - 3 * var(--pg-gap)) / 4);
  width: auto;
  height: auto;
  aspect-ratio: 68 / 82;
  scroll-snap-align: start;
}

.pg-thumbs-arrow {
  display: none;
  flex: 0 0 auto;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid rgba(27, 59, 54, 0.2);
  background: #ffffff;
  color: #1b3b36;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
  transition: opacity 0.2s, background 0.2s;
  padding: 0;
}

.pg-thumbs-strip.has-more .pg-thumbs-arrow {
  display: inline-flex;
}

.pg-thumbs-arrow:hover:not(:disabled) {
  background: #f6efe1;
}

.pg-thumbs-arrow:disabled {
  opacity: 0.3;
  cursor: default;
}

@media (max-width: 640px) {
  #publicProductDetailModal .pg-thumbs-viewport {
    --pg-gap: 8px;
  }

  .pg-thumbs-arrow {
    width: 28px;
    height: 28px;
  }
}

/* ---------- Khung xem ảnh lớn toàn màn hình ---------- */
.pg-lightbox {
  position: fixed;
  inset: 0;
  z-index: 100500;
  display: none;
  background: rgba(8, 13, 12, 0.96);
  color: #ffffff;
  touch-action: none;
  overscroll-behavior: contain;
  user-select: none;
  -webkit-user-select: none;
}

.pg-lightbox.open {
  display: block;
  animation: pgFadeIn 0.2s ease;
}

/* Ẩn nút liên hệ nổi khi đang xem ảnh lớn để không che ảnh */
body.pg-lightbox-open .floating-contact-widget {
  display: none !important;
}

@keyframes pgFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.pg-lb-top {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  z-index: 3;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: calc(12px + env(safe-area-inset-top, 0px)) 16px 12px;
}

.pg-lb-counter {
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  color: #dfb85b;
}

.pg-lb-close {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
  font-size: 2rem;
  line-height: 1;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.pg-lb-stage {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  padding: calc(68px + env(safe-area-inset-top, 0px)) 12px calc(48px + env(safe-area-inset-bottom, 0px));
}

.pg-lb-slide {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.35s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.35s ease;
}

.pg-lb-slide img {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
  border-radius: 4px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  pointer-events: auto;
  -webkit-user-drag: none;
}

.pg-lb-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 3;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.16);
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
}

.pg-lb-nav:hover {
  background: rgba(255, 255, 255, 0.28);
}

.pg-lb-prev { left: 16px; }
.pg-lb-next { right: 16px; }

.pg-lb-dots {
  position: absolute;
  left: 0;
  right: 0;
  bottom: calc(18px + env(safe-area-inset-bottom, 0px));
  z-index: 3;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 7px;
  padding: 0 20px;
}

.pg-lb-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.35);
  transition: background 0.2s, transform 0.2s;
}

.pg-lb-dots span.on {
  background: #dfb85b;
  transform: scale(1.3);
}

@media (max-width: 640px) {
  .pg-lb-nav {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.12);
  }

  .pg-lb-prev { left: 8px; }
  .pg-lb-next { right: 8px; }

  .pg-lb-stage {
    padding-left: 4px;
    padding-right: 4px;
  }
}
