/* ════════════════════════════════════════════════════════════════
   KRISH — JARVIS HUD THEME
   Cyan / navy holographic interface. No green.
   ════════════════════════════════════════════════════════════════ */

:root {
  --bg-primary:   #0a0e27;
  --bg-secondary: #0f1535;
  --bg-panel:     rgba(10, 14, 39, 0.92);
  --bg-glass:     rgba(15, 21, 53, 0.85);

  --text-primary:   #00d9ff;
  --text-secondary: #b0c4ff;
  --text-dim:       #5a7a9a;

  --accent-glow: #00ffff;
  --glow-color:  #0099ff;
  --grid-line:   rgba(0, 217, 255, 0.08);

  --red-accent: #ff3333;
  --red-glow:   rgba(255, 51, 51, 0.5);

  --font-display: 'Orbitron', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;

  --glow-sm: 0 0 5px rgba(0, 217, 255, 0.4), 0 0 15px rgba(0, 217, 255, 0.2);
  --glow-md: 0 0 5px rgba(0, 217, 255, 0.4), 0 0 15px rgba(0, 217, 255, 0.3),
            0 0 30px rgba(0, 217, 255, 0.15), inset 0 0 10px rgba(0, 217, 255, 0.08);
  --glow-lg: 0 0 10px rgba(0, 217, 255, 0.5), 0 0 30px rgba(0, 217, 255, 0.35),
            0 0 60px rgba(0, 217, 255, 0.2), inset 0 0 20px rgba(0, 217, 255, 0.1);
}

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

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

body {
  background:
    radial-gradient(ellipse at 50% 40%, rgba(0, 153, 255, 0.06), transparent 60%),
    radial-gradient(ellipse at 50% 100%, rgba(0, 217, 255, 0.04), transparent 50%),
    var(--bg-primary);
}

/* ─── Background layers ─────────────────────────────────────────── */
#scanlines {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(
    0deg, transparent, transparent 2px, rgba(0, 217, 255, 0.025) 3px, transparent 4px
  );
  opacity: 0.5;
}
#matrix-rain, #arc-reactor {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
}
#arc-reactor { z-index: 1; }

/* ─── HUD Overlay ───────────────────────────────────────────────── */
#hud-overlay {
  position: relative; z-index: 10;
  display: flex; flex-direction: column;
  height: 100vh; width: 100vw;
}

/* ─── Top bar ───────────────────────────────────────────────────── */
#hud-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 24px;
  background: linear-gradient(180deg, rgba(10, 14, 39, 0.95), rgba(10, 14, 39, 0.6));
  border-bottom: 1px solid rgba(0, 217, 255, 0.25);
  box-shadow: 0 2px 20px rgba(0, 217, 255, 0.1);
}
.topbar-left { display: flex; align-items: baseline; gap: 8px; }
.logo-text {
  font-family: var(--font-display); font-weight: 900; font-size: 26px;
  letter-spacing: 4px; color: var(--text-primary);
  text-shadow: var(--glow-md);
  animation: flicker 6s infinite;
}
.logo-version {
  font-size: 11px; color: var(--text-dim); letter-spacing: 1px;
}
.topbar-center { display: flex; align-items: center; gap: 10px; }
.status-dot {
  width: 10px; height: 10px; border-radius: 50%;
  background: var(--text-dim); box-shadow: 0 0 6px var(--text-dim);
}
.status-dot.idle { background: #334; box-shadow: none; }
.status-dot.listening { background: var(--accent-glow); box-shadow: 0 0 10px var(--accent-glow); animation: pulse-glow 1s infinite; }
.status-dot.wake_listening { background: var(--accent-glow); box-shadow: 0 0 10px var(--accent-glow); animation: pulse-glow 1.5s infinite; }
.status-dot.thinking { background: var(--text-primary); box-shadow: 0 0 10px var(--text-primary); animation: pulse-glow 0.5s infinite; }
.status-dot.speaking { background: var(--glow-color); box-shadow: 0 0 10px var(--glow-color); animation: pulse-glow 0.8s infinite; }
.status-dot.generating_speech { background: var(--glow-color); box-shadow: 0 0 10px var(--glow-color); }
.status-dot.transcribing { background: var(--text-secondary); box-shadow: 0 0 8px var(--text-secondary); }
#status-label {
  font-family: var(--font-display); font-size: 13px; letter-spacing: 2px;
  color: var(--text-secondary);
}
.topbar-right { display: flex; align-items: center; gap: 10px; }
.model-badge {
  font-size: 11px; color: var(--text-dim);
  border: 1px solid rgba(0, 217, 255, 0.2); padding: 2px 8px;
  border-radius: 3px; letter-spacing: 1px;
}

/* ─── HUD buttons (hexagon) ─────────────────────────────────────── */
.hud-btn {
  font-family: var(--font-display); font-size: 12px; letter-spacing: 1px;
  color: var(--text-primary); background: rgba(0, 217, 255, 0.05);
  border: 1px solid var(--text-primary);
  padding: 6px 14px; cursor: pointer;
  clip-path: polygon(12% 0, 100% 0, 88% 100%, 0 100%);
  transition: all 0.2s ease; box-shadow: var(--glow-sm);
}
.hud-btn:hover {
  background: rgba(0, 217, 255, 0.15);
  box-shadow: var(--glow-md); color: var(--accent-glow);
}
.hud-btn.small { padding: 4px 10px; font-size: 16px; line-height: 1; }
.hud-btn:active { transform: scale(0.96); }

/* ─── Main area ─────────────────────────────────────────────────── */
#main-area {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 30px; padding: 20px; position: relative;
}

/* ─── Vision panel ──────────────────────────────────────────────── */
.vision-panel {
  width: 100%; max-width: 320px;
  display: flex; flex-direction: column; gap: 8px;
  opacity: 1; pointer-events: auto;
  order: -1; /* Show above transcript */
}
.vision-panel.hidden { opacity: 0; pointer-events: none; height: 0; overflow: hidden; }
.vision-feed {
  position: relative; border: 1px solid rgba(0, 217, 255, 0.3);
  border-radius: 6px; overflow: hidden; box-shadow: var(--glow-sm);
  background: #000;
}
.vision-feed video { width: 100%; display: block; max-height: 160px; }
.vision-label {
  position: absolute; top: 4px; left: 6px;
  font-size: 10px; letter-spacing: 1px; color: var(--accent-glow);
  text-shadow: var(--glow-sm);
}
.vision-controls { display: flex; gap: 4px; flex-wrap: wrap; }
.vision-btn {
  flex: 1; min-width: 60px;
  font-family: var(--font-mono); font-size: 9px; letter-spacing: 1px;
  color: var(--text-dim); background: rgba(0, 217, 255, 0.04);
  border: 1px solid rgba(0, 217, 255, 0.2); padding: 4px 3px;
  cursor: pointer; transition: all 0.2s; border-radius: 3px;
}
.vision-btn:hover { color: var(--text-primary); border-color: var(--text-primary); }
.vision-btn.active { color: var(--accent-glow); border-color: var(--accent-glow); box-shadow: var(--glow-sm); }

/* ─── Transcript ────────────────────────────────────────────────── */
#transcript-panel {
  width: min(680px, 90vw); max-height: 38vh; overflow-y: auto;
  display: flex; flex-direction: column; gap: 12px;
  padding: 16px; border: 1px solid rgba(0, 217, 255, 0.15);
  border-radius: 8px; background: var(--bg-glass);
  backdrop-filter: blur(4px); box-shadow: var(--glow-sm);
}
.transcript-line {
  display: flex; gap: 10px; align-items: flex-start;
  animation: msg-fade-in 0.3s ease;
}
.prompt-glyph { color: var(--text-primary); font-weight: bold; text-shadow: var(--glow-sm); }
.krish-glyph { color: var(--accent-glow); }
.glow-text { color: var(--text-secondary); line-height: 1.5; }
.glow-text-cyan { color: var(--text-primary); line-height: 1.5; text-shadow: var(--glow-sm); }
.dim-text { color: var(--text-dim); font-style: italic; }
.user-line { border-left: 2px solid var(--glow-color); padding-left: 10px; }
.krish-line { border-left: 2px solid var(--accent-glow); padding-left: 10px; }
.interim-line { opacity: 0.7; }

/* ─── Mic container ─────────────────────────────────────────────── */
#mic-container {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  position: relative;
}
.wake-indicator {
  display: flex; align-items: center; gap: 8px;
  font-family: var(--font-display); font-size: 12px; letter-spacing: 2px;
  color: var(--accent-glow); text-shadow: var(--glow-sm);
  animation: flicker 3s infinite;
}
.wake-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent-glow); box-shadow: 0 0 10px var(--accent-glow);
  animation: pulse-glow 1.5s infinite;
}

/* Mic button with sonar rings */
.mic-btn {
  position: relative; width: 120px; height: 120px;
  border: none; background: transparent; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.mic-ring-1, .mic-ring-2, .mic-ring-3 {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(0, 217, 255, 0.3);
}
.mic-ring-1 { box-shadow: var(--glow-sm); animation: breathing 3.5s ease-in-out infinite; }
.mic-ring-2 { inset: 14px; border-color: rgba(0, 217, 255, 0.2); animation: breathing 3.5s ease-in-out infinite 0.4s; }
.mic-ring-3 { inset: 28px; border-color: rgba(0, 217, 255, 0.15); animation: breathing 3.5s ease-in-out infinite 0.8s; }

/* Sonar ping (active listening) */
.mic-btn.active .mic-ring-1::after,
.mic-btn.active .mic-ring-2::after,
.mic-btn.active .mic-ring-3::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid var(--accent-glow);
  animation: sonar-ping 2s ease-out infinite;
}
.mic-btn.active .mic-ring-2::after { animation-delay: 0.6s; }
.mic-btn.active .mic-ring-3::after { animation-delay: 1.2s; }

.mic-inner {
  position: relative; z-index: 2;
  width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(0, 217, 255, 0.15), rgba(10, 14, 39, 0.9));
  border: 2px solid var(--text-primary);
  box-shadow: var(--glow-md);
  transition: all 0.2s;
}
.mic-btn:hover .mic-inner { box-shadow: var(--glow-lg); border-color: var(--accent-glow); }
.mic-btn.active .mic-inner {
  background: radial-gradient(circle, rgba(0, 255, 255, 0.3), rgba(10, 14, 39, 0.9));
  border-color: var(--accent-glow);
  animation: shimmer 2.5s linear infinite;
}
.mic-icon { width: 32px; height: 32px; color: var(--text-primary); }
.mic-btn.active .mic-icon { color: var(--accent-glow); }
.mic-hint {
  font-family: var(--font-display); font-size: 13px; letter-spacing: 3px;
  color: var(--text-secondary); text-shadow: var(--glow-sm);
}

/* Mute button (always-listen mode) */
.mute-btn {
  position: relative; width: 120px; height: 120px; display: none;
  border: none; background: transparent; cursor: pointer;
  align-items: center; justify-content: center;
}
.mute-btn .mic-ring-1, .mute-btn .mic-ring-2, .mute-btn .mic-ring-3 {
  position: absolute; inset: 0; border-radius: 50%;
  border: 1px solid rgba(0, 217, 255, 0.3);
}
.mute-btn .mic-ring-1 { box-shadow: var(--glow-sm); animation: breathing 3.5s ease-in-out infinite; }
.mute-btn .mic-ring-2 { inset: 14px; border-color: rgba(0, 217, 255, 0.2); animation: breathing 3.5s ease-in-out infinite 0.4s; }
.mute-btn .mic-ring-3 { inset: 28px; border-color: rgba(0, 217, 255, 0.15); animation: breathing 3.5s ease-in-out infinite 0.8s; }
.mute-btn .mic-ring-1::after, .mute-btn .mic-ring-2::after, .mute-btn .mic-ring-3::after {
  content: ""; position: absolute; inset: -2px; border-radius: 50%;
  border: 2px solid var(--accent-glow);
  animation: sonar-ping 2s ease-out infinite;
}
.mute-btn .mic-ring-2::after { animation-delay: 0.6s; }
.mute-btn .mic-ring-3::after { animation-delay: 1.2s; }
.mute-btn .mic-inner {
  position: relative; z-index: 2; width: 72px; height: 72px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(0, 217, 255, 0.15), rgba(10, 14, 39, 0.9));
  border: 2px solid var(--text-primary); box-shadow: var(--glow-md); transition: all 0.2s;
}
.mute-btn .mute-icon { width: 32px; height: 32px; color: var(--text-primary); }
.mute-btn.muted .mic-inner {
  background: radial-gradient(circle, rgba(255, 80, 80, 0.2), rgba(10, 14, 39, 0.9));
  border-color: #ff5050; box-shadow: 0 0 16px rgba(255, 80, 80, 0.5);
}
.mute-btn.muted .mute-icon { color: #ff5050; }
.mute-btn.muted .mic-ring-1, .mute-btn.muted .mic-ring-2, .mute-btn.muted .mic-ring-3 {
  border-color: rgba(255, 80, 80, 0.4);
}
.mute-btn.muted .mic-ring-1::after, .mute-btn.muted .mic-ring-2::after, .mute-btn.muted .mic-ring-3::after {
  border-color: #ff5050; animation: none;
}

/* ─── Footer ────────────────────────────────────────────────────── */
#hud-footer {
  display: flex; gap: 24px; justify-content: center;
  padding: 8px; font-size: 11px; letter-spacing: 1px;
  color: var(--text-dim);
  background: rgba(10, 14, 39, 0.8);
  border-top: 1px solid rgba(0, 217, 255, 0.15);
}
.footer-item { white-space: nowrap; }

/* ─── Side panels ───────────────────────────────────────────────── */
.side-panel {
  position: fixed; top: 0; bottom: 0; width: 340px; z-index: 50;
  background: var(--bg-panel); backdrop-filter: blur(8px);
  border-right: 1px solid rgba(0, 217, 255, 0.3);
  box-shadow: var(--glow-md);
  transform: translateX(-100%); transition: transform 0.3s ease;
  display: flex; flex-direction: column;
}
.side-panel.right { right: 0; left: auto; border-right: none; border-left: 1px solid rgba(0, 217, 255, 0.3); transform: translateX(100%); }
.side-panel.open { transform: translateX(0); }
.panel-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px; font-family: var(--font-display); font-size: 14px;
  letter-spacing: 2px; color: var(--text-primary); text-shadow: var(--glow-sm);
  border-bottom: 1px solid rgba(0, 217, 255, 0.2);
}
.settings-body, #history-list { flex: 1; overflow-y: auto; padding: 20px; display: flex; flex-direction: column; gap: 18px; }
.panel-footer { padding: 16px 20px; border-top: 1px solid rgba(0, 217, 255, 0.2); }

.setting-group { display: flex; flex-direction: column; gap: 6px; }
.setting-label {
  font-family: var(--font-display); font-size: 11px; letter-spacing: 2px;
  color: var(--text-secondary);
}
.setting-input, .setting-select {
  background: rgba(0, 217, 255, 0.04); border: 1px solid rgba(0, 217, 255, 0.25);
  color: var(--text-primary); padding: 8px 10px; font-family: var(--font-mono);
  font-size: 13px; border-radius: 4px; box-shadow: var(--glow-sm);
}
.setting-input:focus, .setting-select:focus { outline: none; border-color: var(--accent-glow); box-shadow: var(--glow-md); }
.setting-input[readonly] { color: var(--text-dim); cursor: default; }
.toggle-row { display: flex; align-items: center; justify-content: space-between; font-size: 13px; color: var(--text-secondary); }

/* Toggle switch */
.toggle-switch { position: relative; width: 44px; height: 22px; display: inline-block; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0; cursor: pointer;
  background: rgba(0, 217, 255, 0.1); border: 1px solid rgba(0, 217, 255, 0.3);
  border-radius: 22px; transition: 0.2s;
}
.toggle-slider::before {
  content: ""; position: absolute; height: 16px; width: 16px; left: 3px; top: 2px;
  background: var(--text-dim); border-radius: 50%; transition: 0.2s;
}
.toggle-switch input:checked + .toggle-slider {
  background: rgba(0, 217, 255, 0.2); border-color: var(--accent-glow);
  box-shadow: var(--glow-sm);
}
.toggle-switch input:checked + .toggle-slider::before {
  transform: translateX(22px); background: var(--accent-glow); box-shadow: 0 0 8px var(--accent-glow);
}

/* Range slider */
input[type="range"] {
  -webkit-appearance: none; appearance: none; height: 4px;
  background: rgba(0, 217, 255, 0.2); border-radius: 2px; outline: none;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%;
  background: var(--accent-glow); box-shadow: 0 0 10px var(--accent-glow); cursor: pointer;
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%; border: none;
  background: var(--accent-glow); box-shadow: 0 0 10px var(--accent-glow); cursor: pointer;
}
.threshold-val { font-size: 12px; color: var(--text-primary); }

.settings-actions { display: flex; gap: 10px; margin-top: 8px; }
.settings-actions .hud-btn { flex: 1; text-align: center; }

/* History list */
.history-item {
  border-left: 2px solid var(--glow-color); padding: 8px 10px;
  background: rgba(0, 217, 255, 0.03); border-radius: 0 4px 4px 0;
  font-size: 13px; color: var(--text-secondary);
}
.history-item .h-q { color: var(--text-primary); }
.history-item .h-a { color: var(--text-dim); font-size: 12px; margin-top: 4px; }

/* ─── Toast ──────────────────────────────────────────────────────── */
#toast-container {
  position: fixed; top: 70px; left: 50%; transform: translateX(-50%);
  z-index: 100; display: flex; flex-direction: column; gap: 8px; align-items: center;
}
.toast {
  font-family: var(--font-display); font-size: 13px; letter-spacing: 1px;
  padding: 8px 20px; background: var(--bg-panel);
  border: 1px solid var(--text-primary); border-radius: 4px;
  color: var(--text-primary); box-shadow: var(--glow-md);
  animation: msg-fade-in 0.3s ease;
}
.toast.error { border-color: var(--red-accent); color: var(--red-accent); box-shadow: 0 0 15px var(--red-glow); }

/* ─── Animations ────────────────────────────────────────────────── */
@keyframes breathing {
  0%, 100% { transform: scale(1); opacity: 0.8; }
  50% { transform: scale(1.08); opacity: 1; }
}
@keyframes sonar-ping {
  0% { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.8); opacity: 0; }
}
@keyframes shimmer {
  0% { background-position: -200px 0; }
  100% { background-position: 200px 0; }
}
@keyframes pulse-glow {
  0%, 100% { opacity: 0.5; }
  50% { opacity: 1; }
}
@keyframes msg-fade-in {
  0% { opacity: 0; transform: translateY(10px); }
  100% { opacity: 1; transform: translateY(0); }
}
@keyframes flicker {
  0%, 19%, 21%, 23%, 25%, 54%, 56%, 100% { opacity: 1; }
  20%, 24%, 55% { opacity: 0.7; }
}

/* ─── Scrollbar ─────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0, 217, 255, 0.3); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0, 217, 255, 0.5); }

/* ─── Responsive ────────────────────────────────────────────────── */
@media (max-width: 640px) {
  #hud-topbar { padding: 10px 14px; }
  .logo-text { font-size: 20px; }
  .model-badge { display: none; }
  .vision-panel { width: 180px; top: 10px; right: 10px; }
  #transcript-panel { max-height: 32vh; }
  .mic-btn { width: 100px; height: 100px; }
}

/* ─── Reduced motion ────────────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::after, *::before { animation: none !important; transition: none !important; }
}
