/* ============================================================
   FanCloud 后台主题 · 墨青（古风 × 科技）
   ------------------------------------------------------------
   作用域：html[data-fc-console="1"]（console-theme.js 打标）
   思路：
   1. 前台与后台同源，都是 shadcn 变量 + data-slot 组件，
      所以直接改写变量（含 --sidebar 系列）而不是逐条覆盖；
   2. 圆角统一 2px，只留一点收边；
   3. 古风：墨底 / 宣纸 / 茶青 / 金线；科技：发丝边框 / 青色辉光；
   4. 不使用背景图。
   ============================================================ */

/* ---------------- 1. 圆角：统一 2px ---------------- */
html[data-fc-console="1"] {
  --radius: 2px;
  --radius-sm: 2px;
  --radius-md: 2px;
  --radius-lg: 2px;
  --radius-xl: 2px;
  --radius-2xl: 2px;
  --radius-3xl: 2px;
  --radius-full: 2px;
  --cell-radius: 2px;
}

html[data-fc-console="1"] *,
html[data-fc-console="1"] *::before,
html[data-fc-console="1"] *::after {
  border-radius: 2px !important;
}

/* 圆形元素（头像、状态点、耗时竖条、开关球）必须保留圆，否则会变成方块影响识别。
   注意 `*::before/::after` 的 2px 规则会把 shadcn 用 after:rounded-full 画的
   头像外圈也拍平，所以伪元素要一起放行。 */
html[data-fc-console="1"] img,
html[data-fc-console="1"] [data-slot="switch-thumb"],
html[data-fc-console="1"] [data-slot="checkbox-indicator"],
html[data-fc-console="1"] [data-slot="radio-group-indicator"],
html[data-fc-console="1"] [data-slot="progress-indicator"],
html[data-fc-console="1"] [data-slot="skeleton"],
html[data-fc-console="1"] [data-slot="avatar"],
html[data-fc-console="1"] [data-slot="avatar-image"],
html[data-fc-console="1"] [data-slot="avatar-fallback"],
html[data-fc-console="1"] [data-slot="avatar-badge"],
html[data-fc-console="1"] [class*="rounded-full"] {
  border-radius: 9999px !important;
}

html[data-fc-console="1"] [data-slot="avatar"]::before,
html[data-fc-console="1"] [data-slot="avatar"]::after,
html[data-fc-console="1"] [class*="rounded-full"]::before,
html[data-fc-console="1"] [class*="rounded-full"]::after {
  border-radius: 9999px !important;
}

/* 头像不要被裁切或挤压：尺寸交给原生 size-8，内边距归零，字母不换行 */
html[data-fc-console="1"] [data-slot="avatar"] {
  padding: 0 !important;
  overflow: visible;
}

html[data-fc-console="1"] [data-slot="avatar-fallback"] {
  padding: 0 !important;
  line-height: 1 !important;
  white-space: nowrap;
}

/* ---------------- 2. 深色：墨底 · 茶青 · 金 ---------------- */
html.dark[data-fc-console="1"] {
  --background: #070b12;
  --foreground: #e6eef8;
  --card: #0b131e;
  --card-foreground: #e6eef8;
  --popover: #0c1521;
  --popover-foreground: #e6eef8;
  --primary: #1fb6c9;
  --primary-foreground: #04141a;
  --secondary: #0f1a27;
  --secondary-foreground: #cfe0f2;
  --muted: #0e1825;
  --muted-foreground: #8ba0b8;
  --accent: #14263a;
  --accent-foreground: #dff6fb;
  --destructive: #d9534f;
  --destructive-foreground: #fdf3f2;
  --success: #22a37a;
  --success-foreground: #04140f;
  --warning: #c8a45c;
  --warning-foreground: #17110a;
  --info: #3b82f6;
  --info-foreground: #eaf3ff;
  --border: rgba(150, 190, 225, 0.13);
  --input: rgba(150, 190, 225, 0.17);
  --ring: #2aa7b8;

  --sidebar: #090f19;
  --sidebar-foreground: #c2d4e8;
  --sidebar-primary: #1fb6c9;
  --sidebar-primary-foreground: #04141a;
  --sidebar-accent: #122238;
  --sidebar-accent-foreground: #e2f6fb;
  --sidebar-border: rgba(150, 190, 225, 0.11);
  --sidebar-ring: #2aa7b8;

  --fc-gold: #c8a45c;
  background-color: #070b12;
}

/* ---------------- 3. 浅色：宣纸 · 墨 · 茶青 ---------------- */
html:not(.dark)[data-fc-console="1"] {
  --background: #faf6ec;
  --foreground: #1b2430;
  --card: #fffdf8;
  --card-foreground: #1b2430;
  --popover: #fffdf8;
  --popover-foreground: #1b2430;
  --primary: #0f766e;
  --primary-foreground: #f7fbfa;
  --secondary: #f0ead9;
  --secondary-foreground: #2c3a4a;
  --muted: #f2ecdd;
  --muted-foreground: #67768a;
  --accent: #ebe4d2;
  --accent-foreground: #1b2430;
  --destructive: #b4413c;
  --destructive-foreground: #fdf6f5;
  --success: #0f766e;
  --success-foreground: #f7fbfa;
  --warning: #a98446;
  --warning-foreground: #fffdf8;
  --info: #0e7490;
  --info-foreground: #f5fbfd;
  --border: rgba(27, 36, 48, 0.11);
  --input: rgba(27, 36, 48, 0.15);
  --ring: #0f766e;

  --sidebar: #f6f1e4;
  --sidebar-foreground: #1b2430;
  --sidebar-primary: #0f766e;
  --sidebar-primary-foreground: #f7fbfa;
  --sidebar-accent: #ece5d3;
  --sidebar-accent-foreground: #16202b;
  --sidebar-border: rgba(27, 36, 48, 0.1);
  --sidebar-ring: #0f766e;

  --fc-gold: #a98446;
  background-color: #faf6ec;
}

/* ---------------- 4. 背景：只用极淡光晕，不用图片 ---------------- */
html[data-fc-console="1"] #root {
  position: relative;
  z-index: 1;
  background: transparent !important;
}

html[data-fc-console="1"] #root > div,
html[data-fc-console="1"] main {
  background-color: transparent !important;
  background-image: none !important;
}

html.dark[data-fc-console="1"] body::before,
html:not(.dark)[data-fc-console="1"] body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

html.dark[data-fc-console="1"] body::before {
  background:
    radial-gradient(58% 38% at 80% -8%, rgba(31, 182, 201, 0.09), transparent 62%),
    radial-gradient(48% 34% at 0% 100%, rgba(15, 118, 110, 0.09), transparent 62%);
}

html:not(.dark)[data-fc-console="1"] body::before {
  background:
    radial-gradient(58% 38% at 84% -8%, rgba(15, 118, 110, 0.07), transparent 60%),
    radial-gradient(44% 32% at 0% 100%, rgba(169, 132, 70, 0.06), transparent 60%);
}

/* ---------------- 5. 侧边栏：墨色 + 青线 ---------------- */
html[data-fc-console="1"] [data-slot="sidebar"],
html[data-fc-console="1"] [data-sidebar="sidebar"],
html[data-fc-console="1"] aside,
html[data-fc-console="1"] nav[class*="border-r"] {
  background-color: var(--sidebar) !important;
  border-right: 1px solid var(--sidebar-border) !important;
}

/* 选中项：左侧 2px 青条 + 淡青底 */
html[data-fc-console="1"] [data-slot="sidebar"] [data-active="true"],
html[data-fc-console="1"] [data-slot="sidebar"] a[aria-current="page"],
html[data-fc-console="1"] [data-sidebar="menu-button"][data-active="true"],
html[data-fc-console="1"] .bg-sidebar-primary\/10,
html[data-fc-console="1"] [class*="sidebar"][class*="active"] {
  position: relative;
}

html[data-fc-console="1"] [data-slot="sidebar"] [data-active="true"],
html[data-fc-console="1"] [data-slot="sidebar"] a[aria-current="page"],
html[data-fc-console="1"] [data-sidebar="menu-button"][data-active="true"] {
  background-color: var(--sidebar-accent) !important;
  color: var(--sidebar-accent-foreground) !important;
  box-shadow: inset 2px 0 0 0 var(--sidebar-primary);
}

/* ---------------- 6. 卡片与数据表 ---------------- */
html[data-fc-console="1"] [data-slot="card"],
html[data-fc-console="1"] [data-slot="data-table-card"] {
  position: relative;
  border: 1px solid var(--border) !important;
  background-color: var(--card) !important;
  box-shadow: none !important;
}

html[data-fc-console="1"] [data-slot="card"]::before,
html[data-fc-console="1"] [data-slot="data-table-card"]::before {
  content: "";
  position: absolute;
  inset: -1px -1px auto -1px;
  height: 1px;
  background: linear-gradient(90deg, rgba(31, 182, 201, 0.5), rgba(31, 182, 201, 0) 55%);
  pointer-events: none;
}

html[data-fc-console="1"] [data-slot="table-container"] {
  border-radius: 2px !important;
}

html[data-fc-console="1"] [data-slot="table-header"] th,
html[data-fc-console="1"] [data-slot="table-head"] {
  font-size: 11.5px;
  letter-spacing: 0.09em;
  color: var(--muted-foreground) !important;
  font-weight: 500;
  border-bottom: 1px solid var(--border) !important;
}

html[data-fc-console="1"] [data-slot="table-row"] {
  border-bottom: 1px solid rgba(150, 190, 225, 0.06) !important;
}

html:not(.dark)[data-fc-console="1"] [data-slot="table-row"] {
  border-bottom: 1px solid rgba(27, 36, 48, 0.06) !important;
}

html.dark[data-fc-console="1"] [data-slot="table-row"]:hover {
  background-color: rgba(31, 182, 201, 0.05) !important;
}

html:not(.dark)[data-fc-console="1"] [data-slot="table-row"]:hover {
  background-color: rgba(15, 118, 110, 0.05) !important;
}

/* ---------------- 7. 控件：方形 · 发丝描边 · 青色聚焦 ---------------- */
html[data-fc-console="1"] [data-slot="input"],
html[data-fc-console="1"] [data-slot="textarea"],
html[data-slot="native-select"],
html[data-fc-console="1"] [data-slot="select-trigger"],
html[data-fc-console="1"] [data-slot="input-group"],
html[data-fc-console="1"] input,
html[data-fc-console="1"] textarea,
html[data-fc-console="1"] select {
  border-radius: 2px !important;
  border: 1px solid var(--input) !important;
  background-color: rgba(255, 255, 255, 0.02) !important;
}

html:not(.dark)[data-fc-console="1"] [data-slot="input"],
html:not(.dark)[data-fc-console="1"] [data-slot="textarea"],
html:not(.dark)[data-fc-console="1"] [data-slot="select-trigger"],
html:not(.dark)[data-fc-console="1"] input,
html:not(.dark)[data-fc-console="1"] textarea,
html:not(.dark)[data-fc-console="1"] select {
  background-color: rgba(255, 255, 255, 0.7) !important;
}

html[data-fc-console="1"] [data-slot="input"]:focus,
html[data-fc-console="1"] input:focus,
html[data-fc-console="1"] textarea:focus,
html[data-fc-console="1"] select:focus,
html[data-fc-console="1"] [data-slot="select-trigger"][data-state="open"] {
  outline: none !important;
  border-color: var(--ring) !important;
  box-shadow: 0 0 0 1px rgba(31, 182, 201, 0.32), 0 0 12px rgba(31, 182, 201, 0.16) !important;
}

html[data-fc-console="1"] [data-slot="button"] {
  border-radius: 2px !important;
  letter-spacing: 0.02em;
}

/* 次级按钮走发丝描边，主按钮保留青底 */
html[data-fc-console="1"] [data-slot="button"][data-variant="outline"],
html[data-fc-console="1"] [data-slot="button"][data-variant="secondary"] {
  border: 1px solid var(--border) !important;
  background-color: transparent !important;
}

/* 徽章 / 状态签：方形小印，不用胶囊。
   只点名具体组件，绝不能用 [class*="rounded-full"] 做通配——
   那会把头像、耗时竖条、状态圆点一起拍平方，并且凭空给它们加上
   左右各 6px 的 padding，头像被挤窄、耗时条被撑成怪形状（2026-11-04 踩过）。 */
html[data-fc-console="1"] [data-slot="badge-cell"],
html[data-fc-console="1"] [data-slot="status-badge"] {
  border-radius: 2px !important;
  padding-left: 6px;
  padding-right: 6px;
}

html.dark[data-fc-console="1"] [data-slot="status-badge"] {
  border: 1px solid rgba(31, 182, 201, 0.22);
  background-color: rgba(31, 182, 201, 0.1);
}

/* 弹层、下拉、标签页：同样收成方角 */
html[data-fc-console="1"] [data-slot="dialog-content"],
html[data-fc-console="1"] [data-slot="dropdown-menu-content"],
html[data-fc-console="1"] [data-slot="popover-content"],
html[data-fc-console="1"] [data-slot="select-content"],
html[data-fc-console="1"] [data-slot="sheet-content"],
html[data-fc-console="1"] [data-slot="command"],
html[data-fc-console="1"] [data-slot="alert-dialog-content"] {
  border-radius: 2px !important;
  border: 1px solid var(--border) !important;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.45) !important;
}

html:not(.dark)[data-fc-console="1"] [data-slot="dialog-content"],
html:not(.dark)[data-fc-console="1"] [data-slot="dropdown-menu-content"],
html:not(.dark)[data-fc-console="1"] [data-slot="popover-content"],
html:not(.dark)[data-fc-console="1"] [data-slot="select-content"] {
  box-shadow: 0 16px 40px rgba(27, 36, 48, 0.14) !important;
}

html[data-fc-console="1"] [data-slot="tabs-trigger"] {
  border-radius: 2px !important;
  letter-spacing: 0.02em;
}

/* ---------------- 8. 细节 ---------------- */
html[data-fc-console="1"] ::selection {
  background: rgba(31, 182, 201, 0.26);
  color: #f2fdff;
}

html[data-fc-console="1"] :focus-visible {
  outline: 1px solid var(--ring);
  outline-offset: 1px;
}

html[data-fc-console="1"] .tabular-nums,
html[data-fc-console="1"] [data-slot="table-cell"] {
  font-variant-numeric: tabular-nums;
}

/* 滚动条收窄、方角 */
html[data-fc-console="1"] ::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

html[data-fc-console="1"] ::-webkit-scrollbar-thumb {
  background: rgba(140, 176, 214, 0.22);
  border-radius: 0;
}

html[data-fc-console="1"] ::-webkit-scrollbar-track {
  background: transparent;
}