/**
 * @file
 * 火彩商城 - 产品列表页面样式
 * 基于 design-prototypes/product-list.html 设计
 */

/* ===== 产品列表页面布局调整 ===== */
.layout-product-list {
  overflow-x: hidden;
}

/* ===== 筛选栏 - 固定定位 ===== */
.filter-bar {
  position: fixed;
  top: 56px;
  left: 0;
  right: 0;
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: saturate(180%) blur(20px);
  -webkit-backdrop-filter: saturate(180%) blur(20px);
  border-bottom: 1px solid rgba(0, 0, 0, 0.08);
  z-index: 40;
  padding: 12px 0;
}

.filter-bar .content-section {
  max-width: 1440px;
  margin: 0 auto;
  padding: 0 12px;
}

/* 筛选栏头部 */
.filter-bar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
}

.filter-bar-header .section-title {
  font-size: 24px;
  font-weight: 600;
  color: #1D1D1F;
  margin: 0;
}

/* 筛选按钮 */
.filter-toggle {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  color: #0066CC;
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-toggle:hover {
  background: #F5F5F7;
}

.filter-toggle svg {
  width: 16px;
  height: 16px;
}

/* 分类标签 */
.filter-chips {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 12px;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
}

.filter-chips::-webkit-scrollbar {
  display: none;
}

.filter-chip {
  display: inline-flex;
  align-items: center;
  padding: 6px 14px;
  background: #F5F5F7;
  border-radius: 16px;
  font-size: 13px;
  color: #1D1D1F;
  text-decoration: none;
  transition: all 0.2s ease;
  white-space: nowrap;
  cursor: pointer;
  border: none;
}

.filter-chip:hover {
  background: #E8E8ED;
}

.filter-chip.active {
  background: #0066CC;
  color: white;
}

/* 筛选栏底部 */
.filter-bar-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-top: 12px;
  border-top: 1px solid rgba(0, 0, 0, 0.06);
}

.product-count {
  font-size: 13px;
  color: #6E6E73;
}

.filter-bar-actions {
  display: flex;
  align-items: center;
  gap: 16px;
}

/* 视图切换按钮组 */
.view-toggle-group {
  display: flex;
  align-items: center;
  gap: 4px;
  padding-right: 16px;
  border-right: 1px solid rgba(0, 0, 0, 0.1);
}

.view-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: #6E6E73;
  cursor: pointer;
  transition: all 0.2s ease;
}

.view-toggle:hover {
  background: #F5F5F7;
  color: #1D1D1F;
}

.view-toggle.active {
  background: #0066CC;
  color: white;
}

.view-toggle svg {
  width: 20px;
  height: 20px;
}

/* 排序选择 - 美化样式 */
.sort-select-wrapper {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: #F5F5F7;
  border-radius: 12px;
  transition: all 0.2s ease;
}

.sort-select-wrapper:hover {
  background: #E8E8ED;
}

.sort-icon {
  width: 16px;
  height: 16px;
  color: #6E6E73;
  flex-shrink: 0;
}

.sort-select {
  font-size: 14px;
  font-weight: 500;
  border: none;
  background: transparent;
  color: #1D1D1F;
  cursor: pointer;
  padding: 4px 28px 4px 8px;
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.sort-select:hover {
  color: #0066CC;
}

.sort-select:focus {
  outline: none;
  background: rgba(0, 102, 204, 0.08);
}

/* 下拉箭头 */
.sort-select-wrapper {
  position: relative;
}

.sort-select-wrapper::after {
  content: '';
  position: absolute;
  right: 14px;
  top: 50%;
  transform: translateY(-50%);
  width: 0;
  height: 0;
  border-left: 5px solid transparent;
  border-right: 5px solid transparent;
  border-top: 5px solid #6E6E73;
  pointer-events: none;
  transition: all 0.2s ease;
}

.sort-select-wrapper:hover::after {
  border-top-color: #0066CC;
}

/* 移动端优化 */
@media (max-width: 767px) {
  .sort-select-wrapper {
    padding: 6px 12px;
  }

  .sort-select {
    font-size: 13px;
    padding: 4px 24px 4px 6px;
  }

  .sort-icon {
    width: 14px;
    height: 14px;
  }
}

/* ===== 主内容区域 ===== */
/* ===== 主内容区 - 为固定定位的筛选栏预留空间 ===== */
.product-list-main {
  padding-top: 180px; /* /products 页面：无 filter-chips */
  padding-bottom: 48px;
  min-height: calc(100vh - 56px);
}

/* 有 filter-chips 的页面（/tea, /taxonomy/term 等）增加 padding */
.layout-product-list:has(.filter-chips) .product-list-main,
.page-taxonomy-term .product-list-main {
  padding-top: 230px; /* 有分类标签时需要更多空间 */
}

/* 当有通知栏时调整 */
body.has-notice .product-list-main {
  padding-top: 220px; /* 基础值 + 44px */
}

body.has-notice.has-status .product-list-main {
  padding-top: 262px; /* 基础值 + 88px */
}

/* 当有通知栏且有分类标签时 */
body.has-notice:has(.filter-chips) .product-list-main,
body.has-notice.page-taxonomy-term .product-list-main {
  padding-top: 274px; /* 有分类标签 (230px) + 通知栏 (44px) */
}

body.has-notice.has-status:has(.filter-chips) .product-list-main,
body.has-notice.has-status.page-taxonomy-term .product-list-main {
  padding-top: 318px; /* 有分类标签 (230px) + 通知栏 + 状态栏 (88px) */
}

body.has-notice .filter-bar {
  top: 100px;
}

body.has-notice.has-status .filter-bar {
  top: 142px;
}

/* ===== 产品网格 ===== */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  margin-top: 0; /* 由 .product-list-main 的 padding-top 统一控制 */
  margin-bottom: 24px;
}

@media (min-width: 768px) {
  .product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
  }
}

@media (min-width: 1024px) {
  .product-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

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

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

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

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

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

.product-card-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #C0C0C0;
}

.product-card-placeholder svg {
  width: 48px;
  height: 48px;
}

/* 产品徽章 */
.product-badge {
  position: absolute;
  top: 8px;
  left: 8px;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  z-index: 10;
}

.badge-new {
  background: #FF3B30;
  color: white;
}

.badge-sale {
  background: #0066CC;
  color: white;
}

.badge-hot {
  background: #FF9500;
  color: white;
}

/* ========== 产品标签徽章颜色 ========== */
.badge-new {
  background: #34C759;
  color: white;
}

.badge-recommend {
  background: #0066CC;
  color: white;
}

.badge-old-tea {
  background: #C69C6D;
  color: white;
}

/* 产品卡片内容 */
.product-card-content {
  padding: 12px;
}

.product-card-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;
}

.product-card-description {
  font-size: 11px;
  color: #6E6E73;
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 1;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.product-card-footer {
  display: flex;
  align-items: center;
  gap: 8px;
}

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

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

/* 如果有原价，说明是会员价，显示为红色 */
.product-card-footer:has(.product-card-price-original) .product-card-price {
  color: #EA0029;
  font-size: 13px;
}

.product-card-price-original {
  font-size: 11px;
  color: #86868B;
  text-decoration: line-through;
  margin-right: 4px;
}

.product-card-footer {
  display: flex;
  align-items: baseline;
  flex-wrap: wrap;
}

/* ===== 列表视图样式 ===== */
.product-grid.list-view {
  grid-template-columns: 1fr;
  gap: 16px;
}

.product-grid.list-view .product-card {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.product-grid.list-view .product-card > *:first-child {
  flex-shrink: 0;
}

.product-grid.list-view .product-card-image-wrapper {
  width: 120px;
  height: 120px;
}

@media (min-width: 768px) {
  .product-grid.list-view .product-card-image-wrapper {
    width: 160px;
    height: 160px;
  }
}

.product-grid.list-view .product-card-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  padding: 12px 16px;
}

.product-grid.list-view .product-card-title {
  font-size: 15px;
}

@media (min-width: 768px) {
  .product-grid.list-view .product-card-title {
    font-size: 17px;
  }
}

/* 列表视图徽章 */
.list-badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-bottom: 8px;
  align-self: flex-start;
  background: #E8E8ED !important;
  color: #6E6E73 !important;
}

.list-badge.badge-new {
  background: #34C759 !important;
  color: white !important;
}

.list-badge.badge-recommend {
  background: #0066CC !important;
  color: white !important;
}

.list-badge.badge-sale {
  background: #FF3B30 !important;
  color: white !important;
}

.list-badge.badge-hot {
  background: #FF9500 !important;
  color: white !important;
}

.list-badge.badge-old-tea {
  background: #C69C6D !important;
  color: white !important;
}

/* ===== 空状态 ===== */
.product-grid-empty {
  grid-column: 1 / -1;
  text-align: center;
  padding: 80px 20px;
  color: #6E6E73;
}

.product-grid-empty p {
  font-size: 15px;
  margin: 0;
}

/* ===== 加载更多按钮 ===== */
.load-more-container {
  margin-top: 32px;
  text-align: center;
}

.load-more-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px;
  background: white;
  border: 1.5px solid rgba(0, 0, 0, 0.08);
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  color: #0066CC;
  cursor: pointer;
  transition: all 0.2s ease;
}

.load-more-btn:hover {
  background: #F5F5F7;
  border-color: rgba(0, 0, 0, 0.12);
}

.load-more-btn:active {
  transform: scale(0.98);
}

.load-more-text {
  font-size: 15px;
}

.load-more-count {
  font-size: 13px;
  color: #86868B;
  font-weight: 400;
}

.load-more-icon {
  width: 16px;
  height: 16px;
  transition: transform 0.2s ease;
}

.load-more-btn:hover .load-more-icon {
  transform: translateY(2px);
}

.load-more-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  color: #86868B;
  font-size: 14px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  animation: spin 1s linear infinite;
}

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

.load-more-complete {
  text-align: center;
  padding: 20px;
  color: #86868B;
  font-size: 14px;
}

.load-more-complete p {
  margin: 0;
}

/* ===== Views Load More 按钮统一样式 ===== */
.pager {
  margin-top: 32px;
  text-align: center;
}

/* Views Load More 链接样式，使其与我们的按钮一致 */
.pager .js-pager__link {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 28px !important;
  background: white !important;
  border: 1.5px solid rgba(0, 0, 0, 0.08) !important;
  border-radius: 12px !important;
  font-size: 15px !important;
  font-weight: 600 !important;
  color: #0066CC !important;
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none !important;
  margin: 0 !important;
  min-width: auto !important;
}

.pager .js-pager__link:hover {
  background: #F5F5F7 !important;
  border-color: rgba(0, 0, 0, 0.12) !important;
  color: #0066CC !important;
}

.pager .js-pager__link:active {
  transform: scale(0.98);
}

/* Views 加载状态 */
.pager .js-pager__loading {
  display: inline-flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 20px;
  color: #86868B;
  font-size: 14px;
}

.pager .js-pager__loading-item {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* 隐藏 Views 默认的加载 spinner，使用我们的 */
.pager .js-pager__loading-item::after {
  content: "";
  display: none;
}

/* ===== 分页 ===== */
.product-list-pagination {
  margin-top: 32px;
}

/* ===== 响应式调整 ===== */
@media (max-width: 767px) {
  .filter-bar-header .section-title {
    font-size: 20px;
  }

  .product-list-main {
    padding-top: 180px;
    padding-bottom: 32px;
  }

  .product-card-content {
    padding: 10px;
  }

  .product-card-title {
    font-size: 12px;
  }

  .product-card-description {
    font-size: 10px;
  }

  .product-card-price {
    font-size: 14px;
  }
}
