/* HUD Dashboard 全息视觉系统
   风格: 深空黑 + 青色霓虹辉光 + 玻璃拟态面板 + 网格地板
   字体: Orbitron (标题) + JetBrains Mono (数据)
   主题色: --cyan #00e5ff, --magenta #ff00ea, --green #00ff88, --amber #ffae00
*/

:root {
  --bg-deep: #050811;
  --bg-mid: #0a0e1c;
  --bg-panel: rgba(13, 17, 31, 0.65);
  --cyan: #00e5ff;
  --cyan-dim: rgba(0, 229, 255, 0.4);
  --magenta: #ff00ea;
  --green: #00ff88;
  --amber: #ffae00;
  --red: #ff3355;
  --text: #d8e1f0;
  --text-dim: #6c7a96;
  --border: rgba(0, 229, 255, 0.25);
  --grid: rgba(0, 229, 255, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  width: 100%;
  height: 100vh;
  overflow: auto;   /* 2026-08-10 修复: auto 而非 hidden，让页面可纵向滚动 */
  background: var(--bg-deep);
  color: var(--text);
  font-family: 'JetBrains Mono', 'Menlo', monospace;
  font-size: 12px;
  line-height: 1.4;
  -webkit-font-smoothing: antialiased;
}

body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    linear-gradient(var(--grid) 1px, transparent 1px) 0 0 / 40px 40px,
    linear-gradient(90deg, var(--grid) 1px, transparent 1px) 0 0 / 40px 40px,
    radial-gradient(ellipse at center, rgba(0, 229, 255, 0.04) 0%, transparent 70%);
  z-index: 0;
  pointer-events: none;
}

#hud-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  opacity: 0.55;
  pointer-events: none;
}

/* ===== 顶部栏 ===== */
#hud-top {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 20px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border);
  box-shadow: 0 4px 20px rgba(0, 229, 255, 0.08);
  z-index: 10;
}

.hud-brand { display: flex; align-items: center; gap: 12px; }
.hud-logo {
  font-size: 24px;
  color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan);
  animation: pulse 2s ease-in-out infinite;
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}
.hud-title {
  font-family: 'Orbitron', sans-serif;
  font-weight: 700;
  font-size: 14px;
  letter-spacing: 2px;
  color: var(--cyan);
  text-shadow: 0 0 8px var(--cyan-dim);
}
.hud-version {
  font-size: 10px;
  color: var(--text-dim);
  padding: 2px 8px;
  border: 1px solid var(--border);
  border-radius: 3px;
}

.hud-stats { display: flex; gap: 16px; flex: 1; }
.hud-stat {
  font-size: 11px;
  color: var(--text);
  padding: 4px 10px;
  background: rgba(0, 229, 255, 0.05);
  border: 1px solid var(--border);
  border-radius: 3px;
  font-family: 'JetBrains Mono', monospace;
  min-width: 100px;
}

.hud-clock {
  font-family: 'Orbitron', sans-serif;
  font-size: 18px;
  color: var(--cyan);
  letter-spacing: 3px;
  text-shadow: 0 0 6px var(--cyan-dim);
}

.hud-actions { display: flex; gap: 8px; }
.hud-btn {
  width: 32px;
  height: 32px;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid var(--border);
  color: var(--cyan);
  font-size: 14px;
  cursor: pointer;
  border-radius: 3px;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.hud-btn:hover {
  background: rgba(0, 229, 255, 0.18);
  box-shadow: 0 0 12px var(--cyan-dim);
}

/* ===== 左侧侧栏 ===== */
#hud-side {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 28px;
  width: 200px;
  padding: 16px 12px;
  background: var(--bg-panel);
  backdrop-filter: blur(16px);
  border-right: 1px solid var(--border);
  z-index: 10;
  overflow-y: auto;
}

.side-block { margin-bottom: 20px; }
.side-block h3 {
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 2px;
  color: var(--cyan);
  margin-bottom: 8px;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--border);
}
.side-metric {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 11px;
  padding: 4px 0;
}
.side-metric .lbl { color: var(--text-dim); }
.side-metric .val {
  color: var(--cyan);
  font-weight: 600;
  text-shadow: 0 0 4px var(--cyan-dim);
}

/* ===== 主网格 ===== */
/* 2026-08-10 修复: position: absolute 让 grid 高度随内容自适应，不再被 fixed viewport 卡死而挤压面板。
   top: 56px 紧贴 header；left/right/overflow-y:auto 保证网格区域可滚动。
   header(56px) / side(200px) / bottom(28px) 保持 fixed 不动。 */
#hud-grid {
  position: absolute;
  top: 56px;
  left: 208px;
  right: 8px;
  bottom: 28px;
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  grid-auto-rows: minmax(240px, auto);
  gap: 8px;
  z-index: 5;
  overflow-y: auto;
  padding: 4px;
}

/* ===== 面板 ===== */
.panel {
  background: var(--bg-panel);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 10px 12px;
  display: flex;
  flex-direction: column;
  position: relative;
  /* 2026-08-10 tooltip fix: 改 visible 让 tooltip 逃出 panel 边界显示完整 */
  overflow: visible;
  box-shadow:
    0 0 20px rgba(0, 229, 255, 0.08),
    inset 0 0 40px rgba(0, 229, 255, 0.02);
  min-height: 0;
}
.panel::before {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 8px;
  height: 8px;
  border-top: 2px solid var(--cyan);
  border-left: 2px solid var(--cyan);
}
.panel::after {
  content: '';
  position: absolute;
  bottom: 0; right: 0;
  width: 8px;
  height: 8px;
  border-bottom: 2px solid var(--cyan);
  border-right: 2px solid var(--cyan);
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: 'Orbitron', sans-serif;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 1.5px;
  color: var(--cyan);
  text-shadow: 0 0 4px var(--cyan-dim);
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
  flex: 0 0 auto;
}

.panel-header .badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 9px;
  font-weight: normal;
  color: var(--text-dim);
  padding: 2px 6px;
  background: rgba(0, 229, 255, 0.08);
  border: 1px solid var(--border);
  border-radius: 3px;
  letter-spacing: 0.5px;
  text-shadow: none;
}

.panel-header .badge.live {
  color: var(--green);
  border-color: var(--green);
  animation: pulse 1.5s ease-in-out infinite;
}
.panel-header .badge.offline {
  color: var(--red);
  border-color: var(--red);
}

.panel-body {
  flex: 1;
  min-height: 0;
  position: relative;
  /* 2026-08-10 修复: auto 让 panel 内容超长时内部滚动, 不挤压相邻 panel */
  overflow-y: auto;
}

.panel-body > div,
.panel-body > canvas {
  width: 100% !important;
  height: 100% !important;
}

.panel-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-dim);
  font-size: 10px;
  letter-spacing: 1px;
}

/* ===== 底部状态条 ===== */
#hud-bottom {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 28px;
  background: var(--bg-panel);
  backdrop-filter: blur(12px);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 24px;
  padding: 0 16px;
  font-size: 10px;
  color: var(--text-dim);
  z-index: 10;
}
.bot-stat { color: var(--text); }
#bot-status { color: var(--green); }

/* ===== Services Matrix LED ===== */
.svc-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(72px, 1fr));
  gap: 4px;
  height: 100%;
  overflow-y: auto;
  align-content: start;
}
.svc-cell {
  font-size: 9px;
  padding: 4px 6px;
  border: 1px solid var(--border);
  border-radius: 2px;
  display: flex;
  flex-direction: column;
  align-items: center;
  background: rgba(0, 229, 255, 0.02);
  position: relative;
}
.svc-cell .led {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  margin-bottom: 2px;
  box-shadow: 0 0 6px currentColor;
}
.svc-cell.online .led { background: var(--green); color: var(--green); }
.svc-cell.offline .led { background: var(--red); color: var(--red); }
.svc-cell .svc-name { font-weight: 600; color: var(--text); }
.svc-cell .svc-port { font-size: 8px; color: var(--text-dim); }
.svc-cell .svc-ms { font-size: 8px; color: var(--cyan); }
.svc-cell.core { border-color: var(--cyan-dim); }
.svc-cell.tool { border-color: rgba(255, 174, 0, 0.3); }

/* ===== Pulse Gauges ===== */
.gauges {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 4px;
  height: 100%;
}
.gauge-cell { min-height: 0; }

/* ===== Activity Stream ===== */
.activity-stream {
  height: 100%;
  overflow-y: auto;
  font-size: 10px;
  line-height: 1.5;
}
.activity-row {
  display: grid;
  grid-template-columns: 60px 60px 1fr 50px;
  gap: 6px;
  padding: 2px 0;
  border-bottom: 1px dotted rgba(0, 229, 255, 0.08);
}
.activity-row .ts { color: var(--text-dim); }
.activity-row .ep { color: var(--cyan); }
.activity-row .status-2xx { color: var(--green); }
.activity-row .status-4xx { color: var(--amber); }
.activity-row .status-5xx { color: var(--red); }
.activity-row .ms { color: var(--text); text-align: right; }

/* ===== Responsive ===== */
@media (max-width: 1280px) {
  #hud-side { width: 160px; }
  #hud-grid { left: 168px; grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 900px) {
  #hud-side { display: none; }
  #hud-grid { left: 8px; grid-template-columns: 1fr; grid-template-rows: repeat(12, 220px); }
}
/* ===== 2026-08-10 global echarts tooltip dark theme ===== */
.echarts-tooltip,
.echarts-tooltip-wrap {
  background: rgba(13, 17, 31, 0.95) !important;
  border: 1px solid rgba(0, 229, 255, 0.45) !important;
  color: #d8e1f0 !important;
  box-shadow: 0 0 16px rgba(0, 229, 255, 0.3) !important;
  border-radius: 3px !important;
  font-family: "JetBrains Mono", monospace !important;
  font-size: 11px !important;
  padding: 6px 10px !important;
  backdrop-filter: blur(8px);
}
.echarts-tooltip .name,
.echarts-tooltip .series-name { color: #00e5ff !important; }
.echarts-tooltip .value,
.echarts-tooltip .num { color: #00ff88 !important; }

/* 强制所有 echarts 内部 SVG tooltip rect 背景深色 */
g[echarts-tooltip] rect[fill="rgba(50,50,50,0.7)"] { fill: rgba(13, 17, 31, 0.95) !important; }
g[echarts-tooltip] rect { fill: rgba(13, 17, 31, 0.95) !important; stroke: rgba(0,229,255,0.45) !important; }
