/* ============================================================
   批发订货系统 - 全局CSS变量 & 基础样式
   ============================================================ */
:root {
  --primary:      #1677ff;
  --primary-dark: #0958d9;
  --danger:       #ff4d4f;
  --success:      #52c41a;
  --warning:      #faad14;
  --text:         #1a1a2e;
  --text-light:   #666;
  --border:       #e8e8e8;
  --bg:           #f5f7fa;
  --bg-card:      #ffffff;
  --shadow:       0 2px 12px rgba(0,0,0,.08);
  --radius:       12px;
  --radius-sm:    8px;
  --nav-h:        56px;
  --header-h:     48px;
  --font:         -apple-system,BlinkMacSystemFont,"PingFang SC","Hiragino Sans GB","Microsoft YaHei",sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; -webkit-tap-highlight-color: transparent; }
html,body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  max-width: 480px;
  margin: 0 auto;
  position: relative;
}

a { text-decoration: none; color: inherit; }
img { display: block; max-width: 100%; }
button { font-family: inherit; cursor: pointer; border: none; outline: none; }
input  { font-family: inherit; outline: none; border: none; background: transparent; }

/* 页面容器 */
.page { display: none; flex-direction: column; height: 100vh; overflow: hidden; }
.page.active { display: flex; }

/* 顶部导航 */
.header {
  height: var(--header-h);
  background: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 17px;
  font-weight: 600;
  flex-shrink: 0;
  border-bottom: 1px solid var(--border);
  position: relative;
}
.header .back-btn {
  position: absolute;
  left: 16px;
  font-size: 22px;
  color: var(--text);
  line-height: 1;
}

/* 滚动内容区 */
.scroll-content {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-bottom: calc(var(--nav-h) + 8px);
}
.scroll-content.no-nav { padding-bottom: 16px; }

/* 底部导航 */
.bottom-nav {
  height: var(--nav-h);
  background: #fff;
  border-top: 1px solid var(--border);
  display: flex;
  align-items: stretch;
  flex-shrink: 0;
  position: relative;
  z-index: 100;
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  color: var(--text-light);
  gap: 3px;
  position: relative;
  cursor: pointer;
  transition: color .15s;
}
.nav-item svg { width: 24px; height: 24px; }
.nav-item.active { color: var(--primary); }
.nav-badge {
  position: absolute;
  top: 6px;
  right: calc(50% - 20px);
  background: var(--danger);
  color: #fff;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
}

/* 卡片 */
.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 16px;
  margin: 8px 12px;
}

/* 按钮 */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  font-size: 15px;
  padding: 10px 20px;
  transition: opacity .15s;
  font-weight: 500;
}
.btn:active { opacity: .75; }
.btn-primary  { background: var(--primary);  color: #fff; }
.btn-danger   { background: var(--danger);   color: #fff; }
.btn-ghost    { background: transparent;     color: var(--primary); border: 1px solid var(--primary); }
.btn-block    { width: 100%; }

/* 数量加减器 */
.stepper {
  display: flex;
  align-items: center;
  gap: 0;
  background: #f0f0f0;
  border-radius: 20px;
  overflow: hidden;
}
.stepper button {
  width: 28px;
  height: 28px;
  font-size: 18px;
  color: var(--text);
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.stepper button:disabled { color: #ccc; cursor: default; }
.stepper input {
  width: 36px;
  text-align: center;
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  -moz-appearance: textfield;
}
.stepper input::-webkit-outer-spin-button,
.stepper input::-webkit-inner-spin-button { -webkit-appearance: none; }

/* 价格 */
.price { color: var(--danger); font-weight: 700; }
.price-change-up   { color: var(--danger);   font-size: 12px; }
.price-change-down { color: var(--success);  font-size: 12px; }
.price-change-zero { color: var(--text-light); font-size: 12px; }

/* 标签 */
.tag {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
}
.tag-status-0 { background: #fff7e6; color: var(--warning); }
.tag-status-1 { background: #f6ffed; color: var(--success); }
.tag-status-2 { background: #f5f5f5; color: var(--text-light); }

/* Toast提示 */
#toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(.9);
  background: rgba(0,0,0,.72);
  color: #fff;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 14px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 9999;
  opacity: 0;
  transition: opacity .2s, transform .2s;
}
#toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* 加载中 */
.loading-wrap {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 0;
  color: var(--text-light);
  font-size: 14px;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .8s linear infinite;
  margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* 空状态 */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 0;
  color: var(--text-light);
  font-size: 14px;
  gap: 12px;
}
.empty-state svg { width: 64px; height: 64px; opacity: .3; }

/* 对话框遮罩 */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: flex-end;
  z-index: 1000;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s;
}
.modal-overlay.show { opacity: 1; pointer-events: all; }
.modal-box {
  width: 100%;
  background: #fff;
  border-radius: 20px 20px 0 0;
  padding: 20px;
  transform: translateY(100%);
  transition: transform .3s;
}
.modal-overlay.show .modal-box { transform: translateY(0); }
.modal-title {
  font-size: 17px;
  font-weight: 600;
  text-align: center;
  margin-bottom: 16px;
}

/* 分割线 */
.divider { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* 搜索栏 */
.search-bar {
  display: flex;
  align-items: center;
  background: var(--bg);
  border-radius: 20px;
  padding: 8px 14px;
  gap: 8px;
  margin: 8px 12px;
  border: 1px solid var(--border);
}
.search-bar svg { width: 16px; height: 16px; color: var(--text-light); flex-shrink: 0; }
.search-bar input { flex: 1; font-size: 14px; color: var(--text); }
.search-bar input::placeholder { color: var(--text-light); }

/* 分类tabs */
.category-tabs {
  display: flex;
  overflow-x: auto;
  gap: 8px;
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  scrollbar-width: none;
}
.category-tabs::-webkit-scrollbar { display: none; }
.category-tab {
  flex-shrink: 0;
  padding: 5px 14px;
  border-radius: 20px;
  font-size: 13px;
  cursor: pointer;
  white-space: nowrap;
  background: var(--bg);
  color: var(--text-light);
  transition: all .15s;
}
.category-tab.active {
  background: var(--primary);
  color: #fff;
}

/* 商品列表 */
.product-item {
  display: flex;
  gap: 12px;
  padding: 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
  align-items: center;
}
.product-img {
  width: 80px;
  height: 80px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  background: var(--bg);
  flex-shrink: 0;
}
.product-info { flex: 1; min-width: 0; }
.product-name { font-size: 15px; font-weight: 500; margin-bottom: 4px; }
.product-meta { font-size: 12px; color: var(--text-light); margin-bottom: 6px; }
.product-price-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.product-price-main { font-size: 17px; }

/* 购物车徽章 */
.cart-fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 16px;
  width: 52px;
  height: 52px;
  background: var(--primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(22,119,255,.4);
  z-index: 200;
  cursor: pointer;
}
.cart-fab svg { width: 26px; height: 26px; color: #fff; }
.cart-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  background: var(--danger);
  color: #fff;
  font-size: 11px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}
