/* ============================================================
   高端简约设计系统 — Modern Design System v2.0
   统一所有页面的视觉风格
   ============================================================ */

/* --- 1. 设计令牌 (Design Tokens) --- */
:root {
  /* 主色调 */
  --color-primary: #1a1a1a;
  --color-accent: #2563eb;
  --color-accent-hover: #1d4ed8;
  --color-accent-light: #eff6ff;

  /* 中性色 */
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-border: #e5e7eb;
  --color-border-light: #f3f4f6;
  --color-text: #111827;
  --color-text-secondary: #6b7280;
  --color-text-muted: #9ca3af;

  /* 语义色 */
  --color-success: #059669;
  --color-warning: #d97706;
  --color-danger: #dc2626;
  --color-info: #3b82f6;

  /* 间距 */
  --space-xs: 4px;
  --space-sm: 8px;
  --space-md: 16px;
  --space-lg: 24px;
  --space-xl: 32px;
  --space-2xl: 48px;
  --space-3xl: 64px;

  /* 圆角 */
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-xl: 24px;
  --radius-full: 9999px;

  /* 阴影 */
  --shadow-sm: 0 1px 2px rgba(0,0,0,.04);
  --shadow-md: 0 4px 12px rgba(0,0,0,.06);
  --shadow-lg: 0 10px 30px rgba(0,0,0,.08);
  --shadow-xl: 0 20px 60px rgba(0,0,0,.1);

  /* 字体 */
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Cascadia Code', monospace;

  /* 过渡 */
  --transition-fast: 150ms ease;
  --transition-base: 250ms ease;
  --transition-slow: 400ms ease;
}

/* --- 2. 全局重置 --- */
*, *::before, *::after { box-sizing: border-box; }

html {
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-rendering: optimizeLegibility;
}

body {
  font-family: var(--font-sans);
  background: var(--color-bg);
  color: var(--color-text);
  line-height: 1.6;
  margin: 0;
  padding: 0;
  overflow-x: hidden;
}

a { color: var(--color-accent); text-decoration: none; transition: color var(--transition-fast); }
a:hover { color: var(--color-accent-hover); }

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

/* --- 3. 顶部导航 — 极简透明 --- */
.top-navbar {
  background: rgba(255,255,255,.85) !important;
  backdrop-filter: blur(20px) saturate(180%);
  -webkit-backdrop-filter: blur(20px) saturate(180%);
  border-bottom: 1px solid var(--color-border-light);
  padding: 0 var(--space-lg);
  height: 64px;
  display: flex;
  align-items: center;
  z-index: 1000;
}
.top-navbar .navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--color-primary) !important;
}
.top-navbar .nav-link {
  font-size: .875rem;
  font-weight: 500;
  color: var(--color-text-secondary) !important;
  padding: var(--space-sm) var(--space-md) !important;
  border-radius: var(--radius-sm);
  transition: all var(--transition-fast);
}
.top-navbar .nav-link:hover,
.top-navbar .nav-link.active {
  color: var(--color-primary) !important;
  background: var(--color-border-light);
}
.top-navbar .nav-link i { margin-right: 4px; }
.top-navbar .cart-count {
  background: var(--color-accent);
  font-size: .7rem;
  padding: 2px 6px;
}

/* --- 4. 底部导航 — 极简图标式 --- */
.bottom-nav-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: rgba(255,255,255,.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--color-border-light);
  display: flex;
  justify-content: space-around;
  align-items: center;
  height: 64px;
  padding-bottom: env(safe-area-inset-bottom);
  z-index: 999;
}
.bottom-nav-bar .nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: var(--space-xs) var(--space-md);
  color: var(--color-text-muted);
  font-size: .65rem;
  font-weight: 500;
  transition: color var(--transition-fast);
  text-decoration: none;
  border-radius: var(--radius-sm);
  min-width: 56px;
}
.bottom-nav-bar .nav-item i { font-size: 1.25rem; }
.bottom-nav-bar .nav-item.active {
  color: var(--color-accent);
  font-weight: 600;
}
.bottom-nav-bar .nav-item:active { transform: scale(.95); }

/* --- 5. 容器与卡片 --- */
.container {
  max-width: 1200px;
  padding: 0 var(--space-md);
}

.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  transition: all var(--transition-base);
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}
.card-img-top {
  aspect-ratio: 1;
  object-fit: cover;
  width: 100%;
  background: var(--color-border-light);
}
.card-body { padding: var(--space-md); }
.card-title {
  font-size: .9rem;
  font-weight: 600;
  line-height: 1.4;
  color: var(--color-text);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: var(--space-xs);
}
.card-price {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--color-danger);
}
.card-price .original {
  font-size: .75rem;
  color: var(--color-text-muted);
  text-decoration: line-through;
  font-weight: 400;
  margin-left: var(--space-xs);
}

/* --- 6. 首页Banner轮播 --- */
.home-banner-carousel {
  border-radius: var(--radius-lg);
  overflow: hidden;
}
.home-banner-carousel .carousel-item img {
  width: 100%;
  height: 360px;
  object-fit: cover;
}
@media (max-width: 768px) {
  .home-banner-carousel .carousel-item img { height: 200px; }
}
.home-banner-carousel .carousel-indicators li {
  width: 8px; height: 8px; border-radius: var(--radius-full);
  background: rgba(255,255,255,.6);
  border: none;
}
.home-banner-carousel .carousel-indicators .active { background: #fff; }

/* --- 7. 分区标题 --- */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-lg) 0 var(--space-md);
}
.section-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--color-primary);
  position: relative;
}
.section-title::after {
  content: '';
  display: inline-block;
  width: 24px; height: 3px;
  background: var(--color-accent);
  border-radius: var(--radius-full);
  margin-left: var(--space-sm);
  vertical-align: middle;
}
.section-more {
  font-size: .8rem;
  color: var(--color-text-muted);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 4px;
}
.section-more:hover { color: var(--color-accent); }

/* --- 8. 按钮 --- */
.btn {
  font-weight: 600;
  font-size: .875rem;
  padding: var(--space-sm) var(--space-lg);
  border-radius: var(--radius-md);
  border: none;
  cursor: pointer;
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  gap: var(--space-xs);
  letter-spacing: .01em;
}
.btn-primary {
  background: var(--color-accent);
  color: #fff;
}
.btn-primary:hover { background: var(--color-accent-hover); transform: translateY(-1px); box-shadow: var(--shadow-md); }
.btn-outline {
  background: transparent;
  color: var(--color-accent);
  border: 1.5px solid var(--color-accent);
}
.btn-outline:hover { background: var(--color-accent-light); }
.btn-lg { padding: var(--space-md) var(--space-2xl); font-size: 1rem; border-radius: var(--radius-lg); }
.btn-sm { padding: var(--space-xs) var(--space-md); font-size: .8rem; }
.btn-block { width: 100%; justify-content: center; }

/* --- 9. 表单 --- */
.form-group { margin-bottom: var(--space-md); }
.form-label {
  display: block;
  font-size: .8rem;
  font-weight: 600;
  color: var(--color-text-secondary);
  margin-bottom: var(--space-xs);
}
.form-control {
  width: 100%;
  padding: var(--space-sm) var(--space-md);
  font-size: .9rem;
  border: 1.5px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-surface);
  color: var(--color-text);
  transition: all var(--transition-fast);
  font-family: var(--font-sans);
  line-height: 1.5;
}
.form-control:focus {
  outline: none;
  border-color: var(--color-accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.form-control::placeholder { color: var(--color-text-muted); }
select.form-control { 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='%236b7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 12px center; padding-right: 36px; }

/* --- 10. 提示消息 --- */
.alert {
  padding: var(--space-md);
  border-radius: var(--radius-md);
  font-size: .9rem;
  font-weight: 500;
  margin-bottom: var(--space-md);
  border: none;
}
.alert-success { background: #ecfdf5; color: var(--color-success); }
.alert-danger { background: #fef2f2; color: var(--color-danger); }
.alert-info { background: var(--color-accent-light); color: var(--color-accent); }
.alert-warning { background: #fffbeb; color: var(--color-warning); }

/* --- 11. 标签/徽章 --- */
.badge {
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
}
.badge-primary { background: var(--color-accent); color: #fff; }
.badge-success { background: #d1fae5; color: var(--color-success); }
.badge-danger { background: #fee2e2; color: var(--color-danger); }
.badge-warning { background: #fef3c7; color: var(--color-warning); }

/* --- 12. 商品网格 --- */
.product-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-md);
}
@media (max-width: 992px) { .product-grid { grid-template-columns: repeat(3, 1fr); } }
@media (max-width: 768px) { .product-grid { grid-template-columns: repeat(2, 1fr); gap: var(--space-sm); } }

.product-card { border: none; box-shadow: var(--shadow-sm); }
.product-card:hover { box-shadow: var(--shadow-lg); }
.product-card .card-img-wrapper {
  position: relative;
  overflow: hidden;
}
.product-card .card-img-wrapper img {
  transition: transform var(--transition-slow);
}
.product-card:hover .card-img-wrapper img {
  transform: scale(1.05);
}
.product-card .product-tag {
  position: absolute;
  top: var(--space-sm);
  left: var(--space-sm);
  background: var(--color-danger);
  color: #fff;
  font-size: .7rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: var(--radius-sm);
}

/* --- 13. 详情页 --- */
.detail-gallery {
  border-radius: var(--radius-lg);
  overflow: hidden;
  background: var(--color-border-light);
}
.detail-gallery img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
}
.detail-info { padding: var(--space-lg); }
.detail-title { font-size: 1.5rem; font-weight: 700; margin-bottom: var(--space-sm); }
.detail-price { font-size: 1.75rem; font-weight: 700; color: var(--color-danger); }
.detail-desc { color: var(--color-text-secondary); margin-top: var(--space-md); line-height: 1.8; }

/* --- 14. 订单/列表表格 --- */
.table-clean {
  width: 100%;
  border-collapse: collapse;
}
.table-clean th {
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: var(--space-sm) var(--space-md);
  border-bottom: 1px solid var(--color-border);
}
.table-clean td {
  padding: var(--space-md);
  border-bottom: 1px solid var(--color-border-light);
  font-size: .875rem;
}
.table-clean tr:hover td { background: var(--color-border-light); }

/* --- 15. 会员中心 --- */
.member-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: var(--space-lg);
  min-height: calc(100vh - 64px - 64px);
}
@media (max-width: 768px) {
  .member-layout { grid-template-columns: 1fr; }
}
.member-sidebar {
  background: var(--color-surface);
  border-radius: var(--radius-lg);
  padding: var(--space-lg);
  border: 1px solid var(--color-border);
  height: fit-content;
}
.member-sidebar .user-avatar {
  width: 64px; height: 64px;
  border-radius: var(--radius-full);
  object-fit: cover;
  margin-bottom: var(--space-sm);
}
.member-sidebar .user-name {
  font-size: 1rem;
  font-weight: 700;
}
.member-sidebar .sidebar-menu {
  list-style: none;
  padding: 0;
  margin: var(--space-md) 0 0;
}
.member-sidebar .sidebar-menu li a {
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  padding: var(--space-sm) var(--space-md);
  border-radius: var(--radius-sm);
  color: var(--color-text-secondary);
  font-size: .875rem;
  text-decoration: none;
  transition: all var(--transition-fast);
}
.member-sidebar .sidebar-menu li a:hover,
.member-sidebar .sidebar-menu li a.active {
  background: var(--color-accent-light);
  color: var(--color-accent);
  font-weight: 600;
}

/* --- 16. 空状态 --- */
.empty-state {
  text-align: center;
  padding: var(--space-3xl) var(--space-lg);
  color: var(--color-text-muted);
}
.empty-state i { font-size: 3rem; display: block; margin-bottom: var(--space-md); }
.empty-state p { font-size: .9rem; }

/* --- 17. 页面加载动画 --- */
.page-transition {
  animation: fadeIn .4s var(--transition-slow) both;
}
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
.fade-in-up { animation: slideUp .5s ease both; }

/* --- 18. 懒加载骨架屏 --- */
.skeleton {
  background: linear-gradient(90deg, var(--color-border-light) 25%, #e8e8e8 50%, var(--color-border-light) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.5s infinite;
  border-radius: var(--radius-sm);
}
@keyframes shimmer {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

/* --- 19. 响应式 --- */
@media (max-width: 768px) {
  :root {
    --space-lg: 16px;
    --space-xl: 24px;
  }
  html, body {
    overflow-x: hidden;
    width: 100%;
  }
  .container {
    padding: 0 var(--space-sm);
    max-width: 100%;
  }
  body {
    padding-bottom: 80px; /* 底部导航空间 */
  }

  /* 表格横向滚动 */
  table, .table-responsive {
    display: block;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  /* 卡片全宽 */
  .card { margin-left: 0; margin-right: 0; }

  /* 表单全宽 */
  .form-control, input[type="text"], input[type="email"], input[type="password"],
  input[type="number"], select, textarea {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    font-size: 16px; /* 防止iOS缩放 */
  }

  /* 两列网格改为单列 */
  .grid-2 { grid-template-columns: 1fr; }
  .grid-3 { grid-template-columns: 1fr; }

  /* 会员布局改垂直 */
  .member-layout {
    grid-template-columns: 1fr;
  }

  /* 隐藏桌面导航 */
  .top-navbar { display: none !important; }

  /* 增大按钮触摸区域 */
  .btn, button[type="submit"] {
    min-height: 44px;
  }

  /* 图片防溢出 */
  img {
    max-width: 100%;
    height: auto;
  }

  /* 固定元素不遮挡内容 */
  .fixed-top, .fixed-bottom {
    position: relative;
    width: 100%;
  }

  /* 隐藏PC端footer */
  footer { display: none !important; }
}

/* --- 20. 工具类 --- */
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }
.text-muted { color: var(--color-text-muted); }
.text-secondary { color: var(--color-text-secondary); }
.text-accent { color: var(--color-accent); }
.text-sm { font-size: .8rem; }
.text-xs { font-size: .7rem; }
.font-bold { font-weight: 700; }
.mt-0 { margin-top: 0; }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.rounded-lg { border-radius: var(--radius-lg); }
.shadow-sm { box-shadow: var(--shadow-sm); }
.shadow-md { box-shadow: var(--shadow-md); }
.bg-surface { background: var(--color-surface); }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: var(--space-md); }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: var(--space-md); }
@media (max-width: 768px) {
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}
