/* 样式表：为居家乐商城提供简洁、科技感的绿色主题。 */

/* 通用变量 */
:root {
  --primary-color: #0a9a62; /* 主色调：深绿色 */
  --secondary-color: #0ec489; /* 次色调：浅绿色 */
  --neutral-light: #f7fdf8; /* 浅背景色 */
  --text-dark: #013b24; /* 深色文本 */
  --text-light: #ffffff; /* 白色文本 */
  --max-width: 1140px;
  --border-radius: 6px;
  --transition-fast: 0.2s ease;
}

/* 重置默认样式 */
*, *::before, *::after {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: "Arial", "Helvetica Neue", sans-serif;
  background-color: var(--neutral-light);
  color: var(--text-dark);
  line-height: 1.6;
}

a {
  color: var(--primary-color);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* 容器 */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 1rem;
}

/* 页面头部 */
.site-header {
  background-color: var(--primary-color);
  color: var(--text-light);
  padding: 0.8rem 0;
}

.site-header .logo {
  margin: 0;
  font-size: 1.5rem;
  font-weight: bold;
}

.main-nav ul {
  list-style: none;
  display: flex;
  flex-wrap: wrap;
  margin: 0;
  padding: 0;
  gap: 1.2rem;
}

.main-nav a {
  color: var(--text-light);
  font-weight: 500;
  transition: color var(--transition-fast);
}

.main-nav a:hover {
  color: #c9f7e2;
}

/* 英雄区域 */
.hero {
  position: relative;
  overflow: hidden;
  margin-bottom: 2rem;
}

.hero-image {
  width: 100%;
  height: 320px;
  object-fit: cover;
}

.hero-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: var(--text-light);
  text-align: center;
}

.hero-content h2 {
  margin: 0 0 0.5rem;
  font-size: 2rem;
  font-weight: bold;
}

.hero-content p {
  margin: 0 0 1rem;
  font-size: 1rem;
}

.btn {
  display: inline-block;
  padding: 0.6rem 1.4rem;
  border-radius: var(--border-radius);
  font-weight: bold;
  cursor: pointer;
  text-align: center;
  transition: background-color var(--transition-fast);
}

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

.btn-primary:hover {
  background-color: #0fbf7b;
}

/* 功能卡片 */
.features {
  background-color: #e9f7ef;
  padding: 2rem 0;
}

.features-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 1rem;
  align-items: stretch;
}

.feature-card {
  background-color: #fff;
  border: 1px solid #d5ead4;
  border-radius: var(--border-radius);
  padding: 1rem;
  text-align: center;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.feature-card img {
  width: 64px;
  height: 64px;
  object-fit: contain;
  margin-bottom: 0.6rem;
}

.feature-card h3 {
  margin: 0.4rem 0;
  font-size: 1.2rem;
  color: var(--primary-color);
}

.feature-card p {
  margin: 0;
  font-size: 0.9rem;
  color: #47685b;
}

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

/* 商品分类 */
.categories {
  padding: 2rem 0;
}

.categories h2 {
  margin-bottom: 1.5rem;
  font-size: 1.6rem;
  text-align: center;
  color: var(--primary-color);
}

.category-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
}

.category-card {
  background-color: #fff;
  border: 1px solid #d5ead4;
  border-radius: var(--border-radius);
  text-align: center;
  padding: 1rem;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.category-card img {
  width: 80px;
  height: 80px;
  object-fit: contain;
  margin-bottom: 0.4rem;
}

.category-card h4 {
  margin: 0;
  font-size: 1rem;
  color: var(--primary-color);
}

.category-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
}

/* 底部 */
.site-footer {
  background-color: var(--primary-color);
  padding: 1rem 0;
  color: var(--text-light);
  text-align: center;
  font-size: 0.9rem;
}

/* 响应式调整 */
@media (max-width: 600px) {
  .hero-image {
    height: 260px;
  }
  .hero-content h2 {
    font-size: 1.6rem;
  }
}

/* =============== 新增电商页面样式 =============== */

/* 重新定义英雄区域，使背景图居中覆盖，并添加渐变遮罩效果 */
.hero {
  position: relative;
  height: 360px;
  background-size: cover;
  background-position: center;
  margin-bottom: 2rem;
}
.hero .overlay {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  justify-content: center;
  background: linear-gradient(90deg, rgba(10, 154, 98, 0.45), rgba(255, 255, 255, 0));
  padding-left: 8%;
  color: #ffffff;
}
.hero h1 {
  margin: 0 0 8px;
  font-size: 40px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  color: #fff;
}
.hero p {
  margin: 0 0 16px;
  color: #eafff5;
}

/* 卡片和网格布局 */
.card-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 8px 0 24px;
}
.card {
  background: #fff;
  border: 1px solid var(--border, #d8eee3);
  border-radius: 12px;
  overflow: hidden;
}
.card-body {
  padding: 16px;
}
.card-title {
  margin: 0 0 6px;
  font-size: 1.1rem;
  color: var(--primary-color);
}
.card-text {
  margin: 0;
  color: #47685b;
}

/* 产品网格 */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin: 16px 0;
}
.product-card {
  background: #fff;
  border: 1px solid var(--border, #d8eee3);
  border-radius: 12px;
  overflow: hidden;
}
.product-card .thumb {
  background: #e6f7ee;
  background-size: cover;
  background-position: center;
  height: 160px;
}
.product-card .product-title {
  margin: 8px 12px 4px;
  font-weight: 600;
}
.product-card .product-price {
  margin: 0 12px 8px;
  color: var(--primary-color);
  font-weight: 600;
}
.product-card .product-desc {
  margin: 0 12px 16px;
  color: #5b7f71;
  font-size: 0.9rem;
}
.product-card .product-link {
  display: block;
  color: inherit;
  text-decoration: none;
}

/* 商品详情页 */
.product-detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin: 24px 0;
}
.product-detail .thumb.lg {
  height: 360px;
  background-size: cover;
  background-position: center;
  border-radius: 12px;
  border: 1px solid var(--border, #d8eee3);
}
.product-detail .price {
  color: var(--primary-color);
  font-size: 24px;
  font-weight: 700;
}
.product-detail .buy-box {
  display: flex;
  gap: 12px;
  align-items: center;
  margin: 12px 0;
}
.product-detail input[type=number] {
  width: 80px;
  padding: 8px;
  border: 1px solid var(--border, #d8eee3);
  border-radius: 8px;
}
.product-detail .features {
  list-style: none;
  padding-left: 0;
  margin-top: 16px;
  color: #47685b;
}

/* 购物车页面 */
.cart-list .cart-item {
  display: grid;
  grid-template-columns: 96px 1fr 120px;
  gap: 12px;
  align-items: center;
  border-bottom: 1px solid var(--border, #d8eee3);
  padding: 12px 0;
}
.cart-item .thumb {
  height: 72px;
  background-size: cover;
  background-position: center;
  border-radius: 8px;
}
.cart-item .meta .name {
  font-weight: 600;
}
.cart-item .meta .price {
  color: var(--primary-color);
}
.cart-item .qty-box {
  display: flex;
  gap: 8px;
  align-items: center;
}
.cart-item .qty-box button {
  padding: 6px 10px;
  border: 1px solid var(--border, #d8eee3);
  background: #fff;
  color: var(--primary-color);
  border-radius: 4px;
  cursor: pointer;
}
.cart-item .qty-box button:hover {
  background: #e9f7ef;
}
.cart-item .line {
  font-weight: 700;
}

/* 订单结算页 */
.order-items {
  border: 1px solid var(--border, #d8eee3);
  border-radius: 12px;
  padding: 12px;
}
.order-line {
  display: flex;
  justify-content: space-between;
  border-bottom: 1px dashed var(--border, #d8eee3);
  padding: 8px 0;
}
.order-line:last-child {
  border-bottom: none;
}

/* 按钮样式（覆盖全局） */
.btn-primary {
  background: var(--primary-color);
  color: #fff;
  border: none;
  border-radius: 8px;
  padding: 10px 16px;
  cursor: pointer;
  text-decoration: none;
  display: inline-block;
}
.btn-outline {
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
  background: #fff;
  border-radius: 8px;
  padding: 9px 16px;
  text-decoration: none;
  display: inline-block;
}
.btn-primary:hover {
  filter: brightness(0.95);
}
.btn-outline:hover {
  background: #e9fbf3;
}

/* 响应式布局：中屏两列，小屏单列 */
@media (max-width: 900px) {
  .card-grid,
  .product-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .product-detail {
    grid-template-columns: 1fr;
  }
}
@media (max-width: 560px) {
  .card-grid,
  .product-grid {
    grid-template-columns: 1fr;
  }
  .hero {
    height: 260px;
  }
  .hero h1 {
    font-size: 28px;
  }
}

/* =============================== */
/* 新增样式：顶部导航与首页三列布局 */
/* 顶部导航改为白底深色字，包含六大栏目 */
.site-header {
  position: sticky;
  top: 0;
  z-index: 20;
  background: #fff;
  border-bottom: 1px solid #d8eee3;
  color: var(--text-dark);
}
.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  padding: 0.5rem 0;
}
.topbar .logo {
  font-weight: bold;
  font-size: 1.4rem;
  color: var(--text-dark);
  text-decoration: none;
}
.main-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 18px;
}
.main-nav a {
  color: var(--text-dark);
  text-decoration: none;
  padding: 6px;
  border-radius: 6px;
}
.main-nav a:hover {
  background: rgba(10, 154, 98, 0.08);
  text-decoration: none;
}
.main-nav a.active {
  color: var(--primary-color);
  background: rgba(10, 154, 98, 0.12);
}
.user-nav .cart-link {
  color: var(--text-dark);
  text-decoration: none;
}
.badge {
  display: inline-block;
  background: var(--primary-color);
  color: #fff;
  border-radius: 999px;
  padding: 2px 8px;
  margin-left: 6px;
  font-size: 12px;
}
@media (max-width: 900px) {
  .topbar {
    flex-direction: column;
    align-items: flex-start;
  }
  .user-nav {
    align-self: flex-end;
  }
}

/* 首页三列布局样式 */
.home-3col {
  display: grid;
  grid-template-columns: 220px 1fr 280px;
  gap: 16px;
  margin: 16px 0;
}
.side-cats {
  background: #fff;
  border: 1px solid #d8eee3;
  border-radius: 12px;
  padding: 10px;
}
.cats-title {
  margin: 6px 8px;
  font-size: 16px;
}
.cats-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.cats-list li a {
  display: block;
  padding: 10px 12px;
  color: var(--text-dark);
  text-decoration: none;
  border-radius: 8px;
}
.cats-list li a:hover {
  background: #e9fbf3;
  color: var(--primary-color);
}
.home-hero .hero {
  height: 300px;
  background-size: cover;
  background-position: center;
  border-radius: 12px;
  position: relative;
  overflow: hidden;
}
.home-hero .overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, rgba(10,154,98,0.45), rgba(255,255,255,0));
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding-left: 6%;
}
.home-hero h1 {
  color: #fff;
  margin: 0 0 6px;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
  font-size: 32px;
}
.home-hero p {
  color: #eafff5;
  margin: 0 0 12px;
}
.promo-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 12px;
  margin-top: 12px;
}
.promo-card {
  display: flex;
  gap: 10px;
  align-items: center;
  padding: 10px;
  background: #fff;
  border: 1px solid #d8eee3;
  border-radius: 12px;
  text-decoration: none;
  color: var(--text-dark);
}
.promo-thumb {
  width: 56px;
  height: 56px;
  border-radius: 10px;
  background: #e6f7ee;
}
.promo-body span {
  display: block;
  color: #5b7f71;
  font-size: 12px;
}
.side-user .user-card {
  background: #fff;
  border: 1px solid #d8eee3;
  border-radius: 12px;
  padding: 14px;
  text-align: center;
}
.uc-avatar {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  margin: 8px auto;
  background: #e6f7ee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 28px;
}
.uc-welcome {
  margin: 6px 0 10px;
}
.uc-actions .btn-primary,
.uc-actions .btn-outline {
  display: block;
  margin: 8px 0;
}
.uc-links {
  display: flex;
  justify-content: center;
  gap: 12px;
  margin-top: 8px;
}
@media (max-width: 1100px) {
  .home-3col {
    grid-template-columns: 200px 1fr;
  }
  .side-user {
    display: none;
  }
  .promo-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}
@media (max-width: 720px) {
  .home-3col {
    grid-template-columns: 1fr;
  }
  .promo-grid {
    grid-template-columns: 1fr 1fr;
  }
  .home-hero .hero {
    height: 240px;
  }
}

/* === 新首页布局 === */
.home-layout {
  display: grid;
  grid-template-columns: 220px 1fr;
  gap: 16px;
  margin: 16px 0;
}
.main-area > .featured-products {
  margin-top: 20px;
}
.featured-products h2 {
  margin: 0 0 12px;
  font-size: 20px;
  color: var(--primary-color);
}
.home-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
  gap: 16px;
}
.home-product-card {
  background: #fff;
  border: 1px solid #d8eee3;
  border-radius: 12px;
  padding: 12px;
  text-align: left;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}
.home-product-card:hover {
  transform: translateY(-3px);
  box-shadow: 0 3px 8px rgba(0, 0, 0, 0.08);
}
.home-product-card img {
  width: 100%;
  height: 120px;
  object-fit: contain;
  margin-bottom: 8px;
}
.home-product-card h4 {
  margin: 0 0 4px;
  font-size: 16px;
  color: var(--text-dark);
}
.home-product-card p {
  margin: 0 0 6px;
  color: var(--primary-color);
  font-weight: 600;
}
.home-product-card a.btn-small {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  background: var(--primary-color);
  color: #fff;
  font-size: 12px;
  text-align: center;
  transition: background-color var(--transition-fast);
}
.home-product-card a.btn-small:hover {
  background: var(--secondary-color);
}
.cat-icon {
  width: 20px;
  height: 20px;
  margin-right: 8px;
  vertical-align: middle;
}
.cats-list li a {
  display: flex;
  align-items: center;
  gap: 8px;
}

/* 响应式调整新首页布局 */
@media (max-width: 900px) {
  .home-layout {
    grid-template-columns: 1fr;
  }
  .cats-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
  }
  .cats-list li {
    flex: 1 1 48%;
  }
}