/* Tallizen 自訂 product gallery — 見 tallizen-product-image-override.php
 *
 * v1.1.0 (2026-10-08): 縮圖數量 + 箭頭樣式
 *   - PC / 平板 ≥1024px 顯示 7 個縮圖 (thumb 寬 72px)
 *   - 平板 768-1023px 顯示 6 個 (thumb 寬 64px)
 *   - 手機 <768px 顯示 5 個 (thumb 寬 60px)
 *   - 左右箭頭: 黑色填充 + 透明背景, 不要圓邊 / 邊框, 與縮圖同行
 * v1.0.5 (2026-10-08): 解決 1280 / 平板視口右欄內容被擠到左半
 * v1.0.4 (2026-10-08): 縮圖單行 + 左右箭頭按鈕
 * v1.0.0 (2026-10-08): 取代 v6.1.0 的 .tz-gv-* 系列
 */

/* ===== 容器 ===== */
.tz-product-gallery {
  margin-bottom: 0;
  width: 100%;
  max-width: 720px;
  display: block;
  position: relative;
  margin-left: auto;
  margin-right: auto;
}

/* ===== 大屏 (≥ 1024px): 標準兩欄佈局 (左 gallery + 右 summary) ===== */
@media (min-width: 1024px) {
  .single-product div.product.type-product.entry.entry-content-wrap {
    display: grid;
    grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
    grid-template-areas:
      "gallery summary"
      "meta    meta"
      "tabs    tabs"
      "reviews reviews"
      "related related";
    gap: 32px 40px;
    align-items: start;
  }
  .single-product div.product.type-product.entry.entry-content-wrap > .tz-product-gallery {
    grid-area: gallery;
    margin: 0;
    max-width: 100%;
    min-width: 0;
  }
  /* v1.0.5: 右欄強制撐滿 column + form/swatch/button 100% 寬 */
  .single-product div.product.type-product.entry.entry-content-wrap > .summary.entry-summary {
    grid-area: summary;
    width: 100%;
    max-width: 100%;
    min-width: 0;
    align-self: stretch;
  }
  .single-product div.product.type-product.entry.entry-content-wrap > .summary.entry-summary > *,
  .single-product div.product.type-product.entry.entry-content-wrap > .summary.entry-summary form.cart,
  .single-product div.product.type-product.entry.entry-content-wrap > .summary.entry-summary form.cart > *,
  .single-product div.product.type-product.entry.entry-content-wrap > .summary.entry-summary form.cart .variations,
  .single-product div.product.type-product.entry.entry-content-wrap > .summary.entry-summary form.cart .woocommerce-variation-add-to-cart,
  .single-product div.product.type-product.entry.entry-content-wrap > .summary.entry-summary form.cart .single_add_to_cart_button,
  .single-product div.product.type-product.entry.entry-content-wrap > .summary.entry-summary .button {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 0;
    align-self: stretch;
  }
  /* v1.1.0 (2026-10-08): 分 4 個獨立 row 避免 area 衝突 */
  .single-product div.product.type-product.entry.entry-content-wrap > .ppcp-messages {
    grid-area: meta;
  }
  .single-product div.product.type-product.entry.entry-content-wrap > .woocommerce-tabs {
    grid-area: tabs;
  }
  .single-product div.product.type-product.entry.entry-content-wrap > .product_meta {
    grid-area: meta;
  }
  .single-product div.product.type-product.entry.entry-content-wrap > #reviews,
  .single-product div.product.type-product.entry.entry-content-wrap > .tallizen-product-reviews {
    grid-area: reviews;
  }
  .single-product div.product.type-product.entry.entry-content-wrap > .related.products {
    grid-area: related;
  }
}

/* ===== 主顯示區 (1:1 比例但限寬, 不撐爆視口) ===== */
.tz-pg-viewport {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  max-height: 600px;
  background: #f7f5f0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, .10);
}
.tz-pg-slide img.tz-pg-slide-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.tz-pg-slide {
  position: absolute;
  inset: 0;
  display: none;
  align-items: center;
  justify-content: center;
  background: #f7f5f0;
}
.tz-pg-slide.is-active {
  display: flex;
}
.tz-pg-slide-video video {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  background: #0b0b0d;
}

/* ===== 放大鏡按鈕 ===== */
.tz-pg-zoom {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, .92);
  color: #1a1a1a;
  border-radius: 50%;
  text-decoration: none;
  font-size: 16px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, .15);
  transition: background .2s, transform .2s;
  z-index: 5;
}
.tz-pg-zoom:hover {
  background: #fff;
  transform: scale(1.06);
}

/* ===== 縮圖列 (单行, 水平滑块) ===== */
.tz-pg-thumbs-wrap {
  position: relative;
  margin-top: 14px;
  width: 100%;
}
.tz-pg-thumbs {
  list-style: none;
  margin: 0;
  padding: 0 36px;
  display: flex;
  flex-wrap: nowrap;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-behavior: smooth;
  scrollbar-width: none;
  -ms-overflow-style: none;
  -webkit-overflow-scrolling: touch;
  scroll-snap-type: x mandatory;
}
.tz-pg-thumbs::-webkit-scrollbar {
  display: none;
}
.tz-pg-thumb {
  position: relative;
  flex: 0 0 auto;
  width: 72px;
  aspect-ratio: 1 / 1;
  background: #f7f5f0;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  overflow: hidden;
  transition: border-color .2s, transform .2s;
  margin: 0;
  padding: 0;
  scroll-snap-align: start;
}
.tz-pg-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.tz-pg-thumb:hover {
  transform: translateY(-1px);
}
.tz-pg-thumb.is-active {
  border-color: #B8860B;
}

/* ===== 視頻縮圖 + 播放角標 ===== */
.tz-pg-video-thumb img {
  filter: saturate(.35) brightness(.8);
  transition: filter .2s;
}
.tz-pg-video-thumb:hover img,
.tz-pg-video-thumb.is-active img {
  filter: none;
}
.tz-pg-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 32px;
  height: 32px;
  display: flex !important;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: rgba(184, 134, 11, .95);
  border-radius: 50%;
  box-shadow: 0 3px 10px rgba(0, 0, 0, .45);
  pointer-events: none;
  z-index: 2;
}
.tz-pg-play-icon svg {
  display: block;
  width: 16px;
  height: 16px;
  margin-left: 2px;
}

/* ===== 左右滑塊箭頭 (黑底實心 / 透明背景, 與縮圖同行) ===== */
.tz-pg-thumbs-prev,
.tz-pg-thumbs-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  color: #1a1a1a;
  border: 0;
  border-radius: 6px;
  cursor: pointer;
  z-index: 3;
  transition: opacity .2s, transform .2s;
  padding: 0;
}
.tz-pg-thumbs-prev:hover,
.tz-pg-thumbs-next:hover {
  opacity: 0.7;
  transform: translateY(-50%) scale(1.1);
}
.tz-pg-thumbs-prev {
  left: 0;
}
.tz-pg-thumbs-next {
  right: 0;
}
.tz-pg-thumbs-prev svg,
.tz-pg-thumbs-next svg {
  display: block;
  width: 22px;
  height: 22px;
  fill: #1a1a1a;
}
.tz-pg-thumbs-prev.is-disabled,
.tz-pg-thumbs-next.is-disabled {
  opacity: 0.25;
  cursor: not-allowed;
  pointer-events: none;
}

/* ===== Lightbox ===== */
.tz-pg-lightbox {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .92);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  box-sizing: border-box;
  opacity: 0;
  transition: opacity .2s;
}
.tz-pg-lightbox.is-open {
  opacity: 1;
}
.tz-pg-lightbox img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  display: block;
}
.tz-pg-lightbox-close,
.tz-pg-lightbox-prev,
.tz-pg-lightbox-next {
  position: absolute;
  background: rgba(255, 255, 255, .12);
  color: #fff;
  border: 0;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  font-size: 28px;
  line-height: 1;
  cursor: pointer;
  transition: background .2s;
  font-family: inherit;
}
.tz-pg-lightbox-close:hover,
.tz-pg-lightbox-prev:hover,
.tz-pg-lightbox-next:hover {
  background: rgba(255, 255, 255, .25);
}
.tz-pg-lightbox-close {
  top: 16px;
  right: 16px;
}
.tz-pg-lightbox-prev {
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
}
.tz-pg-lightbox-next {
  right: 16px;
  top: 50%;
  transform: translateY(-50%);
}

/* ===== 平板 (768-1023px): 6 個縮圖 ===== */
@media (max-width: 1023px) and (min-width: 768px) {
  .tz-pg-thumb {
    width: 64px;
  }
  .tz-pg-thumbs {
    padding: 0 36px;
    gap: 6px;
  }
}

/* ===== 手機 (<768px): 5 個縮圖 ===== */
@media (max-width: 767px) {
  .tz-product-gallery {
    max-width: 100%;
  }
  .tz-pg-thumb {
    width: 60px;
  }
  .tz-pg-thumbs {
    padding: 0 32px;
    gap: 6px;
    margin-top: 10px;
  }
  .tz-pg-thumbs-prev,
  .tz-pg-thumbs-next {
    width: 24px;
    height: 24px;
  }
  .tz-pg-thumbs-prev svg,
  .tz-pg-thumbs-next svg {
    width: 18px;
    height: 18px;
  }
  .tz-pg-play-icon {
    width: 26px;
    height: 26px;
  }
  .tz-pg-play-icon svg {
    width: 13px;
    height: 13px;
  }
  .tz-pg-zoom {
    width: 32px;
    height: 32px;
    font-size: 14px;
    top: 10px;
    right: 10px;
  }
}
