/* AhiXLight Autonomous AI Lab UI Theme Config */
:root {
  --color-bg: #05070D;
  --color-primary: #0066FF;
  --color-primary-glow: rgba(0, 102, 255, 0.25);
  --color-secondary: #6FA8FF;
  --color-secondary-glow: rgba(111, 168, 255, 0.15);
  --color-white: #F8FAFC;
  --color-accent: #FFD700;
  --color-border: rgba(255, 255, 255, 0.04);
  --color-border-focus: rgba(0, 102, 255, 0.3);
  --color-card-bg: rgba(6, 9, 19, 0.45);
  
  --font-mono: 'Fira Code', monospace;
  --font-sans: 'Outfit', sans-serif;
}

/* Reset and Layout */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

html, body {
  width: 100vw;
  height: 100vh;
  background-color: var(--color-bg);
  color: var(--color-white);
  font-family: var(--font-sans);
  overflow-x: hidden;
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

/* Scrollbar styles */
::-webkit-scrollbar {
  width: 4px;
}
::-webkit-scrollbar-track {
  background: transparent;
}
::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 2px;
}
::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* Three.js Canvas Container */
.canvas-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: auto;
  background-color: var(--color-bg);
}

/* Futuristic Scanline grid overlay */
.grid-overlay {
  position: fixed;
  inset: 0;
  z-index: 2;
  background-image: 
    linear-gradient(rgba(255, 255, 255, 0.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.015) 1px, transparent 1px);
  background-size: 40px 40px;
  background-position: center;
}

/* Absolute Main Interface Layer */
.lab-interface {
  position: relative;
  z-index: 10;
  display: flex;
  flex-direction: column;
  height: 100vh;
  width: 100vw;
  padding: 1.5rem;
  pointer-events: none; /* Let clicks pass to 3D canvas unless hovering UI panels */
}

/* Top Header Bar */
.hud-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 1rem;
  margin-bottom: 1.5rem;
  pointer-events: auto; /* Active header button/interactions */
  flex-shrink: 0;
}

.hud-logo-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.hud-logo-icon {
  width: 16px;
  height: 16px;
  background-color: var(--color-primary);
  border-radius: 2px;
  box-shadow: 0 0 15px var(--color-primary);
  position: relative;
}

.hud-logo-icon::after {
  content: '';
  position: absolute;
  inset: -4px;
  border: 1px solid var(--color-primary);
  border-radius: 4px;
  animation: logo-ping 2.5s infinite cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes logo-ping {
  0% { transform: scale(1); opacity: 1; }
  100% { transform: scale(2.2); opacity: 0; }
}

.hud-title {
  font-size: 1.25rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  color: var(--color-white);
}

.accent-sub {
  color: var(--color-primary);
  text-shadow: 0 0 8px var(--color-primary-glow);
}

.hud-subtitle {
  font-family: var(--font-mono);
  font-size: 9px;
  color: #64748B;
  margin-top: 0.15rem;
}

.hud-metrics-section {
  display: flex;
  gap: 2rem;
  font-size: 0.7rem;
}

.hud-metric {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hud-metric .label {
  color: #64748B;
}

.hud-metric .val {
  color: var(--color-white);
  font-weight: bold;
}

.text-blue {
  color: var(--color-secondary) !important;
}

.dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}

.dot.green-pulse {
  background-color: #00C853;
  box-shadow: 0 0 6px #00C853;
  animation: pulse-op 1.5s infinite ease-in-out;
}

@keyframes pulse-op {
  0%, 100% { opacity: 0.4; }
  50% { opacity: 1; }
}

/* Main Dashboard Panel Layout */
.hud-layout {
  display: flex;
  justify-content: space-between;
  flex-grow: 1;
  min-height: 0;
  gap: 2rem;
  margin-bottom: 1rem;
}

/* Glassmorphic Panel Base Styles */
.hud-panel {
  width: 360px;
  background-color: var(--color-card-bg);
  backdrop-filter: blur(16px) saturate(180%);
  -webkit-backdrop-filter: blur(16px) saturate(180%);
  border: 1px solid var(--color-border);
  border-radius: 6px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto; /* Active panel controls */
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
  transition: border-color 0.4s ease, box-shadow 0.4s ease;
}

.hud-panel:hover {
  border-color: var(--color-border-focus);
  box-shadow: 0 15px 45px rgba(0, 102, 255, 0.08);
}

.panel-header {
  background-color: rgba(11, 16, 33, 0.8);
  border-bottom: 1px solid var(--color-border);
  padding: 0.75rem 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.panel-icon {
  width: 8px;
  height: 8px;
  background-color: var(--color-primary);
  border-radius: 50%;
}

.panel-icon.icon-secondary {
  background-color: var(--color-accent);
}

.panel-title {
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 700;
  color: #94A3B8;
  letter-spacing: 0.05em;
}

.panel-content {
  padding: 1.25rem;
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  overflow-y: auto;
}

/* Left Panel: Project Assembly */
.project-info {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  border-bottom: 1px solid var(--color-border);
  padding-bottom: 0.75rem;
}

.proj-label {
  font-size: 9px;
  color: #64748B;
  letter-spacing: 0.05em;
}

.proj-value {
  font-size: 0.85rem;
  font-weight: bold;
  color: var(--color-white);
}

/* Progress bar */
.progress-container {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}

.progress-header {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #64748B;
}

.progress-track {
  width: 100%;
  height: 5px;
  background-color: rgba(6, 7, 14, 0.5);
  border: 1px solid var(--color-border);
  border-radius: 4px;
  overflow: hidden;
}

.progress-bar {
  height: 100%;
  background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
  transition: width 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  box-shadow: 0 0 8px rgba(0, 102, 255, 0.5);
}

/* Checklist items */
.task-checklist {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  font-size: 0.7rem;
}

.checklist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: #94A3B8;
  padding: 0.35rem 0.5rem;
  border-radius: 3px;
  background-color: rgba(255, 255, 255, 0.01);
  border-left: 2px solid transparent;
  transition: all 0.3s ease;
}

.checklist-item.active {
  color: var(--color-secondary);
  background-color: rgba(111, 168, 255, 0.03);
  border-left-color: var(--color-secondary);
}

.checklist-item.success {
  color: #00C853;
  border-left-color: #00C853;
}

.chk-status {
  font-weight: bold;
}

/* Center HUD Helper (Scroll & Mouse Parallax) */
.hud-center-helper {
  flex-grow: 1;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  padding-bottom: 2rem;
  pointer-events: none;
}

.scroll-helper {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.75rem;
  opacity: 0.5;
  animation: breathe 3s infinite ease-in-out;
}

@keyframes breathe {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 0.7; transform: translateY(-4px); }
}

.mouse-icon {
  width: 18px;
  height: 30px;
  border: 1.5px solid var(--color-white);
  border-radius: 12px;
  position: relative;
  display: block;
}

.mouse-icon .wheel {
  width: 3px;
  height: 6px;
  background-color: var(--color-white);
  border-radius: 2px;
  position: absolute;
  top: 6px;
  left: 50%;
  transform: translateX(-50%);
  animation: scroll-wheel 1.8s infinite ease-in-out;
}

@keyframes scroll-wheel {
  0% { top: 6px; opacity: 1; }
  100% { top: 16px; opacity: 0; }
}

.helper-text {
  font-size: 8px;
  letter-spacing: 0.08em;
  color: var(--color-white);
  text-align: center;
}

/* Right Panel: Load Distribution & Terminal */
.agent-distribution {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.dist-bar-item {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.dist-header {
  display: flex;
  justify-content: space-between;
  font-size: 9px;
  color: #94A3B8;
}

.dist-track {
  width: 100%;
  height: 4px;
  background-color: rgba(6, 7, 14, 0.5);
  border-radius: 2px;
  overflow: hidden;
}

.dist-fill {
  height: 100%;
  background-color: var(--color-primary);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.dist-bar-item:nth-child(even) .dist-fill {
  background-color: var(--color-accent);
}

/* Live Terminal Panel Overlay */
.terminal-hud {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--color-border);
  background-color: #03060E;
  border-radius: 4px;
  overflow: hidden;
  height: 220px;
}

.terminal-hud-header {
  background-color: rgba(11, 16, 33, 0.9);
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-size: 8px;
  letter-spacing: 0.05em;
}

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

.c-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
}
.c-dot.red { background-color: #EF4444; }
.c-dot.yellow { background-color: #F59E0B; }
.c-dot.green { background-color: #10B981; }

.terminal-hud-body {
  padding: 0.75rem;
  font-size: 10px;
  color: #64748B;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  flex-grow: 1;
}

.term-line {
  line-height: 1.4;
  white-space: pre-wrap;
}

.term-line.cmd { color: var(--color-secondary); }
.term-line.success { color: #00C853; }
.term-line.warn { color: var(--color-accent); }

/* Floating HTML Agent Tags projected onto Three.js Canvas coordinates */
.labels-container {
  position: fixed;
  inset: 0;
  z-index: 5;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
}

.agent-tag {
  position: absolute;
  transform: translate(-50%, -100%);
  background-color: rgba(6, 9, 19, 0.85);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid var(--color-border);
  border-radius: 3px;
  padding: 0.35rem 0.5rem;
  font-family: var(--font-mono);
  font-size: 8px;
  color: #A0AABF;
  width: 110px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
  transition: opacity 0.25s ease, border-color 0.25s ease;
  will-change: transform, opacity;
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
}

.agent-tag:hover {
  border-color: var(--color-primary);
  z-index: 100;
}

.tag-id {
  font-weight: bold;
  color: var(--color-white);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  padding-bottom: 0.1rem;
}

.tag-role {
  color: var(--color-secondary);
}

.tag-task {
  color: #64748B;
  font-style: italic;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Footer HUD */
.hud-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-top: 1px solid var(--color-border);
  padding-top: 0.75rem;
  margin-top: 1.5rem;
  font-size: 8px;
  color: #64748B;
  flex-shrink: 0;
  pointer-events: auto;
}

.footer-right {
  display: flex;
  gap: 1.5rem;
}

/* Responsive constraints */
@media (max-width: 1024px) {
  .hud-layout {
    flex-direction: column;
    overflow-y: auto;
    gap: 1.5rem;
    align-items: center;
  }
  .hud-panel {
    width: 100%;
    max-width: 500px;
    height: 320px;
    flex-shrink: 0;
  }
  .hud-center-helper {
    display: none;
  }
  .lab-interface {
    overflow-y: auto;
  }
}

/* Custom Cursor Hiding and KING AI Cursor */
body, html, #canvas-container, .lab-interface, a, button, .agent-tag, .hud-panel, .hud-header {
  cursor: none !important;
}

.king-ai-cursor {
  position: fixed;
  pointer-events: none;
  z-index: 10000;
  transform: translate(-50%, -50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  will-change: transform, left, top;
}

.cursor-glow {
  width: 12px;
  height: 12px;
  background-color: #00E5FF;
  border-radius: 50%;
  box-shadow: 0 0 12px #00E5FF, 0 0 24px #00E5FF;
  transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.king-ai-cursor.hovering .cursor-glow {
  transform: scale(1.6);
  background-color: #FF007F;
  box-shadow: 0 0 15px #FF007F, 0 0 30px #FF007F;
}

.cursor-label {
  margin-top: 6px;
  font-family: var(--font-mono), monospace;
  font-size: 8px;
  font-weight: 700;
  color: #00E5FF;
  background-color: rgba(5, 7, 13, 0.95);
  border: 1px solid rgba(0, 229, 255, 0.4);
  padding: 2px 6px;
  border-radius: 2px;
  letter-spacing: 0.1em;
  white-space: nowrap;
  text-shadow: 0 0 5px rgba(0, 229, 255, 0.6);
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.8);
  transition: color 0.2s ease, border-color 0.2s ease, text-shadow 0.2s ease;
}

.king-ai-cursor.hovering .cursor-label {
  color: #FF007F;
  border-color: rgba(255, 0, 127, 0.5);
  text-shadow: 0 0 5px rgba(255, 0, 127, 0.6);
}
