/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: #000000;
  color: #f1f5f9;
  height: 100vh;
  overflow: hidden;
  display: flex;
}
::selection { background: rgba(239, 68, 68, 0.3); color: #fff; }
.hidden { display: none !important; }

/* ── Scrollbar Hide ── */
.scroll-hide::-webkit-scrollbar { display: none; }
.scroll-hide { -ms-overflow-style: none; scrollbar-width: none; }

/* ── Glassmorphism ── */
.glass {
  background: rgba(9, 9, 11, 0.75);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid rgba(220, 38, 38, 0.15);
}
.glass-card {
  background: rgba(9, 9, 11, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(220, 38, 38, 0.12);
}
.glass-ai {
  background: rgba(24, 6, 8, 0.7);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(220, 38, 38, 0.2);
}

/* ── Glow Effects ── */
.glow-crimson { box-shadow: 0 0 20px rgba(220, 38, 38, 0.15), 0 0 60px rgba(220, 38, 38, 0.05); }
.glow-crimson-sm { box-shadow: 0 0 12px rgba(220, 38, 38, 0.12); }
.glow-crimson-text { text-shadow: 0 0 40px rgba(220, 38, 38, 0.3), 0 0 80px rgba(220, 38, 38, 0.1); }

/* ── Sidebar Overlay ── */
.sidebar-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px); z-index: 30;
  opacity: 0; visibility: hidden; transition: all 0.3s ease;
}
.sidebar-overlay.active { opacity: 1; visibility: visible; }

/* ── Sidebar ── */
.sidebar-panel {
  width: 260px; height: 100vh;
  background: #09090b;
  border-right: 1px solid rgba(220,38,38,0.12);
  display: flex; flex-direction: column;
  position: fixed; left: 0; top: 0; bottom: 0; z-index: 40;
  transform: translateX(-100%);
  transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
}
.sidebar-panel.open { transform: translateX(0); }
.sidebar-inner { display: flex; flex-direction: column; flex: 1; min-height: 0; }
.sidebar-close-btn {
  display: flex; position: absolute; top: 12px; right: 12px;
  width: 28px; height: 28px; border-radius: 8px;
  border: none; background: none;
  color: rgba(255,255,255,0.3); cursor: pointer;
  align-items: center; justify-content: center;
  transition: all 0.2s;
}
.sidebar-close-btn:hover { color: rgba(255,255,255,0.7); background: rgba(255,255,255,0.05); }

/* ── Sidebar Scroll ── */
.sidebar-scroll {
  flex: 1; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(220,38,38,0.15) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(220,38,38,0.2); border-radius: 4px; }

/* ── History Items ── */
.history-item .delete-btn { opacity: 0; transition: opacity 0.2s ease; }
.history-item:hover .delete-btn { opacity: 1; }

/* ── Main Area ── */
.main-area {
  flex: 1; display: flex; flex-direction: column;
  min-width: 0; position: relative;
  background: #000000;
}
/* ── Top Header ── */
.top-header {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid rgba(220,38,38,0.08);
  background: rgba(9,9,11,0.8);
  backdrop-filter: blur(16px);
}

/* ── Welcome Screen ── */
.welcome-screen {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 72px 24px 48px; text-align: center;
  overflow-y: auto;
}
.welcome-logo { animation: logo-pulse 4s ease-in-out infinite; }
@keyframes logo-pulse {
  0%, 100% { filter: drop-shadow(0 0 30px rgba(220,38,38,0.15)); }
  50% { filter: drop-shadow(0 0 60px rgba(220,38,38,0.3)); }
}
.welcome-cards {
  display: grid; grid-template-columns: 1fr;
  gap: 12px; width: 100%; max-width: 32rem;
}
@media (min-width: 640px) { .welcome-cards { grid-template-columns: repeat(3, 1fr); } }
.welcome-card { border-radius: 12px; padding: 16px; text-align: left; }

/* ── Chat Feed ── */
.chat-feed {
  flex: 1; display: flex; flex-direction: column;
  overflow: hidden;
}
.messages-container {
  flex: 1; overflow-y: auto;
  padding: 24px 16px;
  scrollbar-width: none;
}
.messages-container::-webkit-scrollbar { display: none; }

/* ── Input Area ── */
.input-area {
  flex-shrink: 0;
  padding: 0 16px 16px;
  background: linear-gradient(to top, #000000, transparent);
}
.input-container { max-width: 56rem; margin: 0 auto; }
.input-bar {
  border-radius: 16px; padding: 12px 16px;
  display: flex; align-items: flex-end; gap: 12px;
  border: 1px solid rgba(220,38,38,0.25);
  transition: all 0.3s ease;
}
.input-bar:focus-within {
  border-color: rgba(220,38,38,0.6);
  box-shadow: 0 0 24px rgba(220,38,38,0.12);
}
.input-textarea {
  flex: 1; background: none; border: none; outline: none;
  resize: none; color: rgba(255,255,255,0.8);
  font-size: 14px; line-height: 1.6;
  padding: 4px 0; max-height: 120px;
  font-family: inherit;
}
.input-textarea::placeholder { color: rgba(255,255,255,0.2); }
.input-icon-btn {
  flex-shrink: 0; width: 36px; height: 36px;
  border-radius: 10px; border: none; background: none;
  color: rgba(255,255,255,0.2); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 15px; transition: all 0.2s;
}
.input-icon-btn:hover { background: rgba(220,38,38,0.1); color: #ef4444; }
.input-send-btn {
  flex-shrink: 0; width: 40px; height: 40px;
  border-radius: 12px; border: none; cursor: pointer;
  background: rgba(220,38,38,0.8); color: white;
  display: flex; align-items: center; justify-content: center;
  font-size: 16px; transition: all 0.25s ease;
}
.input-send-btn:not(:disabled):hover {
  box-shadow: 0 0 32px rgba(220,38,38,0.4);
}
.input-send-btn:not(:disabled).active {
  box-shadow: 0 0 24px rgba(220,38,38,0.35), 0 0 48px rgba(220,38,38,0.1);
}
.input-send-btn:disabled { opacity: 0.3; cursor: not-allowed; }
.input-disclaimer {
  font-size: 10px; color: rgba(255,255,255,0.15);
  text-align: center; margin-top: 8px; letter-spacing: 0.05em;
}

/* ── Attachment Preview ── */
.attach-preview {
  display: flex; gap: 8px; flex-wrap: wrap;
  padding: 8px 4px; margin-bottom: 4px;
}
.attach-chip {
  display: flex; align-items: center; gap: 6px;
  background: rgba(24,6,8,0.7);
  border: 1px solid rgba(220,38,38,0.2);
  border-radius: 8px; padding: 4px 8px;
  font-size: 11px; color: rgba(255,255,255,0.7);
}
.attach-thumb {
  width: 28px; height: 28px; border-radius: 4px;
  object-fit: cover; border: 1px solid rgba(255,255,255,0.1);
}
.attach-name { max-width: 120px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.attach-remove {
  background: none; border: none; cursor: pointer;
  color: rgba(255,255,255,0.3); font-size: 12px; padding: 2px;
  display: flex; align-items: center; justify-content: center;
}
.attach-remove:hover { color: #ef4444; }
.input-icon-btn.recording { color: #ef4444; animation: pulse-dot 1.4s ease-in-out infinite; }

/* ── Typing Animation ── */
.typing-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #ef4444; display: inline-block;
  animation: pulse-dot 1.4s ease-in-out infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse-dot {
  0%, 60%, 100% { transform: scale(0.6); opacity: 0.3; box-shadow: 0 0 0 #ef4444; }
  30% { transform: scale(1.1); opacity: 1; box-shadow: 0 0 12px #ef4444; }
}

/* ── Message Animation ── */
@keyframes slide-up {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}
.msg-anim { animation: slide-up 0.15s ease-out both; }

/* ── Code Blocks ── */
.code-header {
  background: rgba(0, 0, 0, 0.6);
  border-bottom: 1px solid rgba(220, 38, 38, 0.15);
  padding: 6px 14px;
  display: flex; align-items: center; justify-content: space-between;
  font-family: 'JetBrains Mono', monospace; font-size: 0.75rem;
  color: rgba(255,255,255,0.5);
  border-radius: 8px 8px 0 0;
}
.code-header .dots { display: flex; gap: 6px; }
.code-header .dots span { width: 10px; height: 10px; border-radius: 50%; }
.code-header .dots span:nth-child(1) { background: #ef4444; }
.code-header .dots span:nth-child(2) { background: #f59e0b; }
.code-header .dots span:nth-child(3) { background: #10b981; }
.code-block-content {
  background: rgba(0, 0, 0, 0.7);
  padding: 16px; overflow-x: auto;
  font-family: 'JetBrains Mono', monospace; font-size: 0.85rem; line-height: 1.6;
  color: #e2e8f0; border-radius: 0 0 8px 8px;
}

/* ── Avatar ── */
.avatar-ai {
  width: 32px; height: 32px; border-radius: 8px;
  background: linear-gradient(135deg, rgba(220,38,38,0.3), rgba(0,0,0,0.6));
  border: 1px solid rgba(220,38,38,0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 1rem; color: #ef4444; flex-shrink: 0;
}

/* ── Ghost Button ── */
.btn-ghost { transition: all 0.2s ease; border: none; background: none; cursor: pointer; }
.btn-ghost:hover { background: rgba(220, 38, 38, 0.1); color: #ef4444; }
.btn-ghost:active { transform: scale(0.95); }

/* ══════════════════════════════════════════
   SETTINGS PANEL
   ══════════════════════════════════════════ */
.settings-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  z-index: 50;
  opacity: 0; visibility: hidden;
  transition: all 0.3s ease;
}
.settings-overlay.active { opacity: 1; visibility: visible; }

.settings-panel {
  position: fixed; top: 0; right: 0; bottom: 0;
  width: 420px; max-width: 100vw;
  z-index: 60;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
}
.settings-panel.open { transform: translateX(0); }
.settings-inner {
  height: 100%; display: flex; flex-direction: column;
  background: rgba(9, 9, 11, 0.95);
  backdrop-filter: blur(24px);
  border-left: 1px solid rgba(220, 38, 38, 0.15);
}

.settings-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid rgba(220, 38, 38, 0.1);
  flex-shrink: 0;
}

.settings-body {
  flex: 1; overflow-y: auto; padding: 24px;
  scrollbar-width: thin; scrollbar-color: rgba(220,38,38,0.15) transparent;
}
.settings-body::-webkit-scrollbar { width: 4px; }
.settings-body::-webkit-scrollbar-thumb { background: rgba(220,38,38,0.2); border-radius: 4px; }

.settings-section {
  margin-bottom: 28px;
  padding-bottom: 24px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.settings-section:last-child { border-bottom: none; margin-bottom: 0; }

.settings-section-title {
  font-size: 13px; font-weight: 600; color: rgba(255,255,255,0.8);
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 14px; text-transform: uppercase; letter-spacing: 0.08em;
}

/* ── Settings Inputs ── */
.settings-input {
  width: 100%; background: rgba(0,0,0,0.4);
  border: 1px solid rgba(220, 38, 38, 0.15);
  border-radius: 10px; padding: 10px 14px;
  color: rgba(255,255,255,0.8); font-size: 13px;
  font-family: 'JetBrains Mono', monospace;
  outline: none; transition: all 0.2s;
}
.settings-input:focus {
  border-color: rgba(220, 38, 38, 0.5);
  box-shadow: 0 0 16px rgba(220, 38, 38, 0.08);
}
.settings-input::placeholder { color: rgba(255,255,255,0.15); }

/* ── Model Grid ── */
.settings-model-grid {
  display: flex; flex-direction: column; gap: 6px;
  max-height: 280px; overflow-y: auto;
  scrollbar-width: thin; scrollbar-color: rgba(220,38,38,0.15) transparent;
}
.settings-model-grid::-webkit-scrollbar { width: 4px; }
.settings-model-grid::-webkit-scrollbar-thumb { background: rgba(220,38,38,0.2); border-radius: 4px; }

.model-card {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 12px; border-radius: 10px;
  border: 1px solid rgba(255,255,255,0.05);
  background: rgba(0,0,0,0.3);
  cursor: pointer; transition: all 0.2s;
  font-size: 12px; color: rgba(255,255,255,0.6);
}
.model-card:hover {
  border-color: rgba(220, 38, 38, 0.2);
  background: rgba(220, 38, 38, 0.05);
}
.model-card.selected {
  border-color: rgba(220, 38, 38, 0.4);
  background: rgba(220, 38, 38, 0.08);
  color: rgba(255,255,255,0.9);
}
.model-card .model-icon { font-size: 16px; flex-shrink: 0; width: 24px; text-align: center; }
.model-card .model-info { flex: 1; min-width: 0; }
.model-card .model-name { font-weight: 600; font-size: 12px; }
.model-card .model-provider { font-size: 10px; color: rgba(255,255,255,0.3); margin-top: 1px; }
.model-card .model-check { color: #ef4444; font-size: 12px; opacity: 0; transition: opacity 0.2s; }
.model-card.selected .model-check { opacity: 1; }

/* ── Settings Rows ── */
.settings-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 0;
}
.settings-label { font-size: 13px; color: rgba(255,255,255,0.6); }

/* ── Range Slider ── */
.settings-range {
  -webkit-appearance: none; appearance: none;
  width: 100px; height: 4px; border-radius: 4px;
  background: rgba(220, 38, 38, 0.15);
  outline: none; cursor: pointer;
}
.settings-range::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 14px; height: 14px; border-radius: 50%;
  background: #ef4444; cursor: pointer;
  box-shadow: 0 0 8px rgba(220,38,38,0.4);
}
.settings-range::-moz-range-thumb {
  width: 14px; height: 14px; border-radius: 50%;
  background: #ef4444; cursor: pointer; border: none;
}
.settings-range-val {
  font-size: 11px; color: rgba(255,255,255,0.4);
  min-width: 28px; text-align: center;
}

/* ── Toggle Switch ── */
.settings-toggle {
  position: relative; display: inline-block;
  width: 40px; height: 22px; cursor: pointer;
}
.settings-toggle input { opacity: 0; width: 0; height: 0; }
.settings-toggle-slider {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.1);
  border-radius: 22px; transition: all 0.3s;
}
.settings-toggle-slider::before {
  content: ''; position: absolute;
  width: 16px; height: 16px;
  left: 3px; bottom: 3px;
  background: rgba(255,255,255,0.4);
  border-radius: 50%; transition: all 0.3s;
}
.settings-toggle input:checked + .settings-toggle-slider {
  background: rgba(220, 38, 38, 0.4);
}
.settings-toggle input:checked + .settings-toggle-slider::before {
  transform: translateX(18px);
  background: #ef4444;
  box-shadow: 0 0 8px rgba(220,38,38,0.5);
}

/* ── Buttons ── */
.settings-btn-row { display: flex; gap: 8px; }
.settings-btn {
  flex: 1; padding: 10px 14px;
  border-radius: 10px; border: 1px solid rgba(220,38,38,0.2);
  background: rgba(220,38,38,0.05);
  color: rgba(255,255,255,0.6);
  font-size: 12px; cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.2s;
}
.settings-btn:hover {
  background: rgba(220,38,38,0.12);
  border-color: rgba(220,38,38,0.35);
  color: rgba(255,255,255,0.9);
}
.settings-btn:active { transform: scale(0.97); }
.settings-btn-danger {
  border-color: rgba(239,68,68,0.2);
  background: rgba(239,68,68,0.05);
  color: rgba(239,68,68,0.7);
}
.settings-btn-danger:hover {
  background: rgba(239,68,68,0.12);
  border-color: rgba(239,68,68,0.35);
  color: #ef4444;
}

/* ── Toast Notifications ── */
.toast-container {
  position: fixed; bottom: 24px; left: 50%; transform: translateX(-50%);
  z-index: 9999; display: flex; flex-direction: column; gap: 8px;
  pointer-events: none; max-width: 90vw;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 20px; border-radius: 12px;
  font-size: 13px; font-weight: 500;
  background: rgba(9, 9, 11, 0.95);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255,255,255,0.1);
  color: rgba(255,255,255,0.9);
  box-shadow: 0 8px 32px rgba(0,0,0,0.5);
  pointer-events: auto;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  transform: translateY(16px) scale(0.95);
  opacity: 0;
}
.toast.toast-visible {
  transform: translateY(0) scale(1);
  opacity: 1;
}
.toast-success { border-color: rgba(34, 197, 94, 0.3); }
.toast-success i { color: #22c55e; }
.toast-error { border-color: rgba(239, 68, 68, 0.3); }
.toast-error i { color: #ef4444; }
.toast-warning { border-color: rgba(234, 179, 8, 0.3); }
.toast-warning i { color: #eab308; }
.toast-info { border-color: rgba(220, 38, 38, 0.3); }
.toast-info i { color: #ef4444; }

/* ── API Key Status ── */
.api-valid { color: #22c55e; }
.api-invalid { color: #ef4444; }
.api-empty { color: rgba(255,255,255,0.3); }
