/* ═══════════════════════════════════════════════════════════
   AISYAH JARVIS INTERFACE — CSS
   Iron Man HUD aesthetic  |  dark bg, cyan accent
═══════════════════════════════════════════════════════════ */

:root {
  --bg:        #000d1a;
  --bg2:       #001428;
  --cyan:      #00d4ff;
  --cyan-dim:  #005f7f;
  --cyan-glow: rgba(0,212,255,0.18);
  --blue:      #0066cc;
  --green:     #00ff88;
  --orange:    #ff9900;
  --red:       #ff3333;
  --text:      #9de4ff;
  --text-dim:  #3a7a99;
  --font-hud:  'Orbitron', sans-serif;
  --font-mono: 'Share Tech Mono', monospace;
  --panel-border: 1px solid rgba(0,212,255,0.25);
  --panel-bg: rgba(0,20,40,0.85);

  /* state colours */
  --col-idle:      var(--cyan);
  --col-listening: var(--green);
  --col-thinking:  var(--orange);
  --col-speaking:  #aa88ff;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { width: 100%; height: 100%; overflow: hidden; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font-mono);
  font-size: 12px;
  user-select: none;
  position: relative;
}

/* ══ BACKGROUND LAYERS ══════════════════════════════════════ */

.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(0,212,255,0.04) 1px, transparent 1px),
    linear-gradient(90deg, rgba(0,212,255,0.04) 1px, transparent 1px);
  background-size: 40px 40px;
}

.scan-line {
  position: fixed; inset: 0; z-index: 1; pointer-events: none;
  background: repeating-linear-gradient(
    0deg,
    transparent,
    transparent 3px,
    rgba(0,0,0,0.08) 3px,
    rgba(0,0,0,0.08) 4px
  );
  animation: scanMove 8s linear infinite;
}
@keyframes scanMove {
  0%   { background-position: 0 0; }
  100% { background-position: 0 100px; }
}

.vignette {
  position: fixed; inset: 0; z-index: 2; pointer-events: none;
  background: radial-gradient(ellipse at center,
    transparent 50%,
    rgba(0,0,10,0.7) 100%
  );
}

/* ══ HEADER ═════════════════════════════════════════════════ */

.hud-header {
  position: relative; z-index: 10;
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 20px;
  border-bottom: 1px solid rgba(0,212,255,0.3);
  background: linear-gradient(180deg, rgba(0,30,60,0.95) 0%, rgba(0,15,30,0.85) 100%);
  backdrop-filter: blur(6px);
}

.logo {
  font-family: var(--font-hud);
  font-size: 18px; font-weight: 900;
  color: var(--cyan);
  letter-spacing: 6px;
  text-shadow: 0 0 20px var(--cyan), 0 0 40px rgba(0,212,255,0.4);
}
.logo .bracket  { color: var(--cyan-dim); font-weight: 400; }
.logo .version  { font-size: 10px; font-weight: 400; margin-left: 6px;
                  color: var(--text-dim); letter-spacing: 2px; vertical-align: super; }

.status-bar { display: flex; gap: 10px; }

.status-chip {
  display: flex; align-items: center; gap: 5px;
  font-family: var(--font-hud); font-size: 9px; font-weight: 600;
  letter-spacing: 1.5px; color: var(--text-dim);
  padding: 3px 8px; border: 1px solid rgba(0,212,255,0.15);
  border-radius: 2px; transition: all 0.4s;
}
.status-chip.active {
  color: var(--cyan);
  border-color: rgba(0,212,255,0.5);
  background: rgba(0,212,255,0.06);
  text-shadow: 0 0 8px var(--cyan);
}

.chip-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.4s;
}
.status-chip.active .chip-dot {
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
  animation: dotPulse 2s ease-in-out infinite;
}
.status-chip.error .chip-dot {
  background: var(--red);
  box-shadow: 0 0 6px var(--red);
}

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

.header-right {
  display: flex; align-items: center; gap: 12px;
}

.clock {
  font-family: var(--font-hud); font-size: 14px; font-weight: 700;
  color: var(--cyan); letter-spacing: 3px;
  text-shadow: 0 0 10px var(--cyan);
}

.hdr-btn {
  background: none; border: 1px solid rgba(0,212,255,0.3);
  color: var(--cyan); font-size: 16px; cursor: pointer;
  width: 32px; height: 28px; border-radius: 2px;
  transition: all 0.2s; display: flex; align-items: center; justify-content: center;
}
.hdr-btn:hover { background: rgba(0,212,255,0.15); border-color: var(--cyan); }

/* ══ LAYOUT ════════════════════════════════════════════════ */

.layout {
  position: relative; z-index: 5;
  display: grid;
  grid-template-columns: 260px 1fr 260px;
  height: calc(100vh - 48px);
  overflow: hidden;
}

/* ══ PANELS ════════════════════════════════════════════════ */

.panel {
  display: flex; flex-direction: column;
  border-color: rgba(0,212,255,0.2);
  background: var(--panel-bg);
  backdrop-filter: blur(4px);
  overflow: hidden;
}
.log-panel  { border-right: var(--panel-border); }
.conv-panel { border-left:  var(--panel-border); }

.panel-hdr {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 12px;
  font-family: var(--font-hud); font-size: 9px; font-weight: 700;
  letter-spacing: 2px; color: var(--cyan);
  border-bottom: var(--panel-border);
  background: rgba(0,212,255,0.04);
  flex-shrink: 0;
}
.ph-icon { color: var(--cyan-dim); font-size: 8px; }
.panel-clear {
  margin-left: auto; background: none; border: none;
  color: var(--text-dim); cursor: pointer; font-size: 10px;
  transition: color 0.2s;
}
.panel-clear:hover { color: var(--red); }

/* Log list */
.log-list {
  flex: 1; overflow-y: auto; padding: 8px 10px;
  display: flex; flex-direction: column; gap: 3px;
}
.log-list::-webkit-scrollbar { width: 4px; }
.log-list::-webkit-scrollbar-track { background: transparent; }
.log-list::-webkit-scrollbar-thumb { background: var(--cyan-dim); border-radius: 2px; }

.log-entry {
  display: flex; gap: 6px; align-items: flex-start;
  font-size: 10px; line-height: 1.5;
  padding: 2px 4px; border-radius: 2px;
  animation: logFade 0.3s ease-out;
}
@keyframes logFade {
  from { opacity: 0; transform: translateX(-6px); }
  to   { opacity: 1; transform: translateX(0); }
}
.log-ts  { color: var(--text-dim); white-space: nowrap; flex-shrink: 0; }
.log-msg { color: var(--text); word-break: break-word; }
.log-entry.ok     .log-msg { color: var(--green); }
.log-entry.error  .log-msg { color: var(--red); }
.log-entry.warn   .log-msg { color: var(--orange); }
.log-entry.info   .log-msg { color: var(--text); }

/* Conversation */
.conv-list {
  flex: 1; overflow-y: auto; padding: 10px;
  display: flex; flex-direction: column; gap: 10px;
}
.conv-list::-webkit-scrollbar { width: 4px; }
.conv-list::-webkit-scrollbar-thumb { background: var(--cyan-dim); border-radius: 2px; }

.conv-msg {
  display: flex; flex-direction: column; gap: 3px;
  animation: msgSlide 0.3s ease-out;
}
@keyframes msgSlide {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.conv-label {
  font-family: var(--font-hud); font-size: 8px; font-weight: 700;
  letter-spacing: 1.5px;
}
.conv-msg.user  .conv-label { color: var(--text-dim); }
.conv-msg.aisyah .conv-label { color: var(--cyan); text-shadow: 0 0 6px var(--cyan); }
.conv-bubble {
  padding: 7px 10px; border-radius: 2px;
  font-size: 11px; line-height: 1.6;
  border-left: 2px solid;
}
.conv-msg.user   .conv-bubble { border-color: var(--text-dim); background: rgba(0,212,255,0.04); }
.conv-msg.aisyah .conv-bubble { border-color: var(--cyan);     background: rgba(0,212,255,0.08); color: #d0f4ff; }
.conv-meta {
  font-size: 9px; color: var(--text-dim);
}

/* ══ CENTER COLUMN ══════════════════════════════════════════ */

.center-col {
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 18px; padding: 16px 20px 12px;
  position: relative; overflow: hidden;
}

/* State label */
.state-label {
  font-family: var(--font-hud); font-size: 15px; font-weight: 700;
  letter-spacing: 8px; color: var(--cyan);
  text-shadow: 0 0 12px var(--cyan);
  transition: color 0.4s, text-shadow 0.4s;
}
body.state-listening .state-label { color: var(--green);  text-shadow: 0 0 12px var(--green);  }
body.state-thinking  .state-label { color: var(--orange); text-shadow: 0 0 12px var(--orange); }
body.state-speaking  .state-label { color: #aa88ff;       text-shadow: 0 0 12px #aa88ff;       }

/* ══ ORB ════════════════════════════════════════════════════ */

.orb-wrap {
  position: relative;
  width: 390px; height: 390px;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}

/* Rings */
.ring {
  position: absolute;
  border-radius: 50%;
  border: 1px solid rgba(0,212,255,0.35);
  transition: border-color 0.5s, box-shadow 0.5s;
}
.r1 { width: 390px; height: 390px; animation: spin1 12s linear infinite; border-style: dashed; }
.r2 { width: 330px; height: 330px; animation: spin2  8s linear infinite; }
.r3 { width: 270px; height: 270px; animation: spin1 15s linear infinite reverse;
      border-style: dotted; border-color: rgba(0,212,255,0.2); }
.r4 { width: 210px; height: 210px; animation: spin2  6s linear infinite; }

@keyframes spin1 { to { transform: rotate(360deg);  } }
@keyframes spin2 { to { transform: rotate(-360deg); } }

/* State: listening */
body.state-listening .ring { border-color: rgba(0,255,136,0.5); box-shadow: 0 0 10px rgba(0,255,136,0.1); }
body.state-thinking  .ring { border-color: rgba(255,153,0,0.5); box-shadow: 0 0 10px rgba(255,153,0,0.1); }
body.state-speaking  .ring { border-color: rgba(170,136,255,0.5); box-shadow: 0 0 10px rgba(170,136,255,0.1); }

/* Orbit dots */
.orbit-dot {
  position: absolute; width: 6px; height: 6px;
  border-radius: 50%; background: var(--cyan);
  box-shadow: 0 0 8px var(--cyan), 0 0 16px var(--cyan);
  transition: background 0.4s, box-shadow 0.4s;
}
.od1 { animation: orbitDot1 8s linear infinite; }
.od2 { animation: orbitDot2 12s linear infinite reverse; }

@keyframes orbitDot1 {
  0%   { transform: rotate(0deg)   translateX(165px); }
  100% { transform: rotate(360deg) translateX(165px); }
}
@keyframes orbitDot2 {
  0%   { transform: rotate(45deg)  translateX(195px); }
  100% { transform: rotate(405deg) translateX(195px); }
}

body.state-listening .orbit-dot { background: var(--green); box-shadow: 0 0 8px var(--green), 0 0 16px var(--green); }
body.state-thinking  .orbit-dot { background: var(--orange); box-shadow: 0 0 8px var(--orange), 0 0 16px var(--orange); }
body.state-speaking  .orbit-dot { background: #aa88ff; box-shadow: 0 0 8px #aa88ff, 0 0 16px #aa88ff; }

/* Waveform canvas (centered) */
#waveform {
  position: absolute; z-index: 2;
  width: 330px; height: 330px;
  border-radius: 50%;
}

/* Core */
.orb-core {
  position: absolute; z-index: 3;
  width: 105px; height: 105px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(circle, rgba(0,212,255,0.2) 0%, rgba(0,20,40,0.9) 70%);
  box-shadow: 0 0 20px rgba(0,212,255,0.4), inset 0 0 20px rgba(0,212,255,0.1);
  animation: corePulse 3s ease-in-out infinite;
  transition: box-shadow 0.5s;
}
.core-hex {
  font-size: 42px; color: var(--cyan);
  text-shadow: 0 0 15px var(--cyan);
  animation: hexSpin 20s linear infinite;
}

@keyframes corePulse {
  0%,100% { transform: scale(1);    box-shadow: 0 0 20px rgba(0,212,255,0.4), inset 0 0 20px rgba(0,212,255,0.1); }
  50%      { transform: scale(1.05); box-shadow: 0 0 35px rgba(0,212,255,0.7), inset 0 0 30px rgba(0,212,255,0.2); }
}
@keyframes hexSpin { to { transform: rotate(360deg); } }

body.state-listening .orb-core {
  background: radial-gradient(circle, rgba(0,255,136,0.25) 0%, rgba(0,20,40,0.9) 70%);
  box-shadow: 0 0 30px rgba(0,255,136,0.5), inset 0 0 20px rgba(0,255,136,0.1);
  animation: coreListening 0.6s ease-in-out infinite;
}
@keyframes coreListening {
  0%,100% { transform: scale(1);   }
  50%      { transform: scale(1.1); }
}

body.state-thinking .orb-core {
  background: radial-gradient(circle, rgba(255,153,0,0.2) 0%, rgba(0,20,40,0.9) 70%);
  box-shadow: 0 0 25px rgba(255,153,0,0.5), inset 0 0 20px rgba(255,153,0,0.1);
  animation: coreThinking 0.4s linear infinite;
}
@keyframes coreThinking {
  to { transform: rotate(360deg); }
}

body.state-speaking .orb-core {
  background: radial-gradient(circle, rgba(170,136,255,0.25) 0%, rgba(0,20,40,0.9) 70%);
  box-shadow: 0 0 30px rgba(170,136,255,0.5), inset 0 0 20px rgba(170,136,255,0.1);
}

/* ══ SPEECH BOX ═════════════════════════════════════════════ */

.speech-box {
  display: flex; flex-direction: column; gap: 4px; width: 100%; max-width: 460px;
  min-height: 48px; padding: 0 4px;
}
.speech-user, .speech-aisyah {
  font-size: 12px; line-height: 1.5;
  padding: 6px 10px; border-radius: 2px;
  transition: opacity 0.3s;
  min-height: 0;
}
.speech-user {
  color: var(--text-dim);
  border-left: 2px solid var(--text-dim);
  background: rgba(0,212,255,0.03);
}
.speech-user::before { content: "▸ "; color: var(--text-dim); }

.speech-aisyah {
  color: #d0f4ff;
  border-left: 2px solid var(--cyan);
  background: rgba(0,212,255,0.06);
  text-shadow: 0 0 2px rgba(0,212,255,0.3);
}
.speech-aisyah::before { content: "◈ AISYAH: "; color: var(--cyan); font-family: var(--font-hud); font-size: 9px; font-weight: 700; }

/* ══ CONTROLS ═══════════════════════════════════════════════ */

.controls-row {
  display: flex; align-items: center; gap: 20px;
}

/* Mic button */
.mic-btn {
  width: 88px; height: 88px; border-radius: 50%;
  border: 2px solid var(--cyan);
  background: radial-gradient(circle, rgba(0,212,255,0.08) 0%, rgba(0,13,26,0.9) 80%);
  color: var(--cyan); cursor: pointer;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
  transition: all 0.2s;
  box-shadow: 0 0 15px rgba(0,212,255,0.2), inset 0 0 15px rgba(0,212,255,0.05);
  position: relative; overflow: hidden;
}
.mic-btn::before {
  content: ''; position: absolute; inset: -2px;
  border-radius: 50%;
  border: 2px solid transparent;
  background: linear-gradient(var(--bg), var(--bg)) padding-box,
              linear-gradient(45deg, var(--cyan), transparent, var(--cyan)) border-box;
}
.mic-icon { font-size: 22px; line-height: 1; }
.mic-lbl  { font-family: var(--font-hud); font-size: 8px; font-weight: 700; letter-spacing: 2px; }

.mic-btn:hover,
.mic-btn.listening {
  background: radial-gradient(circle, rgba(0,255,136,0.15) 0%, rgba(0,13,26,0.9) 80%);
  border-color: var(--green);
  box-shadow: 0 0 25px rgba(0,255,136,0.4), inset 0 0 20px rgba(0,255,136,0.1);
  color: var(--green);
  transform: scale(1.06);
}
.mic-btn.listening .mic-icon { animation: micPulse 0.8s ease-in-out infinite; }
@keyframes micPulse {
  0%,100% { transform: scale(1);    opacity: 1;   }
  50%      { transform: scale(1.15); opacity: 0.7; }
}

/* Toggle */
.toggle-wrap {
  display: flex; flex-direction: column; align-items: center; gap: 4px;
}
.toggle-label {
  font-family: var(--font-hud); font-size: 7px; font-weight: 700;
  letter-spacing: 2px; color: var(--text-dim);
}
.toggle-switch { position: relative; width: 38px; height: 20px; cursor: pointer; }
.toggle-switch input { opacity: 0; width: 0; height: 0; }
.toggle-slider {
  position: absolute; inset: 0;
  background: rgba(0,212,255,0.1);
  border: 1px solid var(--cyan-dim);
  border-radius: 20px;
  transition: all 0.3s;
}
.toggle-slider::after {
  content: ''; position: absolute;
  top: 2px; left: 2px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--cyan-dim);
  transition: all 0.3s;
}
.toggle-switch input:checked + .toggle-slider {
  background: rgba(0,212,255,0.2);
  border-color: var(--cyan);
  box-shadow: 0 0 8px rgba(0,212,255,0.4);
}
.toggle-switch input:checked + .toggle-slider::after {
  left: calc(100% - 16px);
  background: var(--cyan);
  box-shadow: 0 0 6px var(--cyan);
}

/* ══ TEXT PROMPT ════════════════════════════════════════════ */

.text-prompt-row {
  width: 100%; max-width: 480px;
}
.prompt-wrap {
  display: flex; gap: 0;
  border: 1px solid rgba(0,212,255,0.35);
  border-radius: 2px;
  background: rgba(0,20,40,0.7);
  transition: border-color 0.2s, box-shadow 0.2s;
}
.prompt-wrap:focus-within {
  border-color: var(--cyan);
  box-shadow: 0 0 12px rgba(0,212,255,0.25);
}
.prompt-input {
  flex: 1; background: none; border: none; outline: none;
  color: var(--text); font-family: var(--font-mono); font-size: 12px;
  padding: 10px 14px; caret-color: var(--cyan);
  letter-spacing: 0.5px;
}
.prompt-input::placeholder { color: var(--text-dim); }
.prompt-send {
  background: rgba(0,212,255,0.1); border: none;
  border-left: 1px solid rgba(0,212,255,0.25);
  color: var(--cyan); font-size: 14px; cursor: pointer;
  padding: 0 16px; transition: all 0.2s;
}
.prompt-send:hover { background: rgba(0,212,255,0.25); }

/* ══ EMBED PANEL ════════════════════════════════════════════ */

.embed-panel {
  position: fixed; bottom: 0; left: 0; right: 0; z-index: 50;
  height: 0; overflow: hidden;
  border-top: 2px solid var(--cyan);
  background: var(--bg2);
  transition: height 0.4s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex; flex-direction: column;
  box-shadow: 0 -10px 40px rgba(0,212,255,0.15);
}
.embed-panel.open { height: 45vh; }

.embed-hdr {
  display: flex; align-items: center; padding: 6px 14px; gap: 10px;
  border-bottom: 1px solid rgba(0,212,255,0.2);
  background: rgba(0,212,255,0.05);
  flex-shrink: 0;
}
.embed-title {
  font-family: var(--font-hud); font-size: 9px; font-weight: 700;
  letter-spacing: 2px; color: var(--cyan); flex: 1;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.embed-actions { display: flex; gap: 6px; }
.emb-btn {
  background: none; border: 1px solid rgba(0,212,255,0.3);
  color: var(--text-dim); font-size: 10px; cursor: pointer;
  padding: 3px 10px; border-radius: 2px; transition: all 0.2s;
  font-family: var(--font-hud); letter-spacing: 1px;
}
.emb-btn:hover { color: var(--cyan); border-color: var(--cyan); background: rgba(0,212,255,0.1); }

.embed-resize-bar {
  height: 4px; cursor: ns-resize;
  background: linear-gradient(90deg, transparent, rgba(0,212,255,0.3), transparent);
  flex-shrink: 0;
}

#embed-frame {
  flex: 1; border: none; background: #fff;
  width: 100%;
}

/* ══ CAMERA PANEL ═══════════════════════════════════════════ */

.camera-panel {
  position: fixed; bottom: 20px; right: 20px; z-index: 60;
  width: 380px;
  border: 1px solid rgba(0,255,136,0.4);
  border-radius: 4px;
  background: #000;
  box-shadow: 0 0 30px rgba(0,255,136,0.2);
  overflow: hidden;
  transform: translateX(420px);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.camera-panel.open { transform: translateX(0); }

.cam-hdr {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px;
  background: rgba(0,255,136,0.08);
  border-bottom: 1px solid rgba(0,255,136,0.2);
  font-family: var(--font-hud); font-size: 9px; font-weight: 700;
  letter-spacing: 2px; color: var(--green);
}
.cam-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--green); box-shadow: 0 0 8px var(--green);
  animation: dotPulse 1s ease-in-out infinite;
  flex-shrink: 0;
}
.cam-hdr .emb-btn { margin-left: auto; }

#camera-feed {
  display: block; width: 100%; height: auto;
  background: #000;
  transform: scaleX(-1); /* mirror — natural selfie view */
}

/* ══ SCROLLBAR GLOBAL ═══════════════════════════════════════ */

::-webkit-scrollbar        { width: 4px; }
::-webkit-scrollbar-track  { background: transparent; }
::-webkit-scrollbar-thumb  { background: var(--cyan-dim); border-radius: 2px; }

/* ══ RESPONSIVE (single-col compact) ═══════════════════════ */

@media (max-width: 900px) {
  .layout {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr auto auto;
  }
  .log-panel  { display: none; }
  .conv-panel { max-height: 180px; border-left: none; border-top: var(--panel-border); }
}
