@import url("./ui-schemes.css");
@import url("./ui-scheme-layout.css");
/* ==========================================================================
   工业平台统一 UI 主题 — themes.css
   对应开发清单：UI-03（视觉规范）、UI-04（Design Token）、UI-08（状态与反馈）、
                 UI-17（主题与品牌）
   版本：1.1.0  （与 tokens.json / theme.js 同源，修改须三处同步）

   接入方式：
     1. <link rel="stylesheet" href="themes.css"> 或构建工具 import 'themes.css'
     2. 在 <html> 上设置 data-theme="light" | "dark"（默认 light）
     3. 可选：<html data-density="compact"> 开启高密度模式
   主题切换由 theme-context.jsx（React）或各系统自行写入 data-theme 完成，
   跨系统同步协议见 README.md。
   ========================================================================== */

:root {
  /* ---------- 种子 Token（Seed）---------- */
  --seed-bg: #eef1f7;
  --seed-fg: #1f2733;
  --seed-surface: #ffffff;
  --seed-surface-2: #f7f9fc;
  --seed-primary: #1668dc;
  --seed-accent: #13b8c2;
  --seed-muted: #5b6472;
  --seed-border: #e6ebf2;

  /* ---------- 状态 Token（禁止仅用颜色表达状态，须配图标/文字）---------- */
  --status-success: #16a34a;
  --status-warning: #e08e0b;
  --status-danger: #e5484d;
  --status-info: #1668dc;
  --status-offline: #8a93a3;

  /* ---------- 尺寸与缩放 ---------- */
  --seed-radius: 12px;       /* 面板圆角 */
  --seed-density: 1;         /* 缩放内边距与间距 */
  --seed-font-scale: 1;      /* 缩放区域字号 */

  /* ---------- 系统识别色（各系统可覆盖，见 README「系统识别色」）---------- */
  --sys-accent: var(--seed-primary);

  /* ---------- 派生 Token（Derived）---------- */
  --text-1: var(--seed-fg);
  --text-2: var(--seed-muted);
  --text-3: color-mix(in srgb, var(--seed-muted) 72%, var(--seed-surface));
  --panel: var(--seed-surface);
  --panel-2: var(--seed-surface-2);
  --panel-border: var(--seed-border);
  --panel-radius: var(--seed-radius);
  --grid-line: color-mix(in srgb, var(--seed-border) 78%, transparent);
  --primary-soft: color-mix(in srgb, var(--seed-primary) 12%, var(--seed-surface));
  --primary-line: color-mix(in srgb, var(--seed-primary) 30%, transparent);
  --accent-soft: color-mix(in srgb, var(--seed-accent) 14%, var(--seed-surface));

  /* 状态的柔和底/边（用于状态标签、提示条），由状态色派生，禁止硬编码 */
  --success-soft: color-mix(in srgb, var(--status-success) 12%, var(--panel));
  --success-line: color-mix(in srgb, var(--status-success) 26%, transparent);
  --warning-soft: color-mix(in srgb, var(--status-warning) 12%, var(--panel));
  --warning-line: color-mix(in srgb, var(--status-warning) 26%, transparent);
  --danger-soft: color-mix(in srgb, var(--status-danger) 12%, var(--panel));
  --danger-line: color-mix(in srgb, var(--status-danger) 26%, transparent);
  --info-soft: color-mix(in srgb, var(--status-info) 12%, var(--panel));
  --info-line: color-mix(in srgb, var(--status-info) 26%, transparent);
  --offline-soft: color-mix(in srgb, var(--status-offline) 12%, var(--panel));
  --offline-line: color-mix(in srgb, var(--status-offline) 26%, transparent);

  /* ---------- 字体（信创回退：Noto Sans CJK SC / Microsoft YaHei）---------- */
  --font-sans: -apple-system, 'PingFang SC', 'Microsoft YaHei', 'Noto Sans CJK SC',
    'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --mono: 'JetBrains Mono', 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, monospace;

  /* ---------- 间距（随密度缩放）---------- */
  --pad: calc(20px * var(--seed-density));
  --pad-sm: calc(14px * var(--seed-density));
  --gap: calc(16px * var(--seed-density));
  --radius-sm: calc(var(--seed-radius) * 0.6);
  --shadow-panel: 0 1px 2px rgba(20, 30, 55, 0.04), 0 8px 24px rgba(20, 30, 55, 0.05);

  /* ---------- 字号（清单 5.7.3：不随视口连续缩放）---------- */
  --fs-page-title: 20px;   /* 页面一级标题，600 字重 */
  --fs-section: 16px;      /* 区域标题，600 字重 */
  --fs-body: 14px;         /* 正文与表格 */
  --fs-table-compact: 13px;/* 高密度表格，下限 12px */
  --fs-aux: 12px;          /* 辅助信息 */
  --row-height: 40px;      /* 表格默认行高 */
  --row-height-compact: 34px;
}

/* ---------- 深色主题 ---------- */
[data-theme='dark'] {
  --seed-bg: #0c1220;
  --seed-fg: #e7ebf2;
  --seed-surface: #161d2e;
  --seed-surface-2: #1b2436;
  --seed-primary: #4c9aff;
  --seed-accent: #36cfc9;
  --seed-muted: #9aa6b8;
  --seed-border: #28324a;

  --status-success: #49aa19;
  --status-warning: #d89614;
  --status-danger: #e5484d;
  --status-info: #4c9aff;
  --status-offline: #727d8f;

  --shadow-panel: 0 1px 2px rgba(0, 0, 0, 0.4), 0 10px 30px rgba(0, 0, 0, 0.35);
  color-scheme: dark;
}

/* ---------- 高密度模式（清单 5.7.3：紧凑表格 32-36px 行高）---------- */
[data-density='compact'] {
  --seed-density: 0.8;
  --row-height: var(--row-height-compact);
  --fs-body: var(--fs-table-compact);
}

/* ==========================================================================
   基础样式（所有系统共用，ip- 前缀）
   ========================================================================== */

* {
  box-sizing: border-box;
}

html,
body {
  height: 100%;
  margin: 0;
}

body {
  background: var(--seed-bg);
  color: var(--text-1);
  font-family: var(--font-sans);
  font-size: var(--fs-body);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
  text-rendering: optimizeLegibility;
}

/* ---------- 应用外壳（门户 / 控制台通用骨架）---------- */
.ip-app {
  display: flex;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 100% -10%,
      color-mix(in srgb, var(--seed-primary) 8%, transparent), transparent 60%),
    var(--seed-bg);
}

.ip-sider {
  /* 244px × 2/3, rounded to a whole CSS pixel for all three portals. */
  width: 163px;
  flex: 0 0 163px;
  display: flex;
  flex-direction: column;
  background: color-mix(in srgb, var(--seed-surface) 92%, var(--seed-fg) 2%);
  border-right: 1px solid var(--panel-border);
  position: sticky;
  top: 0;
  height: 100vh;
  z-index: 20;
}

.ip-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 18px 12px 14px;
}
.ip-brand .logo {
  flex-shrink: 0;
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: linear-gradient(135deg, var(--sys-accent), var(--seed-accent));
  box-shadow: 0 6px 16px color-mix(in srgb, var(--sys-accent) 40%, transparent);
}
.ip-brand .logo svg { display: block; }
.ip-brand .name {
  font-size: calc(16px * var(--seed-font-scale));
  font-weight: 700;
  letter-spacing: 0.2px;
  color: var(--text-1);
  line-height: 1.1;
}
.ip-brand .sub {
  font-family: var(--font-sans);
  font-size: var(--fs-aux);
  letter-spacing: .04em;
  color: var(--text-3);
  margin-top: 2px;
}

.ip-scroll {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0 16px;
}
.ip-scroll::-webkit-scrollbar,
.ip-content-scroll::-webkit-scrollbar { width: 10px; }
.ip-scroll::-webkit-scrollbar-thumb,
.ip-content-scroll::-webkit-scrollbar-thumb {
  background: color-mix(in srgb, var(--seed-muted) 26%, transparent);
  border-radius: 10px;
}

.ip-navlabel {
  font-family: var(--mono);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-3);
  padding: 8px 12px 2px;
}
.ip-navgroup {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-3);
  padding: 5px 10px 5px calc(10px + var(--nav-depth, 1) * 14px);
  line-height: 1.3;
}

.ip-sider-foot {
  border-top: 1px solid var(--panel-border);
  padding: 12px 10px;
  overflow-wrap: anywhere;
}

.ip-main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.ip-header {
  height: 64px;
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 0 24px;
  border-bottom: 1px solid var(--panel-border);
  background: color-mix(in srgb, var(--seed-surface) 82%, transparent);
  backdrop-filter: saturate(140%) blur(8px);
  position: sticky;
  top: 0;
  z-index: 15;
}

.ip-content-scroll {
  height: calc(100vh - 64px);
  overflow-y: auto;
  padding: var(--pad);
}

/* ---------- 面板 ---------- */
.ip-panel {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--shadow-panel);
  padding: var(--pad);
  position: relative;
}
.ip-panel--pad0 { padding: 0; overflow: hidden; }
.ip-panel-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 4px;
}
.ip-panel-title {
  font-size: calc(15.5px * var(--seed-font-scale));
  font-weight: 650;
  color: var(--text-1);
  letter-spacing: 0.1px;
}
.ip-panel-sub { font-size: 12.5px; color: var(--text-3); }
.ip-eyebrow {
  font-family: var(--mono);
  font-size: 11px;
  letter-spacing: 1.4px;
  text-transform: uppercase;
  color: var(--text-3);
}

/* ---------- KPI 指标卡 ---------- */
.ip-kpi {
  background: var(--panel);
  border: 1px solid var(--panel-border);
  border-radius: var(--panel-radius);
  box-shadow: var(--shadow-panel);
  padding: var(--pad);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overflow: hidden;
  position: relative;
}
.ip-kpi::after {
  content: '';
  position: absolute;
  inset: 0 0 auto 0;
  height: 3px;
  background: linear-gradient(90deg, var(--accent-color, var(--seed-primary)), transparent 78%);
  opacity: 0.9;
}
.ip-kpi-top { display: flex; align-items: center; justify-content: space-between; }
.ip-kpi-label { font-size: 13px; color: var(--text-2); }
.ip-kpi-ic {
  width: 34px;
  height: 34px;
  border-radius: 9px;
  display: grid;
  place-items: center;
  background: color-mix(in srgb, var(--accent-color, var(--seed-primary)) 14%, var(--panel));
  color: var(--accent-color, var(--seed-primary));
}
.ip-kpi-value {
  font-size: calc(30px * var(--seed-font-scale));
  font-weight: 700;
  line-height: 1;
  letter-spacing: -0.5px;
  color: var(--text-1);
  font-variant-numeric: tabular-nums;
}
.ip-kpi-value .unit { font-size: 14px; font-weight: 600; color: var(--text-2); margin-left: 4px; }
.ip-kpi-foot { display: flex; align-items: center; justify-content: space-between; gap: 8px; }

/* ---------- 状态标签（固定状态词典，禁止自造同义状态）---------- */
.ip-status {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 1px 9px 1px 7px;
  border-radius: 999px;
  font-size: 12.5px;
  font-weight: 600;
  line-height: 20px;
  border: 1px solid transparent;
}
.ip-status .ip-status-ic { font-size: 12px; display: inline-flex; }
.ip-status[data-tone='success'] { color: var(--status-success); background: var(--success-soft); border-color: var(--success-line); }
.ip-status[data-tone='warning'] { color: var(--status-warning); background: var(--warning-soft); border-color: var(--warning-line); }
.ip-status[data-tone='danger']  { color: var(--status-danger);  background: var(--danger-soft);  border-color: var(--danger-line); }
.ip-status[data-tone='info']    { color: var(--status-info);    background: var(--info-soft);    border-color: var(--info-line); }
.ip-status[data-tone='offline'] { color: var(--status-offline); background: var(--offline-soft); border-color: var(--offline-line); }

@keyframes ip-spin { to { transform: rotate(360deg); } }
.ip-status[data-tone='info'][data-spin] .ip-status-ic { animation: ip-spin 1.4s linear infinite; }

/* ---------- 趋势 ---------- */
.ip-trend { display: inline-flex; align-items: center; gap: 4px; font-size: 12.5px; font-weight: 600; }
.ip-trend.up { color: var(--status-success); }
.ip-trend.down { color: var(--status-danger); }

/* ---------- 页头 ---------- */
.ip-page-head {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
  margin-bottom: var(--gap);
  flex-wrap: wrap;
}
.ip-page-head h1 {
  margin: 0;
  font-size: var(--fs-page-title);
  font-weight: 600;
  letter-spacing: -0.2px;
  color: var(--text-1);
}
.ip-page-head .desc { color: var(--text-2); font-size: 13.5px; margin-top: 4px; max-width: 60ch; }

/* ---------- 表格基线 ---------- */
.ip-table {
  width: 100%;
  border-collapse: collapse;
  font-size: var(--fs-body);
}
.ip-table th {
  text-align: left;
  font-weight: 600;
  font-size: 12.5px;
  color: var(--text-2);
  background: var(--panel-2);
  padding: 0 12px;
  height: 38px;
  border-bottom: 1px solid var(--panel-border);
  white-space: nowrap;
}
.ip-table td {
  padding: 0 12px;
  height: var(--row-height);
  border-bottom: 1px solid var(--panel-border);
  color: var(--text-1);
}
.ip-table tbody tr:hover td { background: color-mix(in srgb, var(--seed-primary) 4%, transparent); }
.ip-table .num { font-variant-numeric: tabular-nums; }

/* ---------- 工具类 ---------- */
.ip-grid { display: grid; gap: var(--gap); }
.ip-mono { font-family: var(--mono); }
.ip-muted { color: var(--text-2); }
.ip-soft { color: var(--text-3); }
.ip-row { display: flex; align-items: center; gap: 10px; }
.ip-spread { display: flex; align-items: center; justify-content: space-between; }
.ip-dot { width: 8px; height: 8px; border-radius: 50%; display: inline-block; }
.ip-tnum { font-variant-numeric: tabular-nums; }
.ip-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 6px 12px;
  border-radius: 999px;
  background: var(--panel-2);
  border: 1px solid var(--panel-border);
  font-size: 12.5px;
  color: var(--text-2);
}
.ip-chip b { color: var(--text-1); font-variant-numeric: tabular-nums; }

/* 减少动效（无障碍，清单 UI-16） */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}
