/* 首页专用样式文件 */

/* 定义CSS变量 */
:root {
  --site-max-width: 1400px;
  --primary-color: #007AFF;
  --secondary-color: #FF6B35;
  --accent-color: #00C896;
  --text-dark: #1A1A1A;
  --text-light: #666666;
  --text-muted: #999999;
  --bg-white: #FFFFFF;
  --bg-light: #F8F9FA;
  --bg-lighter: #FAFBFC;
  --border-color: #E5E8EB;
  --border-light: #F0F2F5;
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.06);
  --shadow-md: 0 4px 16px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 8px 32px rgba(0, 0, 0, 0.12);
  --radius-sm: 6px;
  --radius-md: 8px;
  --radius-lg: 12px;
  --transition: all 0.2s ease;
  --gradient-primary: linear-gradient(135deg, #007AFF, #00C896);
  --gradient-secondary: linear-gradient(135deg, #FF6B35, #FF9E00);
}

/* 基本容器 */
.home-content.container {
  max-width: var(--site-max-width);
  margin: 0 auto;
  padding: 0 20px;
}

/* Hero 区域样式 */
.home-hero {
  background: linear-gradient(135deg, rgba(0, 122, 255, 0.05) 0%, rgba(0, 200, 150, 0.05) 100%);
  padding: 60px 0;
  border-bottom: 1px solid var(--border-light);
  margin-top: 20px;
}

.home-hero .hero-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 20px;
  max-width: 800px;
  margin: 0 auto;
}

.home-hero h2 {
  font-size: 2.2rem;
  margin: 0;
  color: var(--text-dark);
  font-weight: 600;
}

.home-hero p {
  font-size: 1rem;
  color: var(--text-light);
  margin: 0;
}

/* 搜索栏 */
.search-bar {
  width: 100%;
  max-width: 600px;
  margin-top: 20px;
}

.search-input-wrapper {
  display: flex;
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-md);
  background: var(--bg-white);
  border: 2px solid transparent;
  transition: var(--transition);
  height: 44px;
}

.search-input-wrapper:focus-within {
  border-color: var(--primary-color);
  transform: translateY(-2px);
}

.search-bar input[type=text] {
  flex: 1;
  padding: 12px 20px;
  border: none;
  outline: none;
  font-size: 16px;
  background: transparent;
}

.search-bar button {
  padding: 12px 24px;
  background: var(--gradient-primary);
  color: var(--bg-white);
  border: none;
  cursor: pointer;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: var(--transition);
  font-size: 16px;
}

.search-bar button:hover {
  background: var(--gradient-secondary);
  transform: scale(1.02);
}

.search-icon {
  width: 18px;
  height: 18px;
}

/* 分类和商品推荐区域 */
.home-featured-section {
  display: flex;
  margin-top: 20px;
}

/* 分类区域 */
.category-section {
  flex: 0 0 190px;
  background: var(--bg-white);
  border-radius: 6px;
  padding: 12px;
  position: relative;
}

.category-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 10px;
}

.category-section h3 {
  font-size: 14px;
  font-weight: bold;
  color: #333;
  margin: 0;
  padding-left: 3px;
}

.category-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  display: none;
}

.category-toggle:hover {
  background: var(--bg-light);
}

.toggle-icon {
  transition: transform 0.3s ease;
}

.category-toggle.expanded .toggle-icon {
  transform: rotate(180deg);
}

.category-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-gap: 8px;
}

.category-link {
  text-decoration: none;
  color: var(--text-light);
  font-size: 14px;
  display: block;
  padding: 6px 8px;
  border-radius: 4px;
  transition: all 0.2s ease;
  text-align: center;
}

.category-link:hover {
  background: var(--bg-light);
  color: var(--primary-color);
}

/* 商品推荐区域 */
.product-recommendation-section {
  flex: 1;
  margin-left: 12px;
  margin-right: 12px;
  overflow: hidden;
  padding: 12px;
  background: var(--bg-white);
  border-radius: 6px;
}

.product-recommendation-section h3 {
  font-size: 14px;
  font-weight: bold;
  margin-bottom: 10px;
  color: #333;
}

/* 商品网格 */
.products-grid {
  min-height: 300px;
}

.products-grid-inner {
  display: flex;
  flex-wrap: wrap;
  margin: -4px;
}

.product-card {
  width: calc(16.666% - 8px);
  margin: 4px;
  background: var(--bg-white);
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  transition: all 0.3s ease;
  text-decoration: none;
  display: block;
}

.product-card:hover {
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.product-image {
  position: relative;
  width: 100%;
  padding-top: 100%;
  /* 1:1 Aspect Ratio (square) */
  overflow: hidden;
}

.product-image img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.product-card:hover .product-image img {
  transform: scale(1.05);
}

.product-info {
  padding: 6px;
}

.product-price {
  color: #ff5722;
  font-weight: bold;
  font-size: 12px;
  margin: 0;
  text-align: center;
}

/* 加载状态 */
.loading,
.error,
.no-products {
  text-align: center;
  padding: 30px 0;
  font-size: 14px;
}

.loading {
  color: var(--text-muted);
}

.error {
  color: #e74c3c;
}

.no-products {
  color: var(--text-muted);
}

/* 响应式设计 */
@media (max-width: 1200px) {
  .product-card {
    width: calc(20% - 8px);
  }
}

@media (max-width: 992px) {
  .product-card {
    width: calc(25% - 8px);
  }
}

@media (max-width: 768px) {
  .home-content.container {
    padding: 0 16px;
  }
  
  .home-hero {
    padding: 40px 0;
    margin-top: 16px;
  }
  
  .home-hero h2 {
    font-size: 2rem;
  }
  
  .home-hero .hero-inner {
    gap: 16px;
  }
  
  .home-featured-section {
    flex-direction: column;
  }
  
  .category-section {
    flex: 0 0 auto;
    width: 100%;
    margin-bottom: 20px;
  }
  
  .product-recommendation-section {
    margin-left: 0;
    margin-right: 0;
  }
  
  .product-card {
    width: calc(33.333% - 8px);
  }
  
  /* 移动端分类折叠样式 */
  .category-toggle {
    display: block;
  }
  
  .category-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-gap: 8px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease, opacity 0.3s ease;
    opacity: 0;
  }
  
  .category-section.expanded .category-grid {
    max-height: 500px;
    opacity: 1;
  }
}

@media (max-width: 480px) {
  .home-hero h2 {
    font-size: 1.75rem;
  }
  
  .product-card {
    width: calc(50% - 8px);
  }
  
  /* 小屏幕设备分类样式调整 - 保持2列布局，只调整间距 */
  .category-grid {
    grid-gap: 6px;
  }
}