/* GNB Console — 暗色主题 Dashboard */

:root {
  --bg-primary: #0d1117;
  --bg-secondary: #161b22;
  --bg-tertiary: #21262d;
  --bg-hover: #30363d;
  --border: #30363d;
  --border-accent: #388bfd40;
  --text-primary: #e6edf3;
  --text-secondary: #8b949e;
  --text-muted: #484f58;
  --accent: #388bfd;
  --accent-glow: #388bfd30;
  --green: #3fb950;
  --green-bg: #3fb95020;
  --red: #f85149;
  --red-bg: #f8514920;
  --yellow: #d29922;
  --yellow-bg: #d2992220;
  --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: 'JetBrains Mono', 'Menlo', monospace;
  --radius: 8px;
  --radius-sm: 4px;
  --shadow: 0 2px 8px rgba(0,0,0,.3);
  --transition: 150ms ease;
}

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

html, body {
  height: 100%;
  font-family: var(--font-sans);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--bg-primary);
  -webkit-font-smoothing: antialiased;
}

/* ——— 布局 ——— */

#app { display: flex; flex-direction: column; height: 100vh; }

#header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 0 20px; height: 48px; min-height: 48px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.header-left { display: flex; align-items: center; gap: 12px; }

.logo {
  font-size: 16px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), #a371f7);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.version { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

.header-right { display: flex; align-items: center; gap: 16px; }

.meta-text { font-size: 12px; color: var(--text-secondary); font-family: var(--font-mono); }

#main {
  flex: 1; display: grid;
  grid-template-columns: 240px 1fr 320px;
  overflow: hidden;
}

/* ——— 面板通用 ——— */

.panel-header {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 16px; border-bottom: 1px solid var(--border);
}

.panel-header h2 { font-size: 13px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; color: var(--text-secondary); }

.badge {
  font-size: 11px; font-weight: 600; padding: 2px 8px;
  border-radius: 10px;
  background: var(--bg-tertiary); color: var(--text-secondary);
}

.badge.accent { background: var(--accent-glow); color: var(--accent); }

.status-badge {
  font-size: 11px; font-weight: 500; padding: 2px 10px;
  border-radius: 10px; display: inline-flex; align-items: center; gap: 4px;
}

.status-badge::before { content: ''; width: 6px; height: 6px; border-radius: 50%; }
.status-badge.online { background: var(--green-bg); color: var(--green); }
.status-badge.online::before { background: var(--green); box-shadow: 0 0 6px var(--green); }
.status-badge.offline { background: var(--red-bg); color: var(--red); }
.status-badge.offline::before { background: var(--red); }

/* ——— 节点列表 ——— */

#node-list-panel {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow: hidden;
}

#node-list {
  flex: 1; overflow-y: auto; list-style: none;
  padding: 8px;
}

.node-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; margin-bottom: 2px;
  border-radius: var(--radius-sm);
  cursor: pointer; transition: background var(--transition);
}

.node-item:hover { background: var(--bg-hover); }
.node-item.active { background: var(--accent-glow); border-left: 2px solid var(--accent); }

.node-dot {
  width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}

.node-dot.online { background: var(--green); box-shadow: 0 0 6px var(--green); }
.node-dot.offline { background: var(--red); }
.node-dot.unknown { background: var(--text-muted); }

.node-info { flex: 1; min-width: 0; }
.node-name { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.node-addr { font-size: 11px; color: var(--text-muted); font-family: var(--font-mono); }

/* ——— 节点详情 ——— */

#node-detail-panel {
  display: flex; flex-direction: column; overflow: hidden;
}

.detail-grid {
  flex: 1; overflow-y: auto; padding: 16px;
}

.detail-placeholder {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 100%; color: var(--text-muted);
}

.placeholder-icon { font-size: 48px; margin-bottom: 12px; opacity: .3; }

.stat-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 8px 12px; border-radius: var(--radius-sm);
  transition: background var(--transition);
}

.stat-row:hover { background: var(--bg-tertiary); }

.stat-label { font-size: 12px; color: var(--text-secondary); }

.stat-value { font-size: 13px; font-family: var(--font-mono); font-weight: 500; }

.stat-value.green { color: var(--green); }
.stat-value.red { color: var(--red); }
.stat-value.yellow { color: var(--yellow); }

.section-title {
  font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px;
  color: var(--text-muted); padding: 16px 12px 6px; border-top: 1px solid var(--border);
  margin-top: 8px;
}

.section-title:first-child { border-top: none; margin-top: 0; }

/* ——— 子节点表格 ——— */

.sub-node-table {
  width: 100%; border-collapse: collapse; margin-top: 8px;
}

.sub-node-table th {
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  text-align: left; padding: 6px 10px; border-bottom: 1px solid var(--border);
}

.sub-node-table td {
  font-size: 12px; font-family: var(--font-mono); padding: 6px 10px;
  border-bottom: 1px solid var(--border);
}

/* ——— AI 面板 ——— */

#ai-panel {
  background: var(--bg-secondary);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
}

#ai-messages {
  flex: 1; overflow-y: auto; padding: 12px;
  display: flex; flex-direction: column; gap: 8px;
}

.ai-msg {
  padding: 10px 12px; border-radius: var(--radius); font-size: 13px;
  line-height: 1.5; max-width: 95%; word-break: break-word;
}

.ai-msg.user {
  background: var(--accent-glow); color: var(--text-primary);
  align-self: flex-end; border-bottom-right-radius: 2px;
}

.ai-msg.assistant {
  background: var(--bg-tertiary); color: var(--text-primary);
  align-self: flex-start; border-bottom-left-radius: 2px;
}

.ai-msg pre {
  font-family: var(--font-mono); font-size: 12px;
  background: var(--bg-primary); padding: 8px; border-radius: var(--radius-sm);
  overflow-x: auto; margin-top: 6px;
}

.confirm-btn {
  margin-top: 8px; padding: 6px 16px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer; font-size: 12px; font-weight: 500;
  transition: opacity var(--transition);
}

.confirm-btn:hover { opacity: .85; }

#ai-input-area {
  display: flex; gap: 8px; padding: 12px;
  border-top: 1px solid var(--border);
}

#ai-input {
  flex: 1; padding: 8px 12px;
  background: var(--bg-tertiary); border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary); font-size: 13px; font-family: var(--font-sans);
  outline: none; transition: border-color var(--transition);
}

#ai-input:focus { border-color: var(--accent); }

#ai-send {
  padding: 8px 18px;
  background: var(--accent); color: #fff; border: none;
  border-radius: var(--radius-sm); cursor: pointer;
  font-size: 13px; font-weight: 600;
  transition: opacity var(--transition);
}

#ai-send:hover { opacity: .85; }

/* ——— 滚动条 ——— */

::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-muted); }

/* ——— 待审批 ——— */

.pending-item {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 12px; margin: 4px 8px;
  background: var(--yellow-bg); border-radius: var(--radius-sm);
  border-left: 2px solid var(--yellow);
}

.pending-info { display: flex; align-items: center; gap: 8px; }

.pending-actions { display: flex; gap: 6px; }

.btn-approve {
  padding: 4px 10px; font-size: 11px; font-weight: 600;
  background: var(--green-bg); color: var(--green); border: 1px solid var(--green);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: opacity var(--transition);
}
.btn-approve:hover { opacity: .8; }

.btn-reject {
  padding: 4px 10px; font-size: 11px; font-weight: 600;
  background: var(--red-bg); color: var(--red); border: 1px solid var(--red);
  border-radius: var(--radius-sm); cursor: pointer;
  transition: opacity var(--transition);
}
.btn-reject:hover { opacity: .8; }

#pending-list { max-height: 200px; overflow-y: auto; }

/* ——— 响应式 ——— */

@media (max-width: 1024px) {
  #main { grid-template-columns: 200px 1fr 280px; }
}

@media (max-width: 768px) {
  #main { grid-template-columns: 1fr; grid-template-rows: auto 1fr auto; }
  #node-list-panel { border-right: none; border-bottom: 1px solid var(--border); max-height: 200px; }
  #ai-panel { border-left: none; border-top: 1px solid var(--border); max-height: 300px; }
}
