/* 控制台主题注入 · Nisaka API
 * 通过 nginx sub_filter 注入到 NewAPI 的 HTML 里
 * 目标：深色底 + 青色主色 + 猫娘背景 + 雪
 */

/* ── 1. 强制深色 + 青色主色 ───────────────────────────── */
html.dark {
  --primary: #2dd4bf;
  --primary-foreground: #04211d;
  --ring: #2dd4bf;
  --sidebar-primary: #2dd4bf;
  --sidebar-primary-foreground: #04211d;
  --secondary-foreground: #5eead4;
  --accent-foreground: #d7fff7;
  --accent: color-mix(in oklch, #2dd4bf 16%, #0b0e14);
  --sidebar-accent: color-mix(in oklch, #2dd4bf 16%, #0b0e14);
  --info: #2dd4bf;
  --success: #34d399;
  --border: rgba(255, 255, 255, .10);
  --input: rgba(255, 255, 255, .16);
  --background: #0a0d13;
  --card: rgba(18, 22, 30, .86);
  --popover: rgba(18, 22, 30, .96);
  --muted: rgba(255, 255, 255, .05);
  --table-row: transparent;
  --sidebar: rgba(10, 13, 19, .52);
  --radius: .85rem;
}

/* ── 2. 背景层：猫娘 + 雪 ──────────────────────────────── */
/* body 只铺纯色，并建立独立层，让 ::before 能沉到内容之下 */
html.nx-console body {
  background-color: #070a10 !important;
  isolation: isolate;
}

/* 背景图（两套，用 --nx-bg 切换） */
html.nx-console body::before {
  content: "";
  position: fixed;
  inset: 0;
  z-index: -1;
  pointer-events: none;
  background-image: var(--nx-bg, url("/site/assets/bg.jpg"));
  background-size: cover;
  background-position: var(--nx-pos, 24% 34%);
  background-repeat: no-repeat;
  opacity: 0;   /* 背景改由 #nx-bg 实体层绘制 */
}

/* 压暗渐变，保证面板可读 */
html.nx-console body::after {
  content: "";
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background:
    radial-gradient(120% 80% at 50% 0%, rgba(45, 212, 191, .05), transparent 55%),
    linear-gradient(180deg, rgba(7, 10, 16, .55) 0%, rgba(7, 10, 16, .80) 60%, rgba(7, 10, 16, .92) 100%);
}

/* 背景层（实体 div，z-index 0，在 #root 之下） */
#nx-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  background-size: cover;
  background-position: 24% 34%;
  background-repeat: no-repeat;
  opacity: .82;
  filter: saturate(1.05) brightness(1.0);
  transition: opacity .35s ease;
}

/* 雪 canvas */
#nx-snow {
  position: fixed;
  inset: 0;
  z-index: 0;
  pointer-events: none;
}

/* 内容层抬到背景之上 */
/* ⚠️ 只给 #root 建层叠上下文。绝不能再给 main / aside / [data-sidebar] 设 position ——
 * 上游移动端侧栏抽屉就是靠 class 里的 fixed 定位的，被改成 relative 会掉到页面底部，
 * 用户只看到一个遮罩（蒙版）却看不到任何菜单内容。 */
html.nx-console #root {
  position: relative;
  z-index: 1;
}

/* ── 3. 玻璃化：让卡片透出背景 ────────────────────────── */
html.nx-console.dark [class*="rounded"] {
  backdrop-filter: blur(6px);
}

/* 侧边栏 */
html.nx-console.dark aside {
  background: rgba(9, 12, 18, .72) !important;
  backdrop-filter: blur(14px);
  border-right: 1px solid rgba(255, 255, 255, .07) !important;
}

/* 顶栏 */
html.nx-console.dark header {
  background: rgba(9, 12, 18, .55) !important;
  backdrop-filter: blur(12px);
  border-bottom: 1px solid rgba(255, 255, 255, .06) !important;
}

/* ── 4. 猫娘切换按钮（替换原主题按钮位置） ─────────────── */
#nx-switch {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 60;
  display: flex;
  gap: 8px;
  padding: 8px;
  border-radius: 14px;
  background: rgba(14, 18, 26, .82);
  border: 1px solid rgba(255, 255, 255, .10);
  backdrop-filter: blur(14px);
  box-shadow: 0 10px 30px rgba(0, 0, 0, .45);
  font-family: system-ui, -apple-system, "Microsoft YaHei", sans-serif;
}
#nx-switch button {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px;
  border-radius: 9px;
  border: 1px solid transparent;
  background: rgba(255, 255, 255, .05);
  color: #9aa6b8;
  font-size: 12px;
  cursor: pointer;
  transition: all .15s;
}
#nx-switch button:hover { color: #e8ecf4; border-color: rgba(45, 212, 191, .3); }
#nx-switch button.on {
  color: #04211d;
  font-weight: 600;
  background: linear-gradient(180deg, #2dd4bf, #14b8a6);
}
#nx-switch .nx-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: currentColor; opacity: .8;
}

/* 隐藏官方主题按钮（它只管明/暗，这里改成猫娘两套） */
html.nx-console [aria-label="打开主题设置"],
html.nx-console [aria-label="Theme settings"],
html.nx-console [aria-label="主题设置"] {
  display: none !important;
}

/* 移动端把切换器收窄 */
@media (max-width: 640px) {
  #nx-switch { right: 12px; bottom: 12px; padding: 6px; }
  #nx-switch button { padding: 6px 9px; font-size: 11px; }
}

/* ── 5. 放行背景：NewAPI 内部大量用 bg-background 铺满，会盖住 body ── */
html.nx-console [class*="bg-background"] {
  background-color: transparent !important;
}
/* 但卡片/弹窗要留住，改成半透明玻璃 */
html.nx-console [class*="bg-card"] {
  background-color: rgba(18, 22, 30, .62) !important;
}
html.nx-console [class*="bg-popover"] {
  background-color: rgba(18, 22, 30, .95) !important;
}
/* 侧边栏与顶栏 */
html.nx-console aside,
html.nx-console header,
html.nx-console [data-sidebar] {
  background-color: rgba(9, 12, 18, .60) !important;
}
/* 主内容区 */
html.nx-console main {
  background-color: transparent !important;
}
/* 雪要在内容之上，但低于弹窗 */
html.nx-console #nx-snow { z-index: 2; }
html.nx-console #root { z-index: 1; }

/* NewAPI 的布局容器直接用 bg-sidebar 铺满整屏，必须放行 */
html.nx-console [class*="bg-sidebar"] {
  background-color: rgba(10, 13, 19, .52) !important;
}
html.nx-console [class*="sidebar-wrapper"] {
  background-color: transparent !important;
}

/* ── 6. SPA 登录/注册页：给窄表单容器加玻璃卡，避免文字压在背景图上 ── */
html.nx-console div.mx-auto.flex.w-full.flex-col.justify-center.space-y-2 {
  background: rgba(13, 17, 25, .80) !important;
  border: 1px solid rgba(255, 255, 255, .09) !important;
  border-radius: 18px !important;
  backdrop-filter: blur(16px) saturate(130%);
  -webkit-backdrop-filter: blur(16px) saturate(130%);
  box-shadow: 0 24px 60px rgba(0, 0, 0, .55), inset 0 1px 0 rgba(255, 255, 255, .05);
  padding: 32px !important;
  margin-top: 24px;
  margin-bottom: 24px;
}


/* ── 7. 移动端侧栏抽屉（修复「点开控制栏只有蒙版、看不到内容」） ──
 * 成因：上面的层叠规则曾把 [data-sidebar] 改成 position:relative + z-index:1，
 * 抽屉因此脱离 fixed 定位、掉到页面底部，同时被 z-50 的遮罩盖住。
 * 这里只对窄屏还原上游的定位与层级，并给抽屉一个够实的玻璃底。 */
@media (max-width: 767px) {
  html.nx-console [data-slot="sidebar"],
  html.nx-console [data-sidebar="sidebar"] {
    position: fixed !important;
    top: 0 !important;
    left: 0 !important;
    height: 100svh !important;
    z-index: 51 !important;
    background-color: rgba(8, 11, 17, .96) !important;
    -webkit-backdrop-filter: blur(18px) saturate(120%);
    backdrop-filter: blur(18px) saturate(120%);
  }
  html.nx-console [data-slot="sheet-overlay"] {
    z-index: 50 !important;
    background-color: rgba(3, 5, 10, .58) !important;
    -webkit-backdrop-filter: blur(2px);
    backdrop-filter: blur(2px);
  }
  /* 抽屉里的导航项：抬到玻璃层之上，避免被 backdrop-filter 压灰 */
  html.nx-console [data-slot="sidebar-inset"],
  html.nx-console [data-slot="sidebar-content"] {
    position: relative;
    z-index: 1;
  }
}

/* ===== 20261115 控制台候选 r1（未上线前只在候选目录） ===== */

/* C1 猫娘切换器降到遮罩之下：抽屉打开时不再浮在最上层 */
#nx-switch { z-index: 45; }
html.nx-console body:has([data-slot="sheet-overlay"]) #nx-switch {
  opacity: 0;
  pointer-events: none;
  transition: opacity .18s ease;
}

/* C2 金额/计数统一等宽数字，避免长数字跳动与溢出时参差 */
html.nx-console .tabular-nums,
html.nx-console [data-nx-money] {
  font-variant-numeric: tabular-nums;
  letter-spacing: -.01em;
}
html.nx-console [data-nx-money] { white-space: nowrap; }
