/**
 * 商品详情顶栏图库：阿里巴巴国际站布局
 * 桌面：左侧竖向缩略图 + 右侧 1:1 主图；移动：主图在上、横向缩略图在下
 */

.pd-shop-card--ali {
  padding: 0;
  overflow: hidden;
  border-radius: var(--radius);
}

.pd-shop-layout {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(300px, 400px);
  gap: 0;
  align-items: start;
}

.pd-gallery-ali {
  min-width: 0;
  background: #fff;
}

@media (prefers-color-scheme: dark) {
  .pd-gallery-ali {
    background: var(--card);
  }
}

/* —— 缩略图 + 主图 容器 —— */
.pd-gallery-inner {
  display: flex;
  flex-direction: column;
}

.pd-gallery-main {
  order: -1;
  flex: 1;
  min-width: 0;
}

/* —— 1:1 主图舞台（避免宽图被压成横条） —— */
.pd-gallery-stage {
  position: relative;
  width: 100%;
  max-width: 640px;
  margin: 0 auto;
  aspect-ratio: 1 / 1;
  background: #fff;
  overflow: hidden;
  box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
  .pd-gallery-stage {
    background: var(--card);
  }
}

.pd-gallery-stage-frame {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: clamp(12px, 2.5vw, 20px);
  box-sizing: border-box;
  z-index: 1;
}

.pd-shop-card--ali .pd-gallery-stage .pd-main-img {
  display: block;
  max-width: 100%;
  max-height: 100%;
  width: auto !important;
  height: auto !important;
  object-fit: contain;
  object-position: center;
  cursor: zoom-in;
  border-radius: 0;
}

.pd-gallery-float-actions {
  position: absolute;
  top: max(10px, var(--safe-top));
  right: max(10px, var(--safe-right));
  z-index: 3;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.pd-gallery-float-btn {
  width: 40px;
  height: 40px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.96);
  color: #1a1a1a;
  box-shadow: 0 2px 10px rgba(15, 23, 42, 0.12);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s, box-shadow 0.15s;
}

.pd-gallery-float-btn:hover {
  transform: scale(1.04);
  box-shadow: 0 4px 14px rgba(15, 23, 42, 0.16);
}

.pd-gallery-float-btn svg {
  display: block;
}

.pd-gallery-segments {
  position: absolute;
  left: 50%;
  bottom: 14px;
  transform: translateX(-50%);
  z-index: 3;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px;
  border-radius: 999px;
  background: rgba(30, 30, 30, 0.72);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  max-width: calc(100% - 24px);
}

.pd-gallery-seg {
  margin: 0;
  padding: 8px 14px;
  border: none;
  border-radius: 999px;
  background: transparent;
  color: rgba(255, 255, 255, 0.92);
  font-size: 13px;
  font-weight: 500;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}

.pd-gallery-seg.is-active {
  background: #fff;
  color: #111;
  font-weight: 600;
}

.pd-gallery-seg:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

/* —— 缩略图条（移动：主图下方横向；桌面：左侧竖向） —— */
.pd-gallery-thumbs-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px max(var(--content-gutter), var(--safe-left)) 14px
    max(var(--content-gutter), var(--safe-right));
  background: #fff;
  border-top: 1px solid var(--border);
  box-sizing: border-box;
}

@media (prefers-color-scheme: dark) {
  .pd-gallery-thumbs-bar {
    background: var(--card);
  }
}

.pd-gallery-thumbs-scroll {
  flex: 1;
  min-width: 0;
  display: flex;
  gap: 8px;
  overflow-x: auto;
  overflow-y: hidden;
  scroll-snap-type: x proximity;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.pd-gallery-thumbs-scroll::-webkit-scrollbar {
  display: none;
}

.pd-gallery-thumbs-scroll .pd-thumb-btn {
  flex: 0 0 auto;
  scroll-snap-align: start;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  background: var(--input-bg, #f1f5f9);
  line-height: 0;
  transition: border-color 0.15s;
}

.pd-gallery-thumbs-scroll .pd-thumb-btn.is-active {
  border-color: #111;
  box-shadow: none;
}

@media (prefers-color-scheme: dark) {
  .pd-gallery-thumbs-scroll .pd-thumb-btn.is-active {
    border-color: var(--accent2);
  }
}

.pd-gallery-thumbs-scroll .pd-thumb-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.pd-gallery-more {
  flex: 0 0 auto;
  margin: 0;
  padding: 6px 4px 6px 8px;
  border: none;
  background: transparent;
  color: var(--muted);
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  cursor: pointer;
  font-family: inherit;
}

.pd-gallery-more:hover {
  color: var(--text);
}

/* —— 桌面：国际站左侧竖向缩略图 —— */
@media (min-width: 961px) {
  .pd-gallery-inner {
    flex-direction: row;
    align-items: stretch;
  }

  .pd-gallery-main {
    order: 0;
    flex: 1;
    min-width: 0;
    border-left: 1px solid var(--border);
  }

  .pd-gallery-thumbs-bar {
    order: -1;
    flex: 0 0 84px;
    width: 84px;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 12px 8px;
    border-top: none;
    border-right: none;
    border-bottom: none;
  }

  .pd-gallery-thumbs-scroll {
    flex: 1;
    flex-direction: column;
    overflow-x: hidden;
    overflow-y: auto;
    scroll-snap-type: y proximity;
    max-height: min(640px, 72vh);
  }

  .pd-gallery-thumbs-scroll .pd-thumb-btn {
    width: 64px;
    height: 64px;
    border-radius: 6px;
  }

  .pd-gallery-more {
    align-self: center;
    padding: 4px 0;
    font-size: 12px;
  }
}

.pd-shop-card--ali .pd-buy-col {
  padding: 20px max(var(--content-gutter), var(--safe-right)) 24px
    max(var(--content-gutter), var(--safe-left));
  border-left: 1px solid var(--border);
}

.pd-highlights-anchor {
  scroll-margin-top: calc(var(--nav-h, 120px) + 12px);
}

.pd-shop-card--ali .pd-tool-row {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 8px;
  margin-top: 4px;
}

.pd-shop-card--ali .pd-tool-btn {
  width: 100%;
  min-height: var(--touch-min, 44px);
  padding: 10px 8px;
  font-size: 13px;
  white-space: nowrap;
}

.pd-shop-card--ali .pd-tool-btn.is-favorited {
  border-color: var(--accent2, #0284c7);
  color: var(--accent2, #0284c7);
}

.pd-spec-empty {
  margin: 0;
  padding: 12px 0;
  color: var(--muted);
  font-size: 14px;
}

@media (max-width: 900px) {
  .pd-shop-layout {
    grid-template-columns: 1fr;
  }

  .pd-shop-card--ali .pd-buy-col {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-top: 18px;
  }

  .pd-gallery-stage {
    max-width: none;
  }

  .pd-gallery-seg {
    padding: 7px 12px;
    font-size: 12px;
  }
}
