/* ════════════════════════════════════════════════════════════
   HELIX-AI — Premium Dark Mode UI
   ════════════════════════════════════════════════════════════ */

:root {
  /* Farb-Palette */
  --bg-base:       #080c14;
  --bg-surface:    #0d1117;
  --bg-elevated:   #161b22;
  --bg-overlay:    #1c2330;
  --bg-hover:      #21293a;

  --accent:        #4f9eff;
  --accent-glow:   #4f9eff33;
  --accent-hover:  #6eb3ff;
  --green:         #3ddc84;
  --red:           #ff5e57;
  --yellow:        #f0c060;
  --purple:        #a78bfa;

  --text-primary:  #e6edf3;
  --text-secondary:#8b949e;
  --text-muted:    #484f58;

  --border:        #21293a;
  --border-accent: #4f9eff44;

  --radius:        12px;
  --radius-sm:     8px;
  --sidebar-w:     280px;

  --font-sans: 'Inter', system-ui, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

  --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

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

/* ─── LAYOUT ─────────────────────────────────────────────── */
#app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ─── SIDEBAR ─────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: width var(--transition), min-width var(--transition);
  position: relative;
  z-index: 10;
}
.sidebar.collapsed {
  width: 0;
  min-width: 0;
}

.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 16px 16px;
  border-bottom: 1px solid var(--border);
}
.helix-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}
.logo-icon {
  width: 36px;
  height: 36px;
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 18px;
  color: #fff;
  box-shadow: 0 0 16px var(--accent-glow);
}
.logo-text { display: flex; flex-direction: column; line-height: 1.1; }
.logo-main { font-size: 15px; font-weight: 700; letter-spacing: 2px; color: var(--text-primary); }
.logo-sub { font-size: 9px; font-weight: 500; letter-spacing: 2px; color: var(--accent); text-transform: uppercase; }

.sidebar-section {
  padding: 14px 12px;
  border-bottom: 1px solid var(--border);
  overflow: hidden;
}
.section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text-muted);
  display: block;
  margin-bottom: 8px;
}
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 8px;
}
.section-header .section-label { margin-bottom: 0; }

/* Model Select */
.model-select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 10px;
  font-family: var(--font-sans);
  font-size: 13px;
  cursor: pointer;
  outline: none;
  transition: border-color var(--transition);
}
.model-select:focus { border-color: var(--accent); }

/* Sessions List */
.sessions-list { display: flex; flex-direction: column; gap: 2px; max-height: 180px; overflow-y: auto; }
.session-item {
  padding: 7px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background var(--transition);
  overflow: hidden;
}
.session-item:hover { background: var(--bg-hover); }
.session-item.active { background: var(--bg-overlay); border-left: 2px solid var(--accent); }
.session-item .session-name {
  flex: 1;
  font-size: 12px;
  color: var(--text-secondary);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.session-item.active .session-name { color: var(--text-primary); }

/* Extensions */
.extensions-list { display: flex; flex-direction: column; gap: 3px; max-height: 150px; overflow-y: auto; }
.ext-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
  color: var(--text-secondary);
}
.ext-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--green);
  flex-shrink: 0;
}
.ext-dot.error { background: var(--red); }

.tools-count { font-size: 12px; color: var(--text-secondary); }

.sidebar-footer {
  margin-top: auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid var(--border);
}
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 8px var(--green);
  animation: pulse 2s infinite;
}
.status-dot.offline { background: var(--red); box-shadow: 0 0 8px var(--red); animation: none; }
#status-text { font-size: 11px; color: var(--text-muted); }

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

/* ─── MAIN ───────────────────────────────────────────────── */
.main {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background:
    radial-gradient(ellipse 80% 60% at 50% 0%, #0d1f3a 0%, transparent 60%),
    var(--bg-base);
}

/* ─── HEADER ─────────────────────────────────────────────── */
.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 24px;
  border-bottom: 1px solid var(--border);
  background: var(--bg-surface);
  backdrop-filter: blur(10px);
  flex-shrink: 0;
  gap: 16px;
}
.header-center { flex: 1; text-align: center; }
.header-title { font-size: 18px; font-weight: 700; letter-spacing: 3px; color: var(--text-primary); }
.header-subtitle { font-size: 11px; color: var(--text-muted); letter-spacing: 1px; }
.header-actions { display: flex; align-items: center; gap: 6px; }
.header-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 7px 10px;
  font-size: 15px;
  cursor: pointer;
  transition: all var(--transition);
}
.header-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: var(--accent); }
.header-btn.active { color: var(--accent); border-color: var(--accent); background: var(--accent-glow); }
.header-btn.recording { color: var(--red); border-color: var(--red); animation: pulse 1s infinite; }

/* ─── CHAT AREA ──────────────────────────────────────────── */
.chat-area {
  flex: 1;
  overflow-y: auto;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* Welcome */
.welcome-message {
  text-align: center;
  margin: auto;
  max-width: 550px;
  padding: 48px 24px;
}
.welcome-icon { font-size: 52px; margin-bottom: 16px; filter: drop-shadow(0 0 20px var(--accent)); }
.welcome-message h2 { font-size: 24px; font-weight: 700; margin-bottom: 12px; letter-spacing: -0.5px; }
.welcome-message p { color: var(--text-secondary); line-height: 1.7; margin-bottom: 28px; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; justify-content: center; }
.quick-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary);
  padding: 8px 16px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}
.quick-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
  background: var(--accent-glow);
  transform: translateY(-1px);
}

/* Messages */
.messages { display: flex; flex-direction: column; gap: 20px; max-width: 900px; margin: 0 auto; width: 100%; }

.message {
  display: flex;
  gap: 12px;
  animation: fadeInUp 0.3s ease;
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
.message.user { flex-direction: row-reverse; }

.message-avatar {
  width: 34px;
  height: 34px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  flex-shrink: 0;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
}
.message.user .message-avatar {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border: none;
}

.message-content { flex: 1; max-width: 80%; }
.message.user .message-content { display: flex; flex-direction: column; align-items: flex-end; }

.message-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 14px 18px;
  line-height: 1.7;
  color: var(--text-primary);
  width: fit-content;
  max-width: 100%;
}
.message.user .message-bubble {
  background: linear-gradient(135deg, #1a3a6e, #1e2d5a);
  border-color: var(--border-accent);
}

/* Markdown in Bubbles */
.message-bubble h1, .message-bubble h2, .message-bubble h3 {
  color: var(--text-primary);
  margin: 12px 0 6px;
  font-weight: 600;
}
.message-bubble h1 { font-size: 18px; }
.message-bubble h2 { font-size: 16px; }
.message-bubble h3 { font-size: 14px; }
.message-bubble p { margin: 6px 0; }
.message-bubble ul, .message-bubble ol { margin: 8px 0 8px 20px; }
.message-bubble li { margin: 3px 0; }
.message-bubble strong { color: var(--accent); font-weight: 600; }
.message-bubble a { color: var(--accent); text-decoration: underline; }

/* Code in Bubbles */
.message-bubble code {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 2px 6px;
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--green);
}
.message-bubble pre {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 16px;
  overflow-x: auto;
  margin: 10px 0;
  position: relative;
}
.message-bubble pre code {
  background: none;
  border: none;
  padding: 0;
  color: var(--text-primary);
  font-size: 13px;
}
.code-copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: var(--bg-overlay);
  border: 1px solid var(--border);
  border-radius: 4px;
  color: var(--text-muted);
  padding: 2px 8px;
  font-size: 11px;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--transition);
}
.message-bubble pre:hover .code-copy-btn { opacity: 1; }
.code-copy-btn:hover { color: var(--text-primary); }

/* Tool Calls */
.tool-call-card {
  background: var(--bg-base);
  border: 1px solid var(--border);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  margin: 8px 0;
  overflow: hidden;
}
.tool-call-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 14px;
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--accent);
}
.tool-call-header:hover { background: var(--accent-glow); }
.tool-call-arrow { transition: transform var(--transition); font-size: 10px; }
.tool-call-arrow.open { transform: rotate(90deg); }
.tool-call-body {
  padding: 0 14px 12px;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  display: none;
  overflow-x: auto;
}
.tool-call-body.visible { display: block; }
.tool-result-good { color: var(--green); }
.tool-result-bad { color: var(--red); }

/* Streaming cursor */
.streaming-cursor::after {
  content: '▋';
  animation: blink 0.7s infinite;
  color: var(--accent);
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

/* Thinking indicator */
.thinking-indicator {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 14px 18px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: fit-content;
  color: var(--text-muted);
  font-size: 13px;
}
.thinking-dots span {
  width: 6px;
  height: 6px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
  animation: think 1.4s infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes think {
  0%, 60%, 100% { opacity: 0.3; transform: scale(0.8); }
  30% { opacity: 1; transform: scale(1.1); }
}

/* ─── PERMISSIONS BAR ────────────────────────────────────── */
.permissions-bar {
  padding: 12px 24px;
  background: #1a2030;
  border-top: 1px solid var(--yellow);
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.perm-item {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 13px;
}
.perm-label { flex: 1; color: var(--yellow); }
.perm-approve { background: var(--green); border: none; border-radius: 6px; color: #000; padding: 4px 12px; font-size: 12px; cursor: pointer; font-weight: 600; }
.perm-deny { background: var(--red); border: none; border-radius: 6px; color: #fff; padding: 4px 12px; font-size: 12px; cursor: pointer; font-weight: 600; }

/* ─── INPUT AREA ─────────────────────────────────────────── */
.input-area {
  padding: 16px 24px 20px;
  background: var(--bg-surface);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.input-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 10px 14px;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-wrapper:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}
.message-input {
  flex: 1;
  background: none;
  border: none;
  outline: none;
  color: var(--text-primary);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.6;
  resize: none;
  max-height: 200px;
  overflow-y: auto;
}
.message-input::placeholder { color: var(--text-muted); }
.input-actions { display: flex; align-items: center; gap: 6px; flex-shrink: 0; }
.input-icon-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: color var(--transition);
}
.input-icon-btn:hover { color: var(--text-secondary); }

.send-btn {
  background: linear-gradient(135deg, var(--accent), var(--purple));
  border: none;
  border-radius: 10px;
  color: #fff;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: 0 0 12px var(--accent-glow);
}
.send-btn:hover { transform: scale(1.05); box-shadow: 0 0 20px var(--accent-glow); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.input-footer {
  display: flex;
  justify-content: space-between;
  padding: 6px 4px 0;
}
.input-hint { font-size: 11px; color: var(--text-muted); }

/* ─── BUTTONS ────────────────────────────────────────────── */
.icon-btn {
  background: none;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-muted);
  padding: 5px 8px;
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.icon-btn:hover { color: var(--text-primary); border-color: var(--accent); background: var(--accent-glow); }
.icon-btn.small { padding: 3px 7px; font-size: 16px; }

.primary-btn {
  background: var(--accent);
  border: none;
  border-radius: var(--radius-sm);
  color: #fff;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}
.primary-btn:hover { background: var(--accent-hover); transform: translateY(-1px); }

.secondary-btn {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  padding: 9px 18px;
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  font-family: var(--font-sans);
}
.secondary-btn:hover { border-color: var(--accent); color: var(--text-primary); }

/* ─── MODALS ─────────────────────────────────────────────── */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(6px);
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fadeIn 0.2s ease;
}
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
.modal-content {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  width: 90%;
  max-width: 620px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.5);
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 16px; font-weight: 600; }
.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text-primary); }
.modal-body { padding: 20px 24px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; }
.modal-input {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  transition: border-color var(--transition);
}
.modal-input:focus { border-color: var(--accent); }
.modal-textarea {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 10px 14px;
  font-family: var(--font-sans);
  font-size: 13px;
  outline: none;
  resize: vertical;
  min-height: 100px;
  transition: border-color var(--transition);
}
.modal-textarea:focus { border-color: var(--accent); }
.modal-divider { border: none; border-top: 1px solid var(--border); margin: 8px 0; }
.kb-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.kb-results { display: flex; flex-direction: column; gap: 8px; max-height: 300px; overflow-y: auto; }
.kb-item {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px;
  font-size: 13px;
}
.kb-item h4 { color: var(--text-primary); margin-bottom: 4px; }
.kb-item p { color: var(--text-secondary); font-size: 12px; }
.vault-key-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13px;
}
.vault-delete-btn {
  background: none;
  border: none;
  color: var(--red);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
}

/* ─── RESPONSIVE ─────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed;
    left: 0; top: 0; bottom: 0;
    z-index: 20;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.5);
  }
  .sidebar.collapsed { transform: translateX(-100%); width: var(--sidebar-w); min-width: var(--sidebar-w); }
  #sidebar-open { display: flex !important; }
  .message-content { max-width: 95%; }
  .chat-area { padding: 16px; }
}

/* ─── HEALTH BAR ─────────────────────────────────────────── */
.health-bar {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.health-stat {
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  padding: 3px 6px;
  background: var(--bg-elevated);
  border-radius: 4px;
  border: 1px solid var(--border);
  display: block;
  transition: color var(--transition);
}
.health-stat:hover { color: var(--text-secondary); }

/* ─── ACTIVITY FEED ──────────────────────────────────────── */
.activity-feed {
  display: flex;
  flex-direction: column;
  gap: 3px;
  max-height: 120px;
  overflow-y: auto;
}
.activity-entry {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 4px 6px;
  background: var(--bg-elevated);
  border-radius: 5px;
  border-left: 2px solid var(--accent);
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  animation: fadeInUp 0.2s ease;
  cursor: help;
  overflow: hidden;
}
.activity-entry:hover { color: var(--text-primary); background: var(--bg-hover); }
.activity-icon { flex-shrink: 0; font-size: 12px; }
.activity-name {
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
