/* ═══════════════════════════════════════════════════════════
   ORION Digital — UI v2.0
   Design: Dark theme, glassmorphism, purple/blue accent
   ═══════════════════════════════════════════════════════════ */

:root {
  --bg-primary:    #0a0a0f;
  --bg-secondary:  #111118;
  --bg-card:       #16161f;
  --bg-hover:      #1e1e2a;
  --bg-input:      #1a1a24;
  --border:        rgba(255,255,255,0.07);
  --border-hover:  rgba(255,255,255,0.14);

  --accent:        #7c5cfc;
  --accent-hover:  #9070ff;
  --accent-glow:   rgba(124,92,252,0.3);
  --accent-2:      #00d4ff;
  --accent-3:      #ff6b9d;

  --text-primary:  #f0f0f8;
  --text-secondary:#8888aa;
  --text-muted:    #555570;

  --success:       #22c55e;
  --warning:       #f59e0b;
  --error:         #ef4444;
  --info:          #3b82f6;

  --sidebar-w:     260px;
  --topbar-h:      56px;
  --input-h:       120px;
  --radius:        12px;
  --radius-sm:     8px;
  --radius-lg:     16px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;

  --transition: 0.2s ease;
  --shadow: 0 4px 24px rgba(0,0,0,0.4);
  --shadow-lg: 0 8px 48px rgba(0,0,0,0.6);
}

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

html, body {
  height: 100%;
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 14px;
  line-height: 1.6;
  overflow: hidden;
}

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 4px; height: 4px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 2px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.2); }

/* ── Utilities ── */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.gap-2 { gap: 8px; }

/* ═══════════════════════════════════════════════════════════
   LOGIN SCREEN
   ═══════════════════════════════════════════════════════════ */

.login-screen {
  position: fixed; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: radial-gradient(ellipse at 50% 0%, rgba(124,92,252,0.15) 0%, var(--bg-primary) 70%);
  z-index: 1000;
}

.login-card {
  width: 380px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 40px;
  box-shadow: var(--shadow-lg), 0 0 80px rgba(124,92,252,0.1);
}

.login-logo {
  text-align: center;
  margin-bottom: 32px;
}

.logo-orb {
  width: 64px; height: 64px;
  margin: 0 auto 16px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  animation: spin 8s linear infinite;
  box-shadow: 0 0 40px var(--accent-glow);
}

.logo-orb-sm {
  width: 28px; height: 28px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--accent-2), var(--accent));
  animation: spin 8s linear infinite;
  flex-shrink: 0;
}

@keyframes spin { to { transform: rotate(360deg); } }

.login-logo h1 {
  font-size: 24px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.login-logo p { color: var(--text-secondary); font-size: 13px; margin-top: 4px; }

.login-form { display: flex; flex-direction: column; gap: 16px; }

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }

input[type="text"], input[type="password"], input[type="email"], textarea, select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font);
  font-size: 14px;
  padding: 10px 14px;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
  width: 100%;
}

input:focus, textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.login-error {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: var(--error);
  padding: 10px 14px;
  font-size: 13px;
}

.login-footer {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  margin-top: 24px;
}

/* ── Buttons ── */
.btn-primary {
  background: linear-gradient(135deg, var(--accent), #5a3fd4);
  border: none; border-radius: var(--radius-sm);
  color: #fff; cursor: pointer;
  font-family: var(--font); font-size: 14px; font-weight: 600;
  padding: 11px 20px;
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-primary:hover { background: linear-gradient(135deg, var(--accent-hover), #6a4fe4); transform: translateY(-1px); box-shadow: 0 4px 16px var(--accent-glow); }
.btn-primary:active { transform: translateY(0); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }

.btn-secondary {
  background: var(--bg-hover);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary); cursor: pointer;
  font-family: var(--font); font-size: 14px;
  padding: 10px 20px;
  transition: all var(--transition);
}
.btn-secondary:hover { border-color: var(--border-hover); background: var(--bg-card); }

.btn-full { width: 100%; }

.btn-icon {
  background: transparent; border: none;
  color: var(--text-secondary); cursor: pointer;
  font-size: 16px; padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  display: flex; align-items: center; justify-content: center;
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-hover); }

.btn-loader { animation: spin 1s linear infinite; display: inline-block; }

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

.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ═══════════════════════════════════════════════════════════
   SIDEBAR
   ═══════════════════════════════════════════════════════════ */

.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  transition: width var(--transition), transform var(--transition);
  overflow: hidden;
  position: relative;
  z-index: 100;
}

.sidebar.collapsed { width: 60px; }
.sidebar.collapsed .mode-label,
.sidebar.collapsed .mode-info,
.sidebar.collapsed .mode-name,
.sidebar.collapsed .mode-sub,
.sidebar.collapsed .section-label,
.sidebar.collapsed .agent-name,
.sidebar.collapsed .agent-model,
.sidebar.collapsed .cost-section,
.sidebar.collapsed .chats-section,
.sidebar.collapsed .user-details,
.sidebar.collapsed .sidebar-logo span { display: none; }
.sidebar.collapsed .mode-grid { flex-direction: column; gap: 4px; }
.sidebar.collapsed .mode-btn { padding: 8px; }
.sidebar.collapsed .agents-list { gap: 4px; }
.sidebar.collapsed .agent-item { justify-content: center; padding: 8px; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex; align-items: center; gap: 10px;
  font-size: 16px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
}

.sidebar-toggle {
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 18px; padding: 4px;
  border-radius: 4px; transition: all var(--transition);
  line-height: 1;
}
.sidebar-toggle:hover { color: var(--text-primary); }
.sidebar.collapsed .sidebar-toggle { transform: rotate(180deg); }

/* ── Mode Section ── */
.mode-section {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.mode-label, .section-label {
  font-size: 10px; font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase; letter-spacing: 0.8px;
  margin-bottom: 8px;
}

.mode-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: 6px;
}

.mode-btn {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-secondary); cursor: pointer;
  padding: 8px 6px;
  display: flex; flex-direction: column; align-items: center;
  gap: 2px; transition: all var(--transition);
  font-family: var(--font);
}
.mode-btn:hover { border-color: var(--border-hover); color: var(--text-primary); background: var(--bg-hover); }
.mode-btn.active {
  border-color: var(--accent);
  background: rgba(124,92,252,0.1);
  color: var(--text-primary);
  box-shadow: 0 0 12px var(--accent-glow);
}

.mode-icon { font-size: 14px; }
.mode-name { font-size: 11px; font-weight: 600; }
.mode-sub { font-size: 9px; color: var(--text-muted); }
.mode-btn.active .mode-sub { color: var(--accent); }

.mode-info {
  margin-top: 8px;
  font-size: 10px; color: var(--text-muted);
  text-align: center; line-height: 1.4;
}

/* ── Agents Section ── */
.agents-section {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.agents-list { display: flex; flex-direction: column; gap: 2px; }

.agent-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm);
  transition: background var(--transition);
  cursor: default;
}
.agent-item:hover { background: var(--bg-hover); }
.agent-item.active { background: rgba(124,92,252,0.08); }

.agent-emoji { font-size: 14px; flex-shrink: 0; }
.agent-name { font-size: 12px; flex: 1; color: var(--text-primary); }
.agent-model { font-size: 10px; color: var(--text-muted); }

.agent-status {
  width: 6px; height: 6px;
  border-radius: 50%; flex-shrink: 0;
}
.agent-status.idle { background: var(--text-muted); }
.agent-status.active { background: var(--success); box-shadow: 0 0 6px var(--success); animation: pulse 1.5s infinite; }
.agent-status.thinking { background: var(--warning); box-shadow: 0 0 6px var(--warning); animation: pulse 0.8s infinite; }
.agent-status.error { background: var(--error); }

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

/* ── Cost Section ── */
.cost-section {
  padding: 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.cost-bar-wrap { display: flex; flex-direction: column; gap: 4px; }

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

.cost-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success), var(--warning));
  border-radius: 2px;
  transition: width 0.5s ease, background 0.3s;
}
.cost-fill.warning { background: linear-gradient(90deg, var(--warning), var(--error)); }
.cost-fill.danger { background: var(--error); }

.cost-labels {
  display: flex; justify-content: space-between;
  font-size: 10px; color: var(--text-muted);
}
#cost-current { color: var(--text-secondary); font-weight: 600; }

/* ── Chats Section ── */
.chats-section {
  flex: 1; overflow: hidden;
  display: flex; flex-direction: column;
  padding: 12px;
}

.section-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 8px;
}

.chats-list {
  flex: 1; overflow-y: auto;
  display: flex; flex-direction: column; gap: 2px;
}

.chat-item {
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--transition);
  display: flex; align-items: center; gap: 8px;
  border: 1px solid transparent;
}
.chat-item:hover { background: var(--bg-hover); }
.chat-item.active {
  background: rgba(124,92,252,0.1);
  border-color: rgba(124,92,252,0.2);
}

.chat-item-icon { font-size: 14px; flex-shrink: 0; }
.chat-item-text {
  flex: 1; overflow: hidden;
  font-size: 12px; color: var(--text-secondary);
  white-space: nowrap; text-overflow: ellipsis;
}
.chat-item.active .chat-item-text { color: var(--text-primary); }

/* ── Sidebar Footer ── */
.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border);
  display: flex; align-items: center; gap: 8px;
  flex-shrink: 0;
}

.user-info { display: flex; align-items: center; gap: 8px; flex: 1; min-width: 0; }

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}

.user-details { min-width: 0; }
.user-name { font-size: 12px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 10px; color: var(--text-muted); }

/* ═══════════════════════════════════════════════════════════
   MAIN CONTENT
   ═══════════════════════════════════════════════════════════ */

.main {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden; min-width: 0;
}

/* ── Topbar ── */
.topbar {
  height: var(--topbar-h);
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px;
  flex-shrink: 0;
}

.topbar-left { display: flex; align-items: center; gap: 12px; min-width: 0; }
.topbar-right { display: flex; align-items: center; gap: 8px; flex-shrink: 0; }

.mobile-menu-btn { display: none; }

.chat-title-wrap { display: flex; align-items: center; gap: 8px; min-width: 0; }

.chat-title {
  font-size: 15px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  max-width: 300px;
}

.intent-badge {
  font-size: 10px; font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  background: rgba(124,92,252,0.15);
  border: 1px solid rgba(124,92,252,0.3);
  color: var(--accent);
  white-space: nowrap;
}

.model-indicator {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: var(--text-secondary);
  padding: 4px 10px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
}

.model-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--success);
  box-shadow: 0 0 6px var(--success);
  animation: pulse 2s infinite;
}

/* ── Messages Area ── */
.messages-area {
  flex: 1; overflow-y: auto;
  padding: 24px 0;
  display: flex; flex-direction: column;
}

/* ── Welcome Screen ── */
.welcome-screen {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px; text-align: center;
}

.welcome-orb {
  width: 80px; height: 80px;
  border-radius: 50%;
  background: conic-gradient(from 0deg, var(--accent), var(--accent-2), var(--accent-3), var(--accent));
  animation: spin 10s linear infinite;
  box-shadow: 0 0 60px var(--accent-glow);
  margin-bottom: 24px;
}

.welcome-screen h2 {
  font-size: 28px; font-weight: 700;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 8px;
}

.welcome-screen p { color: var(--text-secondary); margin-bottom: 32px; }

.welcome-chips {
  display: flex; flex-wrap: wrap; gap: 8px;
  justify-content: center; max-width: 600px;
  margin-bottom: 32px;
}

.chip {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  color: var(--text-secondary); cursor: pointer;
  font-family: var(--font); font-size: 12px;
  padding: 8px 14px;
  transition: all var(--transition);
}
.chip:hover {
  border-color: var(--accent);
  color: var(--text-primary);
  background: rgba(124,92,252,0.08);
  transform: translateY(-1px);
}

.welcome-models {
  display: flex; gap: 8px; flex-wrap: wrap; justify-content: center;
}

.model-tag {
  font-size: 11px; padding: 4px 10px;
  border-radius: 20px; font-weight: 600;
}
.model-tag.deepseek { background: rgba(0,212,255,0.1); color: var(--accent-2); border: 1px solid rgba(0,212,255,0.2); }
.model-tag.gemini { background: rgba(255,107,157,0.1); color: var(--accent-3); border: 1px solid rgba(255,107,157,0.2); }
.model-tag.sonnet { background: rgba(124,92,252,0.1); color: var(--accent); border: 1px solid rgba(124,92,252,0.2); }

/* ── Messages ── */
#messages-list {
  display: flex; flex-direction: column; gap: 0;
  max-width: 860px; width: 100%; margin: 0 auto;
  padding: 0 20px;
}

.message {
  display: flex; gap: 12px;
  padding: 16px 0;
  animation: fadeIn 0.3s ease;
}

@keyframes fadeIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: translateY(0); } }

.message.user { flex-direction: row-reverse; }

.msg-avatar {
  width: 32px; height: 32px;
  border-radius: 50%; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 700;
  margin-top: 2px;
}

.message.user .msg-avatar {
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  color: #fff;
}

.message.assistant .msg-avatar {
  background: linear-gradient(135deg, #1a1a2e, #16213e);
  border: 1px solid var(--border);
  font-size: 18px;
}

.msg-content { flex: 1; min-width: 0; max-width: 80%; }

.message.user .msg-content { align-items: flex-end; display: flex; flex-direction: column; }

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius);
  line-height: 1.7;
  word-break: break-word;
}

.message.user .msg-bubble {
  background: linear-gradient(135deg, var(--accent), #5a3fd4);
  color: #fff;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
}

.message.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text-primary);
  border-radius: var(--radius) var(--radius) var(--radius) 4px;
}

.msg-meta {
  display: flex; align-items: center; gap: 8px;
  margin-top: 4px; font-size: 10px; color: var(--text-muted);
}

.message.user .msg-meta { justify-content: flex-end; }

.msg-agent-badge {
  font-size: 10px; padding: 1px 6px;
  border-radius: 10px;
  background: rgba(124,92,252,0.15);
  color: var(--accent);
  border: 1px solid rgba(124,92,252,0.2);
}

/* ── Markdown in messages ── */
.msg-bubble h1, .msg-bubble h2, .msg-bubble h3 {
  margin: 12px 0 6px; font-weight: 600;
  color: var(--text-primary);
}
.msg-bubble h1 { font-size: 18px; }
.msg-bubble h2 { font-size: 16px; }
.msg-bubble h3 { font-size: 14px; }

.msg-bubble p { margin: 6px 0; }
.msg-bubble ul, .msg-bubble ol { margin: 6px 0; padding-left: 20px; }
.msg-bubble li { margin: 3px 0; }

.msg-bubble code {
  background: rgba(0,0,0,0.3);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 12px;
  padding: 1px 5px;
  color: var(--accent-2);
}

.msg-bubble pre {
  background: rgba(0,0,0,0.4);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow-x: auto;
  margin: 8px 0;
}

.msg-bubble pre code {
  background: none; border: none; padding: 0;
  font-size: 12px; color: var(--text-primary);
}

.msg-bubble table {
  width: 100%; border-collapse: collapse;
  margin: 8px 0; font-size: 12px;
}
.msg-bubble th, .msg-bubble td {
  padding: 6px 10px;
  border: 1px solid var(--border);
  text-align: left;
}
.msg-bubble th { background: var(--bg-hover); font-weight: 600; }

.msg-bubble a { color: var(--accent-2); text-decoration: none; }
.msg-bubble a:hover { text-decoration: underline; }

.msg-bubble strong { font-weight: 600; color: var(--text-primary); }
.msg-bubble em { font-style: italic; color: var(--text-secondary); }

.msg-bubble hr { border: none; border-top: 1px solid var(--border); margin: 12px 0; }

/* ── Tool Events ── */
.tool-event {
  max-width: 860px; width: 100%; margin: 0 auto;
  padding: 4px 20px;
}

.tool-event-inner {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 8px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px; color: var(--text-secondary);
  animation: fadeIn 0.2s ease;
}

.tool-event-icon { font-size: 14px; flex-shrink: 0; margin-top: 1px; }
.tool-event-name { font-weight: 600; color: var(--text-primary); }
.tool-event-detail { color: var(--text-muted); font-size: 11px; margin-top: 2px; }
.tool-event-preview {
  font-family: var(--font-mono); font-size: 11px;
  color: var(--text-muted); margin-top: 4px;
  max-height: 60px; overflow: hidden;
  white-space: pre-wrap; word-break: break-all;
}

.tool-event.success .tool-event-inner { border-color: rgba(34,197,94,0.2); }
.tool-event.error .tool-event-inner { border-color: rgba(239,68,68,0.2); }
.tool-event.running .tool-event-inner { border-color: rgba(245,158,11,0.2); }

/* ── Typing Indicator ── */
.typing-indicator {
  display: flex; align-items: center; gap: 4px;
  padding: 12px 16px;
}
.typing-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: typing 1.2s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-6px); opacity: 1; }
}

/* ── Ask User Modal ── */
.ask-user-modal {
  position: absolute;
  bottom: calc(var(--input-h) + 16px);
  left: 50%; transform: translateX(-50%);
  width: min(500px, calc(100% - 40px));
  z-index: 50;
}

.ask-user-card {
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow-lg), 0 0 30px var(--accent-glow);
  animation: fadeIn 0.3s ease;
}

.ask-user-icon { font-size: 24px; margin-bottom: 8px; }
.ask-user-question { font-size: 14px; font-weight: 500; margin-bottom: 12px; color: var(--text-primary); }
.ask-user-input { resize: none; margin-bottom: 12px; }
.ask-user-actions { display: flex; gap: 8px; justify-content: flex-end; }

/* ── Input Area ── */
.input-area {
  padding: 12px 20px 16px;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  flex-shrink: 0;
  position: relative;
}

.input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 8px 8px 8px 12px;
  transition: border-color var(--transition), box-shadow var(--transition);
}

.input-wrap:focus-within {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-glow);
}

.input-tools { display: flex; align-items: flex-end; }

.tool-btn {
  background: transparent; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 16px; padding: 6px;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}
.tool-btn:hover { color: var(--text-primary); background: var(--bg-hover); }

.message-input {
  flex: 1; background: transparent; border: none;
  color: var(--text-primary); font-family: var(--font);
  font-size: 14px; line-height: 1.6;
  outline: none; resize: none;
  max-height: 200px; overflow-y: auto;
  padding: 4px 0;
}

.message-input::placeholder { color: var(--text-muted); }

.input-actions { display: flex; align-items: flex-end; gap: 4px; }

.char-count { font-size: 10px; color: var(--text-muted); padding: 4px; }

.send-btn {
  width: 36px; height: 36px;
  background: linear-gradient(135deg, var(--accent), #5a3fd4);
  border: none; border-radius: var(--radius-sm);
  color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); flex-shrink: 0;
}
.send-btn:hover { background: linear-gradient(135deg, var(--accent-hover), #6a4fe4); transform: scale(1.05); }
.send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.input-footer {
  display: flex; align-items: center; justify-content: space-between;
  margin-top: 6px; padding: 0 2px;
}

.input-hint { font-size: 10px; color: var(--text-muted); }

.stop-btn {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  border-radius: var(--radius-sm);
  color: var(--error); cursor: pointer;
  font-family: var(--font); font-size: 11px;
  padding: 4px 10px;
  transition: all var(--transition);
}
.stop-btn:hover { background: rgba(239,68,68,0.2); }

/* ── File Attachments ── */
.attachments-preview {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 0 4px;
}

.attachment-chip {
  display: flex; align-items: center; gap: 6px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 4px 10px;
  font-size: 11px; color: var(--text-secondary);
}

.attachment-remove {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  font-size: 12px; padding: 0 2px;
}
.attachment-remove:hover { color: var(--error); }

/* ═══════════════════════════════════════════════════════════
   MODAL
   ═══════════════════════════════════════════════════════════ */

.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 500;
  animation: fadeIn 0.2s ease;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  width: min(560px, calc(100vw - 40px));
  max-height: 80vh;
  display: flex; flex-direction: column;
  box-shadow: var(--shadow-lg);
}

.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); cursor: pointer;
  font-size: 16px; padding: 4px;
  border-radius: 4px; transition: all var(--transition);
}
.modal-close:hover { color: var(--text-primary); background: var(--bg-hover); }

.modal-body {
  flex: 1; overflow-y: auto;
  padding: 24px;
  display: flex; flex-direction: column; gap: 24px;
}

.modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

.settings-section h4 {
  font-size: 12px; font-weight: 600;
  color: var(--text-muted); text-transform: uppercase;
  letter-spacing: 0.6px; margin-bottom: 12px;
}

.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }

.modes-detail, .agents-detail {
  display: flex; flex-direction: column; gap: 8px;
}

.mode-detail-item, .agent-detail-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 12px;
}

.mode-detail-item.active { border-color: var(--accent); background: rgba(124,92,252,0.05); }

.mode-detail-label { font-weight: 600; flex: 1; }
.mode-detail-desc { color: var(--text-muted); font-size: 11px; }
.mode-detail-cost { color: var(--warning); font-size: 11px; font-weight: 600; }

/* ═══════════════════════════════════════════════════════════
   RESPONSIVE
   ═══════════════════════════════════════════════════════════ */

@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    transform: translateX(-100%);
    z-index: 200;
    width: var(--sidebar-w) !important;
  }
  .sidebar.mobile-open { transform: translateX(0); }
  .mobile-menu-btn { display: flex !important; }
  .chat-title { max-width: 180px; }
  .model-indicator { display: none; }
  #messages-list { padding: 0 12px; }
  .input-area { padding: 8px 12px 12px; }
}

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

/* ── Toast notifications ── */
.toast-container {
  position: fixed; top: 16px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 1000;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  font-size: 12px; color: var(--text-primary);
  box-shadow: var(--shadow);
  animation: slideIn 0.3s ease;
  max-width: 300px;
}

.toast.success { border-color: rgba(34,197,94,0.3); }
.toast.error { border-color: rgba(239,68,68,0.3); }
.toast.info { border-color: rgba(59,130,246,0.3); }

@keyframes slideIn { from { transform: translateX(100%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
