/* ========================
   电商网站模板样式
   风格：浅色背景 / 圆角卡片 / 蓝色主色
   ======================== */

:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --bg: #f3f4f6;
  --surface: #ffffff;
  --text: #111827;
  --text-secondary: #6b7280;
  --border: #e5e7eb;
  --radius: 16px;
  --radius-sm: 10px;
  --shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
  --shadow-hover: 0 8px 30px rgba(0, 0, 0, 0.1);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
    "Helvetica Neue", Arial, "Noto Sans SC", "PingFang SC", "Microsoft YaHei",
    sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

img {
  max-width: 100%;
  display: block;
}

a {
  text-decoration: none;
  color: inherit;
}

button {
  cursor: pointer;
  border: none;
  font-family: inherit;
}

/* 顶部导航 */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: var(--surface);
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
  padding: 12px 0;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  display: flex;
  align-items: center;
  gap: 16px;
}

.logo {
  font-size: 26px;
  font-weight: 900;
  color: #111827;
  font-family: "Arial Black", "Impact", "微软雅黑", sans-serif;
  letter-spacing: 2px;
  white-space: nowrap;
}

.logo-k {
  color: #111827;
}

.logo-rest {
  color: #e11d2a;
}

.search-box {
  flex: 1;
  position: relative;
  max-width: 560px;
}

.search-box input {
  width: 100%;
  height: 44px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: var(--bg);
  padding: 0 44px 0 20px;
  font-size: 15px;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

.search-box button {
  position: absolute;
  right: 6px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  display: grid;
  place-items: center;
}

.nav-links {
  display: flex;
  gap: 12px;
  align-items: center;
}

.nav-links a {
  font-size: 14px;
  color: var(--text-secondary);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  transition: background 0.2s, color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
  background: rgba(37, 99, 235, 0.08);
  color: var(--primary);
}

/* 轮播图 */
.hero {
  max-width: 1200px;
  margin: 20px auto;
  padding: 0 16px;
}

.carousel {
  position: relative;
  border-radius: var(--radius);
  overflow: hidden;
  background: #ddd;
  aspect-ratio: 16 / 6;
  box-shadow: var(--shadow);
}

.carousel-track {
  display: flex;
  transition: transform 0.5s ease-in-out;
  height: 100%;
}

.carousel-slide {
  min-width: 100%;
  height: 100%;
  position: relative;
}

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

.carousel-caption {
  position: absolute;
  left: 32px;
  bottom: 32px;
  background: rgba(255, 255, 255, 0.92);
  padding: 16px 24px;
  border-radius: var(--radius-sm);
  max-width: 420px;
}

.carousel-caption h2 {
  margin: 0 0 6px;
  font-size: 22px;
}

.carousel-caption p {
  margin: 0;
  color: var(--text-secondary);
  font-size: 14px;
}

.carousel-btn {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  color: var(--text);
  display: grid;
  place-items: center;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.12);
}

.carousel-btn.prev {
  left: 16px;
}

.carousel-btn.next {
  right: 16px;
}

.carousel-dots {
  position: absolute;
  bottom: 14px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 8px;
}

.carousel-dots button {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.55);
}

.carousel-dots button.active {
  background: #fff;
  width: 20px;
  border-radius: 4px;
}

/* 主体容器 */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  margin: 28px 0 16px;
}

/* 分类标签 */
.category-bar {
  display: flex;
  gap: 10px;
  overflow-x: auto;
  padding-bottom: 8px;
  margin-bottom: 8px;
}

.category-bar::-webkit-scrollbar {
  display: none;
}

.category-pill {
  flex: 0 0 auto;
  padding: 9px 18px;
  border-radius: 999px;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s;
}

.category-pill:hover {
  border-color: var(--primary);
  color: var(--primary);
}

.category-pill.active {
  background: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

/* 商品网格 */
.product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 18px;
}

.product-card {
  background: var(--surface);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
  transition: transform 0.2s, box-shadow 0.2s;
  position: relative;
}

.product-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-hover);
}

.product-image {
  aspect-ratio: 1 / 1;
  background: #f9fafb;
  display: grid;
  place-items: center;
  overflow: hidden;
}

.product-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.product-image .placeholder {
  color: var(--text-secondary);
  font-size: 13px;
}

.product-info {
  padding: 14px;
}

.product-name {
  font-size: 15px;
  font-weight: 600;
  margin: 0 0 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 42px;
}

.product-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: 12px;
  margin-bottom: 10px;
}

.product-price {
  font-size: 20px;
  font-weight: 800;
  color: var(--text);
}

.product-price::before {
  content: "¥";
  font-size: 14px;
  margin-right: 2px;
}

.product-tag {
  position: absolute;
  top: 10px;
  left: 10px;
  background: rgba(37, 99, 235, 0.9);
  color: #fff;
  font-size: 11px;
  padding: 4px 8px;
  border-radius: 6px;
}

/* 空状态 */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state svg {
  width: 64px;
  height: 64px;
  margin-bottom: 16px;
  opacity: 0.5;
}

/* 分页 */
.pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 10px;
  margin-top: 36px;
}

.pagination button {
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 14px;
}

.pagination button:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.pagination .page-num {
  width: 36px;
  height: 36px;
  padding: 0;
  display: grid;
  place-items: center;
}

.pagination .page-num.active {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
}

/* 底部 */
.footer {
  background: var(--surface);
  border-top: 1px solid var(--border);
  padding: 30px 16px;
  text-align: center;
  color: var(--text-secondary);
  font-size: 13px;
}

/* 响应式 */
@media (max-width: 768px) {
  .header-inner {
    flex-wrap: wrap;
  }

  .search-box {
    order: 3;
    max-width: 100%;
    flex-basis: 100%;
  }

  .carousel {
    aspect-ratio: 16 / 9;
  }

  .carousel-caption {
    left: 16px;
    bottom: 16px;
    padding: 12px 16px;
    max-width: 70%;
  }

  .carousel-caption h2 {
    font-size: 16px;
  }

  .product-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}

/* ---------- 数据加载提示（参考 KL 电动的同步提示）---------- */
@keyframes spin {
  to { transform: rotate(360deg); }
}
.page-loading {
  position: fixed;
  inset: 0;
  background: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  z-index: 300;
  color: var(--text-secondary);
  font-size: 15px;
}
.page-loading .spin {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

/* ---------- 卡片淡入（参考 KL 电动的 fade-in-up）---------- */
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in-up {
  animation: fadeInUp 0.5s ease forwards;
}

/* ---------- 后台轮播管理 ---------- */
.slide-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}
.slide-card {
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  background: #fff;
  display: flex;
  flex-direction: column;
}
.slide-thumb {
  width: 100%;
  height: 150px;
  background: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}
.slide-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.slide-info {
  padding: 12px 14px;
  flex: 1;
}
.slide-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
  word-break: break-word;
}
.slide-sub {
  font-size: 13px;
  color: var(--text-secondary);
  word-break: break-word;
}
.slide-actions {
  display: flex;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid var(--border);
}
.empty-hint {
  color: var(--text-secondary);
  font-size: 14px;
  padding: 24px 0;
}
