/* JARVIS HUD Theme — Dark + Amber/Gold */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@300;400;500;600&family=Inter:wght@300;400;500;600&display=swap');

:root {
  --bg-primary: #050505;
  --bg-secondary: #0a0f1a;
  --bg-card: #0d1525;
  --bg-input: #111827;
  --border: rgba(245, 158, 11, 0.15);
  --border-active: rgba(245, 158, 11, 0.4);
  --amber: #f59e0b;
  --amber-dim: rgba(245, 158, 11, 0.6);
  --amber-glow: rgba(245, 158, 11, 0.1);
  --text-primary: #e5e7eb;
  --text-secondary: #9ca3af;
  --text-muted: #6b7280;
  --accent-green: #10b981;
  --accent-red: #ef4444;
  --accent-blue: #3b82f6;
  --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
  --font-sans: 'Inter', -apple-system, sans-serif;
}

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

body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100vh;
  overflow: hidden;
}

/* Layout */
.app {
  display: grid;
  grid-template-rows: 48px 1fr 64px;
  grid-template-columns: 280px 1fr;
  height: 100vh;
  gap: 1px;
  background: rgba(245, 158, 11, 0.05);
}

/* Header */
.header {
  grid-column: 1 / -1;
  background: var(--bg-secondary);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.header-logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.header-logo .arc {
  width: 28px;
  height: 28px;
  border: 2px solid var(--amber);
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 3s linear infinite;
}

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

.header-logo h1 {
  font-family: var(--font-mono);
  font-size: 16px;
  font-weight: 600;
  color: var(--amber);
  letter-spacing: 4px;
}

.header-status {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
}

.header-status .dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-green);
}

/* Sidebar — Tool Panel */
.sidebar {
  background: var(--bg-secondary);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
}

.sidebar-section {
  padding: 12px 14px 8px;
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 2px;
  color: var(--amber-dim);
  text-transform: uppercase;
}

.session-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 8px;
}

.session-item {
  padding: 8px 10px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: all 0.15s;
}

.session-item:hover { background: var(--amber-glow); color: var(--text-primary); }
.session-item.active { background: rgba(245, 158, 11, 0.12); color: var(--amber); border-left: 2px solid var(--amber); }

.new-session-btn {
  margin: 8px;
  padding: 8px;
  background: transparent;
  border: 1px dashed var(--border);
  border-radius: 6px;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 12px;
  font-family: var(--font-sans);
  transition: all 0.15s;
}

.new-session-btn:hover { border-color: var(--amber); color: var(--amber); }

/* Tool execution feed */
.tool-feed {
  border-top: 1px solid var(--border);
  padding: 4px 0;
  max-height: 300px;
  overflow-y: auto;
}

.tool-item {
  padding: 6px 14px;
  font-family: var(--font-mono);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-muted);
}

.tool-item .icon { font-size: 12px; }
.tool-item.running { color: var(--amber); }
.tool-item.success { color: var(--accent-green); }
.tool-item.error { color: var(--accent-red); }

/* Chat Panel */
.chat-panel {
  background: var(--bg-primary);
  overflow-y: auto;
  padding: 20px 24px;
  scroll-behavior: smooth;
}

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

.message {
  max-width: 85%;
  margin-bottom: 16px;
  animation: fadeIn 0.2s ease-out;
}

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

.message.user {
  margin-left: auto;
}

.message.user .bubble {
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--border);
  border-radius: 14px 14px 4px 14px;
  padding: 10px 16px;
  font-size: 14px;
  line-height: 1.5;
}

.message.assistant .bubble {
  background: var(--bg-card);
  border: 1px solid rgba(255,255,255,0.04);
  border-radius: 14px 14px 14px 4px;
  padding: 12px 16px;
  font-size: 14px;
  line-height: 1.6;
}

.message.assistant .bubble p { margin-bottom: 8px; }
.message.assistant .bubble p:last-child { margin-bottom: 0; }
.message.assistant .bubble ul, .message.assistant .bubble ol { padding-left: 20px; margin-bottom: 8px; }
.message.assistant .bubble code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: rgba(245, 158, 11, 0.08);
  padding: 2px 6px;
  border-radius: 3px;
  color: var(--amber);
}
.message.assistant .bubble pre {
  background: var(--bg-secondary);
  padding: 12px;
  border-radius: 6px;
  overflow-x: auto;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 12px;
  line-height: 1.5;
}
.message.assistant .bubble strong { color: var(--amber); font-weight: 500; }

.message .label {
  font-size: 10px;
  font-family: var(--font-mono);
  color: var(--text-muted);
  margin-bottom: 4px;
  letter-spacing: 1px;
  text-transform: uppercase;
}

.message.user .label { text-align: right; }

/* Tool call inline */
.tool-call-inline {
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 12px;
  margin: 8px 0;
  font-family: var(--font-mono);
  font-size: 11px;
}

.tool-call-inline .tool-name {
  color: var(--amber);
  font-weight: 500;
}

.tool-call-inline .tool-status {
  float: right;
  font-size: 10px;
}

/* Typing indicator */
.typing-indicator {
  display: inline-flex;
  gap: 4px;
  padding: 8px 0;
}

.typing-indicator span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--amber-dim);
  animation: pulse 1.2s infinite;
}

.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes pulse {
  0%, 80%, 100% { opacity: 0.3; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1); }
}

/* Input Bar */
.input-bar {
  grid-column: 1 / -1;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
}

.voice-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
  position: relative;
}

.voice-btn svg { width: 18px; height: 18px; fill: var(--text-muted); transition: fill 0.2s; }
.voice-btn:hover { border-color: var(--amber); }
.voice-btn:hover svg { fill: var(--amber); }

/* Voice states */
.voice-btn.listening {
  border-color: var(--accent-red);
  animation: voicePulse 1.5s infinite;
}
.voice-btn.listening svg { fill: var(--accent-red); }

.voice-btn.thinking {
  border-color: var(--amber);
  animation: voiceSpin 2s linear infinite;
}

.voice-btn.speaking {
  border-color: var(--accent-green);
}
.voice-btn.speaking svg { fill: var(--accent-green); }

@keyframes voicePulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.4); }
  50% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
}

@keyframes voiceSpin {
  to { border-top-color: transparent; transform: rotate(360deg); }
}

.input-text {
  flex: 1;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 10px 16px;
  color: var(--text-primary);
  font-size: 14px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.2s;
}

.input-text:focus { border-color: var(--amber); }
.input-text::placeholder { color: var(--text-muted); }

.send-btn {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  border: none;
  background: var(--amber);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}

.send-btn:hover { background: #d97706; transform: scale(1.05); }
.send-btn:disabled { opacity: 0.3; cursor: default; transform: none; }
.send-btn svg { width: 18px; height: 18px; fill: #000; }

/* Attach button */
.attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: 2px solid var(--border);
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  flex-shrink: 0;
}
.attach-btn svg { width: 18px; height: 18px; color: var(--text-muted); transition: color 0.2s; }
.attach-btn:hover { border-color: var(--amber); }
.attach-btn:hover svg { color: var(--amber); }

/* Input wrapper with attached files */
.input-wrapper {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.input-wrapper .input-text {
  width: 100%;
}

.attached-files {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
  padding: 0;
}

.attached-files:empty { display: none; }

.attached-files .file-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 3px 10px 3px 8px;
  font-size: 11px;
  font-family: var(--font-mono);
  color: var(--amber);
  margin-bottom: 4px;
  max-width: 200px;
}

.attached-files .file-chip .file-icon { font-size: 13px; }

.attached-files .file-chip .file-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.attached-files .file-chip .file-remove {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 14px;
  padding: 0 2px;
  line-height: 1;
  transition: color 0.15s;
}
.attached-files .file-chip .file-remove:hover { color: var(--accent-red); }

/* Responsive */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}

/* Welcome screen */
.welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  text-align: center;
  gap: 16px;
}

.welcome .logo-ring {
  width: 80px;
  height: 80px;
  border: 3px solid var(--amber);
  border-top-color: transparent;
  border-radius: 50%;
  animation: spin 3s linear infinite;
}

.welcome h2 {
  font-family: var(--font-mono);
  font-size: 24px;
  color: var(--amber);
  letter-spacing: 6px;
  font-weight: 300;
}

.welcome p {
  color: var(--text-muted);
  font-size: 13px;
  max-width: 400px;
  line-height: 1.6;
}

/* Settings Modal */
.modal-overlay {
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal {
  background: var(--bg-secondary);
  border: 1px solid var(--border-active);
  border-radius: 12px;
  width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5), 0 0 40px rgba(245,158,11,0.05);
}

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

.modal-header h2 {
  font-family: var(--font-mono);
  font-size: 14px;
  color: var(--amber);
  letter-spacing: 2px;
  text-transform: uppercase;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 22px;
  cursor: pointer;
  padding: 0 4px;
  transition: color 0.15s;
}
.modal-close:hover { color: var(--text-primary); }

.modal-tabs {
  display: flex;
  padding: 0 20px;
  border-bottom: 1px solid var(--border);
}

.modal-tabs .tab {
  background: none;
  border: none;
  padding: 10px 16px;
  color: var(--text-muted);
  font-size: 12px;
  font-family: var(--font-mono);
  letter-spacing: 1px;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.modal-tabs .tab.active {
  color: var(--amber);
  border-bottom-color: var(--amber);
}
.modal-tabs .tab:hover { color: var(--text-primary); }

.modal-body { padding: 16px 20px; }

.tab-content { display: none; }
.tab-content.active { display: block; }

.setting-group {
  margin-bottom: 16px;
}

.setting-group label {
  display: block;
  font-size: 12px;
  font-family: var(--font-mono);
  color: var(--text-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.5px;
}

.setting-group select,
.setting-group input[type="text"] {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 8px 12px;
  color: var(--text-primary);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  transition: border-color 0.15s;
}

.setting-group select:focus { border-color: var(--amber); }

.setting-group select option {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.setting-group input[type="range"] {
  width: 100%;
  -webkit-appearance: none;
  height: 4px;
  background: var(--bg-input);
  border-radius: 2px;
  outline: none;
}

.setting-group input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--amber);
  cursor: pointer;
  border: 2px solid var(--bg-secondary);
}

.slider-val {
  float: right;
  color: var(--amber);
  font-weight: 500;
}

.slider-hint {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  display: block;
}

.setting-group input[type="checkbox"] {
  accent-color: var(--amber);
  margin-right: 6px;
}

.test-voice-btn {
  width: 100%;
  padding: 10px;
  background: rgba(245, 158, 11, 0.1);
  border: 1px solid var(--amber);
  border-radius: 8px;
  color: var(--amber);
  font-size: 13px;
  font-family: var(--font-mono);
  cursor: pointer;
  transition: all 0.15s;
  margin-top: 8px;
}
.test-voice-btn:hover { background: rgba(245, 158, 11, 0.2); }

.modal-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
}

.save-settings-btn {
  padding: 8px 24px;
  background: var(--amber);
  border: none;
  border-radius: 6px;
  color: #000;
  font-weight: 600;
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s;
}
.save-settings-btn:hover { background: #d97706; }
