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

:root {
  --bg: #0a0e17;
  --panel: #0d1520;
  --border: #1a2a3a;
  --cyan: #00e5ff;
  --cyan-dim: #00e5ff44;
  --cyan-glow: #00e5ff22;
  --gold: #f5c518;
  --gold-dim: #f5c51844;
  --text: #c0d0e0;
  --text-dim: #5a6a7a;
  --danger: #ff3d3d;
  --success: #00ff88;
}

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

body {
  font-family: 'Share Tech Mono', monospace;
  background: var(--bg);
  background-image:
    linear-gradient(rgba(0,229,255,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,229,255,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
  color: var(--text);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.scanlines {
  position: fixed;
  inset: 0;
  background: repeating-linear-gradient(0deg, transparent, transparent 2px, #00000011 2px, #00000011 4px);
  pointer-events: none;
  z-index: 999;
}

/* ── HEADER ── */
header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 20px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  z-index: 10;
}

.logo {
  font-family: 'Orbitron', sans-serif;
  font-weight: 900;
  font-size: 1.1rem;
  letter-spacing: 4px;
  color: var(--cyan);
  text-shadow: 0 0 10px var(--cyan-dim), 0 0 30px var(--cyan-glow);
}

.status-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--success);
  margin-left: 12px;
  animation: blink 2s infinite;
}

@keyframes blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.3; }
}

.status-text {
  margin-left: 6px;
  font-size: 0.7rem;
  color: var(--success);
  text-transform: uppercase;
  letter-spacing: 2px;
}

.clock {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.85rem;
  color: var(--cyan);
  letter-spacing: 2px;
}

.header-info {
  font-size: 0.7rem;
  color: var(--text-dim);
  letter-spacing: 1px;
}

.header-left, .header-right { display: flex; align-items: center; }
.header-center { position: absolute; left: 50%; transform: translateX(-50%); }

/* ── MAIN LAYOUT ── */
main {
  flex: 1;
  display: flex;
  gap: 1px;
  overflow: hidden;
}

.panel-left, .panel-right {
  width: 280px;
  display: flex;
  flex-direction: column;
  gap: 1px;
  overflow-y: auto;
}

.panel-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  position: relative;
}

/* ── WIDGETS ── */
.widget {
  background: var(--panel);
  border: 1px solid var(--border);
  padding: 12px;
}

.widget-title {
  font-family: 'Orbitron', sans-serif;
  font-size: 0.65rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 2px;
  color: var(--cyan);
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}

.icon { margin-right: 6px; }

/* ── CAMERA ── */
.camera-box {
  position: relative;
  border-radius: 4px;
  overflow: hidden;
  background: #000;
  aspect-ratio: 4/3;
  border: 1px solid var(--border);
}

#webcam {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transform: scaleX(-1);
}

.cam-overlay {
  position: absolute;
  top: 6px;
  left: 6px;
  font-size: 0.55rem;
  padding: 2px 6px;
  background: #00ff8833;
  color: var(--success);
  border: 1px solid var(--success);
  border-radius: 2px;
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── STATS ── */
.stats-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.stat {
  background: #0a0e1799;
  border: 1px solid var(--border);
  padding: 8px;
  text-align: center;
  border-radius: 4px;
}

.stat-label {
  display: block;
  font-size: 0.55rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 2px;
  margin-bottom: 4px;
}

.stat-value {
  display: block;
  font-family: 'Orbitron', sans-serif;
  font-size: 0.9rem;
  color: var(--cyan);
}

/* ── EMOTION ── */
.emotion-display { text-align: center; }

.emotion-face {
  font-size: 2rem;
  line-height: 1;
  margin-bottom: 4px;
}

.emotion-label {
  font-size: 0.7rem;
  color: var(--text-dim);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 6px;
}

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

.emotion-bar {
  height: 100%;
  background: var(--cyan);
  border-radius: 2px;
  width: 0%;
  transition: width 0.3s, background 0.3s;
}

/* ── CONTROLS ── */
.controls {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.ctrl-label {
  font-size: 0.75rem;
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
}

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

.ctrl-select {
  background: var(--bg);
  color: var(--cyan);
  border: 1px solid var(--border);
  padding: 4px 8px;
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.75rem;
  border-radius: 2px;
}

/* ── AI CORE (center) ── */
.ai-core {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.avatar-container {
  position: relative;
  width: 300px;
  height: 300px;
}

#avatar-canvas {
  width: 100%;
  height: 100%;
  border-radius: 12px;
}

.core-rings-overlay {
  position: absolute;
  inset: 0;
  pointer-events: none;
}

.core-rings {
  position: relative;
  width: 220px;
  height: 220px;
}

.core-rings-overlay .ring, .core-rings .ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.ring-1 {
  width: 220px;
  height: 220px;
  border-color: var(--cyan-dim);
  animation: rotate 20s linear infinite;
  border-style: dashed;
}

.ring-2 {
  width: 160px;
  height: 160px;
  border-color: var(--cyan);
  animation: rotate 12s linear infinite reverse;
  border-top-color: transparent;
  border-left-color: transparent;
}

.ring-3 {
  width: 100px;
  height: 100px;
  border-color: var(--gold-dim);
  animation: rotate 8s linear infinite;
  border-right-color: transparent;
}

.core-dot {
  display: none;
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: radial-gradient(circle, var(--cyan), transparent 70%);
  animation: core-pulse 2s ease-in-out infinite;
}
@media (max-width: 600px) {
  .core-dot { display: block; }
}

@keyframes rotate { to { transform: translate(-50%, -50%) rotate(360deg); } }

@keyframes core-pulse {
  0%, 100% { opacity: 0.5; transform: translate(-50%, -50%) scale(1); }
  50% { opacity: 1; transform: translate(-50%, -50%) scale(1.3); }
}

.core-label {
  font-family: 'Orbitron', sans-serif;
  font-size: 1.4rem;
  font-weight: 700;
  letter-spacing: 8px;
  color: var(--cyan);
  text-shadow: 0 0 20px var(--cyan-dim);
}

.core-status {
  font-size: 0.75rem;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
}

/* ── CORE STATES ── */
.ai-core.listening .core-dot {
  background: radial-gradient(circle, var(--success), transparent 70%);
  animation: core-pulse 0.8s ease-in-out infinite;
}
.ai-core.listening .ring-2 { border-color: var(--success); }
.ai-core.listening .core-label { color: var(--success); text-shadow: 0 0 20px #00ff8844; }

.ai-core.thinking .core-dot {
  background: radial-gradient(circle, var(--gold), transparent 70%);
  animation: core-pulse 0.5s ease-in-out infinite;
}
.ai-core.thinking .ring-1 { animation-duration: 3s; }
.ai-core.thinking .ring-2 { animation-duration: 2s; border-color: var(--gold); }
.ai-core.thinking .core-label { color: var(--gold); text-shadow: 0 0 20px var(--gold-dim); }

.ai-core.speaking .core-dot {
  background: radial-gradient(circle, var(--cyan), var(--gold), transparent 70%);
  animation: core-pulse 0.4s ease-in-out infinite alternate;
}
.ai-core.speaking .ring-2 { border-color: var(--gold); animation-duration: 4s; }
.ai-core.speaking .core-label { color: var(--gold); }

/* ── ACTION BAR ── */
.action-bar {
  display: flex;
  gap: 16px;
  margin-top: 24px;
}

.action-btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: var(--panel);
  color: var(--text-dim);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.action-btn:hover { border-color: var(--cyan); color: var(--cyan); }

.mic-btn:active, .mic-btn.active {
  border-color: var(--success);
  color: var(--success);
  background: #00ff8811;
  box-shadow: 0 0 20px #00ff8833;
  transform: scale(1.1);
}

.action-btn:disabled { opacity: 0.3; cursor: not-allowed; }

/* ── INTERIM BAR ── */
.interim-bar {
  margin-top: 12px;
  min-height: 24px;
  font-size: 0.8rem;
  color: var(--success);
  text-align: center;
  letter-spacing: 1px;
}

/* ── CHAT ── */
.chat-widget {
  flex: 1;
  display: flex;
  flex-direction: column;
}

.chat-history {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 8px 0;
  max-height: calc(100vh - 200px);
}

.welcome-msg {
  text-align: center;
  color: var(--text-dim);
  font-size: 0.7rem;
  padding: 20px 0;
  letter-spacing: 1px;
}

.msg {
  padding: 8px 10px;
  border-radius: 4px;
  font-size: 0.8rem;
  line-height: 1.5;
  max-width: 95%;
}

.msg.user {
  align-self: flex-end;
  background: #1a2a3a;
  border-left: 2px solid var(--cyan);
  color: var(--text);
}

.msg.assistant {
  align-self: flex-start;
  background: #1a1500;
  border-left: 2px solid var(--gold);
  color: #f0d080;
}

.msg .msg-time {
  display: block;
  font-size: 0.55rem;
  color: var(--text-dim);
  margin-top: 4px;
}

.chat-input-bar {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

#text-input {
  flex: 1;
  padding: 8px 10px;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-family: 'Share Tech Mono', monospace;
  font-size: 0.8rem;
  border-radius: 2px;
  outline: none;
}

#text-input:focus { border-color: var(--cyan); }

.send-btn {
  padding: 8px 12px;
  background: var(--cyan);
  color: var(--bg);
  border: none;
  border-radius: 2px;
  cursor: pointer;
  display: flex;
  align-items: center;
}

.send-btn:hover { background: #33eeff; }

/* ── WAVEFORM ── */
.waveform-canvas {
  width: 100%;
  max-width: 400px;
  height: 50px;
  margin-top: 8px;
  opacity: 0.7;
}

/* ── STT BADGE ── */
.stt-badge {
  margin-top: 8px;
  font-size: 0.55rem;
  color: var(--text-dim);
  letter-spacing: 2px;
  text-transform: uppercase;
  text-align: center;
}

/* ── ENHANCED GLOW ── */
.widget {
  box-shadow: 0 0 8px rgba(0,229,255,0.05);
  transition: box-shadow 0.3s;
}

.widget:hover {
  box-shadow: 0 0 15px rgba(0,229,255,0.1);
}

.msg.assistant {
  box-shadow: 0 0 8px rgba(245,197,24,0.08);
}

header {
  box-shadow: 0 2px 10px rgba(0,0,0,0.3);
}

/* ── ERROR MESSAGE ── */
.msg.error {
  align-self: center;
  background: #2a0a0a;
  border-left: 2px solid var(--danger);
  color: var(--danger);
  font-size: 0.7rem;
  opacity: 0.8;
}

/* ── CLEAR BUTTON ── */
.clear-btn {
  float: right;
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-dim);
  font-family: 'Orbitron', sans-serif;
  font-size: 0.5rem;
  letter-spacing: 1px;
  padding: 2px 6px;
  cursor: pointer;
  border-radius: 2px;
  transition: all 0.2s;
}
.clear-btn:hover {
  border-color: var(--danger);
  color: var(--danger);
}

/* ── THINKING DOTS ── */
.msg.thinking {
  opacity: 0.6;
  font-size: 1.2rem;
  letter-spacing: 4px;
}
.thinking-dots span {
  display: inline-block;
  animation: dot-bounce 1.4s infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes dot-bounce {
  0%, 80%, 100% { opacity: 0.3; }
  40% { opacity: 1; }
}

/* ── STREAMING MESSAGE ── */
.msg.streaming .msg-content {
  border-right: 2px solid var(--gold);
  padding-right: 2px;
  animation: cursor-blink 0.8s step-end infinite;
}
@keyframes cursor-blink {
  0%, 100% { border-color: var(--gold); }
  50% { border-color: transparent; }
}

/* ── SCROLLBAR ── */
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
::-webkit-scrollbar-track { background: transparent; }

/* ── RESPONSIVE TABLET ── */
@media (max-width: 900px) {
  main { flex-direction: column; overflow-y: auto; }
  .panel-left, .panel-right { width: 100%; max-height: 200px; flex-direction: row; overflow-x: auto; }
  .panel-left .widget, .panel-right .widget { min-width: 200px; }
  .panel-center { order: -1; min-height: 250px; }
  .core-label { font-size: 1rem; letter-spacing: 4px; }
  .avatar-container { width: 200px; height: 200px; }
  .ring-1 { width: 200px; height: 200px; }
  .ring-2 { width: 150px; height: 150px; }
  .ring-3 { width: 100px; height: 100px; }
}

/* ── RESPONSIVE MOBILE ── */
@media (max-width: 600px) {
  body { overflow: hidden; }
  header { padding: 4px 10px; }
  .logo { font-size: 0.75rem; letter-spacing: 2px; }
  .header-info { display: none; }
  .clock { font-size: 0.7rem; }

  main {
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - 36px);
  }

  /* Left panel — compact horizontal strip */
  .panel-left {
    width: 100%;
    order: 2;
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    gap: 0;
    flex-shrink: 0;
    max-height: 50px;
  }
  .panel-left .widget {
    min-width: auto;
    padding: 4px 8px;
    border: none;
    border-right: 1px solid var(--border);
    flex-shrink: 0;
  }
  .panel-left .widget-title { display: none; }
  /* Hide camera feed + emotion on mobile */
  .panel-left .widget:nth-child(1) { display: none; }
  .panel-left .widget:nth-child(3) { display: none; }
  /* Stats — single row */
  .panel-left .stats-grid {
    grid-template-columns: repeat(4, auto);
    gap: 4px;
  }
  .panel-left .stat { padding: 2px 6px; border: none; background: none; }
  .panel-left .stat-label { font-size: 0.45rem; margin-bottom: 0; }
  .panel-left .stat-value { font-size: 0.6rem; }
  /* Controls — horizontal */
  .panel-left .controls {
    flex-direction: row;
    gap: 6px;
    align-items: center;
    white-space: nowrap;
  }
  .panel-left .ctrl-label { font-size: 0.6rem; }
  .panel-left .ctrl-select { font-size: 0.6rem; padding: 2px 4px; }

  /* Avatar section — compact on mobile */
  .panel-center {
    order: 1;
    min-height: auto;
    padding: 6px 0;
    flex-shrink: 0;
  }
  .ai-core { gap: 2px; }
  .avatar-container { width: 130px; height: 130px; }
  #avatar-canvas { border-radius: 8px; }
  .ring-1 { width: 130px; height: 130px; }
  .ring-2 { width: 90px; height: 90px; }
  .ring-3 { width: 55px; height: 55px; }
  .core-label { font-size: 0.7rem; letter-spacing: 3px; }
  .core-status { font-size: 0.55rem; letter-spacing: 1px; }

  /* Action buttons */
  .action-bar { margin-top: 4px; gap: 10px; }
  .action-btn { width: 40px; height: 40px; }

  /* Waveform small + STT badge */
  .waveform-canvas { height: 25px; margin-top: 2px; }
  .stt-badge { font-size: 0.45rem; margin-top: 2px; }
  .interim-bar { font-size: 0.6rem; min-height: 16px; margin-top: 2px; }

  /* Chat takes remaining space */
  .panel-right {
    width: 100%;
    order: 3;
    flex: 1;
    min-height: 0;
    overflow: hidden;
  }
  .chat-widget {
    height: 100%;
    border: none;
  }
  .widget-title { font-size: 0.5rem; margin-bottom: 4px; padding-bottom: 3px; }
  .chat-history {
    max-height: none;
    flex: 1;
    min-height: 0;
  }
  .msg { font-size: 0.75rem; padding: 6px 8px; }
  .chat-input-bar { gap: 4px; }
  #text-input { font-size: 16px; padding: 8px; }
  .send-btn { padding: 8px 10px; }
}
