/* ====================================================
   Agora Voice AI — Cyberpunk Theme
   Dark base (#0a0a0f) + neon cyan / magenta / lime
   ==================================================== */

@import url('https://fonts.googleapis.com/css2?family=Orbitron:wght@400;500;600;700;900&family=Share+Tech+Mono&family=Rajdhani:wght@400;500;600;700&display=swap');

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

:root {
  --bg: #0d0d1a;
  --surface: rgba(16, 16, 28, 0.88);
  --surface-hover: rgba(22, 22, 40, 0.95);
  --accent: #00C8D8;
  --accent-glow: rgba(0, 200, 216, 0.28);
  --magenta: #8B2FC9;
  --magenta-glow: rgba(139, 47, 201, 0.25);
  --lime: #88CC00;
  --lime-glow: rgba(136, 204, 0, 0.25);
  --user-bubble-from: #00C8D8;
  --user-bubble-to: #00A0B0;
  --assistant-bubble: rgba(0, 200, 216, 0.06);
  --text: #e0e0ee;
  --text-muted: #6a6a88;
  --border: rgba(0, 200, 216, 0.18);
  --border-soft: rgba(139, 47, 201, 0.15);
  --danger: #ff2244;
  --radius: 4px;
  --transition: 0.18s ease;

  /* Cyberpunk gradients */
  --gradient-primary: linear-gradient(135deg, #00C8D8 0%, #8B2FC9 100%);
  --gradient-secondary: linear-gradient(135deg, #8B2FC9 0%, #88CC00 100%);
  --gradient-accent: linear-gradient(135deg, #88CC00 0%, #00C8D8 100%);
  --glow-primary: rgba(0, 200, 216, 0.32);
  --glow-secondary: rgba(139, 47, 201, 0.28);
  --shadow-soft: 0 4px 24px rgba(0, 200, 216, 0.08), 0 1px 6px rgba(0,0,0,0.5);
  --shadow-card: 0 8px 32px rgba(139, 47, 201, 0.1), 0 2px 8px rgba(0,0,0,0.6);
}

html, body {
  height: 100%;
  overflow: hidden;
  background: var(--bg);
  color: var(--text);
  font-family: 'Rajdhani', 'Share Tech Mono', monospace;
  font-size: 14px;
}

/* Cyberpunk background — dark with faint neon radial glows */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse at 10% 15%, rgba(0, 200, 216, 0.08) 0%, transparent 45%),
    radial-gradient(ellipse at 90% 80%, rgba(139, 47, 201, 0.07) 0%, transparent 45%),
    radial-gradient(ellipse at 50% 5%,  rgba(136, 204, 0, 0.04) 0%, transparent 35%),
    radial-gradient(ellipse at 75% 35%, rgba(0, 200, 216, 0.05) 0%, transparent 30%),
    #0d0d1a;
  z-index: -1;
  pointer-events: none;
}

/* Scanline overlay for CRT effect */
body::after {
  content: '';
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 2px,
    rgba(0, 0, 0, 0.06) 2px,
    rgba(0, 0, 0, 0.06) 4px
  );
  z-index: -1;
  pointer-events: none;
}

/* ====================================================
   Cyber particles layer
   ==================================================== */
.particles-container {
  position: fixed;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  overflow: hidden;
}

.cyber-particle {
  position: absolute;
  top: -20px;
  will-change: transform, opacity;
}

@keyframes particle-fall {
  0%   { transform: translateY(0) rotate(var(--rot-start)); opacity: 0; }
  8%   { opacity: var(--max-opacity); }
  85%  { opacity: calc(var(--max-opacity) * 0.6); }
  100% { transform: translateY(110vh) translateX(var(--drift)) rotate(var(--rot-end)); opacity: 0; }
}

@keyframes particle-glitch {
  0%, 90%, 100% { opacity: var(--max-opacity); }
  92% { opacity: 0; transform: translateX(4px); }
  94% { opacity: var(--max-opacity); transform: translateX(-2px); }
  96% { opacity: 0; }
  98% { opacity: var(--max-opacity); transform: translateX(0); }
}

/* ====================================================
   Avatar container — full-screen background
   ==================================================== */
.avatar-container {
  position: fixed;
  inset: 0;
  z-index: 0;
  background: radial-gradient(ellipse at 50% 55%, rgba(0, 200, 216, 0.06) 0%, rgba(10, 10, 15, 0.8) 70%);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar-container video {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Agora injects a div with inline width/height 100% — override to center portrait video */
#avatar-container > div[id^="agora-video-player"] {
  width: auto !important;
  height: 100% !important;
  max-width: 100%;
  aspect-ratio: 9 / 16;
  flex-shrink: 0;
}

.avatar-placeholder {
  position: absolute;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 20px;
  opacity: 0.9;
  pointer-events: none;
}

.placeholder-orb {
  width: 130px;
  height: 130px;
  border-radius: 50%;
  background: radial-gradient(circle at 35% 35%, rgba(0, 200, 216, 0.8), rgba(139, 47, 201, 0.6) 60%, rgba(136, 204, 0, 0.3));
  animation: pulse-orb 3s ease-in-out infinite;
  box-shadow:
    0 0 40px var(--glow-primary),
    0 0 80px rgba(0, 200, 216, 0.15),
    inset 0 -10px 30px rgba(139, 47, 201, 0.2);
  border: 1px solid rgba(0, 200, 216, 0.4);
}

@keyframes pulse-orb {
  0%, 100% { transform: scale(1); box-shadow: 0 0 40px var(--glow-primary), 0 0 80px rgba(0,240,255,0.15); }
  50% { transform: scale(1.07); box-shadow: 0 0 60px var(--glow-primary), 0 0 120px rgba(0,240,255,0.25); }
}

.placeholder-text {
  color: var(--accent);
  font-family: 'Share Tech Mono', monospace;
  font-size: 12px;
  font-weight: 400;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  text-shadow: 0 0 10px var(--accent-glow);
}

/* ====================================================
   HUD frame overlay
   ==================================================== */
.hud-frame {
  position: absolute;
  inset: 0;
  z-index: 1;
  pointer-events: none;
  --hud-color: rgba(0, 200, 216, 0.45);
  --hud-glow: rgba(0, 200, 216, 0.2);
  transition: --hud-color 0.8s ease, --hud-glow 0.8s ease;
}

/* Corner brackets — L-shaped using border edges */
.hud-corner {
  position: absolute;
  width: 56px;
  height: 56px;
  border-color: var(--hud-color);
  border-style: solid;
  filter: drop-shadow(0 0 4px var(--hud-glow));
  transition: border-color 0.8s ease, filter 0.8s ease;
}
.hud-tl { top: 80px; left: 24px; border-width: 2px 0 0 2px; }
.hud-tr { top: 80px; right: 24px; border-width: 2px 2px 0 0; }
.hud-bl { bottom: 24px; left: 24px; border-width: 0 0 2px 2px; }
.hud-br { bottom: 24px; right: 24px; border-width: 0 2px 2px 0; }

/* HUD text labels */
.hud-label-top,
.hud-label-bottom-left,
.hud-label-bottom-right {
  position: absolute;
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--hud-color);
  text-shadow: 0 0 6px var(--hud-glow);
  transition: color 0.8s ease, text-shadow 0.8s ease;
}
.hud-label-top {
  top: 66px;
  left: 50%;
  transform: translateX(-50%);
}
.hud-label-bottom-left {
  bottom: 10px;
  left: 88px;
}
.hud-label-bottom-right {
  bottom: 10px;
  right: 88px;
}

/* Horizontal scan line sweeping top to bottom */
.hud-scanline {
  display: none;
}

/* ====================================================
   Reactive glow — avatar-container::before driven by agent state
   ==================================================== */
.avatar-container::before {
  content: '';
  position: absolute;
  inset: 0;
  z-index: 0;
  pointer-events: none;
  opacity: 0;
  transition: opacity 1.2s ease, background 1.2s ease;
}

/* Listening: cyan bloom */
#avatar-container[data-agent-state="listening"]::before {
  background: radial-gradient(ellipse at 50% 60%, rgba(0, 200, 216, 0.35) 0%, rgba(0, 200, 216, 0.08) 55%, transparent 75%);
  opacity: 1;
  animation: glow-breathe-cyan 3s ease-in-out infinite;
}
@keyframes glow-breathe-cyan {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 1;   }
}

/* Thinking: magenta bloom */
#avatar-container[data-agent-state="thinking"]::before {
  background: radial-gradient(ellipse at 50% 55%, rgba(139, 47, 201, 0.35) 0%, rgba(139, 47, 201, 0.08) 50%, transparent 70%);
  opacity: 1;
  animation: glow-breathe-magenta 2.4s ease-in-out infinite;
}
@keyframes glow-breathe-magenta {
  0%, 100% { opacity: 0.6; }
  50%       { opacity: 1;   }
}

/* Speaking: lime bloom */
#avatar-container[data-agent-state="speaking"]::before {
  background: radial-gradient(ellipse at 50% 60%, rgba(136, 204, 0, 0.30) 0%, rgba(136, 204, 0, 0.07) 50%, transparent 70%);
  opacity: 1;
  animation: glow-breathe-lime 1.8s ease-in-out infinite;
}
@keyframes glow-breathe-lime {
  0%, 100% { opacity: 0.7; }
  50%       { opacity: 1;   }
}

/* HUD corner color shifts to match agent state */
#avatar-container[data-agent-state="thinking"] .hud-frame {
  --hud-color: rgba(139, 47, 201, 0.4);
  --hud-glow: rgba(139, 47, 201, 0.18);
}
#avatar-container[data-agent-state="speaking"] .hud-frame {
  --hud-color: rgba(136, 204, 0, 0.4);
  --hud-glow: rgba(136, 204, 0, 0.18);
}
#avatar-container[data-agent-state="listening"] .hud-frame {
  --hud-color: rgba(0, 200, 216, 0.55);
  --hud-glow: rgba(0, 200, 216, 0.28);
}

/* ====================================================
   Top bar
   ==================================================== */
.top-bar {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  background: rgba(8, 8, 16, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(0, 200, 216, 0.25);
  box-shadow: 0 2px 20px rgba(0, 200, 216, 0.08), 0 0 1px rgba(0, 200, 216, 0.3);
  z-index: 10;
}

.app-title {
  font-family: 'Orbitron', monospace;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.logo-dot {
  width: 8px;
  height: 8px;
  border-radius: 0;
  background: var(--accent);
  box-shadow: 0 0 10px var(--accent), 0 0 20px var(--accent-glow);
  animation: blink 1.8s ease-in-out infinite;
  flex-shrink: 0;
  transform: rotate(45deg);
}

.agora-logo {
  height: 28px;
  width: auto;
  object-fit: contain;
}

@keyframes blink {
  0%, 100% { opacity: 1; transform: rotate(45deg) scale(1); }
  50% { opacity: 0.3; transform: rotate(45deg) scale(0.7); }
}

.top-bar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}

.connection-status {
  font-size: 11px;
  font-family: 'Share Tech Mono', monospace;
  font-weight: 400;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 3px 10px;
  border-radius: 2px;
  transition: all var(--transition);
}
.connection-status.disconnected {
  background: rgba(255, 34, 68, 0.08);
  color: #ff4466;
  border: 1px solid rgba(255, 34, 68, 0.3);
}
.connection-status.connecting--- {
  background: rgba(255, 170, 0, 0.08);
  color: #ffaa00;
  border: 1px solid rgba(255, 170, 0, 0.3);
  animation: status-pulse 1s ease-in-out infinite;
}
.connection-status.connected {
  background: rgba(136, 204, 0, 0.08);
  color: var(--lime);
  border: 1px solid rgba(136, 204, 0, 0.35);
  box-shadow: 0 0 8px rgba(136, 204, 0, 0.2);
}
.connection-status.error {
  background: rgba(255, 34, 68, 0.12);
  color: #ff2244;
  border: 1px solid rgba(255, 34, 68, 0.4);
}
.connection-status.disconnecting--- {
  background: rgba(255, 170, 0, 0.08);
  color: #ffaa00;
  border: 1px solid rgba(255, 170, 0, 0.3);
}

@keyframes status-pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.conversation-id {
  font-size: 10px;
  color: var(--text-muted);
  font-family: 'Share Tech Mono', monospace;
  letter-spacing: 0.06em;
}

/* ====================================================
   Agent state indicator
   ==================================================== */
.agent-state {
  position: fixed;
  top: 74px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  z-index: 10;
  pointer-events: none;
}

.state-rings {
  position: relative;
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--accent);
  opacity: 0;
  transition: opacity var(--transition);
}
.ring.r1 { width: 48px; height: 48px; }
.ring.r2 { width: 36px; height: 36px; }
.ring.r3 { width: 24px; height: 24px; }

.state-dot {
  width: 12px;
  height: 12px;
  border-radius: 0;
  background: var(--accent);
  transform: rotate(45deg);
  position: relative;
  z-index: 1;
  transition: all var(--transition);
  box-shadow: 0 0 10px var(--accent-glow);
}

.state-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  background: rgba(8, 8, 16, 0.85);
  padding: 2px 10px;
  border: 1px solid rgba(0, 200, 216, 0.12);
  backdrop-filter: blur(8px);
}

/* Thinking */
.agent-state.thinking .ring {
  animation: ring-pulse 1.4s ease-out infinite;
  opacity: 1;
  border-color: var(--magenta);
  box-shadow: 0 0 8px var(--magenta-glow);
}
.agent-state.thinking .ring.r2 { animation-delay: 0.35s; }
.agent-state.thinking .ring.r3 { animation-delay: 0.7s; }
.agent-state.thinking .state-dot {
  background: var(--magenta);
  box-shadow: 0 0 14px var(--magenta-glow);
}

@keyframes ring-pulse {
  0% { transform: scale(0.6); opacity: 0.9; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* Speaking */
.agent-state.speaking .ring {
  border: none;
  background: var(--gradient-primary);
  width: 3px;
  height: 20px;
  border-radius: 2px;
  opacity: 1;
  animation: wave-bar 0.5s ease-in-out infinite alternate;
}
.agent-state.speaking .ring.r1 { left: 6px; animation-delay: 0s; }
.agent-state.speaking .ring.r2 { left: 50%; transform: translateX(-50%); animation-delay: 0.1s; }
.agent-state.speaking .ring.r3 { right: 6px; left: auto; animation-delay: 0.2s; }
.agent-state.speaking .state-dot {
  background: var(--lime);
  box-shadow: 0 0 12px var(--lime-glow);
}

@keyframes wave-bar {
  from { height: 6px; }
  to { height: 28px; }
}

/* Idle */
.agent-state.idle .state-dot {
  background: var(--text-muted);
  box-shadow: none;
}

/* Listening */
.agent-state.listening .state-dot {
  background: var(--lime);
  box-shadow: 0 0 12px var(--lime-glow);
  animation: pulse-orb 1.5s ease-in-out infinite;
}

/* ====================================================
   Chat panel — right side overlay
   ==================================================== */
.chat-panel {
  position: fixed;
  top: 56px;
  right: 0;
  bottom: 88px;
  width: 320px;
  display: flex;
  flex-direction: column;
  background: rgba(8, 8, 16, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-left: 1px solid rgba(0, 200, 216, 0.18);
  box-shadow: -4px 0 30px rgba(0, 200, 216, 0.06);
  z-index: 10;
}

.chat-header {
  padding: 12px 16px;
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  border-bottom: 1px solid rgba(0, 200, 216, 0.1);
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px 12px 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 200, 216, 0.2) transparent;
}

.chat-messages::-webkit-scrollbar { width: 3px; }
.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(0, 200, 216, 0.25);
  border-radius: 0;
}

/* Message bubbles */
.message {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-width: 92%;
}
.message.user { align-self: flex-end; align-items: flex-end; }
.message.assistant { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 9px 14px;
  border-radius: 2px;
  line-height: 1.55;
  font-size: 13px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  word-break: break-word;
  transition: opacity var(--transition);
}

/* User bubble — cyan gradient */
.message.user .bubble {
  background: linear-gradient(135deg, rgba(0, 200, 216, 0.25), rgba(0, 160, 176, 0.35));
  border-bottom-right-radius: 2px;
  color: #e8f8fa;
  box-shadow: 0 3px 16px rgba(0, 200, 216, 0.25);
  border: 1px solid rgba(0, 200, 216, 0.4);
}

/* Assistant bubble — dark with cyan left accent */
.message.assistant .bubble {
  background: var(--assistant-bubble);
  border-bottom-left-radius: 2px;
  border: 1px solid rgba(0, 200, 216, 0.15);
  border-left: 2px solid transparent;
  position: relative;
  padding-left: 14px;
  color: var(--text);
  box-shadow: 0 2px 12px rgba(0, 200, 216, 0.06);
}
.message.assistant .bubble::before {
  content: '';
  position: absolute;
  left: 0; top: 0; bottom: 0;
  width: 2px;
  background: var(--gradient-primary);
}

.message.partial .bubble { opacity: 0.55; }

/* Media messages */
.message.media-message { max-width: 100%; }
.media-img {
  max-width: 100%;
  border-radius: 2px;
  display: block;
  border: 1px solid rgba(0, 200, 216, 0.25);
}
.media-video {
  max-width: 100%;
  border-radius: 2px;
  display: block;
  border: 1px solid rgba(0, 200, 216, 0.25);
  background: #000;
}

.time {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 4px;
  letter-spacing: 0.06em;
  font-family: 'Share Tech Mono', monospace;
}

/* Typing indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 10px 16px;
  flex-shrink: 0;
}
.typing-indicator span {
  width: 6px; height: 6px;
  border-radius: 0;
  transform: rotate(45deg);
  animation: typing-bounce 1.2s ease-in-out infinite;
}
.typing-indicator span:nth-child(1) { background: var(--accent); animation-delay: 0s; }
.typing-indicator span:nth-child(2) { background: var(--magenta); animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { background: var(--lime); animation-delay: 0.4s; }

@keyframes typing-bounce {
  0%, 80%, 100% { transform: rotate(45deg) translateY(0) scale(1); opacity: 0.4; }
  40% { transform: rotate(45deg) translateY(-6px) scale(1.2); opacity: 1; }
}

/* Chat input */
.chat-input-row {
  display: flex;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid rgba(0, 200, 216, 0.08);
  flex-shrink: 0;
}

.chat-input-row input {
  flex: 1;
  background: rgba(0, 200, 216, 0.04);
  border: 1px solid rgba(0, 200, 216, 0.2);
  border-radius: 2px;
  padding: 9px 14px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.chat-input-row input::placeholder { color: var(--text-muted); letter-spacing: 0.06em; }
.chat-input-row input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 200, 216, 0.12), 0 0 12px rgba(0, 200, 216, 0.1);
}
.chat-input-row input:disabled { opacity: 0.3; cursor: not-allowed; }

/* Send button — cyan */
.send-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: 2px;
  background: rgba(0, 200, 216, 0.15);
  border: 1px solid rgba(0, 200, 216, 0.4) !important;
  box-shadow: 0 0 10px rgba(0, 200, 216, 0.15);
  transition: all var(--transition);
}
.send-btn:hover:not(:disabled) {
  background: rgba(0, 200, 216, 0.25);
  box-shadow: 0 0 20px rgba(0, 200, 216, 0.3);
  transform: translateY(-1px);
}
.send-btn:disabled { opacity: 0.2; cursor: not-allowed; }
.send-btn svg { stroke: var(--accent); }

/* ====================================================
   Control bar — bottom center
   ==================================================== */
.control-bar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(8, 8, 16, 0.94);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border: 1px solid rgba(0, 200, 216, 0.2);
  border-radius: 4px;
  padding: 10px 24px;
  z-index: 10;
  box-shadow: 0 8px 32px rgba(0, 200, 216, 0.1), 0 0 1px rgba(0, 200, 216, 0.3), 0 2px 8px rgba(0,0,0,0.6);
}

/* Start button — neon cyan */
.start-btn {
  padding: 9px 28px;
  border-radius: 2px;
  border: 1px solid rgba(0, 200, 216, 0.6);
  background: rgba(0, 200, 216, 0.12);
  color: var(--accent);
  font-family: 'Orbitron', monospace;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  letter-spacing: 0.12em;
  text-transform: uppercase;
  box-shadow: 0 0 12px rgba(0, 200, 216, 0.2), inset 0 0 20px rgba(0, 200, 216, 0.04);
  text-shadow: 0 0 10px var(--accent-glow);
}
.start-btn:hover {
  background: rgba(0, 200, 216, 0.22);
  box-shadow: 0 0 24px rgba(0, 200, 216, 0.4), inset 0 0 20px rgba(0, 200, 216, 0.08);
  transform: translateY(-1px);
}
.start-btn:active { transform: translateY(0) scale(0.98); }
.start-btn.running {
  border-color: rgba(0, 200, 216, 0.6);
  background: rgba(0, 200, 216, 0.12);
  color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 200, 216, 0.25), inset 0 0 20px rgba(0, 200, 216, 0.05);
  text-shadow: 0 0 10px var(--accent-glow);
}
.start-btn.running:hover {
  background: rgba(0, 200, 216, 0.22);
  box-shadow: 0 0 24px rgba(0, 200, 216, 0.4);
}

.mute-btn {
  width: 42px;
  height: 42px;
  border-radius: 2px;
  background: rgba(0, 200, 216, 0.06);
  border: 1px solid rgba(0, 200, 216, 0.15) !important;
  transition: all var(--transition);
  color: var(--text-muted);
}
.mute-btn svg { stroke: currentColor; }
.mute-btn:hover:not(:disabled) {
  background: rgba(0, 200, 216, 0.12);
  border-color: rgba(0, 200, 216, 0.4) !important;
  box-shadow: 0 0 14px rgba(0, 200, 216, 0.2);
  color: var(--accent);
}
.mute-btn:disabled { opacity: 0.2; cursor: not-allowed; }
.mute-btn.muted {
  background: rgba(255, 34, 68, 0.1);
  border-color: rgba(255, 34, 68, 0.35) !important;
  color: var(--danger);
  box-shadow: 0 0 10px rgba(255, 34, 68, 0.2);
}

/* Chat toggle button */
.chat-toggle-btn {
  width: 42px;
  height: 42px;
  border-radius: 2px;
  background: rgba(0, 200, 216, 0.06);
  border: 1px solid rgba(0, 200, 216, 0.15) !important;
  transition: all var(--transition);
  color: var(--text-muted);
}
.chat-toggle-btn svg { stroke: currentColor; }
.chat-toggle-btn:hover {
  background: rgba(0, 200, 216, 0.12);
  border-color: rgba(0, 200, 216, 0.4) !important;
  box-shadow: 0 0 14px rgba(0, 200, 216, 0.2);
  color: var(--accent);
}
.chat-toggle-btn.active {
  background: rgba(0, 200, 216, 0.12);
  border-color: rgba(0, 200, 216, 0.4) !important;
  color: var(--accent);
  box-shadow: 0 0 12px rgba(0, 200, 216, 0.2);
}

/* ====================================================
   Icon buttons (generic)
   ==================================================== */
.icon-btn {
  background: none;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: color var(--transition);
}
.icon-btn svg { width: 18px; height: 18px; stroke: currentColor; }
.icon-btn:hover { color: var(--accent); }

/* ====================================================
   Loading overlay
   ==================================================== */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8, 8, 16, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 20px;
  z-index: 50;
  color: var(--accent);
  font-family: 'Share Tech Mono', monospace;
  font-size: 13px;
  font-weight: 400;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  text-shadow: 0 0 10px var(--accent-glow);
}

.spinner {
  width: 42px; height: 42px;
  border: 2px solid rgba(0, 200, 216, 0.1);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.65s linear infinite;
  box-shadow: 0 0 16px var(--glow-primary);
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ====================================================
   Error toast
   ==================================================== */
.error-toast {
  position: fixed;
  bottom: 100px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(255, 34, 68, 0.15);
  color: #ff4466;
  border: 1px solid rgba(255, 34, 68, 0.4);
  padding: 10px 22px;
  border-radius: 2px;
  font-size: 12px;
  font-family: 'Share Tech Mono', monospace;
  font-weight: 400;
  letter-spacing: 0.06em;
  z-index: 100;
  max-width: 380px;
  text-align: center;
  box-shadow: 0 4px 20px rgba(255, 34, 68, 0.3);
  transition: opacity var(--transition);
}

/* ====================================================
   Settings modal
   ==================================================== */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 80;
  padding: 16px;
}

.modal-box {
  background: rgba(10, 10, 20, 0.98);
  border: 1px solid rgba(0, 200, 216, 0.25);
  border-top: 2px solid var(--accent);
  border-radius: 4px;
  width: 100%;
  max-width: 440px;
  max-height: 90vh;
  overflow-y: auto;
  padding: 26px;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 200, 216, 0.2) transparent;
  box-shadow: 0 20px 60px rgba(0, 200, 216, 0.12), 0 0 1px rgba(0, 200, 216, 0.3), 0 4px 16px rgba(0,0,0,0.8);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 22px;
}
.modal-header h2 {
  font-family: 'Orbitron', monospace;
  font-size: 14px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.close-btn { color: var(--text-muted); }
.close-btn:hover { color: var(--magenta); }

.form-label {
  display: flex;
  flex-direction: column;
  gap: 7px;
  margin-bottom: 16px;
  font-size: 11px;
  font-weight: 600;
  font-family: 'Share Tech Mono', monospace;
  color: var(--text-muted);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}
.form-label .required { color: var(--accent); }

.form-label input[type="text"],
.form-label input[type="number"] {
  background: rgba(0, 200, 216, 0.04);
  border: 1px solid rgba(0, 200, 216, 0.18);
  border-radius: 2px;
  padding: 9px 13px;
  color: var(--text);
  font-size: 13px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 500;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}
.form-label input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(0, 200, 216, 0.1), 0 0 12px rgba(0, 200, 216, 0.1);
}
.form-label input:disabled { opacity: 0.3; cursor: not-allowed; }

.language-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px;
  margin-top: 4px;
}

.lang-option {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 2px;
  background: rgba(0, 200, 216, 0.03);
  border: 1px solid rgba(0, 200, 216, 0.08);
  font-size: 11px;
  font-family: 'Share Tech Mono', monospace;
  font-weight: 400;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  transition: all var(--transition);
}
.lang-option:hover {
  background: rgba(0, 200, 216, 0.08);
  border-color: rgba(0, 200, 216, 0.3);
  color: var(--accent);
}
.lang-option input[type="checkbox"] { accent-color: var(--accent); }

/* ====================================================
   Username popup modal
   ==================================================== */
.username-modal {
  z-index: 100; /* above other modals */
}

.username-modal-box {
  max-width: 360px;
}

.username-modal-hint {
  font-size: 12px;
  color: var(--text-muted);
  font-family: 'Share Tech Mono', monospace;
  margin-bottom: 20px;
  margin-top: -10px;
  line-height: 1.6;
}

.username-continue-btn {
  display: block;
  width: 100%;
  padding: 11px;
  margin-top: 8px;
  background: var(--gradient-primary);
  border: none;
  border-radius: 2px;
  color: #000;
  font-family: 'Orbitron', monospace;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  cursor: pointer;
  transition: opacity var(--transition);
}

.username-continue-btn:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.username-continue-btn:not(:disabled):hover {
  opacity: 0.85;
}

/* ====================================================
   Image popup card
   ==================================================== */
.image-popup {
  position: fixed;
  z-index: 60;
  animation: popup-enter 0.22s ease-out forwards;
}

@keyframes popup-enter {
  from { opacity: 0; transform: translateY(12px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)    scale(1); }
}

.image-popup-card {
  position: relative;
  background: rgba(10, 10, 20, 0.96);
  border: 1px solid rgba(0, 200, 216, 0.4);
  border-top: 2px solid var(--accent);
  border-radius: 4px;
  box-shadow: 0 0 24px rgba(0, 200, 216, 0.2), 0 8px 32px rgba(0,0,0,0.7);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  width: 320px;
  min-width: 160px;
  min-height: 160px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.image-popup-header {
  display: flex;
  align-items: center;
  padding: 6px 10px;
  padding-right: 36px;
  background: rgba(0, 200, 216, 0.08);
  border-bottom: 1px solid rgba(0, 200, 216, 0.15);
  cursor: grab;
  user-select: none;
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.15em;
  text-transform: uppercase;
  color: var(--text-muted);
  flex-shrink: 0;
}
.image-popup-header:active {
  cursor: grabbing;
}

.image-popup-resize-handle {
  position: absolute;
  bottom: 0;
  right: 0;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  background: linear-gradient(135deg, transparent 50%, rgba(0, 200, 216, 0.3) 50%);
  border-radius: 0 0 4px 0;
  z-index: 2;
  flex-shrink: 0;
}
.image-popup-resize-handle:hover {
  background: linear-gradient(135deg, transparent 50%, rgba(0, 200, 216, 0.55) 50%);
}

.image-popup-close {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 26px;
  height: 26px;
  border-radius: 2px;
  background: rgba(0, 0, 0, 0.6);
  border: 1px solid rgba(0, 200, 216, 0.25) !important;
  color: var(--text-muted);
  z-index: 1;
}
.image-popup-close:hover { color: var(--accent); border-color: rgba(0,240,255,0.6) !important; }
.image-popup-close svg { width: 14px; height: 14px; }

.image-popup-img,
.image-popup-video {
  width: 100%;
  flex: 1;
  min-height: 0;
  object-fit: contain;
  display: block;
  background: #000;
}

.image-popup-download {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 14px;
  background: rgba(0, 200, 216, 0.07);
  border: none;
  border-top: 1px solid rgba(0, 200, 216, 0.15);
  color: var(--accent);
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  cursor: pointer;
  transition: background var(--transition), box-shadow var(--transition);
  flex-shrink: 0;
}
.image-popup-download:hover {
  background: rgba(0, 200, 216, 0.15);
  box-shadow: 0 0 14px rgba(0, 200, 216, 0.2);
}
.image-popup-download svg { stroke: var(--accent); flex-shrink: 0; }

/* ====================================================
   Utility
   ==================================================== */
.hidden { display: none !important; }

/* ====================================================
   Stats panel — left-side panel, mirrors chat-panel
   ==================================================== */
.stats-panel {
  position: fixed;
  top: 56px;
  left: 0;
  bottom: 88px;
  width: 280px;
  z-index: 10;
  display: flex;
  flex-direction: column;
  gap: 0;
  padding: 0;
  background: rgba(8, 8, 16, 0.92);
  backdrop-filter: blur(24px);
  -webkit-backdrop-filter: blur(24px);
  border-right: 1px solid rgba(0, 200, 216, 0.18);
  box-shadow: 4px 0 30px rgba(0, 200, 216, 0.06);
  overflow-y: auto;
  overflow-x: hidden;
  scrollbar-width: none;

  /* Hidden by default — slides in from left */
  opacity: 0;
  pointer-events: none;
  transform: translateX(-20px);
  transition: opacity 0.35s ease, transform 0.35s ease;
}
.stats-panel::-webkit-scrollbar { display: none; }

.stats-panel.active {
  opacity: 1;
  pointer-events: auto;
  transform: translateX(0);
}

/* Sections — divider rows, no card background */
.stats-section {
  padding: 12px 16px;
  border-bottom: 1px solid rgba(0, 200, 216, 0.08);
  flex-shrink: 0;
}
.stats-section:last-of-type { border-bottom: none; }

.stats-section-header {
  font-family: 'Orbitron', monospace;
  font-size: 9px;
  font-weight: 600;
  letter-spacing: 0.18em;
  text-transform: uppercase;
  color: rgba(0, 200, 216, 0.5);
  text-shadow: none;
  margin-bottom: 10px;
}

/* Key-value rows */
.stats-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 4px;
}
.stats-row.spark-gap { margin-top: 8px; }
.stats-key {
  font-family: 'Share Tech Mono', monospace;
  font-size: 10px;
  letter-spacing: 0.1em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.stats-val {
  font-family: 'Share Tech Mono', monospace;
  font-size: 11px;
  letter-spacing: 0.06em;
  color: var(--text);
  text-align: right;
}

/* Sparkline SVG */
.sparkline {
  display: block;
  width: 100%;
  height: 30px;
  margin-top: 3px;
  overflow: visible;
}
.stats-val.accent-lime { color: var(--lime); text-shadow: 0 0 6px var(--lime-glow); }
.stats-val.accent-magenta { color: #bb66ff; text-shadow: 0 0 6px var(--magenta-glow); }
.stats-val.danger { color: #ff4466; }

/* Progress bar rows */
.stats-progress-row {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 4px;
}
.stats-progress-row .stats-key { flex-shrink: 0; min-width: 52px; }
.stats-progress-row .stats-val { flex-shrink: 0; min-width: 28px; text-align: right; }
.stats-progress-bar {
  flex: 1;
  height: 4px;
  background: rgba(255,255,255,0.06);
  border-radius: 2px;
  overflow: hidden;
}
.stats-progress-fill {
  height: 100%;
  border-radius: 2px;
  transition: width 0.6s ease;
}
.stats-progress-fill.cyan {
  background: linear-gradient(90deg, var(--accent), rgba(0, 200, 216, 0.6));
  box-shadow: 0 0 6px var(--accent-glow);
}
.stats-progress-fill.danger {
  background: linear-gradient(90deg, #ff2244, #ff6688);
  box-shadow: 0 0 6px rgba(255,34,68,0.3);
}

/* Bar chart for network quality */
.stats-bar-chart {
  display: flex;
  align-items: flex-end;
  gap: 14px;
}
.bar-chart-inner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
}
.bar-chart-bars {
  display: flex;
  align-items: flex-end;
  gap: 2px;
  height: 28px;
}
.bar-chart-bars span {
  display: block;
  width: 6px;
  border-radius: 1px 1px 0 0;
  background: rgba(0, 200, 216, 0.15);
  transition: height 0.5s ease, background 0.5s ease, box-shadow 0.5s ease;
  /* Heights set via JS */
}
.bar-chart-bars span.lit {
  background: var(--accent);
  box-shadow: 0 0 4px var(--accent-glow);
}
.bar-chart-bars span.lit-warn {
  background: #ffaa00;
  box-shadow: 0 0 4px rgba(255,170,0,0.3);
}
.bar-chart-bars span.lit-bad {
  background: #ff4466;
  box-shadow: 0 0 4px rgba(255,68,102,0.3);
}
.bar-chart-label {
  font-family: 'Share Tech Mono', monospace;
  font-size: 8px;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}
.bar-chart-quality {
  margin-left: auto;
  font-family: 'Share Tech Mono', monospace;
  font-size: 9px;
  color: var(--accent);
  text-shadow: 0 0 6px var(--accent-glow);
  letter-spacing: 0.08em;
  align-self: center;
}

/* Footer — pinned at bottom of panel */
.stats-footer {
  margin-top: auto;
  border-top: 1px solid rgba(0, 200, 216, 0.08);
  padding: 8px 16px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 8px;
  letter-spacing: 0.14em;
  color: var(--text-muted);
  text-transform: uppercase;
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}
.stats-footer-sep { color: var(--accent); opacity: 0.5; }


/* ====================================================
   Responsive — narrow screens (< 500px)
   ==================================================== */
@media (max-width: 520px) {
  .stats-panel { display: none !important; }

  .chat-panel {
    width: 100%;
    top: auto;
    bottom: 88px;
    height: 45vh;
    border-left: none;
    border-top: 1px solid rgba(0, 200, 216, 0.18);
  }
  .control-bar { left: 50%; transform: translateX(-50%); }
  .agent-state { top: 64px; }

  .image-popup-card {
    width: 220px;
  }
}
