/* ═══════════════════════════════════════════════════════════════
   JARVIS AI — BioDockify Layout + Theme
   ═══════════════════════════════════════════════════════════════ */

:root {
  --bg:        #000000;
  --bg-card:   #0a0a0f;
  --bg-side:   #06060c;
  --bg-input:  #0d0d14;
  --border:    #1a1a24;
  --border-hi: #252530;
  --blue:      #0066FF;
  --blue2:     #0055DD;
  --blue-dim:  #003388;
  --blue-glow: rgba(0,102,255,0.1);
  --blue-bright: #3388FF;
  --amber:     #f0a030;
  --red:       #ff3355;
  --green:     #22cc66;
  --text:      #8899aa;
  --text-hi:   #dde4f0;
  --text-dim:  #445566;
  --white:     #ffffff;
  --font:      'Inter',-apple-system,BlinkMacSystemFont,'Segoe UI',sans-serif;
  --mono:      'JetBrains Mono','Fira Code','Cascadia Code',monospace;
}

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; background: var(--bg); color: var(--text); font-family: var(--font); overflow: hidden; font-size: 14px; }
::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* ═══════════════ APP LAYOUT ═══════════════ */
#app { display: flex; height: 100vh; }

/* ═══════════════ SIDEBAR ═══════════════ */
#sidebar {
  width: 240px; flex-shrink: 0;
  background: var(--bg-side);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  overflow-y: auto;
}

.sidebar-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 16px 4px;
}
.brand-icon { font-size: 20px; }
.brand-text { font-size: 16px; font-weight: 700; color: var(--white); letter-spacing: 1px; }
.brand-bio { color: var(--blue-bright); }

.sidebar-tagline {
  padding: 0 16px 14px;
  font-size: 11px; color: var(--text-dim);
}

.sidebar-nav { flex: 1; padding: 0 8px; }

.nav-section { margin-bottom: 16px; }

.nav-section-title {
  font-size: 10px; font-weight: 600; color: var(--text-dim);
  letter-spacing: 1.5px; padding: 8px 10px 4px;
}

.nav-item {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 10px; border-radius: 6px;
  color: var(--text); text-decoration: none;
  font-size: 13px; transition: all 0.15s;
  cursor: pointer;
}
.nav-item:hover { background: rgba(255,255,255,0.04); color: var(--text-hi); }
.nav-item.active { background: var(--blue-glow); color: var(--blue-bright); font-weight: 500; }
.nav-icon { font-size: 14px; width: 20px; text-align: center; }

.nav-cmd {
  display: block; width: 100%;
  padding: 6px 10px; border: none;
  background: transparent; border-radius: 4px;
  color: var(--amber); font-family: var(--mono);
  font-size: 12px; text-align: left;
  cursor: pointer; transition: all 0.15s;
}
.nav-cmd:hover { background: rgba(240,160,48,0.08); }
.nav-cmd.active { background: rgba(240,160,48,0.12); color: var(--white); }

.sys-row {
  display: flex; justify-content: space-between;
  padding: 4px 10px; font-size: 11px; font-family: var(--mono);
  color: var(--text-dim);
}
.sys-dot { font-size: 8px; }
.sys-dot.on { color: var(--green); text-shadow: 0 0 4px var(--green); }
.sys-dot.off { color: var(--red); }

.sidebar-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
}
.sidebar-link {
  font-size: 12px; color: var(--text-dim); text-decoration: none;
}
.sidebar-link:hover { color: var(--blue-bright); }

/* ═══════════════ MAIN WRAP ═══════════════ */
#main-wrap {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; overflow: hidden;
}

/* ═══════════════ TOP BAR ═══════════════ */
#topbar {
  display: flex; align-items: center; justify-content: space-between;
  height: 48px; padding: 0 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.tb-nav { display: flex; gap: 4px; }
.tb-link {
  padding: 6px 14px; border-radius: 6px;
  color: var(--text); text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: all 0.15s;
}
.tb-link:hover { color: var(--text-hi); background: rgba(255,255,255,0.04); }
.tb-link.active { color: var(--white); background: rgba(255,255,255,0.06); }

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

.tb-badge {
  padding: 3px 10px; border: 1px solid var(--border); border-radius: 4px;
  font-size: 11px; font-family: var(--mono); color: var(--text-dim);
}
.tb-status {
  font-size: 12px; color: var(--green); font-weight: 500;
}
.tb-status.offline { color: var(--red); }

/* ═══════════════ PAGE HEADER ═══════════════ */
#page-header {
  padding: 16px 24px 0;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
#page-header h1 {
  font-size: 20px; font-weight: 700; color: var(--white);
  margin-bottom: 12px;
}

.tab-bar { display: flex; gap: 0; }
.tab {
  padding: 10px 20px; border: none;
  background: transparent; border-bottom: 2px solid transparent;
  color: var(--text-dim); font-size: 13px; font-weight: 500;
  cursor: pointer; transition: all 0.15s;
  font-family: var(--font);
}
.tab:hover { color: var(--text); }
.tab.active { color: var(--white); border-bottom-color: var(--blue); }

/* ═══════════════ TAB CONTENT ═══════════════ */
.tab-content { display: none; flex: 1; overflow: hidden; }
.tab-content.active { display: flex; flex-direction: column; }

/* ═══════════════ CHAT AREA ═══════════════ */
#chat-area {
  flex: 1; display: flex; overflow: hidden;
}

#chat-center {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; padding: 20px;
  overflow-y: auto;
}

/* ── Reactor ── */
.reactor-wrap {
  display: flex; flex-direction: column; align-items: center;
  margin-bottom: 16px; flex-shrink: 0;
}

.reactor {
  position: relative; width: 120px; height: 120px;
  cursor: pointer; transition: transform 0.2s;
  filter: drop-shadow(0 0 15px rgba(0,102,255,0.25));
}
.reactor:hover { transform: scale(1.08); filter: drop-shadow(0 0 20px rgba(0,102,255,0.4)); }
.reactor:active { transform: scale(0.95); }

.reactor-svg { width: 100%; height: 100%; }
.ring { fill: none; stroke: var(--blue); stroke-width: 1.2; opacity: 0.35; }
.ring-outer { animation: spin 10s linear infinite; stroke-width: 1.5; opacity: 0.45; }
.ring-mid { animation: spin 6s linear infinite reverse; opacity: 0.25; stroke-dasharray: 8 4; }
.ring-inner { animation: spin 4s linear infinite; opacity: 0.2; }
.ring-seg { animation: spin 15s linear infinite; opacity: 0.15; stroke-width: 0.8; }
.ring-seg2 { animation: spin 9s linear infinite reverse; opacity: 0.1; stroke-width: 0.8; }
.core-glow { fill: var(--blue); opacity: 0.1; animation: pulse 2.5s ease-in-out infinite; filter: blur(2px); }
.core-inner { fill: var(--blue); opacity: 0.18; }
.core-dot { fill: var(--blue-bright); opacity: 0.9; filter: drop-shadow(0 0 4px var(--blue)); }

.reactor-pulse {
  position: absolute; inset: -20px; border-radius: 50%;
  border: 1px solid var(--blue); opacity: 0; pointer-events: none;
}
.reactor.pulsing .reactor-pulse { animation: ripple 1.2s ease-out; }
@keyframes spin { to { transform: rotate(360deg); } }
@keyframes pulse { 0%,100% { opacity:1; } 50% { opacity:0.4; } }
@keyframes ripple { 0% { transform: scale(0.7); opacity:0.4; } 100% { transform: scale(1.4); opacity:0; } }

.reactor.recording { filter: drop-shadow(0 0 20px rgba(255,51,85,0.5)); }
.reactor.recording .ring { stroke: var(--red); }
.reactor.recording .core-glow, .reactor.recording .core-inner, .reactor.recording .core-dot { fill: var(--red); }
.reactor.recording .reactor-pulse { border-color: var(--red); animation: ripple 0.8s ease-out infinite; }

.reactor-label {
  font-size: 10px; font-family: var(--mono); color: var(--text-dim);
  letter-spacing: 3px; margin-top: 6px;
}

/* ── Transcript ── */
.transcript-box {
  font-size: 13px; font-family: var(--mono); color: var(--text-hi);
  text-align: center; min-height: 18px; max-height: 40px;
  overflow-y: auto; width: 100%; margin-bottom: 8px;
}
.transcript-box:empty::after { content: 'Click reactor to speak'; color: var(--text-dim); font-size: 12px; }

/* ── Response ── */
.response-area {
  width: 100%; max-width: 700px;
  flex: 1; max-height: 50vh;
  overflow-y: auto; padding: 20px;
  background: var(--bg-card); border: 1px solid var(--border);
  border-radius: 8px;
}

#response-text {
  font-size: 14px; line-height: 1.8;
  white-space: pre-wrap; word-wrap: break-word;
  color: var(--text-hi);
}
#response-text:empty::after {
  content: 'Response will stream here...'; color: var(--text-dim); font-style: italic;
}

.tool-badge {
  display: inline-block; padding: 2px 8px; margin: 2px 0;
  background: var(--blue-glow); border: 1px solid var(--blue-dim);
  border-radius: 4px; font-size: 11px; font-family: var(--mono);
  color: var(--blue-bright);
}

.error-box {
  padding: 10px 14px; margin: 6px 0;
  background: rgba(255,51,85,0.05); border: 1px solid rgba(255,51,85,0.2);
  border-radius: 6px; color: var(--red); font-size: 13px;
}

.kill-btn {
  margin-top: 8px; padding: 5px 14px;
  background: rgba(255,51,85,0.06); border: 1px solid rgba(255,51,85,0.3);
  border-radius: 4px; color: var(--red);
  font-family: var(--mono); font-size: 11px;
  cursor: pointer; transition: all 0.15s;
}
.kill-btn:hover { background: rgba(255,51,85,0.15); }
.kill-btn.hidden { display: none; }

/* ── Tool Sidebar ── */
#tool-sidebar {
  width: 220px; flex-shrink: 0;
  border-left: 1px solid var(--border);
  padding: 12px; overflow-y: auto;
  background: var(--bg-card);
}

.ts-label {
  font-size: 10px; font-weight: 600; color: var(--text-dim);
  letter-spacing: 1.5px; margin-bottom: 8px;
}

.tool-log-box { font-size: 11px; font-family: var(--mono); }

.tool-entry {
  padding: 4px 6px; margin-bottom: 4px;
  border-left: 2px solid var(--blue-dim);
  color: var(--blue-bright); animation: fadeSlide 0.3s ease;
  word-break: break-all; line-height: 1.4;
}
.tool-entry.done { border-left-color: var(--green); color: var(--green); opacity: 0.5; }
@keyframes fadeSlide { from { opacity:0; transform:translateX(-4px); } to { opacity:1; transform:translateX(0); } }

/* ═══════════════ INPUT ═══════════════ */
#input-area {
  padding: 12px 24px 16px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}

.input-shell {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 8px; transition: border-color 0.15s;
}
.input-shell:focus-within { border-color: var(--blue-dim); }

#user-input {
  flex: 1; background: transparent; border: none; outline: none;
  color: var(--text-hi); font-family: var(--font); font-size: 14px;
  resize: none; line-height: 1.5; min-height: 22px; max-height: 80px;
}
#user-input::placeholder { color: var(--text-dim); }

.send-btn {
  width: 36px; height: 36px; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--blue); border: none; border-radius: 8px;
  color: var(--white); font-size: 14px; cursor: pointer;
  transition: all 0.15s;
}
.send-btn:hover { background: var(--blue2); transform: scale(1.05); }

/* ── Approval ── */
#approval-bar {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 8px; padding: 8px 14px;
  background: rgba(240,160,48,0.04); border: 1px solid rgba(240,160,48,0.2);
  border-radius: 6px;
}
#approval-bar.hidden { display: none; }
.appr-icon { font-size: 14px; }
.appr-msg { flex: 1; font-size: 12px; font-family: var(--mono); color: var(--amber); word-break: break-all; }
.appr-btn {
  padding: 5px 14px; border-radius: 4px; border: 1px solid;
  font-family: var(--mono); font-size: 11px; cursor: pointer;
}
.appr-btn.allow { border-color: var(--green); color: var(--green); background: rgba(34,204,102,0.04); }
.appr-btn.allow:hover { background: rgba(34,204,102,0.1); }
.appr-btn.deny { border-color: var(--red); color: var(--red); background: rgba(255,51,85,0.04); }
.appr-btn.deny:hover { background: rgba(255,51,85,0.1); }

/* ═══════════════ EVENTS TAB ═══════════════ */
.events-box {
  flex: 1; overflow-y: auto; padding: 20px;
  font-size: 12px; font-family: var(--mono);
}

/* ═══════════════ EMPTY STATE ═══════════════ */
.empty-state {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  color: var(--text-dim); gap: 8px;
}
.empty-icon { font-size: 40px; opacity: 0.3; }
.empty-state h3 { font-size: 16px; color: var(--text); }
.empty-state p { font-size: 13px; max-width: 400px; text-align: center; }

/* ═══════════════ RESPONSIVE ═══════════════ */
@media (max-width: 768px) {
  #sidebar { display: none; }
  #tool-sidebar { display: none; }
}
