/* ═══════════════════════════════════════════════════════════════════
   Nova AI — Design System & Styles
   ═══════════════════════════════════════════════════════════════════ */

/* ── Reset & Variables ──────────────────────────────────────────── */
*, *::before, *::after { margin: 0; padding: 0; box-sizing: border-box; }

:root {
  --bg-primary:    #09090f;
  --bg-secondary:  #0f0f1a;
  --bg-surface:    #151525;
  --bg-hover:      #1a1a2e;
  --bg-active:     #1e1e35;
  --border:        rgba(255,255,255,0.06);
  --border-focus:  rgba(139,92,246,0.5);
  --text-primary:  #f0f0f5;
  --text-secondary:#9898b0;
  --text-muted:    #5a5a78;
  --accent:        #8b5cf6;
  --accent-2:      #06b6d4;
  --accent-glow:   rgba(139,92,246,0.15);
  --success:       #22c55e;
  --error:         #ef4444;
  --radius:        12px;
  --radius-lg:     16px;
  --font:          'Inter', -apple-system, sans-serif;
  --font-mono:     'JetBrains Mono', 'Fira Code', monospace;
  --sidebar-w:     280px;
  --topbar-h:      56px;
  --transition:    0.2s cubic-bezier(.4,0,.2,1);
}

html, body { height: 100%; }
body {
  font-family: var(--font);
  background: var(--bg-primary);
  color: var(--text-primary);
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ── Scrollbar ──────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.08); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.14); }

/* ── App layout ─────────────────────────────────────────────────── */
.app { display: flex; height: 100vh; position: relative; overflow: hidden; }

/* ── Animated background ────────────────────────────────────────── */
.bg-effects { position: fixed; inset: 0; pointer-events: none; z-index: 0; overflow: hidden; }
.orb {
  position: absolute; border-radius: 50%; filter: blur(100px); opacity: .18;
  animation: float 20s ease-in-out infinite;
}
.orb-1 { width: 600px; height: 600px; background: #8b5cf6; top: -20%; left: -10%; animation-delay: 0s; }
.orb-2 { width: 500px; height: 500px; background: #06b6d4; bottom: -15%; right: -8%; animation-delay: -7s; }
.orb-3 { width: 400px; height: 400px; background: #ec4899; top: 40%; left: 50%; animation-delay: -14s; }
@keyframes float {
  0%, 100% { transform: translate(0, 0) scale(1); }
  33% { transform: translate(30px, -40px) scale(1.05); }
  66% { transform: translate(-20px, 30px) scale(0.95); }
}
.grid-overlay {
  position: absolute; inset: 0;
  background-image:
    linear-gradient(rgba(255,255,255,.015) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255,255,255,.015) 1px, transparent 1px);
  background-size: 60px 60px;
}

/* ── Sidebar ────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w); min-width: var(--sidebar-w);
  height: 100vh; display: flex; flex-direction: column;
  background: rgba(12,12,22,0.85); backdrop-filter: blur(24px) saturate(1.4);
  border-right: 1px solid var(--border);
  position: relative; z-index: 20;
  transition: margin-left var(--transition), opacity var(--transition);
}
.sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); opacity: 0; pointer-events: none; }

.sidebar-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 18px; border-bottom: 1px solid var(--border);
}
.logo { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 32px; height: 32px; }
.logo-text { font-size: 18px; font-weight: 700; background: linear-gradient(135deg,#a78bfa,#06b6d4); -webkit-background-clip: text; -webkit-text-fill-color: transparent; }

.new-chat-btn {
  display: flex; align-items: center; gap: 10px;
  margin: 14px 14px 4px; padding: 10px 16px;
  background: rgba(139,92,246,0.12); border: 1px solid rgba(139,92,246,0.25);
  border-radius: var(--radius); color: var(--accent);
  font: 500 14px var(--font); cursor: pointer;
  transition: all var(--transition);
}
.new-chat-btn:hover { background: rgba(139,92,246,0.22); border-color: rgba(139,92,246,0.45); }

.sidebar-section { flex: 1; overflow-y: auto; padding: 8px; }
.section-label { padding: 8px 10px 6px; font-size: 11px; text-transform: uppercase; letter-spacing: 1px; color: var(--text-muted); }

.chat-history-item {
  padding: 10px 12px; border-radius: 8px; font-size: 13px;
  color: var(--text-secondary); cursor: pointer; transition: background var(--transition);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chat-history-item:hover { background: var(--bg-hover); color: var(--text-primary); }

.sidebar-footer { padding: 14px 18px; border-top: 1px solid var(--border); }
.status-badge {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-muted);
}
.status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--text-muted);
  transition: background var(--transition);
}
.status-badge.online .status-dot { background: var(--success); box-shadow: 0 0 8px rgba(34,197,94,0.5); }
.status-badge.error  .status-dot { background: var(--error);   box-shadow: 0 0 8px rgba(239,68,68,0.5); }

/* ── Button icon ────────────────────────────────────────────────── */
.btn-icon {
  width: 36px; height: 36px; display: grid; place-items: center;
  background: transparent; border: none; border-radius: 8px;
  color: var(--text-secondary); cursor: pointer; transition: all var(--transition);
}
.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }

/* ── Main area ──────────────────────────────────────────────────── */
.main {
  flex: 1; display: flex; flex-direction: column;
  position: relative; z-index: 10; min-width: 0;
}

/* ── Topbar ─────────────────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h); display: flex; align-items: center; gap: 12px;
  padding: 0 20px; border-bottom: 1px solid var(--border);
  background: rgba(9,9,15,0.6); backdrop-filter: blur(12px);
}
.topbar-title { font-weight: 600; font-size: 15px; }
.topbar-right { margin-left: auto; }
.model-badge {
  padding: 4px 12px; border-radius: 20px; font-size: 12px; font-weight: 500;
  background: rgba(139,92,246,0.12); color: var(--accent);
  border: 1px solid rgba(139,92,246,0.2);
}

/* ── Chat container ─────────────────────────────────────────────── */
.chat-container {
  flex: 1; overflow-y: auto; padding: 0 0 16px;
  display: flex; flex-direction: column;
}

/* ── Welcome ────────────────────────────────────────────────────── */
.welcome {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  padding: 40px 20px; text-align: center;
  animation: fadeUp .6s ease-out;
}
.welcome.hidden { display: none; }
.welcome-icon { width: 72px; height: 72px; margin-bottom: 24px; animation: pulse-glow 3s ease-in-out infinite; }
@keyframes pulse-glow {
  0%, 100% { filter: drop-shadow(0 0 8px rgba(139,92,246,0.3)); }
  50% { filter: drop-shadow(0 0 20px rgba(139,92,246,0.6)); }
}
.welcome-title {
  font-size: 32px; font-weight: 700;
  background: linear-gradient(135deg,#e0e0f0,#a0a0c0);
  -webkit-background-clip: text; -webkit-text-fill-color: transparent;
  margin-bottom: 10px;
}
.welcome-sub { font-size: 15px; color: var(--text-secondary); max-width: 420px; line-height: 1.6; }
.quick-actions { display: flex; flex-wrap: wrap; gap: 10px; margin-top: 32px; justify-content: center; max-width: 560px; }
.quick-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 18px; border-radius: 10px;
  background: var(--bg-surface); border: 1px solid var(--border);
  color: var(--text-secondary); font: 400 13px var(--font);
  cursor: pointer; transition: all var(--transition);
}
.quick-btn:hover { background: var(--bg-hover); color: var(--text-primary); border-color: rgba(255,255,255,0.1); transform: translateY(-1px); }

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

.message { display: flex; gap: 14px; padding: 16px 0; animation: fadeUp .35s ease-out; }
@keyframes fadeUp { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }

.message-avatar {
  width: 32px; height: 32px; border-radius: 10px; flex-shrink: 0;
  display: grid; place-items: center; font-size: 14px; font-weight: 600;
  margin-top: 2px;
}
.message.user .message-avatar { background: linear-gradient(135deg,#6366f1,#8b5cf6); color: #fff; }
.message.assistant .message-avatar { background: linear-gradient(135deg,#0e7490,#06b6d4); color: #fff; }

.message-body { flex: 1; min-width: 0; }
.message-role { font-size: 12px; font-weight: 600; text-transform: uppercase; letter-spacing: .5px; margin-bottom: 6px; }
.message.user .message-role { color: #a78bfa; }
.message.assistant .message-role { color: #22d3ee; }

.message-content { font-size: 14.5px; line-height: 1.75; color: var(--text-primary); word-wrap: break-word; }
.message-content p { margin-bottom: 10px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin: 8px 0; padding-left: 22px; }
.message-content li { margin-bottom: 4px; }
.message-content strong { color: #e0e0f5; font-weight: 600; }
.message-content em { color: var(--text-secondary); }
.message-content a { color: var(--accent); text-decoration: none; }
.message-content a:hover { text-decoration: underline; }

/* Code blocks */
.message-content .code-block {
  margin: 14px 0;
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
  background: #0b0f1a;
  box-shadow: 0 4px 14px rgba(0,0,0,0.25);
}
.message-content .code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 12px;
  background: linear-gradient(180deg, rgba(139,92,246,0.12), rgba(6,182,212,0.06));
  border-bottom: 1px solid var(--border);
  font-family: var(--font-mono); font-size: 12px;
}
.message-content .code-lang {
  color: #c4b5fd; text-transform: uppercase; letter-spacing: 0.06em; font-weight: 600;
}
.message-content .code-actions { display: flex; gap: 6px; }
.message-content .code-btn {
  background: rgba(255,255,255,0.06);
  color: var(--text-primary);
  border: 1px solid var(--border);
  padding: 4px 10px; border-radius: 6px;
  font-size: 12px; cursor: pointer;
  font-family: inherit;
  transition: background 0.15s, border-color 0.15s;
}
.message-content .code-btn:hover { background: rgba(139,92,246,0.18); border-color: #a78bfa; }
.message-content .code-btn:disabled { opacity: 0.6; cursor: wait; }
.message-content .code-run { color: #86efac; }
.message-content .code-block pre {
  background: transparent; border: none; border-radius: 0;
  margin: 0; padding: 14px 16px;
  overflow-x: auto; font-size: 13px; line-height: 1.55;
}
.message-content pre {
  background: #0b0f1a; border: 1px solid var(--border);
  border-radius: 10px; padding: 14px 16px; margin: 12px 0;
  overflow-x: auto; font-size: 13px; line-height: 1.55;
}
.message-content code {
  font-family: var(--font-mono); font-size: 13px;
}
.message-content :not(pre) > code {
  background: rgba(139,92,246,0.12); color: #c4b5fd;
  padding: 2px 7px; border-radius: 5px;
}
.message-content .code-output {
  border-top: 1px solid var(--border);
  background: #06080f;
  color: #e2e8f0;
  font-family: var(--font-mono); font-size: 12.5px;
  padding: 10px 14px;
  white-space: pre-wrap; word-break: break-word;
  max-height: 320px; overflow-y: auto;
}
.message-content .code-output.error { color: #fca5a5; background: #1a0a0e; }
.message-content blockquote {
  border-left: 3px solid var(--accent); padding: 8px 16px;
  margin: 10px 0; color: var(--text-secondary); background: rgba(139,92,246,0.05);
  border-radius: 0 8px 8px 0;
}
.message-content table { width: 100%; border-collapse: collapse; margin: 12px 0; font-size: 13px; }
.message-content th, .message-content td {
  padding: 8px 12px; border: 1px solid var(--border); text-align: left;
}
.message-content th { background: var(--bg-surface); font-weight: 600; }
.message-content h1, .message-content h2, .message-content h3 {
  margin: 16px 0 8px; font-weight: 600;
}
.message-content h1 { font-size: 20px; }
.message-content h2 { font-size: 17px; }
.message-content h3 { font-size: 15px; }

/* File chips in user message */
.file-chips { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 8px; }
.file-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 8px;
  background: rgba(139,92,246,0.1); border: 1px solid rgba(139,92,246,0.2);
  font-size: 12px; color: var(--accent);
}
.file-chip svg { flex-shrink: 0; }

/* ── Thinking indicator ─────────────────────────────────────────── */
.thinking-indicator { display: flex; gap: 14px; padding: 16px 0; animation: fadeUp .35s ease-out; }
.thinking-dots { display: flex; gap: 5px; align-items: center; padding: 12px 18px; background: var(--bg-surface); border-radius: 12px; border: 1px solid var(--border); }
.thinking-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent); animation: bounce 1.4s ease-in-out infinite;
}
.thinking-dots span:nth-child(2) { animation-delay: .2s; }
.thinking-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes bounce { 0%, 80%, 100% { transform: scale(0.6); opacity: .4; } 40% { transform: scale(1); opacity: 1; } }

/* ── File preview bar ───────────────────────────────────────────── */
.file-preview-bar {
  display: none; gap: 8px; padding: 8px 20px; flex-wrap: wrap;
  max-width: 820px; width: 100%; margin: 0 auto;
}
.file-preview-bar.active { display: flex; }
.file-preview-item {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 12px; border-radius: 8px;
  background: var(--bg-surface); border: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
  animation: fadeUp .25s ease-out;
}
.file-remove {
  width: 18px; height: 18px; display: grid; place-items: center;
  border: none; background: rgba(255,255,255,0.06); border-radius: 50%;
  color: var(--text-muted); cursor: pointer; font-size: 12px; line-height: 1;
  transition: all var(--transition);
}
.file-remove:hover { background: rgba(239,68,68,0.2); color: var(--error); }

/* ── Input area ─────────────────────────────────────────────────── */
.input-wrapper {
  padding: 0 20px 20px; display: flex; flex-direction: column; align-items: center;
}
.input-area {
  display: flex; align-items: flex-end; gap: 8px;
  width: 100%; max-width: 820px;
  padding: 10px 14px; border-radius: var(--radius-lg);
  background: var(--bg-surface); border: 1px solid var(--border);
  transition: border-color var(--transition), box-shadow var(--transition);
}
.input-area:focus-within {
  border-color: var(--border-focus);
  box-shadow: 0 0 0 3px var(--accent-glow), 0 4px 24px rgba(0,0,0,0.3);
}

#promptInput {
  flex: 1; border: none; outline: none; resize: none;
  background: transparent; color: var(--text-primary);
  font: 400 14.5px/1.55 var(--font);
  max-height: 200px; padding: 6px 4px;
}
#promptInput::placeholder { color: var(--text-muted); }

.attach-btn { color: var(--text-muted); }
.attach-btn:hover { color: var(--accent); }

.send-btn {
  width: 38px; height: 38px; display: grid; place-items: center;
  border: none; border-radius: 10px;
  background: linear-gradient(135deg,#7c3aed,#6366f1);
  color: #fff; cursor: pointer;
  transition: all var(--transition); flex-shrink: 0;
}
.send-btn:hover:not(:disabled) { transform: scale(1.05); box-shadow: 0 0 16px rgba(139,92,246,0.4); }
.send-btn:disabled { opacity: .35; cursor: default; }

.input-hint {
  margin-top: 8px; font-size: 11px; color: var(--text-muted); text-align: center;
}

/* ── Drop overlay ───────────────────────────────────────────────── */
.drop-overlay {
  position: fixed; inset: 0; z-index: 999;
  background: rgba(9,9,15,0.85); backdrop-filter: blur(8px);
  display: none; place-items: center;
}
.drop-overlay.active { display: grid; }
.drop-content {
  display: flex; flex-direction: column; align-items: center; gap: 14px;
  padding: 48px 64px; border-radius: 20px;
  border: 2px dashed var(--accent); color: var(--accent);
  font-size: 18px; font-weight: 500;
  animation: fadeUp .3s ease-out;
}

/* ── Responsive ─────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .sidebar {
    position: fixed; left: 0; top: 0; z-index: 100;
    box-shadow: 4px 0 24px rgba(0,0,0,0.4);
  }
  .sidebar.collapsed { margin-left: calc(-1 * var(--sidebar-w)); }
  .welcome-title { font-size: 24px; }
  .quick-actions { flex-direction: column; }
  .messages { padding: 16px 12px; }
}
