/* ============================================================================
   AutoPromo · 浅色主题（唯一主题，无深色模式）
   ----------------------------------------------------------------------------
   结构：
     1. 设计令牌（品牌色 / 文字层级 / 边框 / 阴影）
     2. 基础元素
     3. 壳层：侧边栏 / 顶栏 / 用户区
     4. 组件：按钮 / 输入 / 卡片 / 表格 / 徽章 / 弹窗 / Toast
     5. 浅色适配覆盖层（最后一段，必须保持在文件末尾）
   ============================================================================ */

/* ---------------------------- 1. 设计令牌 ---------------------------- */
:root {
  /* 品牌色（取自 logo XICEL 的蓝→青→青绿渐变） */
  --brand: #1E9BF0;
  --brand-2: #22C3F0;
  --brand-3: #3DDCB4;
  --brand-dark: #1583CC;
  --brand-soft: #EAF6FE;
  --brand-grad: linear-gradient(135deg, #1E9BF0 0%, #22C3F0 52%, #3DDCB4 100%);

  /* 底色与层次 */
  --bg: #F5F8FC;
  --surface: #FFFFFF;
  --surface-2: #F8FAFC;

  /* 文字层级（越往后越弱） */
  --fg: #0F172A;
  --fg-2: #334155;
  --fg-3: #475569;
  --fg-4: #64748B;
  --fg-5: #94A3B8;

  /* 边框 */
  --line: #E6ECF5;
  --line-soft: #EEF2F8;

  /* 语义色 */
  --ok: #10B981;
  --warn: #F59E0B;
  --danger: #EF4444;

  /* 阴影与光环 */
  --ring: 0 0 0 3px rgba(30, 155, 240, 0.18);
  --shadow-xs: 0 1px 2px rgba(15, 23, 42, 0.04);
  --shadow-sm: 0 2px 8px -4px rgba(15, 23, 42, 0.10);
  --shadow-md: 0 12px 32px -20px rgba(15, 23, 42, 0.28);
  --shadow-lg: 0 24px 60px -28px rgba(15, 23, 42, 0.36);

  --radius: 12px;
}

/* ---------------------------- 2. 基础元素 ---------------------------- */
* { box-sizing: border-box; }

html, body { height: 100%; }

body {
  font-family: "Inter", "PingFang SC", "Microsoft YaHei", system-ui, sans-serif;
  background: var(--bg);
  color: var(--fg);
  -webkit-font-smoothing: antialiased;
}

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

button:focus-visible,
a:focus-visible,
[tabindex]:focus-visible {
  outline: 2px solid var(--brand);
  outline-offset: 2px;
}

input[type="checkbox"], input[type="radio"] { accent-color: var(--brand); }

::selection { background: rgba(30, 155, 240, 0.18); }

/* ---------------------------- 3. 壳层 ---------------------------- */
/* 侧边栏：白底 + 右侧 1px 边线 */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--line);
}
.side-brand { border-bottom: 1px solid var(--line); }

/* 顶栏 */
.header {
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

/* 顶栏图标按钮（搜索） */
.icon-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 32px;
  padding: 0 10px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg-3);
  font-size: 12px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.icon-btn:hover {
  background: var(--brand-soft);
  border-color: #C9E4F8;
  color: var(--brand);
}

/* 用户区 */
.user-chip {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 3px 10px 3px 3px;
  border-radius: 999px;
  border: 1px solid transparent;
}
.user-chip:hover { background: var(--surface-2); border-color: var(--line); }

.avatar {
  width: 26px;
  height: 26px;
  flex: 0 0 26px;
  border-radius: 50%;
  background: var(--brand-grad);
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  display: grid;
  place-items: center;
}

.role-badge {
  display: inline-block;
  font-size: 10px;
  line-height: 15px;
  padding: 0 6px;
  border-radius: 999px;
  font-weight: 600;
  background: var(--brand-soft);
  color: var(--brand-dark);
  border: 1px solid #CBE7FA;
}
.role-badge.role-super_admin { background: #F3EEFE; color: #6D28D9; border-color: #DDD6FE; }
.role-badge.role-admin       { background: var(--brand-soft); color: var(--brand-dark); border-color: #CBE7FA; }
.role-badge.role-operator    { background: #ECFDF5; color: #047857; border-color: #A7F3D0; }
.role-badge.role-viewer      { background: var(--surface-2); color: var(--fg-4); border-color: var(--line); }

/* 侧边导航 */
.nav-group {
  padding: 14px 12px 6px;
  font-size: 11px;
  line-height: 1;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--fg-5);
}
.nav-group:first-child { padding-top: 6px; }

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 10px;
  margin-bottom: 2px;
  border-radius: 9px;
  border-left: 3px solid transparent;
  color: var(--fg-3);
  font-size: 13px;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.nav-item:hover { background: #F1F7FD; color: var(--fg); }
.nav-item.active {
  background: var(--brand-soft);
  border-left-color: var(--brand);
  color: var(--brand);
  font-weight: 600;
}

.nav-ico {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  opacity: .85;
}
.nav-item.active .nav-ico { opacity: 1; }
.nav-item > span:last-child { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

/* ---------------------------- 4. 组件 ---------------------------- */
/* 输入控件 */
.input,
select.input,
textarea.input {
  width: 100%;
  margin-top: 4px;
  padding: 8px 12px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  color: var(--fg);
  font-size: 13px;
  font-family: inherit;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.input:hover { border-color: #D3DEEC; }
.input:focus {
  border-color: var(--brand);
  box-shadow: var(--ring);
}
.input::placeholder { color: #A3B0C2; }
.input:disabled { background: var(--surface-2); color: var(--fg-5); cursor: not-allowed; }
textarea.input { resize: vertical; line-height: 1.65; }
select.input { cursor: pointer; }

.field-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--fg-3);
  margin-bottom: 5px;
}

/* 主按钮：品牌渐变、白字 */
.btn-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  background: var(--brand-grad);
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  padding: 9px 16px;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  white-space: nowrap;
  box-shadow: 0 6px 16px -10px rgba(30, 155, 240, .8);
  transition: filter .15s, box-shadow .15s, transform .1s, opacity .15s;
}
.btn-primary:hover {
  filter: brightness(.93) saturate(1.06);
  box-shadow: 0 10px 22px -12px rgba(30, 155, 240, .95);
}
.btn-primary:active { transform: translateY(1px); box-shadow: none; }
.btn-primary:disabled,
.btn-primary[disabled] {
  opacity: .5;
  cursor: not-allowed;
  filter: none;
  box-shadow: none;
  transform: none;
}

/* 次按钮：白底 1px 边框 */
.btn-ghost {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg-3);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  white-space: nowrap;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.btn-ghost:hover {
  background: var(--brand-soft);
  border-color: #C9E4F8;
  color: var(--brand);
}
.btn-ghost:active { transform: translateY(1px); }
.btn-ghost:disabled,
.btn-ghost[disabled] { opacity: .5; cursor: not-allowed; background: var(--surface); }

/* 分段切换按钮（数据分析 tabs） */
.tab-btn {
  padding: 6px 13px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--fg-3);
  font-size: 12px;
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.tab-btn:hover { background: var(--brand-soft); border-color: #C9E4F8; color: var(--brand); }
.tab-btn.is-active {
  background: var(--brand-soft);
  border-color: rgba(30, 155, 240, .45);
  color: var(--brand);
  font-weight: 600;
}

/* 行内小按钮（表格 / 列表里的"通过 / 驳回 / 编辑"） */
.mini-btn {
  font-size: 11px;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 6px;
  border: 1px solid transparent;
  background: var(--surface);
  color: var(--fg-3);
  font-weight: 500;
  font-family: inherit;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s;
}
.mini-btn:disabled,
.mini-btn[disabled] { opacity: .4; cursor: not-allowed; }
.mini-ok { background: #ECFDF5; color: #047857; border-color: #A7F3D0; }
.mini-ok:hover:not(:disabled) { background: #D1FAE5; }
.mini-danger { background: #FEF2F2; color: #BE123C; border-color: #FECDD3; }
.mini-danger:hover:not(:disabled) { background: #FFE4E6; }
.mini-ghost { background: var(--surface); color: var(--fg-3); border-color: var(--line); }
.mini-ghost:hover:not(:disabled) { background: var(--brand-soft); border-color: #C9E4F8; color: var(--brand); }

/* 纯图标按钮 */
.icon-btn-plain {
  display: inline-grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: transparent;
  color: var(--fg-5);
  font-size: 18px;
  line-height: 1;
  cursor: pointer;
  transition: background .15s, color .15s;
}
.icon-btn-plain:hover { background: var(--surface-2); color: var(--fg-2); }

.kbd {
  font-family: ui-monospace, monospace;
  font-size: 10px;
  padding: 1px 5px;
  border-radius: 5px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  color: var(--fg-5);
}

/* 卡片 */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 14px;
  padding: 18px;
  box-shadow: var(--shadow-xs);
  transition: border-color .2s, box-shadow .2s;
}
.card:hover { border-color: #D2E7F8; box-shadow: var(--shadow-sm); }

.gradient-text {
  background: var(--brand-grad);
  -webkit-background-clip: text;
  background-clip: text;
  color: transparent;
}

/* 状态徽章 */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: 11px;
  line-height: 18px;
  padding: 0 9px;
  border-radius: 999px;
  font-weight: 500;
  border: 1px solid transparent;
  white-space: nowrap;
}
.badge-green  { background: #ECFDF5; color: #047857; border-color: #A7F3D0; }
.badge-yellow { background: #FFFBEB; color: #B45309; border-color: #FDE68A; }
.badge-red    { background: #FEF2F2; color: #BE123C; border-color: #FECDD3; }
.badge-gray   { background: var(--surface-2); color: var(--fg-4); border-color: var(--line); }
.badge-blue   { background: #EFF6FF; color: #1D4ED8; border-color: #BFDBFE; }

/* 状态点 */
.dot {
  display: inline-block;
  width: 8px; height: 8px;
  flex: 0 0 8px;
  border-radius: 50%;
}
.dot-ok { background: var(--ok); }
.dot-warn { background: var(--warn); }
.dot-bad { background: var(--danger); }

/* 数字等宽 */
.mono { font-family: ui-monospace, "SF Mono", Menlo, monospace; font-variant-numeric: tabular-nums; }

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

/* 表格 */
.tbl { width: 100%; border-collapse: collapse; font-size: 13px; }
.tbl th {
  text-align: left;
  background: var(--surface-2);
  color: var(--fg-3);
  font-weight: 600;
  font-size: 12px;
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}
.tbl td {
  padding: 11px 12px;
  border-bottom: 1px solid var(--line-soft);
  color: var(--fg-2);
  vertical-align: middle;
}
.tbl tr:hover td { background: var(--surface-2); }
.tbl tr:last-child td { border-bottom: none; }

/* 热力矩阵格 */
.heat {
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 500;
}

/* 空状态 */
.empty { text-align: center; padding: 48px 0; color: var(--fg-5); font-size: 13px; }
.empty .em-icon { font-size: 28px; opacity: .45; display: block; margin-bottom: 6px; }

/* 弹窗 */
.modal-backdrop {
  background: rgba(15, 23, 42, 0.38);
  -webkit-backdrop-filter: blur(4px);
  backdrop-filter: blur(4px);
}
.modal-panel {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-lg);
}

/* Toast */
.toast {
  position: fixed;
  top: 16px;
  right: 16px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 8px;
  max-width: 360px;
  padding: 10px 14px;
  border-radius: 10px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--brand);
  color: var(--fg);
  font-size: 13px;
  box-shadow: 0 14px 34px -18px rgba(15, 23, 42, .45);
  animation: pop .22s ease both;
}
.toast-ok { border-left-color: var(--ok); }
.toast-error { border-left-color: var(--danger); }
.toast-dot {
  width: 6px; height: 6px;
  flex: 0 0 6px;
  border-radius: 50%;
  background: var(--brand);
}
.toast-ok .toast-dot { background: var(--ok); }
.toast-error .toast-dot { background: var(--danger); }

/* 动效 */
@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.fade-in { animation: fadeIn .4s ease both; }

@keyframes pop { from { opacity: 0; transform: scale(.97); } to { opacity: 1; transform: scale(1); } }
.pop-in { animation: pop .25s ease both; }

.count-up { transition: color .3s; }

/* ============================================================================
   5. 浅色适配覆盖层
   ----------------------------------------------------------------------------
   存量页面（含不可修改的 pages/*.js）大量使用深色主题的 Tailwind 类名。
   这里用「属性选择器 + !important」把它们整体映射到浅色语义，
   从而不逐页改文件即可全部变浅色。新增页面请直接用基础类或 CSS 变量。

   文字层级映射（深色由亮到暗 → 浅色由深到浅，保持原有强弱关系）：
     slate-100/200 → 主文字 #0F172A   slate-300 → #334155
     slate-400     → #475569          slate-500 → #64748B   slate-600 → #94A3B8

   ⚠ 所有选择器都带 `html ` 前缀，把特异度提到 0,1,1，
     确保压过 Tailwind Play CDN 运行时注入的 `.text-xxx`（同特异度，但它是动态
     append 到 <head> 末尾的，不能赌文档顺序）。
   ============================================================================ */

/* ---- 5.1 文字：深色主题里的"亮字"在浅色下就是主文字 ---- */
html [class~="text-white"],
html [class*="text-white/"] { color: var(--fg) !important; }

html [class~="text-slate-100"],
html [class~="text-slate-200"] { color: var(--fg) !important; }
html [class~="text-slate-300"] { color: var(--fg-2) !important; }
html [class~="text-slate-400"] { color: var(--fg-3) !important; }
html [class~="text-slate-500"] { color: var(--fg-4) !important; }
html [class~="text-slate-600"] { color: var(--fg-5) !important; }

/* ---- 5.2 文字：300 档浅色语义色在白底上不可读，统一降到 700 档 ---- */
html [class*="text-amber-200"],
html [class*="text-amber-300"],
html [class*="text-amber-400"] { color: #B45309 !important; }   /* amber-700 */

html [class*="text-rose-300"],
html [class*="text-rose-400"] { color: #BE123C !important; }    /* rose-700 */

html [class*="text-emerald-300"],
html [class*="text-emerald-400"] { color: #047857 !important; } /* emerald-700 */

html [class*="text-sky-300"] { color: #0369A1 !important; }     /* sky-700 */

/* ---- 5.3 背景：深色底 → 卡片白 / 浅灰底 ---- */
html [class*="bg-slate-950"],
html [class*="bg-slate-900"],
html [class*="bg-slate-800"] { background-color: var(--surface) !important; }

/* 纯 bg-white（如二维码容器）保持纯白 */
html [class~="bg-white"] { background-color: #fff !important; }

/* 半透明白（bg-white/5、bg-white/10）在深色下是"提亮"，在浅色下要变成"压暗" */
html [class*="bg-white/"] { background-color: rgba(15, 23, 42, 0.04) !important; }
html [class*="hover:bg-white/"]:hover { background-color: rgba(30, 155, 240, 0.08) !important; }

/* 深色遮罩 / 代码块深底：区分开处理 */
html [class*="bg-black/60"],
html [class*="bg-black/50"],
html [class*="bg-black/70"] { background-color: rgba(15, 23, 42, 0.38) !important; }
html [class*="bg-black/30"],
html [class*="bg-black/20"],
html [class*="bg-black/10"] { background-color: var(--surface-2) !important; }

/* 品牌淡色底（选中态）保持品牌调 */
html [class*="bg-brand-600/"],
html [class*="bg-brand-500/"] { background-color: rgba(30, 155, 240, 0.10) !important; }

/* 语义淡色底略微加深，白底上才看得见 */
html [class*="bg-emerald-500/5"] { background-color: rgba(16, 185, 129, 0.08) !important; }
html [class*="bg-amber-500/5"] { background-color: rgba(245, 158, 11, 0.10) !important; }
html [class*="bg-rose-500/5"] { background-color: rgba(239, 68, 68, 0.07) !important; }

/* ---- 5.4 边框：白色描边 → 浅灰边框 ---- */
html [class~="border-white"],
html [class*="border-white/"] { border-color: var(--line) !important; }

html [class*="border-brand-500"],
html [class*="border-brand-400"] { border-color: rgba(30, 155, 240, 0.45) !important; }
html [class*="border-emerald-500"],
html [class*="border-emerald-400"] { border-color: rgba(16, 185, 129, 0.32) !important; }
html [class*="border-amber-500"],
html [class*="border-amber-400"] { border-color: rgba(245, 158, 11, 0.35) !important; }
html [class*="border-rose-500"],
html [class*="border-rose-400"] { border-color: rgba(239, 68, 68, 0.30) !important; }
html [class*="border-slate-700"],
html [class*="border-slate-800"] { border-color: var(--line) !important; }

html [class*="hover:border-brand"]:hover { border-color: var(--brand) !important; }

/* ---- 5.5 悬停态：深色 hover 类在浅色下改为品牌淡蓝 ---- */
html [class*="hover:text-white"]:hover { color: var(--brand) !important; }
html [class*="hover:bg-slate-"]:hover { background-color: var(--surface-2) !important; }
html [class*="hover:text-slate-"]:hover { color: var(--fg) !important; }

/* ---- 5.6 品牌色文字收口（浅底上统一压深一档，保证可读） ---- */
html [class*="text-brand-300"] { color: var(--brand-dark) !important; }
html [class*="text-brand-400"] { color: var(--brand) !important; }
