/* ============================================================
   global.css — 设计令牌 + reset + 基础排版 + 通用工具类
   双主题：默认「夜晚模式」+ html[data-theme="light"]「白天模式」
   所有颜色只允许通过令牌引用，禁止在样式里写死色值。
   ============================================================ */

/* ---------- 夜晚模式（默认）---------- */
:root {
  /* 让浏览器原生控件（滚动条 / 日期选择器 / 下拉）跟随主题 */
  color-scheme: dark;

  /* 背景 / 面板 */
  --bg: #0d121c;
  --panel: #151c2b;
  --panel2: #1b2436;
  --panel3: #222d44;
  --border: #29344d;
  --border2: #3a4869;

  /* 文字 */
  --text: #e9eef8;
  --muted: #94a1bb;
  --faint: #6b7892;

  /* 主色 */
  --accent: #5b8cff;
  --accent-hover: #79a3ff;
  --accent-soft: rgba(91, 140, 255, .16);
  --accent-border: rgba(91, 140, 255, .42);
  --accent-contrast: #ffffff;

  /* 状态色：纯色 / 浅底 / 描边 */
  --green:  #3ad29b; --green-soft:  rgba(58, 210, 155, .14);  --green-border:  rgba(58, 210, 155, .34);
  --orange: #f7a93b; --orange-soft: rgba(247, 169, 59, .14);  --orange-border: rgba(247, 169, 59, .34);
  --blue:   #5b8cff; --blue-soft:   rgba(91, 140, 255, .15);  --blue-border:   rgba(91, 140, 255, .38);
  --cyan:   #2fd3e3; --cyan-soft:   rgba(47, 211, 227, .14);  --cyan-border:   rgba(47, 211, 227, .34);
  --purple: #a78bfa; --purple-soft: rgba(167, 139, 250, .15); --purple-border: rgba(167, 139, 250, .34);
  --yellow: #fbbf24; --yellow-soft: rgba(251, 191, 36, .14);  --yellow-border: rgba(251, 191, 36, .34);
  --red:    #f7687e; --red-soft:    rgba(247, 104, 126, .14); --red-border:    rgba(247, 104, 126, .34);
  --red-hover: #ff8598;
  --pink:   #ff6b9d; --pink-soft:   rgba(255, 107, 157, .14); --pink-border:   rgba(255, 107, 157, .38);
  --gray:   #8593ad; --gray-soft:   rgba(133, 147, 173, .16); --gray-border:   rgba(133, 147, 173, .38);

  /* 品牌渐变（Logo / 标题） */
  --brand-1: #5b8cff;
  --brand-2: #a78bfa;

  /* 遮罩：弹窗 / 抽屉 / 移动侧栏 */
  --mask: rgba(5, 9, 17, .66);
  --scrim: rgba(5, 9, 17, .45);

  /* 代码 / 滚动条 */
  --code-bg: var(--panel3);
  --code-fg: var(--cyan);
  --scrollbar: var(--border2);

  /* 阴影 */
  --shadow: 0 8px 30px rgba(0, 0, 0, .35);
  --shadow-lg: 0 16px 48px rgba(0, 0, 0, .5);

  /* 尺寸 */
  --radius-sm: 6px;
  --radius-md: 9px;
  --radius-lg: 12px;
  --sidebar-width: 212px;
  --topbar-height: 56px;
  --transition: .2s ease;
}

/* ============================================================
   白天模式
   ============================================================ */
html[data-theme="light"] {
  color-scheme: light;

  --bg: #f1f4f9;
  --panel: #ffffff;
  --panel2: #f5f7fb;
  --panel3: #eaeef6;
  --border: #e2e8f2;
  --border2: #c8d3e4;

  --text: #16223a;
  --muted: #5b6b85;
  --faint: #8a99b3;

  --accent: #2f6feb;
  --accent-hover: #1c5ad3;
  --accent-soft: rgba(47, 111, 235, .10);
  --accent-border: rgba(47, 111, 235, .32);
  --accent-contrast: #ffffff;

  --green:  #0e8f60; --green-soft:  rgba(14, 143, 96, .10);  --green-border:  rgba(14, 143, 96, .26);
  --orange: #b96a0c; --orange-soft: rgba(185, 106, 12, .10); --orange-border: rgba(185, 106, 12, .26);
  --blue:   #2f6feb; --blue-soft:   rgba(47, 111, 235, .10); --blue-border:   rgba(47, 111, 235, .28);
  --cyan:   #0a7f8e; --cyan-soft:   rgba(10, 127, 142, .10); --cyan-border:   rgba(10, 127, 142, .26);
  --purple: #6b45d8; --purple-soft: rgba(107, 69, 216, .10); --purple-border: rgba(107, 69, 216, .26);
  --yellow: #8a6a00; --yellow-soft: rgba(138, 106, 0, .10);  --yellow-border: rgba(138, 106, 0, .26);
  --red:    #d3384c; --red-soft:    rgba(211, 56, 76, .10);  --red-border:    rgba(211, 56, 76, .26);
  --red-hover: #b9273a;
  --pink:   #d6336c; --pink-soft:   rgba(214, 51, 108, .10); --pink-border:   rgba(214, 51, 108, .26);
  --gray:   #64748b; --gray-soft:   rgba(100, 116, 139, .10);--gray-border:   rgba(100, 116, 139, .26);

  --brand-1: #2f6feb;
  --brand-2: #7c5cf0;

  --mask: rgba(16, 24, 40, .42);
  --scrim: rgba(16, 24, 40, .20);

  --code-bg: #eef2f9;
  --code-fg: #0a7f8e;
  --scrollbar: #c8d3e4;

  --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
  --shadow-lg: 0 12px 40px rgba(16, 24, 40, .14);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

html, body { height: 100%; }

/* 主题切换过渡 */
body, .pms-topbar, .pms-sidebar, .pms-content, .card, .table-card,
.btn, .input, .select, .textarea, .badge, .stat-card, .kanban-col,
.room-cell, .board-stat, .room-drawer, .context-menu, .pms-modal-box {
  transition: background-color .25s ease, color .25s ease, border-color .25s ease;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "PingFang SC", "Hiragino Sans GB",
               "Microsoft YaHei", "Helvetica Neue", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
}

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

button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: var(--scrollbar); border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: var(--border2); }
::-webkit-scrollbar-track { background: transparent; }

::selection { background: var(--accent-soft); color: var(--text); }

/* 键盘焦点环（两种主题下均清晰可见） */
:focus-visible { outline: 2px solid var(--accent-border); outline-offset: 2px; }

/* ---------- 工具类 ---------- */
.hidden { display: none !important; }
.text-muted { color: var(--muted); }
.text-faint { color: var(--faint); }
.text-green { color: var(--green); }
.text-red { color: var(--red); }
.text-orange { color: var(--orange); }
.text-blue { color: var(--blue); }
.text-cyan { color: var(--cyan); }
.text-purple { color: var(--purple); }
.text-yellow { color: var(--yellow); }
.text-gray { color: var(--gray); }
.text-accent { color: var(--accent); }
.text-pink { color: var(--pink); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.mb-24 { margin-bottom: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-wrap { flex-wrap: wrap; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.sp { flex: 1; }

.mono { font-family: "SF Mono", Menlo, Consolas, monospace; }
.ellipsis { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------- 卡片 ---------- */
.card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px;
}

/* ---------- 表格卡片包装 ---------- */
.table-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

/* ---------- 代码块 ---------- */
code {
  background: var(--code-bg);
  color: var(--code-fg);
  padding: 1px 6px;
  border-radius: 4px;
  font-size: 12px;
  font-family: "SF Mono", Menlo, Consolas, monospace;
}

/* ---------- 页面加载态 ---------- */
.page-loading {
  display: flex; align-items: center; gap: 8px; justify-content: center;
  color: var(--muted); padding: 60px 20px;
}
.spinner {
  width: 18px; height: 18px; border: 2px solid var(--border2);
  border-top-color: var(--accent); border-radius: 50%;
  animation: spin .7s linear infinite; display: inline-block;
}
@keyframes spin { to { transform: rotate(360deg); } }
