/* ============================================================
 * styles.css — Premium 设计系统
 * 玻璃拟态 / 渐变光斑 / 明暗双主题 / 流畅动效
 * ============================================================ */

/* ---------- 主题变量 ---------- */
:root {
  --accent: #4f46e5;
  --accent-2: #0ea5e9;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 10px 40px rgba(0, 0, 0, 0.12);
  --shadow-sm: 0 4px 16px rgba(0, 0, 0, 0.08);
  --ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* 明色 */
[data-theme="light"] {
  --bg-1: #eef2ff;
  --bg-2: #e0f2fe;
  --bg-3: #fce7f3;
  --surface: rgba(255, 255, 255, 0.72);
  --surface-solid: #ffffff;
  --text: #1e293b;
  --muted: #64748b;
  --border: rgba(15, 23, 42, 0.08);
  --input-bg: rgba(255, 255, 255, 0.8);
}
/* 暗色 */
[data-theme="dark"] {
  --bg-1: #0f172a;
  --bg-2: #1e1b4b;
  --bg-3: #312e81;
  --surface: rgba(30, 41, 59, 0.6);
  --surface-solid: #1e293b;
  --text: #e2e8f0;
  --muted: #94a3b8;
  --border: rgba(255, 255, 255, 0.1);
  --input-bg: rgba(15, 23, 42, 0.6);
}
/* 跟随系统 */
@media (prefers-color-scheme: dark) {
  [data-theme="system"] {
    --bg-1: #0f172a; --bg-2: #1e1b4b; --bg-3: #312e81;
    --surface: rgba(30, 41, 59, 0.6); --surface-solid: #1e293b;
    --text: #e2e8f0; --muted: #94a3b8; --border: rgba(255, 255, 255, 0.1);
    --input-bg: rgba(15, 23, 42, 0.6);
  }
}
@media (prefers-color-scheme: light) {
  [data-theme="system"] {
    --bg-1: #eef2ff; --bg-2: #e0f2fe; --bg-3: #fce7f3;
    --surface: rgba(255, 255, 255, 0.72); --surface-solid: #ffffff;
    --text: #1e293b; --muted: #64748b; --border: rgba(15, 23, 42, 0.08);
    --input-bg: rgba(255, 255, 255, 0.8);
  }
}

* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC",
    "Microsoft YaHei", Roboto, Helvetica, Arial, sans-serif;
  color: var(--text);
  background: linear-gradient(135deg, var(--bg-1), var(--bg-2) 50%, var(--bg-3));
  background-attachment: fixed;
  transition: background 0.4s var(--ease), color 0.3s var(--ease);
  overflow-x: hidden;
}

/* 背景光斑 */
.bg-orbs { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.orb { position: absolute; border-radius: 50%; filter: blur(80px); opacity: 0.5;
  animation: float 18s var(--ease) infinite alternate; }
.orb-1 { width: 420px; height: 420px; background: #818cf8; top: -120px; left: -80px; }
.orb-2 { width: 360px; height: 360px; background: #38bdf8; bottom: -120px; right: -60px; animation-delay: -6s; }
.orb-3 { width: 300px; height: 300px; background: #f472b6; top: 40%; left: 55%; animation-delay: -12s; }
@keyframes float {
  from { transform: translate(0, 0) scale(1); }
  to { transform: translate(40px, -30px) scale(1.1); }
}

/* 玻璃拟态 */
.glass {
  background: var(--surface);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

/* ---------- 登录视图 ---------- */
.auth-wrap {
  position: relative; z-index: 1;
  min-height: 100vh; display: grid; place-items: center; padding: 24px;
}
.auth-card { width: 100%; max-width: 440px; padding: 36px 32px; }
.brand { text-align: center; margin-bottom: 24px; }
.brand-logo {
  width: 60px; height: 60px; margin: 0 auto 12px; border-radius: 16px;
  display: grid; place-items: center; font-size: 28px; color: #fff;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  box-shadow: 0 8px 24px rgba(79, 70, 229, 0.4);
}
.brand h1 { font-size: 22px; margin: 0 0 6px; letter-spacing: 0.5px; }
.brand-sub { color: var(--muted); font-size: 13px; margin: 0; }

.auth-tabs { display: flex; gap: 6px; padding: 6px; background: var(--input-bg);
  border-radius: 14px; margin-bottom: 22px; }
.auth-tab { flex: 1; padding: 10px; border: none; background: transparent; color: var(--muted);
  border-radius: 10px; cursor: pointer; font-size: 14px; font-weight: 600; transition: all 0.25s var(--ease); }
.auth-tab.active { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: var(--shadow-sm); }

.seg { display: flex; gap: 6px; margin-bottom: 16px; }
.seg-btn { flex: 1; padding: 8px; border: 1px solid var(--border); background: var(--input-bg);
  color: var(--muted); border-radius: 10px; cursor: pointer; font-weight: 600; }
.seg-btn.active { color: var(--accent); border-color: var(--accent); }

.hint { color: var(--muted); font-size: 13px; margin: 0 0 14px; }

/* ---------- 表单 ---------- */
.form { display: flex; flex-direction: column; gap: 14px; }
.form label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); font-weight: 600; }
.form input, .form select, .form textarea {
  padding: 11px 13px; border-radius: 10px; border: 1px solid var(--border);
  background: var(--input-bg); color: var(--text); font-size: 14px; font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.form input:focus, .form select:focus, .form textarea:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.18);
}
.form textarea { resize: vertical; min-height: 84px; }

/* ---------- 按钮 ---------- */
.btn { padding: 11px 18px; border-radius: 12px; border: none; cursor: pointer;
  font-size: 14px; font-weight: 700; transition: transform 0.25s var(--ease), box-shadow 0.25s, filter 0.2s;
  font-family: inherit; }
.btn:active { transform: scale(0.97); }
.btn-primary { background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff;
  box-shadow: 0 8px 22px rgba(79, 70, 229, 0.35); }
.btn-primary:hover { filter: brightness(1.05); box-shadow: 0 12px 30px rgba(79, 70, 229, 0.45); }
.btn-ghost { background: var(--input-bg); color: var(--text); border: 1px solid var(--border); }
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }
.btn-sm { padding: 7px 12px; font-size: 13px; }
.btn-danger { background: #ef4444; color: #fff; }
.btn-success { background: #10b981; color: #fff; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.icon-btn { width: 40px; height: 40px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--input-bg); cursor: pointer; font-size: 18px; transition: all 0.2s; }
.icon-btn:hover { border-color: var(--accent); transform: translateY(-2px); }

/* ---------- 应用布局 ---------- */
.app { position: relative; z-index: 1; display: flex; min-height: 100vh; }
.sidebar { width: 240px; margin: 16px; padding: 20px 16px; display: flex; flex-direction: column;
  position: sticky; top: 16px; height: calc(100vh - 32px); }
.side-brand { font-weight: 800; font-size: 18px; margin-bottom: 24px; padding-left: 6px; }
.side-nav { display: flex; flex-direction: column; gap: 4px; flex: 1; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 11px 14px; border-radius: 12px;
  color: var(--muted); cursor: pointer; font-weight: 600; font-size: 14px; transition: all 0.2s var(--ease);
  border: 1px solid transparent; }
.nav-item:hover { background: var(--input-bg); color: var(--text); }
.nav-item.active { background: linear-gradient(135deg, rgba(79,70,229,0.16), rgba(14,165,233,0.16));
  color: var(--accent); border-color: rgba(79,70,229,0.3); }
.side-foot { border-top: 1px solid var(--border); padding-top: 14px; display: flex; flex-direction: column; gap: 10px; }
.side-user { font-size: 13px; color: var(--muted); }

.main { flex: 1; display: flex; flex-direction: column; padding: 16px 16px 16px 0; min-width: 0; }
.topbar { display: flex; align-items: center; justify-content: space-between; padding: 16px 22px; margin-bottom: 18px; }
.page-title { font-size: 20px; font-weight: 800; }
.view { padding-right: 6px; }

/* ---------- 卡片 / 网格 ---------- */
.grid { display: grid; gap: 18px; }
.grid-products { grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); }
.grid-stats { grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); }

.card { background: var(--surface); backdrop-filter: blur(20px); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow-sm);
  transition: transform 0.3s var(--ease), box-shadow 0.3s; }
.card:hover { transform: translateY(-4px); box-shadow: var(--shadow); }

.stat-card { text-align: left; }
.stat-card .label { color: var(--muted); font-size: 13px; font-weight: 600; }
.stat-card .value { font-size: 28px; font-weight: 800; margin-top: 6px;
  background: linear-gradient(135deg, var(--accent), var(--accent-2)); -webkit-background-clip: text; background-clip: text; -webkit-text-fill-color: transparent; }

/* 产品卡 */
.product-card { cursor: pointer; overflow: hidden; padding: 0; }
.product-card .thumb { height: 150px; background: linear-gradient(135deg, var(--accent), var(--accent-2));
  position: relative; display: grid; place-items: center; color: #fff; font-size: 40px; }
.product-card .thumb img { width: 100%; height: 100%; object-fit: cover; }
.product-card .body { padding: 14px 16px 18px; }
.product-card h3 { margin: 0 0 6px; font-size: 16px; }
.product-card .meta { color: var(--muted); font-size: 13px; display: flex; gap: 10px; flex-wrap: wrap; }
.product-card .price { margin-top: 10px; font-weight: 800; color: var(--accent); font-size: 18px; }
.tag { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 700;
  background: rgba(79,70,229,0.14); color: var(--accent); }
.tag.green { background: rgba(16,185,129,0.16); color: #10b981; }
.tag.amber { background: rgba(245,158,11,0.18); color: #f59e0b; }
.tag.red { background: rgba(239,68,68,0.16); color: #ef4444; }

/* 详情 / 区块 */
.section-title { font-size: 16px; font-weight: 800; margin: 4px 0 14px; }
.row { display: flex; gap: 12px; flex-wrap: wrap; align-items: center; }
.muted { color: var(--muted); }
.spacer { flex: 1; }
.empty { text-align: center; color: var(--muted); padding: 60px 20px; }

/* 表格 */
.table { width: 100%; border-collapse: collapse; font-size: 14px; }
.table th, .table td { padding: 12px 14px; text-align: left; border-bottom: 1px solid var(--border); }
.table th { color: var(--muted); font-weight: 700; font-size: 13px; }
.table tr:hover td { background: var(--input-bg); }

/* 状态时间线 */
.timeline { display: flex; flex-direction: column; gap: 0; margin: 12px 0; }
.tl-item { display: flex; gap: 12px; padding-bottom: 16px; position: relative; }
.tl-item::before { content: ""; position: absolute; left: 7px; top: 18px; bottom: -2px; width: 2px; background: var(--border); }
.tl-item:last-child::before { display: none; }
.tl-dot { width: 16px; height: 16px; border-radius: 50%; background: var(--accent); margin-top: 2px; flex-shrink: 0; box-shadow: 0 0 0 4px rgba(79,70,229,0.15); }
.tl-dot.off { background: var(--muted); box-shadow: none; }
.tl-label { font-weight: 700; font-size: 14px; }
.tl-sub { color: var(--muted); font-size: 12px; }

/* 日期行 */
.date-row { display: flex; gap: 10px; align-items: center; margin-bottom: 8px; }
.date-row input { flex: 1; }
.date-row .price-in { width: 130px; }

/* 加载条 */
.loading-bar { position: fixed; top: 0; left: 0; height: 3px; width: 0;
  background: linear-gradient(90deg, var(--accent), var(--accent-2)); z-index: 999;
  transition: width 0.3s var(--ease); }
.loading-bar.on { width: 70%; }
.loading-bar.done { width: 100%; opacity: 0; }

/* toast */
.toast { position: fixed; bottom: 28px; left: 50%; transform: translateX(-50%) translateY(20px);
  background: var(--surface-solid); color: var(--text); padding: 12px 20px; border-radius: 12px;
  box-shadow: var(--shadow); border: 1px solid var(--border); opacity: 0; pointer-events: none;
  transition: all 0.3s var(--ease); z-index: 1000; font-size: 14px; font-weight: 600; }
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast.err { border-color: #ef4444; color: #ef4444; }

.hidden { display: none !important; }

/* ---------- 弹窗 ---------- */
.modal-overlay { position: fixed; inset: 0; z-index: 500; background: rgba(15, 23, 42, 0.45);
  backdrop-filter: blur(4px); display: grid; place-items: center; padding: 20px; animation: fade 0.25s var(--ease); }
@keyframes fade { from { opacity: 0; } to { opacity: 1; } }
.modal { width: 100%; max-width: 560px; max-height: 86vh; overflow: auto; padding: 22px; }
.modal-head { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.modal-head h3 { margin: 0; font-size: 18px; }
.modal-body { font-size: 14px; }

/* ---------- 未读徽标 ---------- */
.badge { display: inline-block; min-width: 18px; padding: 1px 7px; border-radius: 999px;
  background: #ef4444; color: #fff; font-size: 12px; font-weight: 700; text-align: center; }
.nav-item { position: relative; }
.nav-item .badge { position: absolute; right: 10px; top: 50%; transform: translateY(-50%); }

/* ---------- 客服气泡 ---------- */
.chat-box { display: flex; flex-direction: column; gap: 10px; max-height: 320px; overflow-y: auto; padding: 6px 2px; }
.bubble { max-width: 76%; padding: 9px 13px; border-radius: 14px; font-size: 14px; line-height: 1.45; word-break: break-word; }
.bubble.me { align-self: flex-end; background: linear-gradient(135deg, var(--accent), var(--accent-2)); color: #fff; border-bottom-right-radius: 4px; }
.bubble.other { align-self: flex-start; background: var(--input-bg); color: var(--text); border: 1px solid var(--border); border-bottom-left-radius: 4px; }
.bubble .bt { font-size: 10px; opacity: 0.7; margin-top: 3px; text-align: right; }

/* ---------- 柱状图 ---------- */
.bars { display: flex; flex-direction: column; gap: 10px; }
.bar-row { display: flex; align-items: center; gap: 12px; }
.bar-label { width: 120px; font-size: 13px; color: var(--muted); flex-shrink: 0; text-align: right; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bar-track { flex: 1; height: 14px; background: var(--input-bg); border-radius: 999px; overflow: hidden; border: 1px solid var(--border); }
.bar-fill { height: 100%; border-radius: 999px; background: linear-gradient(90deg, var(--accent), var(--accent-2)); transition: width 0.6s var(--ease); }
.bar-val { width: 50px; font-size: 13px; font-weight: 700; color: var(--text); }

/* ---------- 图谱容器 ---------- */
#graph { background: var(--input-bg); border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px; }

/* 响应式 */
@media (max-width: 820px) {
  .sidebar { position: static; width: auto; height: auto; margin: 12px; flex-direction: row;
    align-items: center; overflow-x: auto; }
  .side-brand { display: none; }
  .side-nav { flex-direction: row; }
  .side-foot { flex-direction: row; border: none; padding: 0; }
  .main { padding: 0 12px 12px; }
}
