/* ============================================================
   极光虚拟商城 Aurora Mall —— 样式表
   移动端优先，现代简洁电商风格
   ============================================================ */
:root {
  --primary: #4f46e5;          /* 主色：极光紫 */
  --primary-dark: #4338ca;
  --accent: #06b6d4;           /* 点缀：极光青 */
  --danger: #dc2626;
  --success: #16a34a;
  --text: #1f2937;
  --text-muted: #6b7280;
  --bg: #f6f7fb;
  --card: #ffffff;
  --border: #e5e7eb;
  --radius: 12px;
  --shadow: 0 1px 3px rgba(0, 0, 0, .08);
  --bottomnav-h: 56px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
    "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
  color: var(--text);
  background: var(--bg);
  padding-bottom: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
}

a { color: var(--primary); text-decoration: none; }
img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; font-size: 1rem; }

/* ---------- 顶部导航 ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: linear-gradient(135deg, #312e81, #4f46e5 55%, #0891b2);
  color: #fff;
}
.logo { color: #fff; font-weight: 700; font-size: 1.05rem; white-space: nowrap; }
.search-box { flex: 1; display: flex; background: #fff; border-radius: 999px; overflow: hidden; }
.search-box input { flex: 1; min-width: 0; border: 0; outline: none; padding: 8px 12px; }
.search-box button { border: 0; background: transparent; padding: 0 10px; font-size: 1rem; }
.cart-link { color: #fff; position: relative; font-size: 1.25rem; white-space: nowrap; }
.cart-badge {
  position: absolute; top: -6px; right: -8px;
  min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: #ef4444; color: #fff;
  font-size: .7rem; line-height: 18px; text-align: center;
}

/* ---------- 布局 ---------- */
.app { max-width: 1080px; margin: 0 auto; padding: 12px 12px 24px; }
.page-title { font-size: 1.25rem; margin: 8px 0 12px; }
.muted { color: var(--text-muted); font-size: .9rem; }
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  padding: 14px; margin-bottom: 12px;
}
.empty { text-align: center; color: var(--text-muted); padding: 40px 12px; }
.loading { text-align: center; color: var(--text-muted); padding: 40px 12px; }
.error-box {
  background: #fef2f2; border: 1px solid #fecaca; color: #b91c1c;
  border-radius: var(--radius); padding: 12px; margin-bottom: 12px;
}

/* ---------- 首页横幅 ---------- */
.banner {
  border-radius: 16px; overflow: hidden; margin-bottom: 14px;
  background: linear-gradient(120deg, #1e1b4b, #4c1d95 45%, #0e7490);
  color: #fff; padding: 28px 20px;
}
.banner h1 { margin: 0 0 6px; font-size: 1.5rem; }
.banner p { margin: 0; opacity: .9; }

/* ---------- 分类入口 ---------- */
.chips { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.chip {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  background: #fff; color: var(--text); font-size: .9rem;
}
.chip.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* ---------- 商品列表 ---------- */
.product-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px;
}
.product-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  overflow: hidden; box-shadow: var(--shadow); display: flex; flex-direction: column;
}
.product-card .thumb {
  aspect-ratio: 1 / 1; background: #eef2ff; display: flex;
  align-items: center; justify-content: center; font-size: 3rem; overflow: hidden;
}
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card .body { padding: 10px; display: flex; flex-direction: column; gap: 4px; flex: 1; }
.product-card .name { font-size: .95rem; font-weight: 600; line-height: 1.35; }
.product-card .cat { font-size: .75rem; color: var(--text-muted); }
.product-card .row { display: flex; align-items: center; justify-content: space-between; margin-top: auto; }
.product-card .price { color: #e11d48; font-weight: 700; font-size: 1.05rem; }
.product-card .stock-out { color: var(--danger); font-size: .8rem; }

/* ---------- 按钮 ---------- */
.btn {
  display: inline-block; border: 0; border-radius: 10px;
  padding: 10px 16px; font-size: .95rem; font-weight: 600;
  background: var(--primary); color: #fff; text-align: center;
}
.btn:hover { background: var(--primary-dark); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-block { display: block; width: 100%; }
.btn-ghost { background: #f3f4f6; color: var(--text); }
.btn-danger { background: var(--danger); }
.btn-success { background: var(--success); }
.btn-sm { padding: 6px 10px; font-size: .85rem; border-radius: 8px; }
.btn-outline { background: #fff; color: var(--primary); border: 1px solid var(--primary); }
.link-btn { background: none; border: 0; color: var(--primary); padding: 4px 0; font-size: .9rem; }

/* ---------- 表单 ---------- */
.form label { display: block; font-size: .9rem; font-weight: 600; margin: 12px 0 4px; }
.form input, .form select, .form textarea {
  width: 100%; border: 1px solid var(--border); border-radius: 10px;
  padding: 10px 12px; background: #fff; outline: none;
}
.form input:focus, .form select:focus, .form textarea:focus { border-color: var(--primary); }
.field-error { color: var(--danger); font-size: .8rem; margin-top: 4px; min-height: 1em; }
.form-error { color: var(--danger); font-size: .9rem; margin-top: 8px; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

/* ---------- 商品详情 ---------- */
.detail-img {
  width: 100%; aspect-ratio: 1 / 1; border-radius: var(--radius);
  background: #eef2ff; display: flex; align-items: center; justify-content: center;
  font-size: 5rem; overflow: hidden; margin-bottom: 12px;
}
.detail-img img { width: 100%; height: 100%; object-fit: cover; }
.detail-name { font-size: 1.3rem; margin: 4px 0; }
.detail-price { color: #e11d48; font-size: 1.5rem; font-weight: 700; }
.detail-desc { color: var(--text); line-height: 1.7; white-space: pre-wrap; }
.qty-row { display: flex; align-items: center; gap: 12px; margin: 14px 0; }
.qty-btn {
  width: 36px; height: 36px; border-radius: 8px; border: 1px solid var(--border);
  background: #fff; font-size: 1.2rem; line-height: 1;
}
.qty-num { min-width: 28px; text-align: center; font-weight: 700; }

/* ---------- 购物车 ---------- */
.cart-item {
  display: flex; gap: 10px; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 10px; margin-bottom: 10px;
}
.cart-item .thumb {
  width: 72px; height: 72px; flex: none; border-radius: 8px; background: #eef2ff;
  display: flex; align-items: center; justify-content: center; font-size: 1.8rem; overflow: hidden;
}
.cart-item .thumb img { width: 100%; height: 100%; object-fit: cover; }
.cart-item .info { flex: 1; min-width: 0; }
.cart-item .name { font-weight: 600; font-size: .95rem; }
.cart-item .price { color: #e11d48; font-weight: 700; }
.cart-total {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 14px; margin: 12px 0; font-size: 1.05rem;
}
.cart-total strong { color: #e11d48; font-size: 1.25rem; }

/* ---------- 订单 ---------- */
.order-card { background: var(--card); border: 1px solid var(--border); border-radius: var(--radius); padding: 14px; margin-bottom: 12px; }
.order-head { display: flex; justify-content: space-between; gap: 8px; flex-wrap: wrap; margin-bottom: 8px; }
.order-id { font-weight: 700; }
.order-lines { border-top: 1px dashed var(--border); margin-top: 10px; padding-top: 10px; }
.order-line { display: flex; justify-content: space-between; padding: 4px 0; font-size: .92rem; }
.status-badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px;
  font-size: .8rem; font-weight: 600; background: #e0e7ff; color: #3730a3;
}
.status-badge.pending { background: #fef3c7; color: #92400e; }
.status-badge.paid { background: #dbeafe; color: #1e40af; }
.status-badge.shipped { background: #cffafe; color: #155e75; }
.status-badge.completed { background: #dcfce7; color: #166534; }
.status-badge.done { background: #dcfce7; color: #166534; }
.status-badge.cancelled { background: #fee2e2; color: #991b1b; }

/* ---------- 管理后台 ---------- */
.admin-nav { display: flex; gap: 8px; flex-wrap: wrap; margin-bottom: 14px; }
.admin-nav a {
  padding: 8px 14px; border-radius: 999px; background: #fff;
  border: 1px solid var(--border); color: var(--text); font-size: .9rem;
}
.admin-nav a.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.stat-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 14px; }
.stat-card {
  background: var(--card); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px 10px; text-align: center; box-shadow: var(--shadow);
}
.stat-card .num { font-size: 1.4rem; font-weight: 800; color: var(--primary); }
.stat-card .label { font-size: .8rem; color: var(--text-muted); margin-top: 2px; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { padding: 8px 6px; border-bottom: 1px solid var(--border); text-align: left; vertical-align: middle; }
.admin-table th { color: var(--text-muted); font-weight: 600; white-space: nowrap; }
.table-wrap { overflow-x: auto; }
.row-actions { display: flex; gap: 6px; flex-wrap: wrap; }
.stock-input { width: 72px; padding: 6px 8px; border: 1px solid var(--border); border-radius: 8px; }

/* ---------- 底部导航 ---------- */
.bottomnav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 50;
  height: calc(var(--bottomnav-h) + env(safe-area-inset-bottom, 0px));
  padding-bottom: env(safe-area-inset-bottom, 0px);
  display: flex; background: #fff; border-top: 1px solid var(--border);
}
.bottomnav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  color: var(--text-muted); font-size: 1.1rem; gap: 1px;
}
.bottomnav a span { font-size: .7rem; }
.bottomnav a.active { color: var(--primary); }

/* ---------- 提示气泡 / 弹窗 ---------- */
.toast {
  position: fixed; left: 50%; bottom: 76px; transform: translateX(-50%) translateY(20px);
  background: rgba(17, 24, 39, .92); color: #fff; padding: 10px 16px;
  border-radius: 999px; font-size: .9rem; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 100; max-width: 90vw; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.modal {
  position: fixed; inset: 0; z-index: 90; background: rgba(0, 0, 0, .45);
  display: flex; align-items: center; justify-content: center; padding: 16px;
}
.modal[hidden] { display: none; }
.modal-card { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 360px; }
.modal-actions { display: flex; justify-content: flex-end; gap: 8px; margin-top: 16px; }

/* ---------- 桌面端增强 ---------- */
@media (min-width: 640px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; }
  .banner h1 { font-size: 2rem; }
}
@media (min-width: 960px) {
  .product-grid { grid-template-columns: repeat(4, 1fr); }
  .app { padding: 20px 16px 32px; }
}
