/* ==============================
   全局重置与基础
   ============================== */
* {
  /* margin: 0;
  padding: 0; */
  box-sizing: border-box;
}

body {
  font-family: "Microsoft YaHei", "PingFang SC", sans-serif;
  background: #f5f5f5;
  color: #333;
}

/* ==============================
   主容器 - 左右布局
   ============================== */
.product-detail-wrapper {
  display: flex;
  max-width: 1400px;
  margin: 20px auto;
  padding: 0 20px;
  gap: 30px;
  align-items: flex-start;
  /* 关键：防止flex子项被拉伸 */
  overflow: visible;
}

/* 保证右侧 sticky 浮动生效：祖先容器不允许滚动裁剪 */
#wrapper {
  overflow: visible;
}

/* ==============================
   左侧区域（65%宽度）
   ============================== */
.product-left {
  flex: 1;
  min-width: 0;
  /* 防止内容溢出 */
  display: flex;
  flex-direction: column;
  gap: 0;
}

/* ---------- 左上：商品主图区 ---------- */
.product-main-image {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
  margin-bottom: 20px;
}

.image-gallery {
  display: flex;
  gap: 15px;
}

.thumb-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  width: 100px;
  flex-shrink: 0;
}

.thumb-item {
  width: 100px;
  height: 100px;
  border: 2px solid transparent;
  border-radius: 6px;
  overflow: hidden;
  cursor: pointer;
  transition: border-color 0.3s;
}

.thumb-item:hover,
.thumb-item.active {
  border-color: #e63c30;
  /* 品牌红色 */
}

.thumb-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.main-image-box {
  flex: 1;
  position: relative;
  overflow: hidden;
  border-radius: 6px;
  background: #fafafa;
  aspect-ratio: 1 / 1;
  /* 保持正方形 */
}

.main-image-box .main-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  transition: transform 0.3s;
  z-index: 1;
}

.zoom-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-repeat: no-repeat;
  background-size: 200% 200%;
  background-color: #fff;
  display: none;
  z-index: 10;
  pointer-events: none;
}

.zoom-tip {
  position: absolute;
  bottom: 10px;
  right: 10px;
  background: rgba(0, 0, 0, 0.5);
  color: #fff;
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  z-index: 2;
}

/* ---------- 左下：商品详情区 ---------- */
.product-detail-content {
  background: #fff;
  border-radius: 8px;
  padding: 25px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* Tab 导航 */
.detail-tabs {
  display: flex;
	justify-content: space-around;
  list-style: none;
  border-bottom: 2px solid #eee;
  margin-bottom: 20px;
  gap: 0;
	max-width: 100%;
}

.tab-item {
  padding: 12px 20px;
  font-size: 16px;
  color: #666;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all 0.3s;
  user-select: none;
}

.tab-item:hover {
  color: #e63c30;
}

.tab-item.active {
  color: #e63c30;
  border-bottom-color: #e63c30;
  font-weight: 600;
}

/* Tab 内容 */
.tab-content {
  display: none;
  animation: fadeIn 0.4s ease;
}

.tab-content.active {
  display: block;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.tab-content h3 {
  font-size: 18px;
  margin-bottom: 15px;
  color: #222;
}

.tab-content p {
  line-height: 1.8;
  color: #555;
  font-size: 14px;
}

.detail-img {
  width: 100%;
  display: block;
  margin-bottom: 0;
}

/* 尺码表样式 */
.size-table {
  width: 100%;
  border-collapse: collapse;
  margin: 10px 0 20px;
  font-size: 14px;
}

.size-table th {
  background: #f8f8f8;
  padding: 10px 15px;
  text-align: center;
  border: 1px solid #eee;
  font-weight: 600;
}

.size-table td {
  padding: 10px 15px;
  text-align: center;
  border: 1px solid #eee;
}

.size-table-wrapper h4 {
  margin: 15px 0 8px;
  font-size: 15px;
  color: #333;
}

/* 面包屑导航 */
.breadcrumb {
  max-width: 1400px;
  margin: 20px auto;
  padding: 0 20px;
  font-size: 14px;
  color: #999;
}

.breadcrumb a {
  color: #666;
  text-decoration: none;
}

.breadcrumb a:hover {
  color: #e63c30;
}

.breadcrumb span {
  color: #333;
}

/* ==============================
   右侧区域（35%宽度）- 浮动固定
   ============================== */
.product-right {
  width: 380px;
  flex-shrink: 0;

  /* ★ 核心：sticky 浮动效果 ★ */
  position: sticky;
  top: 100px;
  /* 距离视口顶部100px，避开导航栏 */
  align-self: flex-start;
  /* 必须配合 flex 布局 */
  max-height: calc(100vh - 120px);
  overflow-y: auto;
}

.product-info-sticky {
  background: #fff;
  border-radius: 8px;
  padding: 28px;
  box-shadow: 0 2px 12px rgba(0, 0, 0, 0.06);
}

/* 商品标题 */
.product-title {
  font-size: 22px;
  font-weight: 700;
  color: #111;
  line-height: 1.4;
  margin-bottom: 18px;
  padding-bottom: 18px;
  border-bottom: 1px solid #f0f0f0;
}

/* 价格 */
.product-price {
  display: flex;
  align-items: baseline;
  gap: 10px;
  margin-bottom: 22px;
  padding: 15px;
  background: linear-gradient(135deg, #fff5f5, #fff0f0);
  border-radius: 8px;
}

.price-label {
  font-size: 14px;
  color: #999;
}

.price-value {
  font-size: 32px;
  font-weight: 800;
  color: #e63c30;
  font-family: "DIN Alternate", "Arial", sans-serif;
}

/* 属性行通用样式 */
.product-color,
.product-size,
.product-quantity {
  margin-bottom: 20px;
}

.attr-label {
  display: block;
  font-size: 14px;
  color: #666;
  margin-bottom: 10px;
}

/* 颜色选择 */
.color-options {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

.color-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 16px;
  border: 2px solid #ddd;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.3s;
}

.color-item:hover,
.color-item.active {
  border-color: #e63c30;
  color: #e63c30;
}

/* 尺码选择 */
.size-options {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.size-item {
  width: 90px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  cursor: default;
}

.size-item:hover,
.size-item.active {
  border-color: #e63c30;
  color: #e63c30;
  background: #fff5f5;
}

.size-item.disabled {
  color: #ccc;
  border-color: #eee;
  cursor: not-allowed;
  text-decoration: line-through;
}

.size-chart-link {
  display: inline-block;
  margin-top: 10px;
  font-size: 13px;
  color: #e63c30;
  text-decoration: none;
}

.size-chart-link:hover {
  text-decoration: underline;
}

/* 数量控制 */
.quantity-control {
  display: inline-flex;
  align-items: center;
  border: 1px solid #ddd;
  border-radius: 6px;
  overflow: hidden;
}

.qty-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: #f5f5f5;
  font-size: 18px;
  cursor: pointer;
  transition: background 0.2s;
}

.qty-btn:hover {
  background: #e8e8e8;
}

.qty-input {
  width: 50px;
  height: 36px;
  border: none;
  border-left: 1px solid #ddd;
  border-right: 1px solid #ddd;
  text-align: center;
  font-size: 15px;
  outline: none;
}

/* 操作按钮 */
.product-actions {
  display: flex;
  gap: 12px;
  margin: 25px 0 20px;
}

.btn-add-cart,
.btn-buy-now {
  flex: 1;
  height: 48px;
  border: none;
  border-radius: 8px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s;
  letter-spacing: 1px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn-add-cart {
  background: #fff;
  color: #e63c30;
  border: 1px solid #e63c30;
}

.btn-add-cart:hover {
  background: #fff5f5;
}

.btn-buy-now {
  background: linear-gradient(135deg, #e63c30, #d42a20);
  color: #fff;
  border: 2px solid transparent;
}

.btn-buy-now:hover {
  background: linear-gradient(135deg, #d42a20, #c01e15);
  transform: translateY(-1px);
  box-shadow: 0 4px 15px rgba(230, 60, 48, 0.35);
}

/* 服务保障 */
.product-service {
  display: flex;
  gap: 15px;
  padding-top: 18px;
  border-top: 1px solid #f0f0f0;
  font-size: 12px;
  color: #999;
}

/* 自定义滚动条（右侧区域溢出时） */
.product-right::-webkit-scrollbar {
  width: 4px;
}

.product-right::-webkit-scrollbar-thumb {
  background: #ddd;
  border-radius: 4px;
}

/* ==============================
   响应式适配
   ============================== */

/* 平板适配 */
@media (max-width: 1024px) {
  .product-detail-wrapper {
    gap: 20px;
    padding: 0 15px;
  }

  .product-right {
    width: 320px;
  }

  .product-info-sticky {
    padding: 20px;
  }
}

/* 移动端：恢复上下结构 */
@media (max-width: 768px) {
  .zoom-tip {
    display: none;
  }

  .breadcrumb {
    display: none;
  }

  .product-detail-wrapper {
    flex-direction: column;
  }

  .product-right {
    width: 100%;
    position: relative;
    /* 取消 sticky */
    top: 0;
    max-height: none;
    overflow-y: visible;
  }

  .image-gallery {
    flex-direction: column-reverse;
  }

  .thumb-list {
    flex-direction: row;
    width: 100%;
    overflow-x: auto;
  }

  .thumb-item {
    width: 60px;
    height: 60px;
    flex-shrink: 0;
  }

  /* 小屏：商品信息固定在底部，收起只显示标题+价格 */
  body {
    padding-bottom: 70px;
  }

  .product-info-sticky {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    top: auto !important;
    max-height: 70px !important;
    overflow: hidden;
    background: #fff;
    border-top: 1px solid #e0e0e0;
    z-index: 999;
    padding: 0px 15px;
    padding-top: 10px;
    transition: max-height 0.3s ease;
  }

  /* 展开状态 */
  .product-info-sticky.expanded {
    max-height: 70vh !important;
    overflow-y: auto;
  }

  /* 标题和价格可点击 */
  .product-info-sticky .product-title,
  .product-info-sticky .product-price {
    cursor: pointer;
  }

  /* 展开指示器 */
  .product-info-sticky::after {
    content: '▲';
    position: absolute;
    top: 18px;
    right: 15px;
    font-size: 22px;
    color: #999;
    transition: transform 0.3s;
    pointer-events: none;
  }

  .product-info-sticky.expanded::after {
    transform: rotate(180deg);
  }

  /* 收起时标题和价格横向排列 */
  .product-info-sticky:not(.expanded) .product-title {
    font-size: 18px;
    line-height: 42px;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 65%;
    display: inline-block;
    vertical-align: middle;
  }

  .product-info-sticky:not(.expanded) .product-price {
    display: inline-block;
    vertical-align: middle;
    margin-left: 12px;
    padding: 0;
    line-height: 42px;
    min-width: 80px;
    text-align: center;
  }

  .product-info-sticky:not(.expanded) .price-label {
    display: none;
  }

  .product-info-sticky:not(.expanded) .price-value {
    font-size: 18px;
    color: #e63c30;
  }

  /* ---- 微信端防溢出 ---- */
  html,
  body {
    max-width: 100%;
    overflow-x: hidden;
  }

  .product-detail-wrapper {
    margin: 10px auto;
    padding: 0 12px;
  }

  .tab-content {
    overflow-x: hidden;
  }

  /* 富文本内容（详情长图/描述）限制在容器内 */
  .descr-text {
    overflow: hidden;
  }

  .descr-text img {
    max-width: 100% !important;
    height: auto !important;
  }

  .descr-text table {
    max-width: 100% !important;
  }

  .descr-text pre,
  .descr-text code {
    white-space: pre-wrap;
    word-break: break-all;
  }

  /* 老内核不支持 aspect-ratio 时主图高度兜底 */
  @supports not (aspect-ratio: 1 / 1) {
    .main-image-box {
      height: 0;
      padding-bottom: 100%;
    }

    .main-image-box .main-img {
      position: absolute;
      top: 0;
      left: 0;
    }
  }
}