/* ============================================================
   DMS 前端统一样式 — 企业级深蓝主题
   ============================================================ */
:root {
  --primary: #1e5eff;
  --primary-dark: #1249d0;
  --primary-light: #eaf0ff;
  --bg: #f4f6fb;
  --card: #ffffff;
  --sidebar-bg: #f2f4f7;
  --sidebar-hover: #e3e7ec;
  --sidebar-active: #aeb6c2;
  --text: #1c2434;
  --text-2: #5a6478;
  --text-3: #8a94a8;
  --border: #e3e8f0;
  --danger: #e5484d;
  --success: #30a46c;
  --radius: 10px;
  --shadow: 0 2px 12px rgba(16, 34, 82, 0.08);
  --shadow-lg: 0 10px 40px rgba(16, 34, 82, 0.16);

  /* ---- 品牌装饰色（不随主题切换，统一管理，避免页面散落硬编码） ---- */
  --brand-grad: linear-gradient(135deg, #1e5eff, #7b5cff);   /* AI 按钮/强调渐变 */
  --brand-blue: #1e5eff;                                      /* 主品牌蓝 */
  --brand-blue-soft: #2563eb;                                 /* 头像渐变浅蓝 */
  --brand-blue-2: #6d9cff;                                    /* 头像渐变亮蓝 */
  --chip-grad: linear-gradient(135deg, #f5f8ff, #eef3ff);     /* 用户胶囊背景 */
  --chip-border: #dbe6ff;                                     /* 用户胶囊边框 */
  --chip-role-bg: #e3edff;                                    /* 角色徽章背景 */
  --ring-brand: rgba(30, 94, 255, .25);                       /* 品牌元素投影 */
  --ring-brand-hover: rgba(30, 94, 255, .4);
  --menu-active-shadow: rgba(20, 30, 50, .12);
  /* ---- 统计卡片图标底色（工作台等页面，不随主题） ---- */
  --stat-blue: #eaf0ff;
  --stat-green: #e8f7f0;
  --stat-orange: #fff3e8;
  --stat-purple: #f1ebff;
  --ring-input: rgba(30, 94, 255, .12);                        /* 输入框聚焦光环 */
  --success-soft: #e8f7f0;                                     /* 成功结果卡背景 */
  --success-border: #b7e4cf;                                   /* 成功结果卡边框 */
  --danger-soft: #fdeeee;                                      /* 失败结果卡背景 */
  --danger-border: #f8c9ca;                                    /* 失败结果卡边框 */
  --border-hover: #b8c8e8;                                     /* 卡片/输入框 hover 边框 */
  --border-strong: #c3cddd;                                    /* 单选/复选描边 */

  /* ---- 主题兜底变量（与 dark-blue.css 同值，仅防 themes/*.css 加载失败时白屏/样式崩；改主题色以 themes/*.css 为准） ---- */
  --sidebar-bg: #0f1c3d;
  --ai-sidebar-bg: #16264a;
  --sidebar-hover: #1a2b55;
  --sidebar-active: #1e5eff;
  --sidebar-text: #c7d3ec;
  --sidebar-text-2: #8fa3cc;
  --sidebar-hover-text: #ffffff;
  --menu-level1-font-size: 14px;
  --menu-level2-font-size: 13px;
  --topbar-bg: #ffffff;
  --topbar-title: #0f1c3d;
  --theme-color: #ffffff;
  --welcome-grad: linear-gradient(135deg, #0f1c3d, #1e3a8a);
  --ai-title-grad: linear-gradient(135deg, #1e5eff, #7b5cff);
  --welcome-text: #ffffff;
  --welcome-sub: #b8c7ea;
  --ai-btn-bg: rgba(255,255,255,.06);
  --ai-btn-border: rgba(255,255,255,.16);
  --ai-btn-text: #e6edfb;
  --ai-search-bg: rgba(255,255,255,.07);
  --ai-search-border: rgba(255,255,255,.08);
  --ai-divider: rgba(255,255,255,.07);
  --scrollbar: #2a3d6b;
  --ai-dot: #34d399;
  --ai-btn-hover-bg: #dfe3e9;
  --ai-btn-hover-border: #c3cad4;
  --ai-ctx-bg: #151d33;
  --ai-ctx-border: rgba(255,255,255,.12);
  --ai-ctx-shadow: 0 8px 24px rgba(4,12,38,.5);
  --ai-ctx-text: #dbe5f7;
  --ai-ctx-hover: rgba(255,255,255,.09);
  --ai-danger-text: #ff8f95;
  --ai-danger-hover: rgba(229,72,77,.18);
  --ai-del-bg: rgba(255,255,255,.1);
  --ai-del-color: #c7d3ec;
  --ai-del-hover: rgba(229,72,77,.8);
  --ai-typing: #9db4e0;
  --ai-mask-shadow: 4px 0 24px rgba(4,12,38,.35);
  --ai-empty-text: #8fa3cc;
  --shadow-brand: 0 10px 30px rgba(30,94,255,.35);
  --shadow-brand-sm: 0 6px 18px rgba(30,94,255,.14);
  --shadow-brand-btn: 0 3px 10px rgba(30,94,255,.3);
  --mask-bg: rgba(10,18,40,.5);
  --md-text: #1c2434;
  --md-text-2: #5a6478;
  --md-heading: #0f1c3d;
  --md-code-inline-bg: #eef1f7;
  --md-code-inline-text: #1249d0;
  --md-code-bg: #1e2430;
  --md-code-text: #e6e9ef;
  --md-table-border: #e3e8f0;
  --md-table-head-bg: #f4f6fb;
  --md-quote-bg: #f6f4ff;
  --md-quote-border: #7b5cff;
  --md-quote-text: #4a4468;
  --md-link: #1e5eff;
  --md-hr: #e3e8f0;
}

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

body {
  font-family: "PingFang SC", "Microsoft YaHei", "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ---------- 通用按钮 ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center;
  gap: 6px; padding: 9px 18px; border: none; border-radius: 8px;
  font-size: 14px; font-weight: 500; transition: all 0.18s;
  background: var(--primary); color: #fff;
}
.btn:hover { background: var(--primary-dark); transform: translateY(-1px); box-shadow: 0 4px 14px rgba(30, 94, 255, 0.3); }
.btn:active { transform: translateY(0); }
.btn:disabled { opacity: 0.55; cursor: not-allowed; transform: none; box-shadow: none; }
.btn-block { width: 100%; padding: 11px; font-size: 15px; }

.btn-ghost {
  background: transparent; color: var(--text-2);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--primary-light); color: var(--primary); border-color: var(--primary); box-shadow: none; transform: none; }

.btn-sm { padding: 5px 12px; font-size: 13px; border-radius: 6px; }

/* ---------- 通用表单 ---------- */
.form-item { margin-bottom: 16px; }
.form-item label { display: block; margin-bottom: 6px; font-size: 13px; color: var(--text-2); font-weight: 500; }
.form-item input, .form-item select {
  width: 100%; padding: 10px 12px; border: 1px solid var(--border);
  border-radius: 8px; font-size: 14px; outline: none; transition: border 0.18s, box-shadow 0.18s;
  background: #fff; color: var(--text);
}
.form-item input:focus, .form-item select:focus {
  border-color: var(--primary); box-shadow: 0 0 0 3px rgba(30, 94, 255, 0.14);
}

/* ---------- 卡片 ---------- */
.card {
  background: var(--card); border-radius: var(--radius); box-shadow: var(--shadow);
  border: 1px solid var(--border); padding: 20px;
}
.card-title { font-size: 16px; font-weight: 600; margin-bottom: 16px; display: flex; align-items: center; gap: 8px; }

/* ---------- 表格 ---------- */
.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
.data-table th {
  background: #f7f9fd; color: var(--text-2); font-weight: 600; text-align: left;
  padding: 10px 12px; border-bottom: 1px solid var(--border); white-space: nowrap;
}
.data-table td { padding: 10px 12px; border-bottom: 1px solid #eef1f7; color: var(--text); }
.data-table tbody tr:hover { background: #f8faff; }
.data-table tbody tr:last-child td { border-bottom: none; }

/* ---------- 徽章 ---------- */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 12px; font-weight: 500;
}
.badge-blue { background: #eaf0ff; color: var(--primary); }
.badge-green { background: #e8f7f0; color: var(--success); }
.badge-red { background: #fdeeee; color: var(--danger); }
.badge-gray { background: #f0f2f6; color: var(--text-2); }

/* ---------- 提示条 ---------- */
.alert { padding: 10px 14px; border-radius: 8px; font-size: 13px; margin-bottom: 14px; display: none; }
.alert.show { display: block; }
.alert-error { background: #fdeeee; color: var(--danger); border: 1px solid #f8c9ca; }
.alert-success { background: #e8f7f0; color: var(--success); border: 1px solid #b7e4cf; }
.alert-info { background: #eaf0ff; color: var(--primary); border: 1px solid #c8d8ff; }

/* ---------- 空状态 ---------- */
.empty { text-align: center; padding: 40px 0; color: var(--text-3); }
.empty .empty-icon { font-size: 40px; margin-bottom: 10px; }

/* ---------- 加载 ---------- */
.loading { text-align: center; padding: 30px; color: var(--text-3); }
.spinner {
  display: inline-block; width: 22px; height: 22px; border: 3px solid var(--border);
  border-top-color: var(--primary); border-radius: 50%; animation: spin 0.8s linear infinite;
  vertical-align: middle; margin-right: 8px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- 滚动条 ---------- */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-thumb { background: #c9d2e3; border-radius: 4px; }
::-webkit-scrollbar-thumb:hover { background: #a8b5cc; }
::-webkit-scrollbar-track { background: transparent; }

/* ---------- 全局反馈卡片（DMSNotify） ---------- */
.dms-notify-mask {
  position: fixed; top: 0; left: 0; right: 0; bottom: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: rgba(0, 0, 0, 0.45);
}
.dms-notify-card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  width: min(440px, calc(100vw - 48px)); padding: 20px;
  max-height: 80vh; display: flex; flex-direction: column;
}
.dms-notify-title { font-size: 15px; font-weight: 600; color: var(--text); margin-bottom: 10px; flex-shrink: 0; }
.dms-notify-body { font-size: 13px; color: var(--text-2); line-height: 1.7; overflow-y: auto; }
.dms-notify-line { margin-bottom: 4px; word-break: break-all; }
.dms-notify-footer { display: flex; justify-content: flex-end; margin-top: 16px; flex-shrink: 0; }

/* ===== 公共弹层（DMSDrawer 抽屉式，2026-08-23 定版：doc-detail 同款，含最大化/关闭） ===== */
.dd-mask { position: fixed; inset: 0; background: var(--mask-bg); z-index: 1200; display: none; align-items: center; justify-content: center; }
.dd-mask.show { display: flex; }
.dd-drawer { background: var(--card); border-radius: 12px; width: calc(100vw - 60px); height: calc(100vh - 60px); max-height: calc(100vh - 60px); display: flex; flex-direction: column; overflow: hidden; box-shadow: var(--shadow-lg); transition: width .15s ease, height .15s ease, border-radius .15s ease; }
.dd-drawer.max { width: 100%; height: 100%; max-height: 100%; border-radius: 0; }
.dd-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid var(--border); flex-shrink: 0; }
.dd-drawer-title { color: var(--text); margin: 0; font-size: 15px; }
.dd-drawer-tools { display: flex; align-items: center; gap: 4px; }
.dd-drawer-maxbtn { background: none; border: none; color: var(--text-2); font-size: 14px; cursor: pointer; line-height: 1; padding: 3px 8px; border-radius: 6px; }
.dd-drawer-maxbtn:hover { color: var(--primary); background: var(--bg); }
.dd-drawer-close { background: none; border: none; color: var(--text-2); font-size: 18px; cursor: pointer; line-height: 1; padding: 2px 8px; border-radius: 6px; }
.dd-drawer-close:hover { color: var(--danger); background: var(--bg); }
.dd-drawer-body { flex: 1; min-height: 0; overflow-y: auto; padding: 14px 16px; }

/* ===== 公共页签 DMS Tabs（2026-08-23 定版：Material 下划线指示器式，非按钮样式） ===== */
.dms-tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 16px; }
.dms-tab { padding: 9px 16px; font-size: 13.5px; color: var(--text-3); background: none; border: none;
  border-bottom: 2px solid transparent; margin-bottom: -1px; cursor: pointer;
  transition: color .18s, border-color .18s; }
.dms-tab:hover { color: var(--primary); }
.dms-tab.active { color: var(--primary); font-weight: 600; border-bottom-color: var(--primary); }
