/* XG 后台主题覆盖 · 注入 new-api SPA
   原理：覆盖 shadcn/Tailwind 语义令牌，明/暗两态统一为磷光绿机房控制台 */
@import url('https://fonts.googleapis.com/css2?family=Chakra+Petch:wght@600;700&family=IBM+Plex+Mono:wght@400;500&display=swap');

:root,
.dark,
[data-theme='dark'],
[data-theme='light'] {
  /* 表面 */
  --background: #0a0f0d;
  --foreground: #e8f5ee;
  --card: #101815;
  --card-foreground: #e8f5ee;
  --popover: #15201b;
  --popover-foreground: #e8f5ee;
  /* 主色：磷光绿 */
  --primary: #2bffa0;
  --primary-foreground: #04170e;
  --secondary: #15201b;
  --secondary-foreground: #e8f5ee;
  --muted: #15201b;
  --muted-foreground: #7d9a8c;
  --accent: #15201b;
  --accent-foreground: #2bffa0;
  --destructive: #ff5d5d;
  --destructive-foreground: #1a0505;
  /* 边框与输入 */
  --border: rgba(43, 255, 160, 0.16);
  --input: rgba(43, 255, 160, 0.16);
  --ring: #2bffa0;
  /* 侧边栏 */
  --sidebar: #0d1411;
  --sidebar-foreground: #e8f5ee;
  --sidebar-primary: #2bffa0;
  --sidebar-primary-foreground: #04170e;
  --sidebar-accent: #15201b;
  --sidebar-accent-foreground: #2bffa0;
  --sidebar-border: rgba(43, 255, 160, 0.16);
  --sidebar-ring: #2bffa0;
  /* 图表色阶：绿色家族 */
  --chart-1: #2bffa0;
  --chart-2: #0e8f5a;
  --chart-3: #7dffd0;
  --chart-4: #14684a;
  --chart-5: #b8ffe6;
}

/* 全局基底 */
html,
body {
  background: #0a0f0d !important;
  color: #e8f5ee !important;
  font-family: 'IBM Plex Mono', 'Noto Sans SC', ui-monospace, monospace !important;
  letter-spacing: 0.01em;
}

/* 标题与品牌字：Chakra Petch */
h1, h2, h3,
[class*='font-bold'][class*='text-2xl'],
[class*='font-semibold'][class*='text-lg'],
[class*='font-bold'][class*='text-lg'],
.sidebar-group-label {
  font-family: 'Chakra Petch', 'Noto Sans SC', sans-serif !important;
  letter-spacing: 0.02em;
}

/* 主按钮：磷光绿切角质感（精确匹配，避免误伤 text-primary-foreground） */
.bg-primary {
  background-color: #2bffa0 !important;
  color: #04170e !important;
}
.text-primary {
  color: #2bffa0 !important;
}
.text-primary-foreground {
  color: #04170e !important;
}
.hover\:bg-primary\/90:hover,
.hover\:bg-primary:hover {
  background-color: #29e693 !important;
  filter: drop-shadow(0 0 10px rgba(43, 255, 160, 0.45));
}

/* 输入与卡片：发丝绿边 */
[class*='border-input'],
input,
textarea,
select {
  border-color: rgba(43, 255, 160, 0.16) !important;
  background-color: #101815 !important;
  color: #e8f5ee !important;
}
input::placeholder,
textarea::placeholder {
  color: #55705f !important;
}
[class*='ring-primary']:focus-visible,
:focus-visible {
  outline: 2px solid #2bffa0 !important;
  outline-offset: 2px;
}

/* 表格行悬停 */
tr:hover {
  background-color: rgba(43, 255, 160, 0.05) !important;
}

/* 滚动条：绿色轨道 */
::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: #0a0f0d; }
::-webkit-scrollbar-thumb {
  background: #1c3328;
  border-radius: 5px;
  border: 2px solid #0a0f0d;
}
::-webkit-scrollbar-thumb:hover { background: #2bffa0; }

/* 开关/进度等组件的选中态统一绿色 */
[data-state='checked'] {
  background-color: #2bffa0 !important;
}

/* 状态徽章色彩体系（成功=绿，失败=红，保持语义可辨） */
[class*='bg-emerald'], [class*='text-emerald'] { color: #2bffa0 !important; }
[class*='bg-green'],  [class*='text-green']  { color: #2bffa0 !important; }
[class*='text-red'],  [class*='bg-red']      { color: #ff5d5d !important; }

@media (prefers-reduced-motion: no-preference) {
  .bg-primary, [class*='bg-primary'] {
    transition: filter 160ms ease-out, transform 160ms ease-out;
  }
}

/* ========== 硬覆盖：new-api 后台部分组件使用 Tailwind 中性色工具类，不走语义令牌 ========== */

/* 白/浅灰表面 → 深绿灰面板 */
.bg-white, .bg-gray-50, .bg-gray-100, .bg-slate-50, .bg-slate-100, .bg-zinc-50, .bg-zinc-100,
[class*='bg-white'] {
  background-color: #101815 !important;
}
.bg-gray-200, .bg-slate-200, .bg-zinc-200 { background-color: #15201b !important; }

/* 深灰表面 → 保持暗但统一绿调 */
.bg-gray-800, .bg-gray-900, .bg-slate-800, .bg-slate-900,
.bg-zinc-800, .bg-zinc-900 {
  background-color: #0d1411 !important;
}

/* 主文字 → 近白 */
.text-gray-900, .text-gray-800, .text-slate-900, .text-slate-800,
.text-zinc-900, .text-zinc-800, .text-black {
  color: #e8f5ee !important;
}
/* 次文字 → 灰绿 */
.text-gray-700, .text-gray-600, .text-gray-500,
.text-slate-700, .text-slate-600, .text-slate-500,
.text-zinc-700, .text-zinc-600, .text-zinc-500 {
  color: #7d9a8c !important;
}
/* 边框 → 发丝绿边 */
.border-gray-100, .border-gray-200, .border-gray-300,
.border-slate-100, .border-slate-200, .border-slate-300,
.border-zinc-100, .border-zinc-200, .border-zinc-300 {
  border-color: rgba(43, 255, 160, 0.16) !important;
}

/* 浅色悬停态 → 绿色微光 */
.hover\:bg-gray-100:hover, .hover\:bg-gray-50:hover,
.hover\:bg-slate-100:hover, .hover\:bg-slate-50:hover,
.hover\:bg-zinc-100:hover, .hover\:bg-zinc-50:hover {
  background-color: rgba(43, 255, 160, 0.08) !important;
}

/* 白底弹层/下拉/对话框 */
[data-radix-popper-content-wrapper] > *,
[role='dialog'], [role='alertdialog'], [role='menu'],
[role='listbox'], [role='tooltip'], [data-slot='popover-content'] {
  background-color: #15201b !important;
  color: #e8f5ee !important;
  border-color: rgba(43, 255, 160, 0.2) !important;
}

/* 分割线与骨架屏 */
hr, [class*='divide-gray'], [class*='divide-slate'] {
  border-color: rgba(43, 255, 160, 0.1) !important;
}
.animate-pulse, [class*='animate-pulse'] {
  background-color: #15201b !important;
}

/* ========== 布局风格层：机房控制台面板语言 ========== */

/* 全局圆角收紧：从大圆角 SaaS 质感切到精密仪器质感 */
:root { --radius: 8px; }

/* 页面氛围：网格坐标纸 + 右上角磷光辉光（压在最底层，内容之上） */
body::before {
  content: ""; position: fixed; inset: 0; pointer-events: none; z-index: 0;
  background:
    radial-gradient(60rem 40rem at 88% -12%, rgba(43, 255, 160, 0.07), transparent 60%),
    repeating-linear-gradient(0deg, rgba(232, 245, 238, 0.022) 0 1px, transparent 1px 56px),
    repeating-linear-gradient(90deg, rgba(232, 245, 238, 0.022) 0 1px, transparent 1px 56px);
}
#root { position: relative; z-index: 1; background: transparent !important; }

/* 顶栏：半透明毛玻璃 + 发丝底边 */
header {
  backdrop-filter: blur(8px);
  background: rgba(10, 15, 13, 0.78) !important;
  border-bottom: 1px solid rgba(43, 255, 160, 0.12) !important;
}

/* 侧边栏：更深的机柜色 + 发丝分隔 */
aside, [data-slot='sidebar'], [data-sidebar='sidebar'] {
  background: #0d1411 !important;
  border-right: 1px solid rgba(43, 255, 160, 0.12) !important;
}
/* 活动菜单项：磷光绿 + 左侧指示条（控制台信号灯语言） */
[data-sidebar='menu-button'][data-active='true'],
[data-sidebar='menu-button'].active {
  background: rgba(43, 255, 160, 0.1) !important;
  color: #2bffa0 !important;
  box-shadow: inset 3px 0 0 #2bffa0 !important;
  border-radius: 4px !important;
}
[data-sidebar='menu-button']:hover:not([data-active='true']) {
  background: rgba(43, 255, 160, 0.06) !important;
  color: #e8f5ee !important;
}

/* 卡片：面板化 —— 发丝绿边、深底、悬停微光 */
[data-slot='card'], .rounded-xl.border, .rounded-lg.border {
  background: #101815 !important;
  border: 1px solid rgba(43, 255, 160, 0.14) !important;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.4) !important;
  transition: box-shadow 320ms cubic-bezier(0.16, 1, 0.3, 1), border-color 320ms ease-out;
}
[data-slot='card']:hover, .rounded-xl.border:hover, .rounded-lg.border:hover {
  border-color: rgba(43, 255, 160, 0.35) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.5), 0 0 20px rgba(43, 255, 160, 0.08) !important;
}

/* 主按钮：切角工艺（仅作用于按钮元素，避免污染图标/徽章） */
button.bg-primary, a.bg-primary {
  clip-path: polygon(9px 0, 100% 0, 100% calc(100% - 9px), calc(100% - 9px) 100%, 0 100%, 0 9px);
  border-radius: 0 !important;
  font-family: 'Chakra Petch', 'Noto Sans SC', sans-serif !important;
  letter-spacing: 0.05em;
  font-weight: 600;
}

/* 数据表：控制台日志风格 */
table { font-variant-numeric: tabular-nums; }
thead th {
  font-family: 'Chakra Petch', 'Noto Sans SC', sans-serif !important;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-size: 11px !important;
  color: #7d9a8c !important;
  border-bottom: 1px solid rgba(43, 255, 160, 0.2) !important;
}
tbody td { border-bottom: 1px solid rgba(232, 245, 238, 0.05) !important; }

/* 数字看板：等宽数字 + 绿色强调 */
.tabular-nums, [class*='text-3xl'], [class*='text-2xl'] {
  font-variant-numeric: tabular-nums;
}

/* 输入控件：暗底 + 绿色聚焦辉光 */
input:focus, textarea:focus, select:focus {
  border-color: rgba(43, 255, 160, 0.5) !important;
  box-shadow: 0 0 0 3px rgba(43, 255, 160, 0.12) !important;
}

/* 标签页激活态：底部磷光条 */
[data-slot='tabs-list'] {
  background: #101815 !important;
  border: 1px solid rgba(43, 255, 160, 0.12) !important;
}
[data-slot='tabs-trigger'][data-state='active'],
[data-state='active'][class*='tabs'] {
  background: rgba(43, 255, 160, 0.12) !important;
  color: #2bffa0 !important;
}
