/* ============================================
   鲜送 (XianSong) - 精致设计系统 v2.0
   ============================================
   设计理念: 简洁 / 留白 / 层次 / 触感
   断点: 480 / 768 / 1024 / 1200
   ============================================ */

/* ============================================
   1. 设计令牌 (Design Tokens)
   ============================================ */
:root {
  /* --- 色彩系统 --- */
  /* 主色: 自然绿 */
  --c-primary: #22c55e;
  --c-primary-light: #4ade80;
  --c-primary-dark: #16a34a;
  --c-primary-50: rgba(34, 197, 94, 0.08);
  --c-primary-100: rgba(34, 197, 94, 0.15);
  
  /* 中性色 */
  --c-bg: #f8fafb;
  --c-surface: #ffffff;
  --c-surface-alt: #f1f5f9;
  --c-border: #e2e8f0;
  --c-border-light: #f1f5f9;
  
  /* 文字色 */
  --c-text: #0f172a;
  --c-text-secondary: #475569;
  --c-text-tertiary: #94a3b8;
  --c-text-inverse: #ffffff;
  
  /* 功能色 */
  --c-success: #22c55e;
  --c-warning: #f59e0b;
  --c-danger: #ef4444;
  --c-info: #3b82f6;
  
  /* --- 间距系统 (8px基准) --- */
  --s-1: 4px;
  --s-2: 8px;
  --s-3: 12px;
  --s-4: 16px;
  --s-5: 20px;
  --s-6: 24px;
  --s-8: 32px;
  --s-10: 40px;
  --s-12: 48px;
  --s-16: 64px;
  
  /* --- 字体 --- */
  --font-sans: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Segoe UI', Roboto, 'Noto Sans SC', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', monospace;
  
  /* 字号 */
  --text-xs: 0.75rem;
  --text-sm: 0.8125rem;
  --text-base: 0.9375rem;
  --text-lg: 1.0625rem;
  --text-xl: 1.25rem;
  --text-2xl: 1.5rem;
  --text-3xl: 1.875rem;
  --text-4xl: 2.25rem;
  
  /* 行高 */
  --leading-tight: 1.25;
  --leading-normal: 1.5;
  --leading-relaxed: 1.625;
  
  /* 字重 */
  --weight-normal: 400;
  --weight-medium: 500;
  --weight-semibold: 600;
  --weight-bold: 700;
  
  /* --- 圆角 --- */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-xl: 20px;
  --radius-full: 9999px;
  
  /* --- 阴影 --- */
  --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
  --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
  --shadow-card: 0 1px 3px rgba(0, 0, 0, 0.04);
  --shadow-card-hover: 0 8px 24px rgba(0, 0, 0, 0.1);
  
  /* --- 动画 --- */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-in-out: cubic-bezier(0.45, 0, 0.55, 1);
  --duration-fast: 150ms;
  --duration-normal: 250ms;
  --duration-slow: 400ms;
  
  /* --- 布局 --- */
  --container-max: 1200px;
  --navbar-h: 56px;
  --bottom-nav-h: 64px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

/* ============================================
   2. 基础重置
   ============================================ */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  -webkit-text-size-adjust: 100%;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  font-size: var(--text-base);
  line-height: var(--leading-normal);
  color: var(--c-text);
  background: var(--c-bg);
  min-height: 100vh;
  overflow-x: hidden;
  touch-action: manipulation;
  -webkit-tap-highlight-color: transparent;
}

img, video, svg {
  display: block;
  max-width: 100%;
  height: auto;
}

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

button {
  font: inherit;
  cursor: pointer;
  border: none;
  background: none;
}

input, textarea, select {
  font: inherit;
}

/* ============================================
   3. 容器
   ============================================ */
.container {
  width: 100%;
  max-width: var(--container-max);
  margin: 0 auto;
  padding: 0 var(--s-4);
}

@media (min-width: 768px) {
  .container {
    padding: 0 var(--s-6);
  }
}

@media (min-width: 1200px) {
  .container {
    padding: 0 var(--s-8);
  }
}

/* ============================================
   4. 导航栏 - 精致版
   ============================================ */
/* PC端导航 */
.xs-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(255, 255, 255, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--c-border-light);
}

.xs-navbar-inner {
  display: flex;
  align-items: center;
  height: var(--navbar-h);
  gap: var(--s-4);
}

.xs-logo {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-shrink: 0;
  padding: var(--s-2) 0;
}

.xs-logo img {
  height: 28px;
  width: auto;
}

.xs-nav-links {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  flex: 1;
  justify-content: center;
  overflow: hidden;
}

.xs-nav-link {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-2) var(--s-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--c-text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.xs-nav-link:hover {
  color: var(--c-primary);
  background: var(--c-primary-50);
}

.xs-nav-link.active {
  color: var(--c-primary);
  background: var(--c-primary-100);
}

.xs-nav-actions {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  flex-shrink: 0;
}

.xs-nav-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 36px;
  padding: 0 var(--s-3);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--c-text-secondary);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-out);
}

.xs-nav-btn:hover {
  color: var(--c-text);
  background: var(--c-surface-alt);
}

.xs-nav-btn-primary {
  color: var(--c-text-inverse);
  background: var(--c-primary);
}

.xs-nav-btn-primary:hover {
  background: var(--c-primary-dark);
}

.xs-nav-city-bar {
  display: flex;
  align-items: center;
  gap: var(--s-1);
  padding: var(--s-2) 0;
  overflow-x: auto;
  scrollbar-width: none;
  border-top: 1px solid var(--c-border-light);
}

.xs-nav-city-bar::-webkit-scrollbar {
  display: none;
}

.xs-city-tag {
  padding: var(--s-1) var(--s-3);
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
  background: var(--c-surface-alt);
  border-radius: var(--radius-full);
  white-space: nowrap;
  transition: all var(--duration-fast) var(--ease-out);
}

.xs-city-tag:hover {
  color: var(--c-primary);
  background: var(--c-primary-50);
}

/* 移动端导航 */
@media (max-width: 767.98px) {
  .xs-nav-links,
  .xs-nav-city-bar {
    display: none;
  }
  
  .xs-mobile-header {
    display: flex;
    align-items: center;
    gap: var(--s-3);
    padding: var(--s-3) var(--s-4);
    background: var(--c-surface);
  }
  
  .xs-mobile-logo {
    flex-shrink: 0;
  }
  
  .xs-mobile-logo img {
    height: 24px;
  }
  
  .xs-mobile-search {
    flex: 1;
    display: flex;
    align-items: center;
    gap: var(--s-2);
    padding: var(--s-2) var(--s-3);
    background: var(--c-surface-alt);
    border-radius: var(--radius-full);
    color: var(--c-text-tertiary);
    font-size: var(--text-sm);
  }
  
  .xs-mobile-menu-btn {
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    width: 32px;
    height: 32px;
    padding: 6px;
  }
  
  .xs-mobile-menu-btn span {
    display: block;
    width: 100%;
    height: 1.5px;
    background: var(--c-text);
    border-radius: 1px;
    transition: all var(--duration-fast) var(--ease-out);
  }
}

@media (min-width: 768px) {
  .xs-mobile-header {
    display: none;
  }
}

/* 移动端侧边菜单 */
.xs-menu-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.4);
  opacity: 0;
  visibility: hidden;
  transition: all var(--duration-normal) var(--ease-out);
  z-index: 200;
}

.xs-menu-overlay.open {
  opacity: 1;
  visibility: visible;
}

.xs-side-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: min(320px, 85vw);
  height: 100%;
  background: var(--c-surface);
  transform: translateX(100%);
  transition: transform var(--duration-normal) var(--ease-out);
  z-index: 201;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-xl);
}

.xs-side-menu.open {
  transform: translateX(0);
}

.xs-menu-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--s-4) var(--s-4);
  border-bottom: 1px solid var(--c-border-light);
}

.xs-menu-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
}

.xs-menu-close {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: var(--radius-md);
  color: var(--c-text-tertiary);
  transition: all var(--duration-fast);
}

.xs-menu-close:hover {
  background: var(--c-surface-alt);
  color: var(--c-text);
}

.xs-menu-body {
  flex: 1;
  overflow-y: auto;
  padding: var(--s-2) 0;
}

.xs-menu-group {
  padding: var(--s-2) 0;
}

.xs-menu-group-title {
  padding: var(--s-2) var(--s-4);
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  color: var(--c-text-tertiary);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.xs-menu-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-3) var(--s-4);
  font-size: var(--text-base);
  color: var(--c-text);
  transition: all var(--duration-fast);
}

.xs-menu-item:hover {
  background: var(--c-surface-alt);
}

.xs-menu-item-icon {
  width: 20px;
  text-align: center;
  flex-shrink: 0;
}

.xs-menu-footer {
  padding: var(--s-4);
  border-top: 1px solid var(--c-border-light);
}

.xs-menu-auth-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 44px;
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  color: var(--c-text-inverse);
  background: var(--c-primary);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast);
}

.xs-menu-auth-btn:hover {
  background: var(--c-primary-dark);
}

/* ============================================
   5. 产品卡片 - 精致版
   ============================================ */
.xs-product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: var(--s-3);
}

@media (min-width: 768px) {
  .xs-product-grid {
    grid-template-columns: repeat(3, 1fr);
    gap: var(--s-4);
  }
}

@media (min-width: 1024px) {
  .xs-product-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: var(--s-5);
  }
}

.xs-product-card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  overflow: hidden;
  box-shadow: var(--shadow-card);
  transition: all var(--duration-normal) var(--ease-out);
  cursor: pointer;
}

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

.xs-product-img-wrap {
  position: relative;
  aspect-ratio: 1;
  overflow: hidden;
  background: var(--c-surface-alt);
}

.xs-product-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform var(--duration-slow) var(--ease-out);
}

.xs-product-card:hover .xs-product-img {
  transform: scale(1.05);
}

.xs-product-badge {
  position: absolute;
  top: var(--s-2);
  left: var(--s-2);
  padding: var(--s-1) var(--s-2);
  font-size: 11px;
  font-weight: var(--weight-semibold);
  color: var(--c-text-inverse);
  background: var(--c-primary);
  border-radius: var(--radius-sm);
  line-height: 1;
}

.xs-product-badge-hot {
  background: linear-gradient(135deg, #f97316, #ef4444);
}

.xs-product-badge-new {
  background: linear-gradient(135deg, #3b82f6, #8b5cf6);
}

.xs-product-body {
  padding: var(--s-3);
}

.xs-product-title {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--c-text);
  line-height: var(--leading-tight);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  min-height: 2.5em;
  margin-bottom: var(--s-2);
}

@media (min-width: 768px) {
  .xs-product-title {
    font-size: var(--text-base);
  }
}

.xs-product-price-row {
  display: flex;
  align-items: baseline;
  gap: var(--s-2);
}

.xs-product-price {
  font-size: var(--text-xl);
  font-weight: var(--weight-bold);
  color: var(--c-danger);
  line-height: 1;
}

.xs-product-price small {
  font-size: var(--text-xs);
  font-weight: var(--weight-normal);
}

.xs-product-original-price {
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
  text-decoration: line-through;
}

.xs-product-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: var(--s-2);
  padding-top: var(--s-2);
  border-top: 1px solid var(--c-border-light);
}

.xs-product-sales {
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
}

.xs-product-add-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-full);
  background: var(--c-primary);
  color: var(--c-text-inverse);
  font-size: 16px;
  line-height: 1;
  transition: all var(--duration-fast);
}

.xs-product-add-btn:hover {
  background: var(--c-primary-dark);
  transform: scale(1.1);
}

/* ============================================
   6. 卡片组件
   ============================================ */
.xs-card {
  background: var(--c-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  overflow: hidden;
}

.xs-card-header {
  padding: var(--s-4) var(--s-4) 0;
}

.xs-card-title {
  font-size: var(--text-lg);
  font-weight: var(--weight-semibold);
  color: var(--c-text);
}

.xs-card-body {
  padding: var(--s-4);
}

.xs-card-footer {
  padding: 0 var(--s-4) var(--s-4);
}

/* ============================================
   7. 按钮
   ============================================ */
.xs-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--s-2);
  height: 40px;
  padding: 0 var(--s-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  transition: all var(--duration-fast) var(--ease-out);
  white-space: nowrap;
}

.xs-btn-primary {
  color: var(--c-text-inverse);
  background: var(--c-primary);
}

.xs-btn-primary:hover {
  background: var(--c-primary-dark);
}

.xs-btn-outline {
  color: var(--c-text-secondary);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
}

.xs-btn-outline:hover {
  border-color: var(--c-primary);
  color: var(--c-primary);
  background: var(--c-primary-50);
}

.xs-btn-ghost {
  color: var(--c-text-secondary);
}

.xs-btn-ghost:hover {
  background: var(--c-surface-alt);
}

.xs-btn-lg {
  height: 48px;
  padding: 0 var(--s-6);
  font-size: var(--text-base);
}

.xs-btn-sm {
  height: 32px;
  padding: 0 var(--s-3);
  font-size: var(--text-xs);
}

.xs-btn-full {
  width: 100%;
}

.xs-btn-round {
  border-radius: var(--radius-full);
}

/* ============================================
   8. 表单
   ============================================ */
.xs-input {
  width: 100%;
  height: 44px;
  padding: 0 var(--s-3);
  font-size: var(--text-base);
  color: var(--c-text);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--radius-md);
  outline: none;
  transition: all var(--duration-fast);
}

.xs-input:focus {
  border-color: var(--c-primary);
  box-shadow: 0 0 0 3px var(--c-primary-50);
}

.xs-input::placeholder {
  color: var(--c-text-tertiary);
}

.xs-input-lg {
  height: 48px;
  padding: 0 var(--s-4);
  font-size: var(--text-lg);
}

.xs-textarea {
  min-height: 100px;
  padding: var(--s-3);
  resize: vertical;
}

.xs-form-label {
  display: block;
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--c-text);
  margin-bottom: var(--s-2);
}

.xs-form-group {
  margin-bottom: var(--s-4);
}

/* ============================================
   9. 标签页
   ============================================ */
.xs-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid var(--c-border);
  overflow-x: auto;
  scrollbar-width: none;
}

.xs-tabs::-webkit-scrollbar {
  display: none;
}

.xs-tab {
  display: flex;
  align-items: center;
  gap: var(--s-2);
  padding: var(--s-3) var(--s-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--c-text-tertiary);
  white-space: nowrap;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: all var(--duration-fast);
}

.xs-tab:hover {
  color: var(--c-text);
}

.xs-tab.active {
  color: var(--c-primary);
  border-bottom-color: var(--c-primary);
}

/* ============================================
   10. 列表
   ============================================ */
.xs-list-item {
  display: flex;
  align-items: center;
  gap: var(--s-3);
  padding: var(--s-4);
  background: var(--c-surface);
  border-bottom: 1px solid var(--c-border-light);
  transition: background var(--duration-fast);
}

.xs-list-item:last-child {
  border-bottom: none;
}

.xs-list-item:hover {
  background: var(--c-surface-alt);
}

.xs-list-icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  background: var(--c-surface-alt);
  border-radius: var(--radius-md);
}

.xs-list-content {
  flex: 1;
  min-width: 0;
}

.xs-list-title {
  font-size: var(--text-base);
  font-weight: var(--weight-medium);
  color: var(--c-text);
  margin-bottom: var(--s-1);
}

.xs-list-desc {
  font-size: var(--text-sm);
  color: var(--c-text-tertiary);
}

.xs-list-meta {
  flex-shrink: 0;
  font-size: var(--text-xs);
  color: var(--c-text-tertiary);
}

/* ============================================
   11. 底部导航
   ============================================ */
.xs-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: var(--bottom-nav-h);
  padding-bottom: var(--safe-bottom);
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--c-border-light);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
  transition: transform var(--duration-normal) var(--ease-out);
}

@media (min-width: 768px) {
  .xs-bottom-nav {
    display: none;
  }
}

.xs-bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--s-2) var(--s-3);
  color: var(--c-text-tertiary);
  font-size: 10px;
  font-weight: var(--weight-medium);
  min-width: 48px;
  transition: color var(--duration-fast);
}

.xs-bottom-nav-item.active {
  color: var(--c-primary);
}

.xs-bottom-nav-icon {
  font-size: 22px;
  line-height: 1;
}

/* ============================================
   12. 工具类
   ============================================ */
/* 文本 */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--c-primary); }
.text-secondary { color: var(--c-text-secondary); }
.text-tertiary { color: var(--c-text-tertiary); }
.text-danger { color: var(--c-danger); }

.font-medium { font-weight: var(--weight-medium); }
.font-semibold { font-weight: var(--weight-semibold); }
.font-bold { font-weight: var(--weight-bold); }

/* 间距 */
.mt-1 { margin-top: var(--s-1); }
.mt-2 { margin-top: var(--s-2); }
.mt-3 { margin-top: var(--s-3); }
.mt-4 { margin-top: var(--s-4); }
.mt-6 { margin-top: var(--s-6); }
.mt-8 { margin-top: var(--s-8); }

.mb-1 { margin-bottom: var(--s-1); }
.mb-2 { margin-bottom: var(--s-2); }
.mb-3 { margin-bottom: var(--s-3); }
.mb-4 { margin-bottom: var(--s-4); }
.mb-6 { margin-bottom: var(--s-6); }
.mb-8 { margin-bottom: var(--s-8); }

.p-2 { padding: var(--s-2); }
.p-3 { padding: var(--s-3); }
.p-4 { padding: var(--s-4); }
.p-6 { padding: var(--s-6); }

/* 响应式显示 */
@media (max-width: 767.98px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 768px) {
  .hide-desktop { display: none !important; }
}

/* ============================================
   13. 动画
   ============================================ */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInRight {
  from { transform: translateX(100%); }
  to { transform: translateX(0); }
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.animate-fade-in {
  animation: fadeIn var(--duration-normal) var(--ease-out);
}

/* 减少动画偏好 */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
