/* base.css — CSS 变量、reset、布局原语、深浅色主题 */

/* ── 颜色变量：语义命名，不绑定任何品牌色 ── */
:root {
  --ink: #1a2332;            /* 主文字 */
  --muted: #6b7785;          /* 次要文字 */
  --surface: #ffffff;        /* 卡片背景 */
  --surface-alt: #f5f7fa;    /* 次级背景 */
  --surface-hover: #eef2f7;  /* hover 背景 */
  --line: #e0e6ee;           /* 分割线/边框 */
  --accent: #2563eb;         /* 主强调色（链接/按钮） */
  --accent-soft: #dbeafe;    /* 强调色浅底 */
  --success: #16a34a;        /* 有货/通过 */
  --success-soft: #dcfce7;
  --danger: #dc2626;         /* 缺货/降价/错误 */
  --danger-soft: #fee2e2;
  --warning: #d97706;        /* 警告/权益类促销 */
  --warning-soft: #fef3c7;
  --best: #1d4ed8;           /* best price 高亮 */
  --best-soft: #e0e7ff;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.16);
  --font-sans: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Helvetica Neue", Arial, sans-serif;
  --font-mono: "SF Mono", "Cascadia Code", "Consolas", monospace;
}

/* 深色主题：@media + [data-theme] 双重支持 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --ink: #e6edf3;
    --muted: #8b96a5;
    --surface: #161b22;
    --surface-alt: #0d1117;
    --surface-hover: #21262d;
    --line: #30363d;
    --accent: #58a6ff;
    --accent-soft: #1a3a5c;
    --success: #3fb950;
    --success-soft: #1a3a1f;
    --danger: #f85149;
    --danger-soft: #3a1a1a;
    --warning: #d29922;
    --warning-soft: #3a2f1a;
    --best: #7aa2f7;
    --best-soft: #1a2233;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
  }
}

:root[data-theme="dark"] {
  --ink: #e6edf3;
  --muted: #8b96a5;
  --surface: #161b22;
  --surface-alt: #0d1117;
  --surface-hover: #21262d;
  --line: #30363d;
  --accent: #58a6ff;
  --accent-soft: #1a3a5c;
  --success: #3fb950;
  --success-soft: #1a3a1f;
  --danger: #f85149;
  --danger-soft: #3a1a1a;
  --warning: #d29922;
  --warning-soft: #3a2f1a;
  --best: #7aa2f7;
  --best-soft: #1a2233;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ── reset ── */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

body {
  font-family: var(--font-sans);
  background: var(--surface-alt);
  color: var(--ink);
  line-height: 1.5;
  min-height: 100vh;
}

button {
  font-family: inherit;
  cursor: pointer;
}

input,
select {
  font-family: inherit;
  font-size: inherit;
}

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

/* ── 布局原语 ── */
.app-shell {
  max-width: 1280px;
  margin: 0 auto;
  padding: 16px 20px 40px;
}

.panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
}

.hidden {
  display: none !important;
}

/* ── 通用按钮 ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 16px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s, border-color 0.15s, opacity 0.15s;
}
.btn:hover {
  background: var(--surface-hover);
}
.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: #fff;
}
.btn-primary:hover:not(:disabled) {
  background: var(--best);
  border-color: var(--best);
}

/* ── 通用 select / input ── */
select,
input[type="text"],
input[type="date"] {
  padding: 8px 10px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  background: var(--surface);
  color: var(--ink);
  min-width: 0;
}
select:focus,
input:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

/* ── 通用 spinner ── */
.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid var(--line);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}
