/**
 * 产品详情页样式
 * 基于 product-detail-v2.html 设计原型
 */

/* ========== 产品图片轮播 ========== */
.product-gallery {
  position: relative;
  background: white;
  padding: var(--space-6);
}

.gallery-slider {
  position: relative;
  overflow: hidden;
  border-radius: var(--radius-lg);
  aspect-ratio: 1;
}

.gallery-slide {
  position: absolute;
  inset: 0;
  opacity: 0;
  transition: opacity var(--transition-base) var(--ease-out);
}

.gallery-slide.active {
  opacity: 1;
}

.gallery-slide img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-bg-light) 0%, var(--color-bg-subtle) 100%);
}

.gallery-dots {
  display: flex;
  justify-content: center;
  gap: var(--space-2);
  margin-top: var(--space-4);
  overflow-x: auto;
  overflow-y: hidden;
  /* 隐藏滚动条但保留滚动功能 */
  scrollbar-width: none; /* Firefox */
  -ms-overflow-style: none; /* IE and Edge */
}

.gallery-dots::-webkit-scrollbar {
  display: none; /* Chrome, Safari, Opera */
}

.gallery-dot {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition-base) var(--ease-out);
  overflow: hidden;
  flex-shrink: 0; /* 防止缩略图被压缩 */
  position: relative;
}

.gallery-thumbnail {
  width: 100%;
  height: 100%;
  border-radius: calc(var(--radius-md) - 1px);
  opacity: 0.6;
  transition: opacity var(--transition-base) var(--ease-out);
}

.gallery-dot.active {
  border-color: #000000;
}

.gallery-dot.active .gallery-thumbnail {
  opacity: 1;
}

.gallery-dot:hover .gallery-thumbnail {
  opacity: 0.8;
}

/* ========== 产品信息 ========== */
.product-info {
  background: white;
  padding: var(--space-6) var(--space-4);
  border-bottom: 1px solid var(--color-border);
}

.product-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin-bottom: var(--space-2);
}

.product-subtitle {
  font-size: 14px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-4);
}

.product-price-wrapper {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  margin-bottom: var(--space-3);
}

.product-price {
  font-size: 28px;
  font-weight: 700;
  color: var(--color-text-primary);
  margin: 0;
}

.product-original-price {
  font-size: 16px;
  font-weight: 400;
  color: var(--color-text-secondary);
  text-decoration: line-through;
  margin: 0;
}

.product-price-note {
  font-size: 13px;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-6);
}

.product-badge {
  display: inline-block;
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  margin-bottom: var(--space-4);
}

.badge-new {
  background: #E8F5E9;
  color: #2E7D32;
}

/* ========== 下拉式选择器 ========== */
.dropdown-selector {
  margin-bottom: var(--space-6);
}

.dropdown-label {
  font-size: 14px;
  font-weight: 600;
  color: var(--color-text-primary);
  margin-bottom: var(--space-3);
}

.custom-select {
  position: relative;
  width: 100%;
}

.select-trigger {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  cursor: pointer;
  transition: all var(--transition-base) var(--ease-out);
  user-select: none;
}

.select-trigger:hover {
  border-color: var(--color-primary);
}

.select-trigger.active {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.select-value {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text-primary);
}

.color-preview {
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  border: 2px solid var(--color-border);
  flex-shrink: 0;
}

.select-arrow {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-slow) var(--ease-out);
  flex-shrink: 0;
}

.select-trigger.active .select-arrow {
  transform: rotate(180deg);
}

.select-dropdown {
  position: absolute;
  top: calc(100% + var(--space-2));
  left: 0;
  right: 0;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  opacity: 0;
  visibility: hidden;
  transform: translateY(-10px);
  transition: all var(--transition-base) var(--ease-out);
  z-index: var(--z-dropdown);
  max-height: 280px;
  overflow-y: auto;
}

.select-dropdown.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.select-option {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  cursor: pointer;
  transition: background var(--transition-fast) var(--ease-out);
  border-bottom: 1px solid var(--color-border-subtle);
}

.select-option:last-child {
  border-bottom: none;
}

.select-option:hover {
  background: var(--color-bg-subtle);
}

.select-option.selected {
  background: #E8F4FD;
}

.select-option-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  flex: 1;
}

.select-option-text {
  font-size: 15px;
  font-weight: 500;
  color: var(--color-text-primary);
}

.select-option.selected .select-option-text {
  color: var(--color-primary);
  font-weight: 600;
}

.select-option-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text-primary);
}

.check-mark {
  width: 18px;
  height: 18px;
  color: var(--color-primary);
  flex-shrink: 0;
  opacity: 0;
  transition: opacity var(--transition-base) var(--ease-out);
}

.select-option.selected .check-mark {
  opacity: 1;
}

/* 禁用状态的规格选项 */
.select-option.disabled {
  opacity: 0.4;
  cursor: not-allowed;
  background: var(--color-bg-light);
  color: var(--color-text-secondary);
}

.select-option.disabled:hover {
  background: var(--color-bg-light);
}

.select-option.disabled .select-option-text {
  color: var(--color-text-secondary);
}

.select-option.disabled .check-mark {
  display: none;
}

/* ========== 数量选择器 ========== */
.quantity-selector {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-4) 0;
  margin-bottom: var(--space-6);
  border-bottom: 1px solid var(--color-border-subtle);
}

.quantity-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text-primary);
}

.quantity-controls {
  display: flex;
  align-items: center;
  gap: 0;
  background: white;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  padding: var(--space-1);
  overflow: hidden;
}

.quantity-btn {
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: none;
  cursor: pointer;
  transition: all var(--transition-base) var(--ease-out);
  font-size: 18px;
  font-weight: 600;
  color: var(--color-text-primary);
  user-select: none;
}

.quantity-btn:hover {
  background: var(--color-bg-subtle);
  color: var(--color-primary);
}

.quantity-btn:active {
  transform: scale(0.95);
}

.quantity-btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.quantity-value {
  min-width: 60px;
  text-align: center;
  font-size: 16px;
  font-weight: 700;
  color: var(--color-text-primary);
  padding: var(--space-2) var(--space-3);
  background: white;
  border-left: 1px solid var(--color-border);
  border-right: 1px solid var(--color-border);
}

/* ========== 折叠内容 ========== */
.collapsible-section {
  background: white;
  margin-top: var(--space-3);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.collapsible-header {
  padding: var(--space-4);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: background var(--transition-base) var(--ease-out);
}

.collapsible-header:hover {
  background: var(--color-bg-subtle);
}

.collapsible-title {
  font-size: 16px;
  font-weight: 600;
}

.collapsible-icon {
  width: 20px;
  height: 20px;
  transition: transform var(--transition-slow) var(--ease-out);
}

.collapsible-section.open .collapsible-icon {
  transform: rotate(180deg);
}

.collapsible-content {
  max-height: 0;
  overflow: hidden;
  transition: max-height var(--transition-slow) var(--ease-out);
}

.collapsible-section.open .collapsible-content {
  max-height: 2000px;
}

.collapsible-body {
  padding: 0 var(--space-4) var(--space-4);
}

/* ========== 产品操作按钮（桌面端） ========== */
.product-actions {
  display: none;
  gap: var(--space-3);
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border-subtle);
}

.action-btn {
  flex: 1;
  padding: var(--space-4) var(--space-6);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base) var(--ease-out);
  text-align: center;
  text-decoration: none;
  border: none;
  min-height: 48px;
}

/* ========== 底部固定栏 ========== */
.bottom-bar {
  position: fixed;
  bottom: 60px; /* 留出底部导航栏的空间 (约60px) */
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--color-border);
  padding: var(--space-3) var(--space-4);
  z-index: 101; /* 高于底部导航栏 (z-index: 100) */
  display: flex;
  gap: var(--space-3);
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1); /* 添加阴影让层次更清晰 */
}

/* 移动端：将底部固定栏放在导航栏上方 */
@media (max-width: 767px) {
  .bottom-bar {
    bottom: 56px; /* 底部导航栏高度 */
  }
}

.bottom-bar-btn {
  flex: 1;
  padding: var(--space-3) var(--space-6);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base) var(--ease-out);
  text-align: center;
  text-decoration: none;
  border: none;
}

.btn-primary {
  background: var(--color-primary);
  color: white;
}

.btn-primary:hover {
  background: #0052A3;
}

.btn-secondary {
  background: var(--color-bg-subtle);
  color: var(--color-text-primary);
}

.btn-secondary:hover {
  background: #E8E8ED;
}

/* ========== 移动端底部栏价格 ========== */
.bottom-bar-price {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
}

.bottom-bar-price .price-label {
  font-size: 12px;
  color: var(--color-text-secondary);
  margin-bottom: 2px;
}

.bottom-bar-price .price-wrapper {
  display: flex;
  align-items: baseline;
  gap: var(--space-2);
}

.bottom-bar-price .price-value {
  font-size: 18px;
  font-weight: 700;
  color: var(--color-primary);
}

.bottom-bar-price .price-original {
  font-size: 14px;
  font-weight: 500;
  color: var(--color-text-secondary);
  text-decoration: line-through;
}

/* ========== 相关产品 ========== */
.related-products {
  padding: var(--space-6) 0;
}

.related-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: var(--space-4);
}

.related-card {
  display: block;
  background: white;
  border-radius: 12px;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  border: 1px solid rgba(0, 0, 0, 0.04);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
}

.related-card:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.1);
}

.related-card-image-wrapper {
  position: relative;
  width: 100%;
  aspect-ratio: 1 / 1;
  overflow: hidden;
  background: linear-gradient(135deg, #F5F5F7 0%, #E8E8ED 100%);
}

.related-card img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.related-card:hover .related-card-image-wrapper img {
  transform: scale(1.05);
}

.related-info {
  padding: 12px;
}

.related-title {
  font-size: 13px;
  font-weight: 600;
  color: #1D1D1F;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
  text-align: left;
}

.related-price-wrapper {
  display: flex;
  align-items: baseline;
  gap: 6px;
}

.related-price {
  font-size: 15px;
  font-weight: 600;
  color: #1D1D1F;
}

.related-original-price {
  font-size: 13px;
  font-weight: 400;
  color: var(--color-text-secondary);
  text-decoration: line-through;
}

/* 相关产品价格后缀（"起"字） */
.related-price .price-suffix {
  font-size: 0.6em;
  margin-left: 2px;
  font-weight: normal;
  color: #999;
}

.related-placeholder-icon {
  width: 48px;
  height: 48px;
  color: #C0C0C0;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* ========== 响应式 ========== */
@media (min-width: 768px) {
  /* 显示桌面端操作按钮 */
  .product-actions {
    display: flex;
  }

  /* 隐藏移动端底部固定栏 */
  .bottom-bar {
    display: none;
  }

  .product-title {
    font-size: 32px;
  }

  .product-price {
    font-size: 36px;
  }

  .product-original-price {
    font-size: 20px;
  }

  .product-gallery {
    padding: var(--space-12);
  }

  .related-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
  }
}

/* ========== Drupal Commerce 添加到购物车表单样式 ========== */
.product-add-to-cart-wrapper,
.product-actions form {
  margin-top: var(--space-6);
  padding-top: var(--space-6);
  border-top: 1px solid var(--color-border-subtle);
}

/* 隐藏表单中不需要的字段 */
.product-add-to-cart-wrapper .form-item,
.product-add-to-cart-wrapper label,
.product-actions form .form-item,
.product-actions form label {
  display: none;
}

/* 样式化提交按钮 */
.product-add-to-cart-wrapper .form-actions,
.product-actions form .form-actions {
  display: flex;
  gap: var(--space-3);
}

.product-add-to-cart-wrapper .button--add-to-cart,
.product-add-to-cart-wrapper .button--add-to-cart-ajax,
.product-actions form .button--add-to-cart,
.product-actions form .button--add-to-cart-ajax {
  flex: 1;
  padding: var(--space-4) var(--space-6);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition-base) var(--ease-out);
  text-align: center;
  min-height: 48px;
}

.product-add-to-cart-wrapper .button--add-to-cart:hover,
.product-add-to-cart-wrapper .button--add-to-cart-ajax:hover,
.product-actions form .button--add-to-cart:hover,
.product-actions form .button--add-to-cart-ajax:hover {
  background: #0052A3;
}

.product-add-to-cart-wrapper .button--add-to-cart:disabled,
.product-add-to-cart-wrapper .button--add-to-cart-ajax:disabled,
.product-actions form .button--add-to-cart:disabled,
.product-actions form .button--add-to-cart-ajax:disabled {
  background: var(--color-bg-subtle);
  color: var(--color-text-secondary);
  cursor: not-allowed;
}

/* 查看购物车链接 */
.product-add-to-cart-wrapper .button--view-cart,
.product-actions form .button--view-cart {
  flex: 1;
  padding: var(--space-4) var(--space-6);
  background: var(--color-bg-subtle);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 16px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  min-height: 48px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.product-add-to-cart-wrapper .button--view-cart:hover,
.product-actions form .button--view-cart:hover {
  background: #E8E8ED;
}

/* 移动端底部栏表单 */
.bottom-bar-form {
  flex: 1;
}

.bottom-bar-form form {
  display: flex;
  gap: var(--space-2);
}

.bottom-bar-form .form-item {
  display: none;
}

.bottom-bar-form .form-actions {
  display: flex;
  gap: 0;
  width: 100%;
}

.bottom-bar-form .button--add-to-cart,
.bottom-bar-form .button--add-to-cart-ajax {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-primary);
  color: white;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
}

.bottom-bar-form .button--add-to-cart:hover,
.bottom-bar-form .button--add-to-cart-ajax:hover {
  background: #0052A3;
}

/* 移动端查看购物车按钮 */
.bottom-bar-form .button--view-cart {
  width: 100%;
  padding: var(--space-3) var(--space-4);
  background: var(--color-bg-subtle);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.bottom-bar-form .button--view-cart:hover {
  background: var(--color-bg-hover);
}

/* AJAX 加载指示器 */
.product-add-to-cart-wrapper .ajax-progress,
.product-actions form .ajax-progress {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* 成功消息 */
.cart-message-success {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 16px 24px;
  border-radius: 8px;
  font-size: 15px;
  z-index: 9999;
  animation: fadeIn 0.3s ease-out;
}

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

/* ========== 产品热度指标和库存指示器（紧凑版，并排显示） ========== */
.product-price-note-wrapper {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-top: var(--space-2);
  margin-bottom: var(--space-2);
}

.product-price-note {
  margin: 0;
  flex: 1;
  min-width: 200px;
}

.product-meta-items {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  flex-wrap: wrap;
}

.product-heat-compact {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  padding: var(--space-1) var(--space-2);
  background: linear-gradient(135deg, #FFF0F0 0%, #FFF5F5 100%);
  border-radius: var(--radius-sm);
  border: 1px solid #FFD0D0;
  font-size: 12px;
  white-space: nowrap;
}

.heat-icon-emoji {
  font-size: 14px;
  line-height: 1;
  flex-shrink: 0;
}

.heat-text {
  color: var(--color-text-secondary);
  line-height: 1.4;
}

.heat-text strong {
  color: #FF4500;
  font-weight: 600;
}

/* ========== 库存指示器 ========== */
.stock-indicator {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-sm);
  font-size: 12px;
  font-weight: 500;
}

.stock-text {
  font-weight: 600;
}

.stock-value {
  font-weight: 400;
  opacity: 0.8;
}

/* 有货 - 绿色 */
.stock-in-stock {
  background: linear-gradient(135deg, #E8F5E9 0%, #F1F8F4 100%);
  border: 1px solid #A5D6A7;
  color: #2E7D32;
}

.stock-in-stock .stock-text {
  color: #2E7D32;
}

/* 库存紧张 - 橙色 */
.stock-low-stock {
  background: linear-gradient(135deg, #FFF3E0 0%, #FFF8F0 100%);
  border: 1px solid #FFB74D;
  color: #F57C00;
}

.stock-low-stock .stock-text {
  color: #F57C00;
}

/* 缺货 - 红色（推荐，更醒目） */
.stock-out-of-stock {
  background: linear-gradient(135deg, #FFEBEE 0%, #FFF5F5 100%);
  border: 1px solid #EF9A9A;
  color: #C62828;
}

.stock-out-of-stock .stock-text {
  color: #C62828;
}

/* 未知状态 - 灰色 */
.stock-unknown {
  background: linear-gradient(135deg, #F5F5F5 0%, #FAFAFA 100%);
  border: 1px solid #E0E0E0;
  color: #757575;
}

.stock-unknown .stock-text {
  color: #757575;
}

/* 移动端优化 */
@media (max-width: 767px) {
  .product-price-note-wrapper {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--space-2);
  }

  .product-price-note {
    min-width: 0;
  }

  .product-meta-items {
    width: 100%;
    justify-content: flex-start;
  }

  .product-heat-compact,
  .stock-indicator {
    font-size: 11px;
    padding: var(--space-1) var(--space-2);
  }

  .heat-icon-emoji {
    font-size: 12px;
  }
}


/* ========== 视频卡片样式 ========== */
.video-card {
  background: white;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
  width: 100%;
  max-width: 800px;
  margin: 0 auto;
}

.video-container {
  position: relative;
  width: 100%;
  aspect-ratio: 16 / 9;
  background: #000;
}

.video-player {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
}

/* 视频加载指示器 */
.video-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.8);
  z-index: 10;
  transition: opacity 0.3s ease;
}

.video-loading-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

.video-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.video-loading-text {
  color: white;
  margin-top: var(--space-3);
  font-size: 14px;
}
