/* ===== 全局重置 ===== */
*, *::before, *::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary: #333;
  --accent: #e74c3c;
  --bg: #f5f5f5;
  --card-bg: #fff;
  --border: #e8e8e8;
  --text: #333;
  --text-secondary: #999;
  --nav-height: 60px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

html, body {
  height: 100%;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  -webkit-font-smoothing: antialiased;
}

#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: 480px;
  margin: 0 auto;
  background: var(--bg);
  position: relative;
  overflow: hidden;
}

/* ===== 主内容区 ===== */
#page-content {
  flex: 1;
  overflow-y: auto;
  padding-bottom: calc(var(--nav-height) + var(--safe-bottom) + 10px);
}

/* ===== 底部导航 ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--card-bg);
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-around;
  align-items: center;
  z-index: 100;
}

.nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 4px;
  position: relative;
  padding: 6px 0;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s;
  min-width: 64px;
}

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

.nav-icon {
  width: 22px;
  height: 22px;
}

.nav-item span {
  font-size: 10px;
}

.badge {
  position: absolute;
  top: 0;
  right: 8px;
  background: var(--accent);
  color: #fff;
  font-size: 10px;
  min-width: 16px;
  height: 16px;
  line-height: 16px;
  border-radius: 8px;
  text-align: center;
  padding: 0 4px;
  display: none;
}

.badge.show {
  display: block;
}

/* ===== 首页 ===== */
.search-bar {
  padding: 12px 16px;
  background: var(--card-bg);
}

.search-bar input {
  width: 100%;
  padding: 10px 16px;
  border: none;
  border-radius: 20px;
  background: var(--bg);
  font-size: 14px;
  outline: none;
}

.banner {
  margin: 12px 16px;
  height: 140px;
  border-radius: 12px;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 20px;
  font-weight: 600;
  letter-spacing: 2px;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 16px 10px;
}

.section-header h2 {
  font-size: 16px;
  font-weight: 600;
}

.section-header span {
  font-size: 12px;
  color: var(--text-secondary);
}

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

.product-card {
  background: var(--card-bg);
  border-radius: 10px;
  overflow: hidden;
  cursor: pointer;
  transition: transform 0.15s;
}

.product-card:active {
  transform: scale(0.97);
}

.product-img {
  width: 100%;
  aspect-ratio: 1;
  object-fit: cover;
  background: #eee;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 40px;
}

.product-info {
  padding: 10px;
}

.product-name {
  font-size: 13px;
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 6px;
}

.product-price {
  font-size: 16px;
  font-weight: 700;
  color: var(--accent);
}

.product-price::before {
  content: '¥';
  font-size: 12px;
}

/* ===== 分类页 ===== */
.category-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 16px;
}

.category-card {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 20px 12px;
  text-align: center;
  cursor: pointer;
  transition: transform 0.15s;
}

.category-card:active {
  transform: scale(0.96);
}

.category-icon {
  font-size: 36px;
  margin-bottom: 8px;
}

.category-name {
  font-size: 13px;
  color: var(--text);
}

/* 分类商品列表 */
.category-products {
  padding: 0 16px;
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
  color: var(--primary);
  font-size: 14px;
  cursor: pointer;
  background: none;
  border: none;
}

/* ===== 购物车 ===== */
.cart-empty {
  text-align: center;
  padding: 80px 20px;
  color: var(--text-secondary);
}

.cart-empty .icon {
  font-size: 64px;
  margin-bottom: 16px;
}

.cart-list {
  padding: 16px 16px 70px;
}

.cart-check {
  width: 22px; height: 22px; border: 2px solid var(--border); border-radius: 50%;
  flex-shrink: 0; cursor: pointer; transition: all 0.2s;
}
.cart-check.checked {
  background: var(--accent); border-color: var(--accent);
  background-image: url("data:image/svg+xml,%3Csvg viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='3'%3E%3Cpolyline points='20 6 9 17 4 12'/%3E%3C/svg%3E");
  background-size: 14px; background-position: center; background-repeat: no-repeat;
}
.checkout-btn.disabled { opacity: 0.4; pointer-events: none; }

.cart-item {
  background: var(--card-bg);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
  display: flex;
  gap: 12px;
  align-items: center;
}

.cart-item-img {
  width: 72px;
  height: 72px;
  border-radius: 8px;
  background: #eee;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 32px;
}

.cart-item-info {
  flex: 1;
  min-width: 0;
}

.cart-item-name {
  font-size: 13px;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.cart-item-spec { font-size: 11px; color: var(--text-secondary); margin-bottom: 4px; }

.cart-item-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--accent);
}

.cart-item-actions {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-top: 6px;
}

.qty-btn {
  width: 28px;
  height: 28px;
  border: 1px solid var(--border);
  border-radius: 50%;
  background: var(--card-bg);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text);
}

.qty-btn:active {
  background: var(--bg);
}

.qty-num {
  font-size: 14px;
  min-width: 20px;
  text-align: center;
}

.cart-footer {
  position: fixed;
  bottom: calc(var(--nav-height) + var(--safe-bottom));
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: var(--card-bg);
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 99;
}

.total-price {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.total-price::before {
  content: '合计 ¥';
  font-size: 13px;
  font-weight: 400;
  color: var(--text);
}

.checkout-btn {
  padding: 10px 28px;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 20px;
  font-size: 14px;
  cursor: pointer;
}

.checkout-btn:active {
  opacity: 0.85;
}

/* ===== 个人中心 ===== */
.profile-header {
  background: var(--card-bg);
  padding: 30px 20px;
  text-align: center;
  margin-bottom: 12px;
}

.avatar {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  background: #ddd;
  margin: 0 auto 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 36px;
}

.profile-name {
  font-size: 18px;
  font-weight: 600;
}

.menu-list {
  background: var(--card-bg);
  margin: 0 16px;
  border-radius: 10px;
  overflow: hidden;
}

.menu-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--bg);
  cursor: pointer;
}

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

.menu-item:active {
  background: var(--bg);
}

.menu-item .arrow {
  color: #ccc;
  font-size: 14px;
}

/* ===== 结算页 ===== */
.checkout-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 8px;
  height: 48px;
  background: var(--card-bg);
  border-bottom: 1px solid var(--border);
  font-size: 16px;
  font-weight: 600;
  position: sticky;
  top: 0;
  z-index: 10;
}

.checkout-section {
  background: var(--card-bg);
  margin: 12px 0;
  padding: 0 16px;
}

.checkout-section-title {
  padding: 14px 0 10px;
  font-size: 14px;
  font-weight: 600;
  border-bottom: 1px solid var(--bg);
}

.checkout-address {
  padding: 12px 0;
}

.checkout-items {
  padding: 8px 0;
}

.checkout-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 0;
  border-bottom: 1px solid var(--bg);
}

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

.checkout-item-price {
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  flex-shrink: 0;
}

.checkout-summary {
  background: var(--card-bg);
  padding: 12px 16px;
  margin-bottom: 80px;
}

.summary-row {
  display: flex;
  justify-content: space-between;
  padding: 6px 0;
  font-size: 13px;
}

.checkout-total {
  font-size: 18px;
  font-weight: 700;
  color: var(--accent);
}

.checkout-total::before {
  content: '¥';
  font-size: 12px;
}

.checkout-submit-bar {
  position: fixed;
  bottom: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 100%;
  max-width: 480px;
  background: var(--card-bg);
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  z-index: 100;
}

/* ===== Toast 提示 ===== */
.toast {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) scale(0.8);
  background: rgba(0, 0, 0, 0.75);
  color: #fff;
  padding: 10px 24px;
  border-radius: 20px;
  font-size: 14px;
  z-index: 999;
  pointer-events: none;
  opacity: 0;
  transition: all 0.25s;
}

.toast.show {
  opacity: 1;
  transform: translate(-50%, -50%) scale(1);
}

/* ===== 登录/注册 ===== */
.login-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 40px 24px;
  background: var(--bg);
}
.login-logo { font-size: 48px; margin-bottom: 8px; }
.login-title { font-size: 24px; font-weight: 600; margin-bottom: 20px; color: var(--text); }
.login-tabs { display: flex; width: 100%; margin-bottom: 24px; border-bottom: 1px solid var(--border); }
.login-tab { flex: 1; text-align: center; padding: 10px 0; font-size: 14px; color: var(--text-secondary); cursor: pointer; position: relative; }
.login-tab.active { color: var(--primary); font-weight: 600; }
.login-tab.active::after { content: ''; position: absolute; bottom: -1px; left: 50%; transform: translateX(-50%); width: 40px; height: 2px; background: var(--primary); border-radius: 1px; }
.sms-input-row { display: flex; gap: 10px; align-items: center; }
.sms-send-btn { padding: 12px 14px; background: var(--primary); color: #fff; border: none; border-radius: 10px; font-size: 13px; cursor: pointer; white-space: nowrap; flex-shrink: 0; }
.sms-send-btn:active { opacity: 0.85; }
.sms-send-btn:disabled { background: #ccc; }

/* ===== 表单组件 ===== */
.form-group { width: 100%; margin-bottom: 14px; }
.form-label { display: block; font-size: 13px; color: var(--text-secondary); margin-bottom: 6px; padding-left: 4px; }
.form-input {
  width: 100%; padding: 12px 16px; border: 1px solid var(--border);
  border-radius: 10px; background: var(--card-bg); font-size: 14px; outline: none;
}
.form-input:focus { border-color: var(--primary); }
.form-btn {
  width: 100%; padding: 12px; background: var(--primary); color: #fff;
  border: none; border-radius: 24px; font-size: 15px; font-weight: 600; cursor: pointer; margin-top: 8px;
}
.form-btn:active { opacity: 0.85; }
.form-link { text-align: center; margin-top: 16px; font-size: 13px; color: var(--text-secondary); cursor: pointer; }
.form-link span { color: var(--primary); font-weight: 500; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

/* ===== 地址卡片 ===== */
.address-card {
  background: var(--card-bg); border-radius: 10px; padding: 14px; margin-bottom: 10px;
}
.addr-name { font-size: 15px; font-weight: 600; margin-right: 12px; }
.addr-phone { font-size: 14px; color: var(--text-secondary); }
.addr-default-tag {
  display: inline-block; background: var(--accent); color: #fff;
  font-size: 10px; padding: 2px 6px; border-radius: 8px; margin-left: 8px; vertical-align: middle;
}
.addr-detail { font-size: 13px; color: var(--text-secondary); margin-top: 8px; line-height: 1.5; }
.addr-card-actions {
  display: flex; justify-content: flex-end; gap: 8px;
  margin-top: 10px; padding-top: 10px; border-top: 1px solid var(--bg);
}
.addr-action-btn {
  padding: 6px 14px; border: 1px solid var(--border); border-radius: 14px;
  background: var(--card-bg); font-size: 12px; color: var(--text); cursor: pointer;
}
.addr-action-btn:active { background: var(--bg); transform: scale(0.97); }
.addr-delete { color: var(--accent); border-color: var(--accent); }
.addr-selectable { cursor: pointer; }
.addr-card-selected { border: 1.5px solid var(--primary); }
.addr-selected { float: right; color: var(--primary); font-size: 18px; font-weight: 700; }

/* ===== 地址表单 ===== */
.addr-form { padding: 16px; }
.addr-form .form-group { margin-bottom: 14px; }

/* ===== 开关 ===== */
.toggle-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 0; border-top: 1px solid var(--bg); margin-top: 4px;
}
.toggle-label { font-size: 14px; color: var(--text); }
.toggle-switch {
  width: 48px; height: 26px; background: var(--border); border-radius: 13px;
  cursor: pointer; position: relative; transition: background 0.2s; flex-shrink: 0;
}
.toggle-switch.on { background: var(--primary); }
.toggle-switch::after {
  content: ''; position: absolute; width: 22px; height: 22px; background: #fff;
  border-radius: 50%; top: 2px; left: 2px; transition: transform 0.2s;
}
.toggle-switch.on::after { transform: translateX(22px); }

/* ===== 退出登录 ===== */
.logout-btn {
  display: block; width: calc(100% - 32px); margin: 20px 16px;
  padding: 12px; background: var(--card-bg); border: 1px solid var(--accent);
  border-radius: 24px; color: var(--accent); font-size: 15px; cursor: pointer; text-align: center;
}
.logout-btn:active { background: var(--bg); }

/* ===== 商品详情 ===== */
.detail-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 8px; height: 48px; background: var(--card-bg);
  border-bottom: 1px solid var(--border); font-size: 16px; font-weight: 600;
  position: sticky; top: 0; z-index: 10;
}
.detail-img {
  width: 100%; aspect-ratio: 1; background: #eee;
  display: flex; align-items: center; justify-content: center; font-size: 80px;
}
.detail-info {
  background: var(--card-bg); padding: 16px; margin-bottom: 10px;
}
.detail-name { font-size: 18px; font-weight: 600; margin-bottom: 8px; line-height: 1.4; }
.detail-price { font-size: 24px; font-weight: 700; color: var(--accent); }
.detail-price::before { content: '¥'; font-size: 14px; }
.detail-desc { font-size: 13px; color: var(--text-secondary); margin-top: 10px; line-height: 1.6; }

.detail-specs { background: var(--card-bg); padding: 16px; margin-bottom: 10px; }
.spec-group { margin-bottom: 14px; }
.spec-group:last-child { margin-bottom: 0; }
.spec-label { font-size: 13px; color: var(--text-secondary); margin-bottom: 8px; }
.spec-options { display: flex; flex-wrap: wrap; gap: 8px; }
.spec-option {
  display: inline-block; padding: 6px 16px; border: 1px solid var(--border);
  border-radius: 16px; font-size: 13px; color: var(--text); cursor: pointer;
  transition: all 0.2s; background: var(--card-bg);
}
.spec-option:active { transform: scale(0.96); }
.spec-option.selected {
  background: var(--primary); color: #fff; border-color: var(--primary);
}
.spec-option.disabled {
  color: #ccc; border-color: #eee; background: #f9f9f9; pointer-events: none;
}

.detail-bottom-bar {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px; background: var(--card-bg);
  padding: 10px 16px; padding-bottom: calc(10px + var(--safe-bottom));
  border-top: 1px solid var(--border); display: flex; gap: 10px; z-index: 100;
}
.detail-cart-btn {
  flex: 1; padding: 12px; background: var(--card-bg); color: var(--primary);
  border: 1px solid var(--primary); border-radius: 24px; font-size: 14px;
  font-weight: 600; cursor: pointer;
}
.detail-cart-btn:active { background: var(--bg); }
.detail-buy-btn {
  flex: 1; padding: 12px; background: var(--accent); color: #fff;
  border: none; border-radius: 24px; font-size: 14px; font-weight: 600; cursor: pointer;
}
.detail-buy-btn:active { opacity: 0.85; }

/* ===== 订单列表 ===== */
.order-tabs {
  display: flex; background: var(--card-bg); border-bottom: 1px solid var(--border);
  position: sticky; top: 0; z-index: 10;
}
.order-tab {
  flex: 1; text-align: center; padding: 14px 0; font-size: 13px;
  color: var(--text-secondary); cursor: pointer; position: relative;
}
.order-tab.active { color: var(--primary); font-weight: 600; }
.order-tab.active::after {
  content: ''; position: absolute; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 24px; height: 2px; background: var(--primary); border-radius: 1px;
}
.order-list { padding: 12px 16px; }
.order-card { background: var(--card-bg); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.order-card-hd {
  display: flex; justify-content: space-between; padding: 12px 14px;
  border-bottom: 1px solid var(--bg);
}
.order-no { font-size: 12px; color: var(--text-secondary); }
.order-status { font-size: 13px; color: var(--accent); font-weight: 600; }
.order-items-scroll {
  display: flex; gap: 10px; padding: 12px 14px; overflow-x: auto;
  scroll-snap-type: x mandatory; -webkit-overflow-scrolling: touch;
}
.order-items-scroll::-webkit-scrollbar { height: 0; }
.order-item-h {
  flex: 0 0 auto; width: 100px; text-align: center; scroll-snap-align: start;
}
.order-item-img {
  width: 72px; height: 72px; background: #eee; border-radius: 8px;
  display: flex; align-items: center; justify-content: center; font-size: 30px;
  margin: 0 auto 6px;
}
.order-item-name {
  font-size: 12px; line-height: 1.3; display: -webkit-box;
  -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
  margin-bottom: 2px;
}
.order-item-spec { font-size: 10px; color: var(--text-secondary); margin-bottom: 2px; }
.order-item-price { font-size: 11px; color: var(--text-secondary); }
.order-card-ft {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; border-top: 1px solid var(--bg); font-size: 12px; color: var(--text-secondary);
}
.order-card-ft b { color: var(--accent); font-size: 15px; }
.order-card { cursor: pointer; }
.order-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 8px; }
.order-pay-btn:active { background: #e8f5e9; }
.order-detail-info { padding: 10px 0; }
.od-row { display: flex; justify-content: space-between; padding: 8px 0; font-size: 13px; }
.od-row span:first-child { color: var(--text-secondary); }
.order-detail-item { display: flex; gap: 12px; padding: 10px 0; align-items: center; }
.order-detail-item + .order-detail-item { border-top: 1px solid var(--bg); }

/* ===== 悬浮购物车 ===== */
.floating-cart {
  position: fixed; bottom: 90px; right: 16px; width: 50px; height: 50px;
  background: var(--card-bg); border-radius: 50%; box-shadow: 0 4px 16px rgba(0,0,0,0.15);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  z-index: 99; transition: transform 0.2s;
}
.floating-cart:active { transform: scale(0.9); }
.floating-cart.bounce { animation: cartBounce 0.3s ease; }
@keyframes cartBounce {
  0%, 100% { transform: scale(1); }
  30% { transform: scale(1.2); }
  60% { transform: scale(0.9); }
}
.floating-cart-icon { font-size: 24px; }
.floating-cart-badge {
  position: absolute; top: -2px; right: -2px; background: var(--accent); color: #fff;
  font-size: 10px; min-width: 18px; height: 18px; line-height: 18px; border-radius: 9px;
  text-align: center; padding: 0 4px; display: none;
}
.floating-cart-badge.show { display: block; }

.fly-item { pointer-events: none; z-index: 200; }

/* ===== 滚动条 ===== */
::-webkit-scrollbar { width: 0; }
