/* ==========================================
   优选商城 - 全局样式
   ========================================== */
:root {
  --primary: #5b7bc7;
  --primary-dark: #4a66a8;
  --primary-light: #d6dee9;
  --secondary: #3a7a8a;
  --success: #38a169;
  --warning: #d69e2e;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --shadow-sm: 0 1px 2px rgba(0,0,0,0.05);
  --shadow: 0 1px 3px rgba(0,0,0,0.1), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);
  --shadow-xl: 0 20px 25px rgba(0,0,0,0.1), 0 10px 10px rgba(0,0,0,0.04);
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Microsoft YaHei', sans-serif;
  color: var(--gray-800);
  background: var(--gray-50);
  min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
img { max-width: 100%; height: auto; }
button { cursor: pointer; border: none; outline: none; }
input, textarea, select { outline: none; font-family: inherit; }

/* ---- 公告栏 ---- */
.announcement-bar {
  background: white;
  color: #b3b3b3;
  text-align: center;
  padding: 8px 16px;
  font-size: 14px;
  font-weight: 500;
}

/* ---- 导航栏 ---- */
.navbar {
  background: white;
  position: sticky;
  top: 0;
  z-index: 1000;
  box-shadow: var(--shadow);
}
.navbar-inner {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 16px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
}
.navbar-brand {
  font-size: 22px;
  font-weight: 800;
  color: var(--primary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}
.navbar-brand span { font-size: 26px; }
.navbar-brand img { height: 32px; width: auto; display: inline-block; vertical-align: middle; margin-right: 6px; }
.navbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}
.navbar-search input {
  width: 100%;
  padding: 10px 16px;
  padding-right: 44px;
  border: 2px solid var(--gray-200);
  border-radius: 24px;
  font-size: 14px;
  transition: border-color var(--transition);
}
.navbar-search input:focus { border-color: var(--primary); }
.navbar-search button {
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  width: 32px;
  height: 32px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
}
.navbar-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: auto;
}
.nav-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 6px 10px;
  border-radius: var(--radius);
  background: none;
  color: var(--gray-600);
  font-size: 11px;
  transition: all var(--transition);
  position: relative;
}
.nav-btn:hover { color: var(--primary); background: var(--gray-50); }
.nav-btn.active { color: var(--primary); background: #e8f0fe; font-weight:700; }
.nav-btn .icon { font-size: 20px; }
.nav-btn.admin { color: var(--secondary); }
.cart-badge {
  position: absolute;
  top: 2px;
  right: 2px;
  background: var(--primary);
  color: white;
  font-size: 10px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
}

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

/* ---- 通用卡片 ---- */
.card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
}

/* ---- 按钮 ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius);
  font-size: 14px;
  font-weight: 600;
  transition: all var(--transition);
  border: none;
  cursor: pointer;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 12px rgba(91,123,199,0.3); }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #2c5282; }
.btn-outline { background: transparent; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:hover { background: var(--primary); color: white; }
.btn-secondary { background: var(--secondary); color: white; }
.btn-secondary:hover { background: #0e7490; }
.btn-lg { padding: 14px 28px; font-size: 16px; border-radius: var(--radius-lg); }
.btn-sm { padding: 6px 14px; font-size: 13px; }
.btn-full { width: 100%; }
.btn-danger { background: #e53e3e; color: white; }
.btn-danger:hover { background: #c53030; }
.btn-success { background: var(--success); color: white; }
.btn-success:hover { background: #276749; }

/* ---- 商品卡片 ---- */
.product-card {
  background: white;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  overflow: hidden;
  transition: all var(--transition);
  cursor: pointer;
}
.product-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-xl); }
.product-card-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: var(--gray-100);
}
.product-card-body { padding: 12px; }
.product-card-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--gray-800);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}
.product-card-price { display: flex; align-items: center; gap: 6px; margin-bottom: 6px; }
.price-current { font-size: 18px; font-weight: 800; color: var(--primary); }
.price-original { font-size: 13px; color: var(--gray-400); text-decoration: line-through; }
.price-tag {
  background: var(--primary);
  color: white;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 700;
}
.product-card-meta { display: flex; align-items: center; justify-content: space-between; }
.product-stars { color: #f6c90e; font-size: 12px; }
.product-sales { font-size: 12px; color: var(--gray-400); }

/* ---- 商品网格 ---- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
}

/* ---- 区块标题 ---- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
}
.section-title {
  font-size: 22px;
  font-weight: 800;
  color: var(--gray-800);
  display: flex;
  align-items: center;
  gap: 8px;
}
.section-title::before {
  content: '';
  display: inline-block;
  width: 4px;
  height: 22px;
  background: var(--primary);
  border-radius: 2px;
}
.section-more {
  font-size: 14px;
  color: var(--secondary);
  font-weight: 500;
}

/* ---- 星级评分 ---- */
.stars { color: #f6c90e; letter-spacing: 1px; }

/* ---- 徽章 ---- */
.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  font-weight: 700;
}
.badge-hot { background: #eff6ff; color: var(--primary); }
.badge-new { background: #ecfeff; color: var(--secondary); }
.badge-sale { background: #eff6ff; color: var(--primary); }

/* ---- 表单元素 ---- */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; font-weight: 600; color: var(--gray-700); margin-bottom: 6px; }
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  font-size: 14px;
  transition: border-color var(--transition);
  background: white;
}
.form-control:focus { border-color: var(--primary); }
.form-hint { font-size: 12px; color: var(--gray-400); margin-top: 4px; }

/* ---- 底部 ---- */
.footer {
  background: var(--gray-800);
  color: var(--gray-400);
  text-align: center;
  padding: 24px 16px;
  font-size: 14px;
  margin-top: 48px;
}

/* ---- Toast 消息 ---- */
.toast-container {
  position: fixed;
  top: 80px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 14px;
  font-weight: 500;
  min-width: 200px;
  animation: slideIn 0.3s ease;
  border-left: 4px solid var(--success);
}
.toast.error { border-left-color: var(--primary); }
.toast.warning { border-left-color: var(--warning); }
@keyframes slideIn {
  from { transform: translateX(100%); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}

/* ---- 加载状态 ---- */
.loading { display: flex; align-items: center; justify-content: center; padding: 48px; }
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---- 空状态 ---- */
.empty-state { text-align: center; padding: 64px 16px; color: var(--gray-400); }
.empty-state .empty-icon { font-size: 56px; margin-bottom: 16px; }
.empty-state p { font-size: 16px; }

/* ---- 分割线 ---- */
.divider { height: 1px; background: var(--gray-200); margin: 16px 0; }

/* ---- 数量选择器 ---- */
.qty-control {
  display: inline-flex;
  align-items: center;
  border: 2px solid var(--gray-200);
  border-radius: var(--radius);
  overflow: hidden;
}
.qty-control button {
  width: 36px;
  height: 36px;
  background: var(--gray-100);
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--transition);
}
.qty-control button:hover { background: var(--gray-200); }
.qty-control input {
  width: 48px;
  height: 36px;
  text-align: center;
  font-size: 15px;
  font-weight: 700;
  border: none;
  border-left: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
}

/* ---- 模态框 ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal {
  background: white;
  border-radius: var(--radius-xl);
  max-width: 480px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  animation: slideUp 0.3s ease;
}
@keyframes slideUp {
  from { transform: translateY(20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}
.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--gray-200);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.modal-title { font-size: 18px; font-weight: 700; }
.modal-close { font-size: 20px; color: var(--gray-400); background: none; }
.modal-close:hover { color: var(--gray-700); }
.modal-body { padding: 24px; }

/* ---- 响应式 ---- */
@media (max-width: 768px) {
  .navbar-inner { padding: 0 12px; gap: 10px; }
  .navbar-brand { font-size: 18px; }
  .nav-btn span:not(.icon) { display: none; }
  .nav-btn.active span:not(.icon) { display: inline; font-size: 11px; }
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 12px; }
  .section-title { font-size: 18px; }
  .toast-container { top: 70px; right: 12px; }
  .btn-lg { padding: 12px 20px; font-size: 15px; }
}
@media (max-width: 480px) {
  .navbar-search { display: none; }
  .navbar-inner { padding: 0 8px; gap: 6px; height: 56px; }
  .navbar-brand { font-size: 16px; gap: 4px; }
  .navbar-brand img { height: 26px; }
  .nav-btn { padding: 4px 6px; }
  .nav-btn .icon { font-size: 18px; }
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 10px; }
}
