/* ══════════════════════════════════════════════════════
   product-detail.css  —  产品详情页专用样式
   ══════════════════════════════════════════════════════ */

/* 桌面：面包屑与下方主内容间距（全局 shop.css 为 36px，此处收紧） */
@media (min-width: 768px) {
  .pg-breadcrumb.pg-breadcrumb--pd {
    margin-bottom: 16px;
  }
}

/* 主内容区：桌面保留上下留白；移动端去掉 container 的 gutter 与 72px 底距，轮播全宽 */
.product-detail-container {
  padding-top: 20px;
  padding-bottom: 72px;
}

@media (max-width: 991.98px) {
  /* 移动端 .site-header 非 sticky，大图 sticky 仅需少量顶距 */
  .pd-gallery-sticky {
    top: 12px !important;
  }
  .product-detail-container {
    padding-top: 0;
    padding-bottom: 0;
    padding-left: 0;
    padding-right: 0;
    max-width: 100%;
  }
  /* 主容器手机端无左右 gutter，相关推荐单独留边，与右侧信息区 px-3 一致 */
  .pd-related-products {
    padding-left: 1rem;
    padding-right: 1rem;
    box-sizing: border-box;
  }
}

/* Bootstrap .row 为 flex：子列默认 min-width:auto，#acc-desc 内富文本/表格/大图会撑宽整页（iOS 横向溢出） */
.product-detail-main-row > [class*='col-'] {
  min-width: 0;
}

/* ── 详情右侧：信任条（IATA / 质保 / EMI） ─────────────── */
.pd-trust-strip {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 12px 16px;
  margin-bottom: 20px;
  padding: 14px 12px;
  background: var(--light);
  border: 1px solid var(--border);
  border-radius: 4px;
  box-sizing: border-box;
  max-width: 100%;
}
.pd-trust-item {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1 1 0;
  min-width: 0;
}
.pd-trust-item__icon {
  flex-shrink: 0;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.pd-trust-item__icon img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}
.pd-trust-item__text {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-family: var(--font-nav);
  font-size: 0.68rem;
  font-weight: 800;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--black);
  line-height: 1.25;
}
.pd-trust-item__text span {
  display: block;
}
@media (max-width: 575.98px) {
  .pd-trust-strip {
    flex-direction: column;
    align-items: stretch;
    gap: 10px;
  }
  .pd-trust-item {
    flex: none;
  }
}

/* Description 折叠区：后台写入的 HTML（图、表、长链接）约束在列宽内 */
#acc-desc {
  min-width: 0;
  max-width: 100%;
  overflow-wrap: anywhere;
  word-wrap: break-word;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}
#acc-desc img,
#acc-desc video,
#acc-desc iframe,
#acc-desc svg {
  max-width: 100%;
  height: auto;
}
#acc-desc table {
  max-width: 100%;
  table-layout: fixed;
  word-break: break-word;
}
#acc-desc pre {
  max-width: 100%;
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* 缩略图外层：桌面左侧窄条；手机全宽横滑 —— 尺寸用 CSS 控制，避免 F12 改视口后仍沿用桌面内联宽度 */
.pd-gallery-thumbs.product-gallery-thumbs {
  width: 72px;
  flex-shrink: 0;
  max-height: 520px;
  box-sizing: border-box;
}

.product-gallery-thumb-slide {
  box-sizing: border-box;
  width: 72px !important;
  height: 72px !important;
  max-width: 72px !important;
  max-height: 72px !important;
  border-radius: 4px;
  overflow: hidden;
  cursor: pointer;
  border: 2px solid rgba(255, 255, 255, 0.55);
  transition: border-color 0.15s;
  background: var(--light);
  flex-shrink: 0;
}

/* ── 商品图库：仅手机端大图在上、缩略图在下横向滑动；≥992px 与原先一致（左竖排） ── */
@media (max-width: 991.98px) {
  .product-gallery-wrap {
    flex-direction: column !important;
    gap: 12px !important;
  }
  .product-gallery-main {
    order: 1;
    width: 100% !important;
    flex: none !important;
  }
  .product-gallery-thumbs.pd-gallery-thumbs {
    order: 2;
    width: 100% !important;
    max-height: none !important;
    height: auto !important;
    flex-shrink: 0 !important;
    padding-left: 1rem;
    padding-right: 1rem;
    box-sizing: border-box;
  }
  .product-gallery-thumbs .swiper-slide.product-gallery-thumb-slide {
    margin-bottom: 0 !important;
    /* 与桌面同尺寸，防止 Swiper 横排时把 slide 拉满屏 */
    width: 72px !important;
    height: 72px !important;
    max-width: 72px !important;
    max-height: 72px !important;
  }
}

/* 桌面端竖向缩略图需要明确高度，Swiper vertical 才能正确计算 */
@media (min-width: 992px) {
  .product-gallery-thumbs.swiper {
    height: 520px;
  }
}

/* ── Swiper 主图 ─────────────────────────────────────── */
.swiper-main { overflow: hidden; }
.swiper-main .swiper-wrapper { height: 100%; }
.swiper-main .swiper-slide {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--light);
}
.swiper-main .swiper-slide img {
  width: 100%; height: 100%;
  object-fit: contain; display: block;
  cursor: zoom-in;
}
.swiper-thumbs .swiper-slide-thumb-active {
  border-color: #d1d5db !important;
  border-width: 2px !important;
}
.swiper-btn-prev:hover,
.swiper-btn-next:hover {
  background: rgba(255,255,255,.85) !important;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}

/* ── Lightbox：背景层 + 舞台层；手机加 .pd-lb-mobile 关闭 JS 缩放，仅全屏看图 ── */
body.lightbox-open .product-gallery-wrap {
  visibility: hidden;
  pointer-events: none;
}
body.lightbox-open .product-gallery-wrap * {
  pointer-events: none !important;
}

#imgLightbox.pd-lightbox {
  display: none;
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100vh;
  height: 100dvh;
  max-height: 100dvh;
  min-height: -webkit-fill-available;
  box-sizing: border-box;
  z-index: 2147483647;
  isolation: isolate;
  flex-direction: column;
  overflow: hidden;
  touch-action: none;
  -webkit-tap-highlight-color: transparent;
  overscroll-behavior: none;
}

#imgLightbox.open {
  display: flex;
}

.pd-lb-backdrop {
  position: absolute;
  inset: 0;
  z-index: 0;
  background: rgba(0, 0, 0, 0.94);
}

#lb-canvas.pd-lb-stage {
  position: relative;
  z-index: 2;
  flex: 1 1 0%;
  min-height: 0;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px 12px;
  box-sizing: border-box;
  overflow: hidden;
  pointer-events: none;
}

#lbImg {
  position: relative;
  z-index: 1;
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto;
  height: auto;
  object-fit: contain;
  object-position: center;
  border-radius: 4px;
  box-shadow: 0 8px 48px rgba(0, 0, 0, 0.45);
  transform-origin: center center;
  transition: transform 0.15s ease;
  cursor: grab;
  user-select: none;
  -webkit-user-drag: none;
  touch-action: none;
  pointer-events: auto;
  will-change: transform;
  animation: lbIn 0.2s ease;
}
#lbImg.grabbing {
  cursor: grabbing;
  transition: none;
}

#imgLightbox .lb-close {
  position: absolute;
  top: max(12px, env(safe-area-inset-top, 0px));
  right: max(12px, env(safe-area-inset-right, 0px));
  z-index: 10;
  color: #fff;
  font-size: 2rem;
  cursor: pointer;
  line-height: 1;
  opacity: 0.75;
  transition: opacity 0.15s;
  background: none;
  border: none;
  padding: 4px 10px;
}
#imgLightbox .lb-close:hover {
  opacity: 1;
}

#imgLightbox .lb-prev,
#imgLightbox .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  color: #fff;
  font-size: 2.2rem;
  cursor: pointer;
  opacity: 0.55;
  transition: opacity 0.15s;
  padding: 14px 12px;
  user-select: none;
  background: none;
  border: none;
}
#imgLightbox .lb-prev {
  left: max(6px, env(safe-area-inset-left, 0px));
}
#imgLightbox .lb-next {
  right: max(6px, env(safe-area-inset-right, 0px));
}
#imgLightbox .lb-prev:hover,
#imgLightbox .lb-next:hover {
  opacity: 1;
}

#lb-zoom-bar {
  position: absolute;
  bottom: max(44px, calc(env(safe-area-inset-bottom, 0px) + 32px));
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
  align-items: center;
  z-index: 10;
}
.lb-zoom-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.3);
  color: #fff;
  font-size: 1.1rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}
.lb-zoom-btn:hover {
  background: rgba(255, 255, 255, 0.35);
}
#lb-zoom-val {
  color: rgba(255, 255, 255, 0.7);
  font-size: 0.75rem;
  min-width: 38px;
  text-align: center;
}

#lb-hint.pd-lb-hint-desktop {
  position: absolute;
  bottom: max(14px, env(safe-area-inset-bottom, 0px));
  left: 50%;
  transform: translateX(-50%);
  color: rgba(255, 255, 255, 0.4);
  font-size: 0.72rem;
  letter-spacing: 0.04em;
  pointer-events: none;
  white-space: nowrap;
  max-width: calc(100vw - 32px);
  text-align: center;
  z-index: 10;
}

.pd-lb-hint-mobile {
  display: none;
}

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

@media (max-width: 767.98px) {
  #imgLightbox.open.pd-lb-mobile {
    padding-top: env(safe-area-inset-top, 0px);
    padding-bottom: env(safe-area-inset-bottom, 0px);
  }

  #imgLightbox.open.pd-lb-mobile #lb-zoom-bar {
    display: none !important;
  }

  #imgLightbox.open.pd-lb-mobile #lb-hint.pd-lb-hint-desktop {
    display: none !important;
  }

  .pd-lb-hint-mobile {
    display: block;
    position: absolute;
    bottom: max(12px, env(safe-area-inset-bottom, 0px));
    left: 0;
    right: 0;
    padding: 0 16px;
    text-align: center;
    font-size: 0.68rem;
    color: rgba(255, 255, 255, 0.42);
    line-height: 1.35;
    pointer-events: none;
    z-index: 10;
  }

  #imgLightbox.open.pd-lb-mobile #lb-canvas.pd-lb-stage {
    padding-bottom: 36px;
  }

  #imgLightbox.open.pd-lb-mobile #lbImg {
    animation: lbIn 0.2s ease;
    box-shadow: none;
    touch-action: manipulation;
    transform: none !important;
    transition: none !important;
    will-change: auto;
  }
}

/* ── 数量输入框 ──────────────────────────────────────── */
#qty::-webkit-outer-spin-button,
#qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
#qty { -moz-appearance: textfield; }

/* ── 变体选项按钮 ─────────────────────────────────────  */
.opt-btn:hover,
.opt-btn.selected {
  border-color: var(--black) !important;
  background: var(--black) !important;
  color: #fff !important;
}

/* ── 收藏按钮 ────────────────────────────────────────── */
#wishBtn.wished {
  color: var(--sale) !important;
  border-color: var(--sale) !important;
}
#wishBtn.wished i { font-weight: 900; }

/* ── 缩略图激活状态 ──────────────────────────────────── */
.thumb-wrap.active { border-color: var(--black) !important; }

/* ── 滚过主 CTA 后底部固定 Add to Cart（窄屏/桌面共用；默认移出屏外，.is-visible 滑入）── */
body.pd-sticky-atc-open {
  padding-bottom: calc(64px + env(safe-area-inset-bottom, 0px));
}
body.pd-sticky-atc-open .product-detail-container {
  padding-bottom: 82px;
}
@media (max-width: 991.98px) {
  body.pd-sticky-atc-open .product-detail-container {
    padding-bottom: 86px;
  }
}
.pd-sticky-atc {
  display: block;
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  /* iOS：裁掉阴影/子像素导致的横向溢出；fixed 条本身不应用 100vw */
  overflow-x: hidden;
  overflow-x: clip;
  /* 与 safe-area 一起时避免宽度超过视口 */
  min-width: 0;
  z-index: 10060;
  padding-top: 10px;
  padding-left: max(14px, env(safe-area-inset-left, 0px));
  padding-right: max(14px, env(safe-area-inset-right, 0px));
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: rgba(255, 255, 255, 0.97);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--border);
  box-shadow: 0 -8px 28px rgba(0, 0, 0, 0.1);
  transform: translate3d(0, 100%, 0);
  /* 仅过渡 transform，避免 JS 同步 bottom 时产生抖动 */
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  pointer-events: none;
  /* 独立合成层，减轻 iOS / 已登录前台工具条下的 fixed 偶发不绘出 */
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}
.pd-sticky-atc.is-visible {
  transform: translate3d(0, 0, 0);
  pointer-events: auto;
  /* 仍低于购物车遮罩(10070)，高于前台工具条 */
  z-index: 10068;
}
.pd-sticky-atc__inner {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  max-width: min(720px, 100%);
  min-width: 0;
  margin: 0 auto;
  box-sizing: border-box;
}
.pd-sticky-atc__meta {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  gap: 2px;
  line-height: 1.2;
  overflow: hidden;
  max-width: 100%;
}
.pd-sticky-atc__price {
  font-family: var(--font-body);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--black);
  letter-spacing: -0.02em;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
/* 有折扣：现价（折扣价）更醒目，原价更小 */
.pd-sticky-atc__meta--sale .pd-sticky-atc__price {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--sale);
  letter-spacing: -0.03em;
}
.pd-sticky-atc__meta--sale .pd-sticky-atc__compare {
  font-size: 0.52rem;
  opacity: 0.85;
}
.pd-sticky-atc__sale-row {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px 6px;
}
.pd-sticky-atc__sale-row[hidden] {
  display: none !important;
}
.pd-sticky-atc__compare {
  font-size: 0.62rem;
  color: var(--muted);
  text-decoration: line-through;
}
.pd-sticky-atc__badge {
  font-size: 0.55rem;
  font-weight: 700;
  background: var(--sale);
  color: #fff;
  padding: 1px 5px;
  border-radius: 3px;
  font-family: var(--font-nav);
  letter-spacing: 0.03em;
  line-height: 1.3;
}
.pd-sticky-atc__thumb {
  width: 52px;
  height: 52px;
  object-fit: cover;
  border-radius: 10px;
  flex-shrink: 0;
  border: 1px solid var(--border);
  background: var(--light);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.pd-sticky-atc__thumb:focus-visible {
  outline: 2px solid var(--black);
  outline-offset: 2px;
}
.pd-sticky-atc__btn {
  flex: 1.15 1 0;
  min-width: 0;
  height: 48px;
  border: none;
  border-radius: 999px;
  background: var(--black);
  color: #fff;
  font-family: var(--font-nav);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  transition: background 0.18s;
}
.pd-sticky-atc__btn:hover {
  background: #333;
}
.pd-sticky-atc__btn i {
  font-size: 1.05rem;
}

/* Buy Now → checkout：全屏 loading，避免等待请求时页面像卡住 */
.pd-buy-now-loading {
  position: fixed;
  inset: 0;
  z-index: 100050;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom)
    env(safe-area-inset-left);
  box-sizing: border-box;
}
.pd-buy-now-loading[hidden] {
  display: none !important;
}
.pd-buy-now-loading__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(255, 255, 255, 0.78);
  backdrop-filter: blur(6px);
}
.pd-buy-now-loading__panel {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 14px;
  padding: 28px 32px;
  border-radius: 12px;
  background: var(--white);
  border: 1px solid var(--border);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.1);
  max-width: 90vw;
}
.pd-buy-now-loading__spinner {
  width: 36px;
  height: 36px;
  border: 2px solid var(--border);
  border-top-color: var(--black);
  border-radius: 50%;
  animation: pd-buy-now-spin 0.65s linear infinite;
}
@keyframes pd-buy-now-spin {
  to {
    transform: rotate(360deg);
  }
}
.pd-buy-now-loading__text {
  margin: 0;
  font-family: var(--font-nav);
  font-size: 0.78rem;
  font-weight: 600;
  letter-spacing: 0.06em;
  color: var(--black);
  text-align: center;
}
