/* ============================================================
   庆阳智慧算力调度系统 — 样式表
   暗色仪表盘主题 · 科技感 · 玻璃态效果
   ============================================================ */

/* ----- CSS 变量 ----- */
:root {
  --bg-deep: #060b18;
  --bg-primary: #0a0e1a;
  --bg-secondary: #111827;
  --bg-tertiary: #1a2236;
  --bg-hover: #1e2a42;
  --border-subtle: #1e3a5f;
  --border-medium: #2a4a7f;
  --text-primary: #e2e8f0;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --accent-cyan: #00d4ff;
  --accent-cyan-dim: rgba(0,212,255,0.15);
  --accent-green: #10b981;
  --accent-green-dim: rgba(16,185,129,0.15);
  --accent-amber: #f59e0b;
  --accent-amber-dim: rgba(245,158,11,0.15);
  --accent-red: #ef4444;
  --accent-red-dim: rgba(239,68,68,0.15);
  --accent-purple: #8b5cf6;
  --accent-purple-dim: rgba(139,92,246,0.15);
  --accent-blue: #3b82f6;
  --accent-blue-dim: rgba(59,130,246,0.15);

  --node-unvisited: #475569;
  --node-visited: #3b82f6;
  --node-current: #f59e0b;
  --node-path: #10b981;
  --edge-default: #334155;
  --edge-highlight: #00d4ff;
  --edge-path: #10b981;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.3);
  --shadow-glow: 0 0 20px rgba(0,212,255,0.15);
  --transition-fast: 0.2s ease;
  --transition-normal: 0.3s ease;

  --font-mono: 'JetBrains Mono', 'Fira Code', 'Consolas', 'Monaco', monospace;
  --font-sans: 'Microsoft YaHei', 'PingFang SC', 'Noto Sans SC', system-ui, -apple-system, sans-serif;
  --font-number: 'JetBrains Mono', 'Consolas', monospace;
}

/* light theme override prep */
.light-theme {
  --bg-deep: #f1f5f9;
  --bg-primary: #f8fafc;
  --bg-secondary: #ffffff;
  --bg-tertiary: #e2e8f0;
  --bg-hover: #cbd5e1;
  --border-subtle: #cbd5e1;
  --border-medium: #94a3b8;
  --text-primary: #1e293b;
  --text-secondary: #475569;
  --text-muted: #94a3b8;
  --shadow-card: 0 4px 24px rgba(0,0,0,0.08);
}

/* ----- 全局重置 ----- */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

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

/* ----- 粒子背景 ----- */
#particleBg {
  position: fixed;
  top: 0; left: 0;
  width: 100%; height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.5;
}

/* ----- 顶部标题栏 ----- */
#topBar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-subtle);
  backdrop-filter: blur(12px);
}

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

.logo-icon {
  font-size: 28px;
  animation: pulse-icon 2s ease-in-out infinite;
}

@keyframes pulse-icon {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.15); opacity: 0.8; }
}

.title-group h1 {
  font-size: 18px;
  font-weight: 700;
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-purple));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  line-height: 1.3;
}

.subtitle {
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 1px;
}

/* 导航标签 */
#tabNav {
  display: flex;
  gap: 4px;
}

.tab-btn {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-md);
  background: transparent;
  color: var(--text-secondary);
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-normal);
  white-space: nowrap;
}

.tab-btn:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.tab-btn.active {
  background: var(--accent-cyan-dim);
  border-color: var(--accent-cyan);
  color: var(--accent-cyan);
  box-shadow: var(--shadow-glow);
}

.tab-icon { font-size: 16px; }

/* 头部右侧 */
.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 200px;
  justify-content: flex-end;
}

.difficulty-selector {
  display: flex;
  align-items: center;
  gap: 6px;
}

.difficulty-selector label {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
}

.difficulty-selector select,
.panel-section select {
  padding: 6px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  cursor: pointer;
  outline: none;
}

.difficulty-selector select:focus,
.panel-section select:focus {
  border-color: var(--accent-cyan);
}

#themeToggle {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-subtle);
  border-radius: 50%;
  background: var(--bg-tertiary);
  font-size: 18px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

#themeToggle:hover {
  background: var(--bg-hover);
  border-color: var(--accent-cyan);
}

/* ----- 模块容器 ----- */
#moduleContainer {
  position: relative;
  z-index: 5;
  height: calc(100vh - 110px);
}

.module-panel {
  display: none;
  height: 100%;
}

.module-panel.active {
  display: block;
}

.module-layout {
  display: grid;
  grid-template-columns: 260px 1fr 300px;
  height: 100%;
  gap: 1px;
  background: var(--border-subtle);
}

/* ----- 控制面板 ----- */
.control-panel {
  background: var(--bg-secondary);
  padding: 16px 14px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.panel-section {
  background: var(--bg-tertiary);
  border-radius: var(--radius-md);
  padding: 12px;
  border: 1px solid var(--border-subtle);
}

.panel-section h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-cyan);
  margin-bottom: 10px;
}

.param-row {
  margin-bottom: 8px;
}

.param-row label {
  display: block;
  font-size: 12px;
  color: var(--text-secondary);
  margin-bottom: 4px;
}

.param-row input[type="range"] {
  width: 100%;
  height: 6px;
  -webkit-appearance: none;
  appearance: none;
  background: var(--border-subtle);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.param-row input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(0,212,255,0.4);
}

.param-row select {
  width: 100%;
}

.param-val {
  font-size: 13px;
  color: var(--text-primary);
  font-family: var(--font-number);
}

.radio-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.radio-label {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--text-secondary);
  cursor: pointer;
}

.radio-label input[type="radio"] {
  accent-color: var(--accent-cyan);
}

/* 图例 */
.legend-list {
  display: flex;
  flex-direction: column;
  gap: 5px;
}

.legend-item {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-secondary);
}

.legend-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
}

/* 指标卡片 */
.metric-card {
  background: var(--bg-hover);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  margin-bottom: 6px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.metric-card.highlight {
  border-left: 3px solid var(--accent-cyan);
}

.metric-card.success {
  border-left: 3px solid var(--accent-green);
}

.metric-label {
  font-size: 11px;
  color: var(--text-muted);
}

.metric-value {
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-number);
  color: var(--text-primary);
}

/* ----- 可视化面板 ----- */
.viz-panel {
  background: var(--bg-primary);
  position: relative;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.viz-panel canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.info-overlay {
  position: absolute;
  top: 12px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0,0,0,0.75);
  backdrop-filter: blur(8px);
  border: 1px solid var(--accent-cyan);
  border-radius: var(--radius-md);
  padding: 8px 16px;
  font-size: 13px;
  color: var(--accent-cyan);
  pointer-events: none;
  transition: opacity var(--transition-normal);
}

/* ----- 代码面板 ----- */
.code-panel {
  background: var(--bg-secondary);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

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

.code-header h3 {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent-cyan);
}

.copy-btn {
  padding: 4px 10px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  font-size: 12px;
  font-family: var(--font-sans);
  cursor: pointer;
  transition: all var(--transition-fast);
}

.copy-btn:hover {
  background: var(--bg-hover);
  color: var(--accent-cyan);
  border-color: var(--accent-cyan);
}

.code-panel pre {
  flex: 1;
  margin: 0;
  padding: 12px 14px;
  overflow: auto;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.65;
  color: var(--text-secondary);
  background: var(--bg-primary);
  white-space: pre-wrap;
  word-break: break-all;
}

.code-panel code {
  font-family: inherit;
}

.code-line {
  display: block;
  padding: 1px 6px;
  margin: 0 -6px;
  border-radius: 2px;
  transition: background var(--transition-fast);
}

.code-line.highlight {
  background: var(--accent-cyan-dim);
  color: var(--accent-cyan);
}

/* ----- 底部动画控制条 ----- */
#animBar {
  position: relative;
  z-index: 10;
  display: flex;
  align-items: center;
  gap: 16px;
  height: 50px;
  padding: 0 20px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-subtle);
}

.anim-controls {
  display: flex;
  gap: 4px;
}

.anim-controls button {
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  color: var(--text-primary);
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all var(--transition-fast);
}

.anim-controls button:hover {
  background: var(--bg-hover);
  border-color: var(--accent-cyan);
  box-shadow: var(--shadow-glow);
}

.anim-controls button:active {
  transform: scale(0.95);
}

.anim-speed {
  display: flex;
  align-items: center;
  gap: 8px;
}

.anim-speed label {
  font-size: 12px;
  color: var(--text-muted);
}

.anim-speed input[type="range"] {
  width: 80px;
  height: 4px;
  -webkit-appearance: none;
  background: var(--border-subtle);
  border-radius: 2px;
}

.anim-speed input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-cyan);
  cursor: pointer;
}

#speedLabel {
  font-size: 12px;
  font-family: var(--font-number);
  color: var(--text-secondary);
  min-width: 32px;
}

.anim-progress {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 10px;
}

.progress-bar-bg {
  flex: 1;
  height: 4px;
  background: var(--bg-tertiary);
  border-radius: 2px;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--accent-cyan), var(--accent-purple));
  border-radius: 2px;
  transition: width var(--transition-normal);
}

#progressText {
  font-size: 12px;
  font-family: var(--font-number);
  color: var(--text-muted);
  min-width: 60px;
  text-align: right;
}

.anim-info {
  min-width: 200px;
  max-width: 350px;
}

#animDescription {
  font-size: 12px;
  color: var(--text-secondary);
  line-height: 1.4;
}

/* ----- 响应式 ----- */
@media (max-width: 1400px) {
  .module-layout {
    grid-template-columns: 240px 1fr 280px;
  }
}

@media (max-width: 1100px) {
  .module-layout {
    grid-template-columns: 1fr;
    grid-template-rows: auto 1fr auto;
  }
  .control-panel {
    flex-direction: row;
    flex-wrap: wrap;
    overflow-x: auto;
    padding: 8px;
  }
  .panel-section {
    flex: 1;
    min-width: 160px;
  }
  .code-panel {
    max-height: 200px;
  }
  .header-left { min-width: auto; }
  .header-right { min-width: auto; }
  #tabNav { gap: 2px; }
  .tab-btn { padding: 6px 10px; font-size: 11px; }
}

/* ----- 滚动条美化 ----- */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--border-subtle);
  border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--border-medium);
}

/* ----- 复制成功提示动画 ----- */
@keyframes copy-flash {
  0% { background: var(--accent-green-dim); }
  100% { background: transparent; }
}

.copy-flash {
  animation: copy-flash 0.8s ease-out;
}

/* ----- Canvas 响应式 ----- */
canvas {
  display: block;
  max-width: 100%;
}
