/* ═══════════════════════════════════════════════════════════════
   OBSIDIAN v3 · CYBER COMMAND
   赛博指挥中心布局 —— 与旧版完全不同
   ═══════════════════════════════════════════════════════════════ */

/* ── 全局变量 ───────────────────────────────────────────────── */
:root {
  --v3-bg-0: #04020c;
  --v3-bg-1: #080514;
  --v3-bg-2: #0d0820;
  --v3-line: rgba(139, 92, 246, .18);
  --v3-line-hot: rgba(168, 85, 247, .55);
  --v3-cyan: #22d3ee;
  --v3-violet: #a855f7;
  --v3-pink: #ec4899;
  --v3-lime: #84cc16;
  --v3-amber: #f59e0b;
  --v3-text: #e2e8f0;
  --v3-muted: #64748b;
  --v3-sidebar-w: 76px;
  --sidebar-width: 76px !important;
  --sidebar-width-icon: 76px !important;
}

/* ── 背景：网格 + 呼吸光晕 + 扫描线 ─────────────────────────── */
html, body {
  background: var(--v3-bg-0) !important;
  color: var(--v3-text) !important;
}
body::before {
  content: '';
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(139,92,246,.045) 1px, transparent 1px),
    linear-gradient(90deg, rgba(139,92,246,.045) 1px, transparent 1px);
  background-size: 44px 44px;
  mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 78%);
  -webkit-mask-image: radial-gradient(ellipse 90% 70% at 50% 0%, #000 30%, transparent 78%);
}
body::after {
  content: '';
  position: fixed; inset: -40%; z-index: 0; pointer-events: none;
  background:
    radial-gradient(circle at 18% 12%, rgba(168,85,247,.16), transparent 42%),
    radial-gradient(circle at 82% 8%, rgba(34,211,238,.12), transparent 40%),
    radial-gradient(circle at 50% 92%, rgba(236,72,153,.08), transparent 46%);
  animation: v3-breathe 16s ease-in-out infinite alternate;
}
@keyframes v3-breathe {
  0%   { transform: scale(1) rotate(0deg); opacity: .85; }
  100% { transform: scale(1.14) rotate(4deg); opacity: 1; }
}

/* 扫描线 */
#root::before {
  content: '';
  position: fixed; left: 0; right: 0; top: 0; height: 2px; z-index: 9998;
  pointer-events: none;
  background: linear-gradient(90deg, transparent, rgba(34,211,238,.75), transparent);
  animation: v3-scan 7s linear infinite;
  opacity: .55;
}
@keyframes v3-scan {
  0%   { transform: translateY(0); opacity: 0; }
  8%   { opacity: .6; }
  92%  { opacity: .6; }
  100% { transform: translateY(100vh); opacity: 0; }
}

#root { position: relative; z-index: 1; }

/* ── 侧边栏：极窄图标栏，hover 展开 ─────────────────────────── */
div[class*="group/sidebar-wrapper"] > div[class*="text-sidebar-foreground"] {
  transition: width .28s cubic-bezier(.34,1.4,.64,1) !important;
}
div[class*="group/sidebar-wrapper"] > div[class*="text-sidebar-foreground"]:hover {
  width: 236px !important;
}
div[class*="group/sidebar-wrapper"] > div[class*="text-sidebar-foreground"]:hover ~ div[class*="fixed inset-y-0"] {
  width: 236px !important;
}
/* 侧边栏本体 */
div[class*="fixed inset-y-0"][class*="md:flex"] > div:first-child,
div[class*="bg-sidebar"][class*="flex h-full w-full flex-col"] {
  background: linear-gradient(175deg, rgba(13,8,32,.97) 0%, rgba(4,2,12,.99) 100%) !important;
  border-right: 1px solid var(--v3-line) !important;
  backdrop-filter: blur(24px) saturate(140%);
}
/* 侧边栏顶部 Logo 区 */
div[class*="bg-sidebar"] > div:first-child {
  border-bottom: 1px solid var(--v3-line) !important;
  padding: 14px 10px !important;
  overflow: hidden;
}
/* 菜单项：图标居中，文字 hover 才出现 */
div[class*="bg-sidebar"] a,
div[class*="bg-sidebar"] button {
  border-radius: 12px !important;
  transition: all .2s ease !important;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
}
div[class*="bg-sidebar"] a:hover,
div[class*="bg-sidebar"] button:hover {
  background: linear-gradient(95deg, rgba(168,85,247,.16), rgba(34,211,238,.06)) !important;
  box-shadow: inset 0 0 0 1px rgba(168,85,247,.28), 0 0 16px -6px rgba(168,85,247,.55) !important;
}
div[class*="bg-sidebar"] a:hover::before,
div[class*="bg-sidebar"] button:hover::before {
  content: '';
  position: absolute; left: 0; top: 18%; bottom: 18%; width: 2px;
  background: linear-gradient(180deg, var(--v3-violet), var(--v3-cyan));
  border-radius: 2px;
  box-shadow: 0 0 8px var(--v3-violet);
}
/* 分组标题 */
div[class*="bg-sidebar"] div[class*="text-xs"],
div[class*="bg-sidebar"] [class*="uppercase"] {
  color: #4b3d6b !important;
  letter-spacing: .14em !important;
  font-size: 10px !important;
  font-weight: 700 !important;
}

/* ── 顶栏：悬浮玻璃胶囊 ─────────────────────────────────────── */
main > header {
  position: sticky !important;
  top: 10px !important;
  z-index: 60 !important;
  margin: 10px 14px 0 !important;
  padding: 0 16px !important;
  height: 54px !important;
  border-radius: 16px !important;
  background: linear-gradient(95deg, rgba(16,10,38,.86), rgba(6,4,18,.9)) !important;
  border: 1px solid var(--v3-line) !important;
  backdrop-filter: blur(28px) saturate(160%);
  box-shadow:
    0 1px 0 rgba(255,255,255,.05) inset,
    0 18px 42px -22px rgba(0,0,0,.95),
    0 0 0 1px rgba(168,85,247,.06) !important;
}
/* 面包屑 */
#breadcrumb { font-weight: 600; letter-spacing: .02em; }
#breadcrumb::before {
  content: '';
  display: inline-block; width: 6px; height: 6px; border-radius: 50%;
  background: var(--v3-cyan); margin-right: 10px; vertical-align: middle;
  box-shadow: 0 0 10px var(--v3-cyan), 0 0 20px rgba(34,211,238,.5);
  animation: v3-pulse 2.2s ease-in-out infinite;
}
@keyframes v3-pulse {
  0%,100% { opacity: 1; transform: scale(1); }
  50%     { opacity: .45; transform: scale(.78); }
}

/* ── 内容区 ─────────────────────────────────────────────────── */
main > div[class*="flex-1"][class*="px-4"] {
  padding: 18px 22px 26px !important;
}

/* ── 统计卡片 → 环形仪表盘改造 ─────────────────────────────── */
/* 找出 6 个统计卡的容器，改成 3×2 非对称网格 */
main div[class*="grid"] {
  gap: 14px !important;
}

/* 每张统计卡：玻璃 + 顶部渐变光条 */
main div[class*="grid"] > div,
main div[class*="grid"] > a {
  position: relative !important;
  border-radius: 18px !important;
  background: linear-gradient(158deg, rgba(18,11,40,.9), rgba(6,4,16,.96)) !important;
  border: 1px solid var(--v3-line) !important;
  overflow: hidden !important;
  transition: transform .22s cubic-bezier(.34,1.4,.64,1), box-shadow .22s, border-color .22s !important;
  backdrop-filter: blur(14px);
}
main div[class*="grid"] > div::before,
main div[class*="grid"] > a::before {
  content: '';
  position: absolute; top: 0; left: 12%; right: 12%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(168,85,247,.7), rgba(34,211,238,.7), transparent);
  opacity: .6;
}
main div[class*="grid"] > div:hover,
main div[class*="grid"] > a:hover {
  transform: translateY(-3px) !important;
  border-color: var(--v3-line-hot) !important;
  box-shadow:
    0 22px 48px -26px rgba(168,85,247,.7),
    0 0 0 1px rgba(168,85,247,.16),
    inset 0 1px 0 rgba(255,255,255,.05) !important;
}
/* 数字：等宽 + 发光 */
main div[class*="grid"] [class*="text-3xl"],
main div[class*="grid"] [class*="text-4xl"],
main div[class*="grid"] [class*="text-5xl"] {
  font-family: 'SF Mono', 'JetBrains Mono', ui-monospace, monospace !important;
  font-weight: 700 !important;
  letter-spacing: -.03em !important;
  background: linear-gradient(135deg, #fff 8%, var(--v3-cyan) 52%, var(--v3-violet) 100%);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  filter: drop-shadow(0 0 18px rgba(34,211,238,.4));
}

/* 环形进度（在线率那张卡） */
.v3-ring {
  position: absolute; right: 14px; bottom: 14px;
  width: 54px; height: 54px; border-radius: 50%;
  background: conic-gradient(var(--v3-cyan) var(--p, 0%), rgba(139,92,246,.1) 0);
  display: grid; place-items: center;
  filter: drop-shadow(0 0 12px rgba(34,211,238,.55));
}
.v3-ring::before {
  content: ''; width: 40px; height: 40px; border-radius: 50%;
  background: rgba(6,4,16,.94);
}
.v3-ring span {
  position: absolute; font-size: 10px; font-weight: 700; color: var(--v3-cyan);
  font-family: ui-monospace, monospace;
}

/* ── 大卡片（公告栏 / 设备分布）─────────────────────────────── */
main div[class*="rounded-"]:not([class*="grid"] > *) {
  border-color: var(--v3-line);
}
main div[class*="card"],
main div[class*="Card"] {
  background: linear-gradient(158deg, rgba(16,10,36,.86), rgba(5,3,14,.94)) !important;
  border: 1px solid var(--v3-line) !important;
  border-radius: 18px !important;
  backdrop-filter: blur(12px);
}

/* 进度条（设备分布）*/
main div[class*="h-2"][class*="rounded"],
main div[class*="h-2.5"][class*="rounded"] {
  background: rgba(139,92,246,.1) !important;
  border-radius: 99px !important;
  overflow: hidden;
}
main div[class*="h-2"][class*="rounded"] > div,
main div[class*="h-2.5"][class*="rounded"] > div {
  background: linear-gradient(90deg, var(--v3-pink), var(--v3-amber)) !important;
  box-shadow: 0 0 14px rgba(236,72,153,.6);
  border-radius: 99px !important;
}

/* ── 滚动条 ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb {
  background: linear-gradient(180deg, rgba(168,85,247,.5), rgba(34,211,238,.4));
  border-radius: 99px;
}
::-webkit-scrollbar-thumb:hover {
  background: linear-gradient(180deg, var(--v3-violet), var(--v3-cyan));
}

/* ── 按钮：霓虹描边 ─────────────────────────────────────────── */
main button[class*="inline-flex"] {
  border-radius: 11px !important;
  transition: all .18s ease !important;
}
main button[class*="inline-flex"]:hover {
  background: rgba(168,85,247,.12) !important;
  box-shadow: 0 0 0 1px rgba(168,85,247,.3), 0 0 20px -6px rgba(168,85,247,.6) !important;
}

/* ── 状态条（系统运行中那行）───────────────────────────────── */
main div[class*="rounded-"]:has(> div[class*="bg-green"]),
main div:has(> span[class*="bg-green-"]) {
  background: linear-gradient(92deg, rgba(34,197,94,.07), transparent 60%) !important;
  border: 1px solid rgba(34,197,94,.16) !important;
  border-radius: 12px !important;
}

/* ── 表格/列表 ──────────────────────────────────────────────── */
main table { border-collapse: separate !important; border-spacing: 0 6px !important; }
main table thead th {
  color: #5b6b8c !important;
  font-size: 11px !important;
  font-weight: 700 !important;
  letter-spacing: .1em !important;
  text-transform: uppercase !important;
  border: none !important;
  padding: 8px 12px !important;
}
main table tbody tr {
  background: rgba(14,9,32,.6) !important;
  transition: all .16s ease !important;
}
main table tbody tr:hover {
  background: rgba(168,85,247,.1) !important;
  box-shadow: 0 0 0 1px rgba(168,85,247,.24);
}
main table tbody td {
  border-top: 1px solid rgba(139,92,246,.08) !important;
  border-bottom: 1px solid rgba(139,92,246,.08) !important;
  padding: 12px !important;
}
main table tbody tr td:first-child {
  border-left: 1px solid rgba(139,92,246,.08) !important;
  border-radius: 12px 0 0 12px !important;
}
main table tbody tr td:last-child {
  border-right: 1px solid rgba(139,92,246,.08) !important;
  border-radius: 0 12px 12px 0 !important;
}

/* ── 右下角浮动按钮 ─────────────────────────────────────────── */
body > div[class*="fixed"][class*="bottom"] button,
body > button[class*="fixed"] {
  border-radius: 16px !important;
  background: linear-gradient(135deg, var(--v3-violet), var(--v3-cyan)) !important;
  box-shadow: 0 12px 32px -10px rgba(168,85,247,.85), 0 0 0 1px rgba(255,255,255,.12) inset !important;
}

/* ── 输入框 / 下拉 ──────────────────────────────────────────── */
main input, main select, main textarea {
  background: rgba(10,6,26,.8) !important;
  border: 1px solid var(--v3-line) !important;
  border-radius: 10px !important;
  transition: all .18s ease !important;
}
main input:focus, main select:focus, main textarea:focus {
  border-color: rgba(34,211,238,.5) !important;
  box-shadow: 0 0 0 3px rgba(34,211,238,.1), 0 0 22px -8px rgba(34,211,238,.6) !important;
  outline: none !important;
}

/* ── 弹窗 ───────────────────────────────────────────────────── */
[role="dialog"] {
  border-radius: 20px !important;
  background: linear-gradient(165deg, rgba(18,11,40,.98), rgba(5,3,14,.99)) !important;
  border: 1px solid rgba(168,85,247,.3) !important;
  box-shadow: 0 40px 90px -30px rgba(0,0,0,.95), 0 0 0 1px rgba(255,255,255,.05) inset !important;
  backdrop-filter: blur(30px);
}
[role="dialog"]::before {
  content: '';
  position: absolute; top: 0; left: 8%; right: 8%; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(168,85,247,.85), rgba(34,211,238,.85), transparent);
}

/* ── 数据流动画（新加的元素）────────────────────────────────── */
.v3-stream {
  position: relative; overflow: hidden;
  border-radius: 18px;
  background: linear-gradient(160deg, rgba(16,10,36,.86), rgba(5,3,14,.94));
  border: 1px solid var(--v3-line);
  padding: 16px 18px;
  margin-top: 14px;
}
.v3-stream-title {
  font-size: 11px; letter-spacing: .12em; text-transform: uppercase;
  color: #6b7ea8; font-weight: 700; margin-bottom: 10px;
  display: flex; align-items: center; gap: 8px;
}
.v3-stream-title::before {
  content: ''; width: 5px; height: 5px; border-radius: 50%;
  background: var(--v3-lime); box-shadow: 0 0 10px var(--v3-lime);
  animation: v3-pulse 1.6s infinite;
}
.v3-stream-row {
  display: flex; align-items: center; gap: 10px;
  padding: 7px 0; font-size: 12px;
  border-bottom: 1px dashed rgba(139,92,246,.1);
  font-family: ui-monospace, monospace;
}
.v3-stream-row:last-child { border-bottom: none; }
.v3-stream-row .t { color: #4a5b7a; min-width: 62px; }
.v3-stream-row .d { color: var(--v3-cyan); flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.v3-stream-row .s { color: var(--v3-lime); font-weight: 700; }

/* ── 响应式 ─────────────────────────────────────────────────── */
@media (max-width: 900px) {
  :root { --sidebar-width: 0px !important; }
  main > header { margin: 8px 8px 0 !important; }
  main > div[class*="flex-1"][class*="px-4"] { padding: 12px !important; }
}

/* ═══ v3.1 修正 ═══ */
/* ① 侧边栏真正压窄（tailwind 变量 + 直接宽度双保险） */
html body,
html body div[class*="group/sidebar-wrapper"] {
  --sidebar-width: 76px !important;
}
html body div[class*="group/sidebar-wrapper"] > div[class*="text-sidebar-foreground"],
html body div[class*="group/sidebar-wrapper"] > div[class*="text-sidebar-foreground"] > div,
html body div[class*="fixed inset-y-0"][class*="md:flex"],
html body div[class*="fixed inset-y-0"][class*="md:flex"] > div {
  width: 76px !important;
  max-width: 76px !important;
  min-width: 76px !important;
  transition: width .26s cubic-bezier(.34,1.4,.64,1), max-width .26s !important;
}
/* hover 展开 */
html body div[class*="group/sidebar-wrapper"] > div[class*="text-sidebar-foreground"]:hover,
html body div[class*="group/sidebar-wrapper"] > div[class*="text-sidebar-foreground"]:hover > div:first-child,
html body div[class*="fixed inset-y-0"][class*="md:flex"]:hover,
html body div[class*="fixed inset-y-0"][class*="md:flex"]:hover > div {
  width: 236px !important;
  max-width: 236px !important;
  min-width: 236px !important;
}
/* 主内容区跟着左移 */
html body main {
  margin-left: 76px !important;
  transition: margin-left .26s !important;
}

/* ② 侧边栏文字：默认隐藏，hover 显示 */
html body div[class*="bg-sidebar"] a span,
html body div[class*="bg-sidebar"] button span,
html body div[class*="bg-sidebar"] div[class*="truncate"] {
  opacity: 0;
  transition: opacity .18s ease .06s;
}
html body div[class*="bg-sidebar"]:hover a span,
html body div[class*="bg-sidebar"]:hover button span,
html body div[class*="bg-sidebar"]:hover div[class*="truncate"] {
  opacity: 1;
}
/* 分组标题隐藏 */
html body div[class*="bg-sidebar"] div[class*="text-xs"] {
  opacity: 0;
  height: 6px;
}
html body div[class*="bg-sidebar"]:hover div[class*="text-xs"] {
  opacity: 1;
  height: auto;
}

/* ③ 公告栏 / 设备分布：恢复高度 */
html body main div[class*="grid"] ~ div[class*="grid"] {
  min-height: 220px !important;
}
html body main div[class*="grid"] + div,
html body main div[class*="grid"] ~ div[class*="rounded"] {
  min-height: 200px !important;
}

/* ④ 浮动构建按钮：移到右下但不挡数据流 */
html body > div[class*="fixed"][class*="bottom-"],
html body > button[class*="fixed"][class*="bottom-"] {
  bottom: 22px !important;
  right: 22px !important;
  transform: scale(.9) !important;
  z-index: 40 !important;
}

/* ⑤ 数据流面板：底部留出空间 */
#v3-stream { margin-bottom: 88px !important; }

/* ═══ v3.2 侧边栏文字彻底处理（防竖排）═══ */
html body div[class*="bg-sidebar"] a,
html body div[class*="bg-sidebar"] button,
html body div[class*="bg-sidebar"] a span,
html body div[class*="bg-sidebar"] button span,
html body div[class*="bg-sidebar"] div[class*="truncate"],
html body div[class*="bg-sidebar"] [class*="text-xs"] {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: clip !important;
  word-break: keep-all !important;
  writing-mode: horizontal-tb !important;
}

/* 未 hover：文字完全隐藏，只留图标 */
html body div[class*="bg-sidebar"]:not(:hover) a span,
html body div[class*="bg-sidebar"]:not(:hover) button span,
html body div[class*="bg-sidebar"]:not(:hover) div[class*="truncate"],
html body div[class*="bg-sidebar"]:not(:hover) [class*="text-xs"] {
  display: none !important;
}
/* 未 hover：菜单项居中图标 */
html body div[class*="bg-sidebar"]:not(:hover) a,
html body div[class*="bg-sidebar"]:not(:hover) button {
  justify-content: center !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
}
/* hover：恢复正常 */
html body div[class*="bg-sidebar"]:hover a,
html body div[class*="bg-sidebar"]:hover button {
  justify-content: flex-start !important;
  padding-left: 14px !important;
}
/* 分组标题未 hover 时缩成细线 */
html body div[class*="bg-sidebar"]:not(:hover) [class*="text-xs"] {
  height: 0 !important;
  margin: 4px 0 !important;
  padding: 0 !important;
}

/* 主内容区：修正 margin（sidebar 是 fixed，不需要额外 margin） */
html body main {
  margin-left: 0 !important;
}
html body main {
  padding-left: 76px !important;
}
html body main > header {
  margin-left: 14px !important;
}

/* ═══ v3.3 侧边栏文字精确定位（shadcn data-sidebar 属性）═══ */
html body div[class*="bg-sidebar"] div,
html body div[class*="bg-sidebar"] span,
html body div[class*="bg-sidebar"] p {
  white-space: nowrap !important;
  writing-mode: horizontal-tb !important;
  word-break: keep-all !important;
}

/* 未 hover：菜单按钮里的文字容器整个隐藏 */
html body div[class*="bg-sidebar"]:not(:hover) [data-sidebar="menu-button"] > div,
html body div[class*="bg-sidebar"]:not(:hover) [data-sidebar="menu-button"] > span {
  display: none !important;
}
/* 未 hover：按钮居中 */
html body div[class*="bg-sidebar"]:not(:hover) [data-sidebar="menu-button"] {
  justify-content: center !important;
  padding-left: 0 !important;
  padding-right: 0 !important;
  gap: 0 !important;
}
/* 未 hover：分组标题压扁 */
html body div[class*="bg-sidebar"]:not(:hover) [data-sidebar="group-label"],
html body div[class*="bg-sidebar"]:not(:hover) [data-sidebar="menu-label"] {
  display: none !important;
}
/* hover：恢复 */
html body div[class*="bg-sidebar"]:hover [data-sidebar="menu-button"] {
  justify-content: flex-start !important;
  padding-left: 12px !important;
  gap: 10px !important;
}
html body div[class*="bg-sidebar"]:hover [data-sidebar="menu-button"] > div {
  display: block !important;
}

/* Logo 区未 hover 时只留图标 */
html body div[class*="bg-sidebar"]:not(:hover) [data-sidebar="header"] {
  padding: 12px 8px !important;
}

/* ═══ v3.5 数据流面板定位修正 ═══ */
#v3-stream {
  margin-top: 16px !important;
  margin-bottom: 20px !important;
  max-height: 210px;
  overflow: hidden;
}
#v3-stream-list { max-height: 168px; overflow: hidden; }
.v3-stream-row { padding: 5px 0 !important; font-size: 11.5px !important; }
