/* ═══════════════════════════════════════════════════════════════
 * B2C Store — 全局样式
 * 轻量、响应式、零框架
 * ═══════════════════════════════════════════════════════════════ */

:root {
  --primary: #0f4c81;
  --primary-dark: #0a3558;
  --primary-light: #3b7db5;
  --accent: #e8913a;
  --accent-dark: #c77a2e;
  --success: #10b981;
  --error: #ef4444;
  --surface: #f8fafc;
  --surface-dark: #f1f5f9;
  --text: #1e293b;
  --text-light: #64748b;
  --border: #e2e8f0;
  --white: #ffffff;
  --black: #0f172a;
  --radius-sm: 6px;
  --radius: 8px;
  --radius-lg: 12px;
  --radius-xl: 16px;
  --shadow-sm: 0 1px 2px rgba(0,0,0,.05);
  --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md: 0 4px 6px -1px rgba(0,0,0,.1), 0 2px 4px -2px rgba(0,0,0,.1);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,.1), 0 4px 6px -4px rgba(0,0,0,.1);
  --container: 1200px;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', 'SF Pro Display', -apple-system, BlinkMacSystemFont,
               'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  color: var(--text);
  background: var(--white);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

a { color: inherit; text-decoration: none; }
img { max-width: 100%; display: block; }
ul, ol { list-style: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* ═══════════════════════════════════════════════════════════════
 * 布局
 * ═══════════════════════════════════════════════════════════════ */
.container {
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

.page-wrap {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.page-main {
  flex: 1;
}

.section {
  padding: 60px 0;
}

/* ═══════════════════════════════════════════════════════════════
 * Header 导航
 * ═══════════════════════════════════════════════════════════════ */
.site-header {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255,255,255,.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 64px;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px;
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--primary);
}

.header-logo .logo-icon {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: var(--white);
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.125rem;
}

.header-nav {
  display: flex;
  align-items: center;
  gap: 4px;
}

.header-nav a {
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text);
  transition: all .15s;
  white-space: nowrap;
}

.header-nav a:hover,
.header-nav a.active {
  color: var(--accent);
  background: rgba(232,145,58,.06);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-cart {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  background: var(--accent);
  color: var(--white);
  transition: all .15s;
}

.header-cart:hover {
  background: var(--accent-dark);
}

.header-cart .cart-badge {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  background: var(--error);
  color: var(--white);
  border-radius: 50%;
  font-size: 0.688rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.header-cart .cart-badge:empty {
  display: none;
}

/* 移动端汉堡菜单 */
.mobile-toggle {
  display: none;
  background: none;
  border: none;
  padding: 8px;
  border-radius: var(--radius);
  color: var(--text);
  font-size: 1.5rem;
}

.mobile-menu {
  display: none;
  border-top: 1px solid var(--border);
  background: var(--white);
  padding: 12px 20px;
}

.mobile-menu.open {
  display: block;
}

.mobile-menu a {
  display: block;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.938rem;
  font-weight: 500;
}

.mobile-menu a:last-child { border-bottom: none; }

@media (max-width: 768px) {
  .header-nav { display: none; }
  .mobile-toggle { display: block; }
}

/* ═══════════════════════════════════════════════════════════════
 * Footer
 * ═══════════════════════════════════════════════════════════════ */
.site-footer {
  background: var(--surface);
  color: var(--text-light);
  padding: 48px 0 20px;
  margin-top: auto;
  border-top: 1px solid var(--border);
}

.footer-grid {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 32px;
  max-width: var(--container);
  margin: 0 auto;
  padding: 0 20px 32px;
  border-bottom: 1px solid var(--border);
}

.footer-col h3 {
  color: var(--text);
  font-size: 0.875rem;
  font-weight: 600;
  margin-bottom: 14px;
}

.footer-col p {
  font-size: 0.813rem;
  line-height: 1.7;
  color: var(--text-light);
}

.footer-col a {
  display: block;
  font-size: 0.813rem;
  padding: 3px 0;
  color: var(--text-light);
  transition: color .15s;
}

.footer-col a:hover {
  color: var(--primary);
}

.footer-bottom {
  max-width: var(--container);
  margin: 0 auto;
  padding: 18px 20px;
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-light);
}

.footer-col hr {
  border-color: var(--border);
}

@media (max-width: 768px) {
  .footer-grid {
    grid-template-columns: 1fr 1fr;
    gap: 24px;
  }
}

@media (max-width: 480px) {
  .footer-grid {
    grid-template-columns: 1fr;
  }
}

/* ═══════════════════════════════════════════════════════════════
 * 按钮
 * ═══════════════════════════════════════════════════════════════ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 24px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 600;
  border: none;
  transition: all .15s;
  text-decoration: none;
  white-space: nowrap;
}

.btn-primary {
  background: var(--primary);
  color: var(--white);
}

.btn-primary:hover {
  background: var(--primary-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-accent {
  background: var(--accent);
  color: var(--white);
}

.btn-accent:hover {
  background: var(--accent-dark);
  transform: translateY(-1px);
  box-shadow: var(--shadow-md);
}

.btn-outline {
  background: var(--white);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-outline:hover {
  background: var(--surface);
  border-color: var(--text-light);
}

.btn-sm {
  padding: 6px 14px;
  font-size: 0.813rem;
}

.btn-lg {
  padding: 14px 32px;
  font-size: 1rem;
}

.btn-block {
  width: 100%;
}

.btn:disabled {
  opacity: .5;
  pointer-events: none;
}

/* ═══════════════════════════════════════════════════════════════
 * 卡片
 * ═══════════════════════════════════════════════════════════════ */
.card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-body {
  padding: 20px;
}

.card-header {
  background: var(--surface-dark);
  border-bottom: 1px solid var(--border);
  padding: 14px 20px;
  font-weight: 600;
}

/* ═══════════════════════════════════════════════════════════════
 * 表单
 * ═══════════════════════════════════════════════════════════════ */
.form-group {
  margin-bottom: 16px;
}

.form-label {
  display: block;
  font-size: 0.813rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.875rem;
  color: var(--text);
  background: var(--white);
  transition: border-color .15s;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(15,76,129,.1);
}

.form-textarea {
  resize: vertical;
  min-height: 100px;
}

/* ═══════════════════════════════════════════════════════════════
 * 消息提示
 * ═══════════════════════════════════════════════════════════════ */
.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  margin-bottom: 16px;
}

.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1d4ed8;
}

.alert-success {
  background: #ecfdf5;
  border: 1px solid #a7f3d0;
  color: #065f46;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-warning {
  background: #fffbeb;
  border: 1px solid #fde68a;
  color: #92400e;
}

/* ═══════════════════════════════════════════════════════════════
 * 面包屑
 * ═══════════════════════════════════════════════════════════════ */
.breadcrumb {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.813rem;
  color: var(--text-light);
  padding: 16px 0;
  flex-wrap: wrap;
}

.breadcrumb a {
  color: var(--text-light);
}

.breadcrumb a:hover {
  color: var(--accent);
}

.breadcrumb .sep {
  color: var(--border);
}

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

.product-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all .2s;
}

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

.product-card-img {
  aspect-ratio: 1;
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  position: relative;
  overflow: hidden;
}

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

.product-card-badge {
  position: absolute;
  top: 12px;
  left: 12px;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 0.688rem;
  font-weight: 700;
  text-transform: uppercase;
}

.badge-new { background: var(--success); color: var(--white); }
.badge-hot { background: var(--error); color: var(--white); }
.badge-sale { background: var(--accent); color: var(--white); }

.product-card-body {
  padding: 16px;
}

.product-card-category {
  font-size: 0.688rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-light);
  margin-bottom: 4px;
}

.product-card-name {
  font-weight: 600;
  color: var(--text);
  margin-bottom: 6px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  line-height: 1.4;
}

.product-card-name a:hover {
  color: var(--accent);
}

.product-card-price {
  display: flex;
  align-items: baseline;
  gap: 8px;
  margin-top: 8px;
}

.product-card-price .price {
  font-size: 1.125rem;
  font-weight: 700;
  color: var(--accent);
}

.product-card-price .price-old {
  font-size: 0.813rem;
  color: var(--text-light);
  text-decoration: line-through;
}

.product-card-actions {
  margin-top: 12px;
}

/* ═══════════════════════════════════════════════════════════════
 * 微动画
 * ═══════════════════════════════════════════════════════════════ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to { opacity: 1; transform: translateY(0); }
}

.animate-in {
  animation: fadeIn .35s ease-out;
}

/* Toast */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  padding: 14px 24px;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--white);
  box-shadow: var(--shadow-lg);
  transform: translateY(100px);
  opacity: 0;
  transition: all .3s ease;
  max-width: 400px;
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

.toast-success { background: var(--success); }
.toast-error { background: var(--error); }
.toast-info { background: var(--primary); }

/* Spinner */
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid currentColor;
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin .6s linear infinite;
}

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

/* ═══════════════════════════════════════════════════════════════
 * 实用类
 * ═══════════════════════════════════════════════════════════════ */
.text-center { text-align: center; }
.text-right { text-align: right; }
.text-success { color: var(--success); }
.text-error { color: var(--error); }
.text-accent { color: var(--accent); }
.text-light { color: var(--text-light); }
.mt-2 { margin-top: 8px; }
.mt-4 { margin-top: 16px; }
.mt-6 { margin-top: 24px; }
.mb-2 { margin-bottom: 8px; }
.mb-4 { margin-bottom: 16px; }
.mb-6 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-wrap { flex-wrap: wrap; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: 8px; }
.gap-4 { gap: 16px; }
.hidden { display: none; }

/* 语言选择器 */
#lang-select {
  -webkit-appearance: none;
  -moz-appearance: none;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 8px center;
  padding-right: 28px;
}

/* ═══════════════════════════════════════════════════════════════
 * 购物车 & 结算页响应式
 * ═══════════════════════════════════════════════════════════════ */
@media (max-width: 768px) {
  #cart-content,
  .checkout-layout {
    grid-template-columns: 1fr !important;
  }
  #cart-content .card[style*="position:sticky"],
  .checkout-layout .card[style*="position:sticky"] {
    position: static !important;
    top: auto !important;
  }
}
