/* ==========================================================================
   NEXUS 3D SERVER COMMAND DECK — CYBERNETIC DESIGN SYSTEM
   ========================================================================== */

:root {
  --bg-primary: #040711;
  --bg-surface: rgba(10, 16, 32, 0.75);
  --bg-surface-elevated: rgba(16, 26, 52, 0.85);
  --border-subtle: rgba(0, 242, 254, 0.15);
  --border-glow: rgba(0, 242, 254, 0.4);

  --neon-cyan: #00f2fe;
  --neon-emerald: #10b981;
  --neon-amber: #f59e0b;
  --neon-rose: #ec4899;
  --neon-purple: #8b5cf6;
  --neon-crimson: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #475569;

  --font-display: 'Space Grotesk', system-ui, -apple-system, sans-serif;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --ease-spring: cubic-bezier(0.175, 0.885, 0.32, 1.275);
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: var(--font-body);
  overflow-x: hidden;
  min-height: 100vh;
  position: relative;
  selection-background-color: var(--neon-cyan);
  selection-color: #000;
}

/* Background Cyber Grid Accent */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background-image: 
    radial-gradient(circle at 50% 0%, rgba(0, 242, 254, 0.08) 0%, transparent 60%),
    radial-gradient(circle at 100% 100%, rgba(139, 92, 246, 0.06) 0%, transparent 50%);
  pointer-events: none;
  z-index: 0;
}

/* 3D Canvas Viewport */
#canvas-3d-container {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  z-index: 1;
  outline: none;
}

/* Main HUD Overlay */
.hud-overlay {
  position: relative;
  z-index: 10;
  pointer-events: none; /* Let clicks pass to 3D canvas by default */
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  padding: 1.5rem 2rem;
  max-width: 1600px;
  margin: 0 auto;
}

.hud-interactive {
  pointer-events: auto; /* Enable clicks on interactive HUD elements */
}

/* ==========================================================================
   HEADER / TOP BAR
   ========================================================================== */
.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1.5rem;
  padding: 1rem 1.75rem;
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(255, 255, 255, 0.05);
}

.brand-wrapper {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.brand-glyph {
  position: relative;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(0, 242, 254, 0.2), rgba(139, 92, 246, 0.2));
  border: 1px solid var(--neon-cyan);
  border-radius: 10px;
  color: var(--neon-cyan);
}

.brand-glyph-pulse {
  position: absolute;
  inset: -3px;
  border: 1px solid var(--neon-cyan);
  border-radius: 12px;
  opacity: 0.4;
  animation: glyphPulse 2.5s infinite;
}

@keyframes glyphPulse {
  0%, 100% { transform: scale(1); opacity: 0.4; }
  50% { transform: scale(1.1); opacity: 0; }
}

.brand-title {
  font-family: var(--font-display);
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  background: linear-gradient(135deg, #ffffff 40%, var(--neon-cyan) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-subtitle {
  font-size: 0.75rem;
  color: var(--text-muted);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

/* Cluster Metrics Counters */
.cluster-metrics {
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.metric-pill {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.45rem 0.9rem;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.metric-pill.online {
  color: var(--neon-emerald);
  border-color: rgba(16, 185, 129, 0.3);
  background: rgba(16, 185, 129, 0.08);
}

.metric-pill.starting {
  color: var(--neon-amber);
  border-color: rgba(245, 158, 11, 0.3);
  background: rgba(245, 158, 11, 0.08);
}

.metric-pill.idle {
  color: var(--text-muted);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: currentColor;
}

.status-dot.pulsing {
  animation: dotBlink 1.2s infinite;
}

@keyframes dotBlink {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.4; transform: scale(0.8); }
}

/* Mode Select & Sound Toggle */
.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mode-selector {
  display: flex;
  background: rgba(0, 0, 0, 0.4);
  padding: 3px;
  border-radius: 8px;
  border: 1px solid var(--border-subtle);
}

.mode-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.2s;
}

.mode-btn.active {
  background: var(--neon-cyan);
  color: #040711;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(0, 242, 254, 0.4);
}

.icon-btn {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s var(--ease-spring);
}

.icon-btn:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  transform: translateY(-2px);
  box-shadow: 0 0 16px rgba(0, 242, 254, 0.3);
}

/* ==========================================================================
   HERO COMMAND PANEL (IGNITE ALL BUTTON & PROGRESS)
   ========================================================================== */
.hero-command-panel {
  margin: 1.5rem auto 1rem;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.25rem;
  text-align: center;
}

/* Giant Cyber Button */
.ignite-btn {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  padding: 1.25rem 3.5rem;
  font-family: var(--font-display);
  font-size: 1.15rem;
  font-weight: 800;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #040711;
  background: linear-gradient(135deg, #00f2fe 0%, #4facfe 50%, #00f2fe 100%);
  background-size: 200% 200%;
  border: none;
  border-radius: 14px;
  cursor: pointer;
  box-shadow: 
    0 0 30px rgba(0, 242, 254, 0.4),
    inset 0 1px 0 rgba(255, 255, 255, 0.6);
  transition: all 0.3s var(--ease-smooth);
  animation: gradientShift 4s ease infinite;
}

@keyframes gradientShift {
  0% { background-position: 0% 50%; }
  50% { background-position: 100% 50%; }
  100% { background-position: 0% 50%; }
}

.ignite-btn:hover {
  transform: translateY(-3px) scale(1.02);
  box-shadow: 
    0 0 50px rgba(0, 242, 254, 0.7),
    0 10px 25px rgba(0, 0, 0, 0.4);
}

.ignite-btn:active {
  transform: translateY(1px) scale(0.98);
}

.ignite-btn.is-running {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  color: #ffffff;
  box-shadow: 0 0 40px rgba(245, 158, 11, 0.6);
}

.ignite-icon {
  font-size: 1.35rem;
  display: inline-block;
  animation: iconSpin 6s linear infinite;
}

@keyframes iconSpin {
  100% { transform: rotate(360deg); }
}

/* Secondary Quick Actions */
.quick-action-bar {
  display: flex;
  gap: 0.75rem;
  align-items: center;
}

.action-pill-btn {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  padding: 0.5rem 1rem;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s;
  backdrop-filter: blur(10px);
}

.action-pill-btn:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
  background: rgba(0, 242, 254, 0.08);
}

/* Global Progress Bar */
.global-progress-bar-wrap {
  width: 100%;
  max-width: 520px;
  background: rgba(0, 0, 0, 0.4);
  border: 1px solid var(--border-subtle);
  border-radius: 9999px;
  height: 10px;
  overflow: hidden;
  position: relative;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.6);
}

.global-progress-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, var(--neon-cyan), var(--neon-emerald));
  border-radius: 9999px;
  transition: width 0.4s var(--ease-smooth);
  box-shadow: 0 0 12px var(--neon-cyan);
}

/* ==========================================================================
   DYNAMIC SERVER CARDS GRID
   ========================================================================== */
.server-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(360px, 1fr));
  gap: 1.25rem;
  margin: 1rem 0;
  width: 100%;
}

.server-card {
  position: relative;
  background: var(--bg-surface);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid var(--border-subtle);
  border-radius: 16px;
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  gap: 1rem;
  transition: all 0.3s var(--ease-smooth);
  overflow: hidden;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

.server-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 3px;
  background: var(--card-color, var(--neon-cyan));
  opacity: 0.8;
}

.server-card:hover {
  transform: translateY(-4px);
  border-color: var(--card-color, var(--neon-cyan));
  box-shadow: 0 12px 30px rgba(0, 0, 0, 0.6), 0 0 25px var(--card-glow, rgba(0, 242, 254, 0.2));
}

.server-card.is-hovered-from-3d {
  border-color: var(--neon-cyan);
  transform: translateY(-6px) scale(1.02);
  box-shadow: 0 0 30px rgba(0, 242, 254, 0.5);
}

/* Card Header */
.card-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  gap: 0.75rem;
}

.card-title-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.card-title {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--text-main);
}

.card-category {
  font-size: 0.75rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

/* State Badge */
.state-badge {
  display: inline-flex;
  align-items: center;
  gap: 0.45rem;
  padding: 0.35rem 0.75rem;
  border-radius: 9999px;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.state-badge.idle {
  background: rgba(100, 116, 139, 0.15);
  color: #94a3b8;
  border: 1px solid rgba(100, 116, 139, 0.3);
}

.state-badge.starting {
  background: rgba(245, 158, 11, 0.15);
  color: var(--neon-amber);
  border: 1px solid rgba(245, 158, 11, 0.4);
}

.state-badge.online {
  background: rgba(16, 185, 129, 0.15);
  color: var(--neon-emerald);
  border: 1px solid rgba(16, 185, 129, 0.4);
  box-shadow: 0 0 10px rgba(16, 185, 129, 0.2);
}

.state-badge.error {
  background: rgba(239, 68, 68, 0.15);
  color: var(--neon-crimson);
  border: 1px solid rgba(239, 68, 68, 0.4);
}

/* Card Body & Metadata */
.card-desc {
  font-size: 0.82rem;
  color: var(--text-muted);
  line-height: 1.4;
}

.endpoint-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: rgba(0, 0, 0, 0.35);
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.05);
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  overflow: hidden;
}

.endpoint-url {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 82%;
}

.endpoint-copy-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  font-size: 0.75rem;
  transition: color 0.2s;
}

.endpoint-copy-btn:hover {
  color: var(--neon-cyan);
}

/* Card Metrics Grid */
.card-stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
  padding: 0.5rem 0;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-item {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.stat-label {
  color: var(--text-dim);
  font-size: 0.65rem;
  text-transform: uppercase;
}

.stat-val {
  color: var(--text-main);
  font-weight: 600;
}

.stat-val.fast {
  color: var(--neon-emerald);
}

.stat-val.slow {
  color: var(--neon-amber);
}

/* Card Response Snippet */
.response-snippet-box {
  background: rgba(0, 0, 0, 0.45);
  border-left: 2px solid var(--card-color, var(--neon-cyan));
  padding: 0.4rem 0.6rem;
  border-radius: 0 6px 6px 0;
  font-family: var(--font-mono);
  font-size: 0.7rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Card Footer Actions */
.card-actions {
  display: flex;
  gap: 0.6rem;
  margin-top: auto;
}

.card-btn {
  flex: 1;
  padding: 0.6rem;
  border-radius: 8px;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s var(--ease-spring);
}

.card-btn.primary {
  background: var(--card-color, var(--neon-cyan));
  color: #040711;
  border: none;
}

.card-btn.primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 0 16px var(--card-glow, rgba(0, 242, 254, 0.4));
}

.card-btn.secondary {
  background: rgba(255, 255, 255, 0.04);
  color: var(--text-main);
  border: 1px solid var(--border-subtle);
}

.card-btn.secondary:hover {
  border-color: var(--neon-cyan);
  color: var(--neon-cyan);
}

/* ==========================================================================
   LIVE EVENT LOG TERMINAL
   ========================================================================== */
.terminal-drawer {
  background: var(--bg-surface);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  border-radius: 14px;
  overflow: hidden;
  margin-top: 1rem;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
}

.terminal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 0.6rem 1rem;
  background: rgba(0, 0, 0, 0.4);
  border-bottom: 1px solid var(--border-subtle);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.terminal-title {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--neon-cyan);
  font-weight: 700;
}

.terminal-actions {
  display: flex;
  gap: 0.5rem;
}

.terminal-body {
  height: 120px;
  overflow-y: auto;
  padding: 0.75rem 1rem;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  background: rgba(4, 7, 17, 0.85);
}

.terminal-line {
  display: flex;
  gap: 0.75rem;
  line-height: 1.4;
}

.terminal-time {
  color: var(--text-dim);
  flex-shrink: 0;
}

.terminal-msg {
  color: var(--text-main);
}

.terminal-msg.success { color: var(--neon-emerald); }
.terminal-msg.warn { color: var(--neon-amber); }
.terminal-msg.error { color: var(--neon-crimson); }

/* Responsive Adjustments */
@media (max-width: 900px) {
  .hud-overlay {
    padding: 1rem;
  }
  .hud-header {
    flex-direction: column;
    align-items: stretch;
  }
  .cluster-metrics {
    justify-content: space-between;
  }
  .server-grid {
    grid-template-columns: 1fr;
  }
}
