/* ============================================================
   Cortexa OS — theme.css
   Enterprise-grade luxury design system
   Linear / Vercel / Apple fidelity
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;450;500;600;700;800&display=swap');

/* ── 1. Root tokens ──────────────────────────────────────────── */
:root {
  /* Deep obsidian backgrounds */
  --bg-root:        #05070f;
  --bg-depth-1:     #080b16;
  --bg-depth-2:     #0b0f1a;
  --bg-depth-3:     #0e1221;
  --bg-depth-4:     #111628;
  --bg-surface:     rgba(12,16,28,0.75);
  --bg-elevated:    rgba(16,22,38,0.80);
  --bg-overlay:     rgba(5,7,15,0.92);

  /* Life Mode — muted royal purple */
  --life:           #8b5cf6;
  --life-dim:       #7c3aed;
  --life-deep:      #6d28d9;
  --life-bg:        rgba(139,92,246,0.06);
  --life-bg-hover:  rgba(139,92,246,0.10);
  --life-border:    rgba(139,92,246,0.12);
  --life-glow:      rgba(139,92,246,0.25);
  --life-text:      #a78bfa;

  /* CEO Mode — refined emerald */
  --ceo:            #10b981;
  --ceo-dim:        #059669;
  --ceo-deep:       #047857;
  --ceo-bg:         rgba(16,185,129,0.05);
  --ceo-bg-hover:   rgba(16,185,129,0.09);
  --ceo-border:     rgba(16,185,129,0.10);
  --ceo-glow:       rgba(16,185,129,0.20);
  --ceo-text:       #34d399;

  /* Borders */
  --b1: rgba(255,255,255,0.03);
  --b2: rgba(255,255,255,0.05);
  --b3: rgba(255,255,255,0.08);
  --b4: rgba(255,255,255,0.12);
  --b5: rgba(255,255,255,0.18);

  /* Text */
  --t1: #f8fafc;
  --t2: #e2e8f0;
  --t3: #94a3b8;
  --t4: #64748b;
  --t5: #475569;
  --t6: #334155;
  --t7: #1e293b;

  /* Status */
  --green:  #10b981;
  --amber:  #f59e0b;
  --red:    #ef4444;
  --blue:   #3b82f6;

  /* Font stacks */
  --sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  --mono: 'SF Mono', 'Fira Code', 'JetBrains Mono', 'Cascadia Code', ui-monospace, monospace;

  /* Easing */
  --ease-smooth: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-out:    cubic-bezier(0.33, 1, 0.68, 1);
  --ease-bounce: cubic-bezier(0.34, 1.56, 0.64, 1);

  /* Shadows */
  --shadow-card: 0 1px 3px rgba(0,0,0,0.4), 0 6px 24px rgba(0,0,0,0.3), inset 0 1px 0 0 rgba(255,255,255,0.03);
  --shadow-elevated: 0 2px 8px rgba(0,0,0,0.4), 0 12px 40px rgba(0,0,0,0.35), inset 0 1px 0 0 rgba(255,255,255,0.04);
  --shadow-modal: 0 24px 80px rgba(0,0,0,0.6), 0 4px 16px rgba(0,0,0,0.4);
  --shadow-glow-life: 0 0 40px rgba(139,92,246,0.06), 0 0 80px rgba(139,92,246,0.03);
  --shadow-glow-ceo: 0 0 40px rgba(16,185,129,0.05), 0 0 80px rgba(16,185,129,0.025);
}


/* ── 2. Mode themes ──────────────────────────────────────────── */
.mode-life {
  --accent: var(--life);
  --accent-dim: var(--life-dim);
  --accent-bg: var(--life-bg);
  --accent-bg-hover: var(--life-bg-hover);
  --accent-border: var(--life-border);
  --accent-glow: var(--life-glow);
  --accent-text: var(--life-text);
  --shadow-glow: var(--shadow-glow-life);
}
.mode-ceo {
  --accent: var(--ceo);
  --accent-dim: var(--ceo-dim);
  --accent-bg: var(--ceo-bg);
  --accent-bg-hover: var(--ceo-bg-hover);
  --accent-border: var(--ceo-border);
  --accent-glow: var(--ceo-glow);
  --accent-text: var(--ceo-text);
  --shadow-glow: var(--shadow-glow-ceo);
}
.mode-life, .mode-ceo {
  transition: all 0.6s var(--ease-smooth);
}


/* ── 3. Reset ────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { height: 100%; font-size: 16px; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; text-rendering: optimizeLegibility; }
body {
  height: 100%;
  background-color: var(--bg-root);
  background-image:
    radial-gradient(ellipse 100% 80% at 50% -20%, rgba(139,92,246,0.04) 0%, transparent 50%),
    radial-gradient(ellipse 80% 60% at 85% 110%, rgba(16,185,129,0.025) 0%, transparent 50%);
  color: var(--t2);
  font-family: var(--sans);
  overflow: hidden;
}
#app { height: 100vh; width: 100vw; }


/* ── 4. Scrollbar ────────────────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 999px; }
::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.12); }
* { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.06) transparent; }

.chat-scroll { overflow-y: auto; scrollbar-width: none; -ms-overflow-style: none; }
.chat-scroll::-webkit-scrollbar { display: none; }
.chat-scroll:hover { scrollbar-width: thin; scrollbar-color: rgba(255,255,255,0.05) transparent; }
.chat-scroll:hover::-webkit-scrollbar { display: block; width: 3px; }
.chat-scroll:hover::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.06); border-radius: 999px; }


/* ── 5. Premium card system ──────────────────────────────────── */
.card {
  background: var(--bg-depth-3);
  border: 1px solid var(--b2);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  position: relative;
  overflow: hidden;
  transition: border-color 0.4s var(--ease-smooth), box-shadow 0.4s var(--ease-smooth), transform 0.4s var(--ease-smooth);
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 0 rgba(255,255,255,0.04);
  pointer-events: none;
}
.card:hover {
  border-color: var(--b3);
  box-shadow: var(--shadow-elevated);
}
.card-lift:hover {
  transform: translateY(-2px);
}
.card-glow:hover {
  box-shadow: var(--shadow-elevated), var(--shadow-glow);
}

/* Premium blur card */
.premium-blur {
  background: rgba(12,16,28,0.6);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border: 1px solid var(--b2);
  border-radius: 14px;
  box-shadow: var(--shadow-card);
  position: relative;
}
.premium-blur::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  box-shadow: inset 0 1px 0 0 rgba(255,255,255,0.05);
  pointer-events: none;
}


/* ── 6. Text utilities ───────────────────────────────────────── */
.text-gradient {
  background: linear-gradient(180deg, #ffffff 0%, #cbd5e1 50%, #64748b 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.text-gradient-accent {
  background: linear-gradient(135deg, var(--accent, #8b5cf6) 0%, var(--t1) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.label {
  font-size: 10px;
  font-weight: 500;
  font-family: var(--mono);
  color: var(--t5);
  text-transform: uppercase;
  letter-spacing: 0.14em;
  line-height: 1;
}


/* ── 7. Premium inputs ───────────────────────────────────────── */
.input {
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.5;
  color: var(--t1);
  background: var(--bg-depth-1);
  border: 1px solid var(--b2);
  border-radius: 10px;
  padding: 11px 14px;
  outline: none;
  width: 100%;
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.2), 0 0 0 0 transparent;
  transition: border-color 0.35s var(--ease-smooth), box-shadow 0.35s var(--ease-smooth), background 0.35s var(--ease-smooth);
}
.input::placeholder { color: var(--t6); font-size: 13px; }
.input:focus {
  border-color: var(--life);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15), 0 0 0 3px rgba(139,92,246,0.08), 0 0 20px rgba(139,92,246,0.06);
  background: rgba(139,92,246,0.02);
}
.input:disabled { opacity: 0.35; cursor: not-allowed; }
textarea.input { resize: vertical; min-height: 80px; }
.mode-ceo .input:focus {
  border-color: var(--ceo);
  box-shadow: inset 0 1px 3px rgba(0,0,0,0.15), 0 0 0 3px rgba(16,185,129,0.06), 0 0 20px rgba(16,185,129,0.05);
  background: rgba(16,185,129,0.02);
}


/* ── 8. Buttons ──────────────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font-family: var(--sans); font-size: 13px; font-weight: 500;
  padding: 9px 18px; border-radius: 9px; border: none; cursor: pointer; outline: none;
  transition: all 0.3s var(--ease-smooth);
  position: relative; overflow: hidden;
}
.btn::before {
  content: '';
  position: absolute; inset: 0; border-radius: inherit;
  box-shadow: inset 0 1px 0 0 rgba(255,255,255,0.08);
  pointer-events: none;
}
.btn-primary {
  background: linear-gradient(180deg, var(--life) 0%, var(--life-deep) 100%);
  color: #fff;
  box-shadow: 0 1px 2px rgba(0,0,0,0.3), 0 4px 12px rgba(139,92,246,0.15), inset 0 1px 0 0 rgba(255,255,255,0.15);
}
.btn-primary:hover {
  box-shadow: 0 2px 4px rgba(0,0,0,0.3), 0 8px 24px rgba(139,92,246,0.25), inset 0 1px 0 0 rgba(255,255,255,0.15);
  transform: translateY(-1px);
}
.btn-primary:active { transform: translateY(0) scale(0.98); }
.btn-primary:disabled { opacity: 0.4; cursor: not-allowed; pointer-events: none; transform: none; }

.btn-ghost {
  background: rgba(255,255,255,0.03);
  border: 1px solid var(--b2);
  color: var(--t3);
  box-shadow: inset 0 1px 0 0 rgba(255,255,255,0.03);
}
.btn-ghost:hover {
  background: rgba(255,255,255,0.05);
  border-color: var(--b4);
  color: var(--t1);
  transform: translateY(-1px);
}
.btn-ghost:active { transform: translateY(0) scale(0.98); }


/* ── 9. Badge / Pill ─────────────────────────────────────────── */
.pill {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono); font-size: 10px; font-weight: 500; letter-spacing: 0.04em;
  padding: 3px 9px; border-radius: 999px;
  border: 1px solid var(--b2); background: rgba(255,255,255,0.02); color: var(--t4);
}
.pill-success { background: rgba(16,185,129,0.06); border-color: rgba(16,185,129,0.14); color: var(--ceo-text); }
.pill-purple  { background: rgba(139,92,246,0.06); border-color: rgba(139,92,246,0.14); color: var(--life-text); }
.pill-warning { background: rgba(245,158,11,0.06); border-color: rgba(245,158,11,0.14); color: var(--amber); }
.pill-error   { background: rgba(239,68,68,0.05); border-color: rgba(239,68,68,0.12); color: #f87171; }


/* ── 10. Nav items ───────────────────────────────────────────── */
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin: 1px 6px; border-radius: 8px;
  font-size: 13px; font-weight: 450; color: var(--t5);
  cursor: pointer; border: 1px solid transparent; position: relative;
  transition: color 0.2s var(--ease-smooth), background 0.2s var(--ease-smooth), border-color 0.2s var(--ease-smooth), box-shadow 0.2s var(--ease-smooth);
  white-space: nowrap; overflow: hidden;
}
.sidebar-link:hover {
  color: var(--t3); background: rgba(255,255,255,0.025);
}
.sidebar-link.active {
  color: var(--t1); background: rgba(255,255,255,0.04);
  border-color: var(--b2);
  box-shadow: inset 0 1px 0 0 rgba(255,255,255,0.04), 0 1px 3px rgba(0,0,0,0.15);
}
.sidebar-link.active::before {
  content: '';
  position: absolute; left: -1px; top: 50%; transform: translateY(-50%);
  width: 2px; height: 16px; border-radius: 0 2px 2px 0;
  background: var(--accent, var(--life));
  box-shadow: 0 0 8px var(--accent-glow, var(--life-glow));
}


/* ── 11. Animations ──────────────────────────────────────────── */
@keyframes fadeIn      { from { opacity: 0; } to { opacity: 1; } }
@keyframes fadeInUp    { from { opacity: 0; transform: translateY(16px); } to { opacity: 1; transform: translateY(0); } }
@keyframes fadeInDown  { from { opacity: 0; transform: translateY(-10px); } to { opacity: 1; transform: translateY(0); } }
@keyframes slideUp     { from { opacity: 0; transform: translateY(24px); } to { opacity: 1; transform: translateY(0); } }
@keyframes scaleIn     { from { opacity: 0; transform: scale(0.96); } to { opacity: 1; transform: scale(1); } }
@keyframes spin        { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }

@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%      { transform: translateY(-4px); }
}

@keyframes pulse-subtle {
  0%, 100% { opacity: 1; box-shadow: 0 0 4px currentColor; }
  50%      { opacity: 0.5; box-shadow: 0 0 8px currentColor; }
}

@keyframes glow-flow {
  0%   { box-shadow: 0 0 4px var(--accent, #8b5cf6), 0 0 12px transparent; opacity: 0.7; }
  50%  { box-shadow: 0 0 8px var(--accent, #8b5cf6), 0 0 20px var(--accent-glow, rgba(139,92,246,0.15)); opacity: 1; }
  100% { box-shadow: 0 0 4px var(--accent, #8b5cf6), 0 0 12px transparent; opacity: 0.7; }
}

@keyframes shimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

@keyframes terminal-blink {
  0%, 100% { opacity: 1; }
  50%      { opacity: 0; }
}

@keyframes dot-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-5px); }
}

.anim-fade-in   { animation: fadeIn    0.4s var(--ease-smooth) both; }
.anim-fade-up   { animation: fadeInUp  0.5s var(--ease-smooth) both; }
.anim-slide-up  { animation: slideUp   0.6s var(--ease-smooth) both; }
.anim-scale-in  { animation: scaleIn   0.4s var(--ease-smooth) both; }
.anim-float     { animation: float     3s ease-in-out infinite; }
.anim-glow      { animation: glow-flow 2.5s ease-in-out infinite; }
.anim-pulse     { animation: pulse-subtle 2s ease-in-out infinite; }
.anim-shimmer {
  background: linear-gradient(90deg, rgba(255,255,255,0.02) 25%, rgba(255,255,255,0.05) 50%, rgba(255,255,255,0.02) 75%);
  background-size: 200% 100%;
  animation: shimmer 2s ease-in-out infinite;
}
.anim-cursor { animation: terminal-blink 1s steps(1) infinite; }

/* Staggered children */
.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 60ms; }
.stagger > *:nth-child(3) { animation-delay: 120ms; }
.stagger > *:nth-child(4) { animation-delay: 180ms; }
.stagger > *:nth-child(5) { animation-delay: 240ms; }
.stagger > *:nth-child(6) { animation-delay: 300ms; }


/* ── 12. View transition ─────────────────────────────────────── */
.view-enter-active { animation: fadeInUp 0.4s var(--ease-smooth) both; }
.view-leave-active { animation: fadeIn 0.15s var(--ease-smooth) reverse both; }


/* ── 13. Range inputs ────────────────────────────────────────── */
input[type="range"] {
  -webkit-appearance: none; appearance: none;
  width: 100%; height: 4px; border-radius: 999px;
  background: rgba(255,255,255,0.04); outline: none; cursor: pointer;
}
input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none; appearance: none;
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--t1); border: 2px solid var(--bg-depth-3);
  box-shadow: 0 0 0 3px rgba(255,255,255,0.06), 0 2px 6px rgba(0,0,0,0.4);
  cursor: pointer; transition: box-shadow 0.2s var(--ease-smooth);
}
input[type="range"]::-webkit-slider-thumb:hover {
  box-shadow: 0 0 0 5px var(--accent-glow, rgba(139,92,246,0.15)), 0 2px 8px rgba(0,0,0,0.4);
}
input[type="range"]::-moz-range-thumb {
  width: 16px; height: 16px; border-radius: 50%;
  background: var(--t1); border: 2px solid var(--bg-depth-3); cursor: pointer;
}


/* ── 14. Inline code ─────────────────────────────────────────── */
code, .inline-code {
  font-family: var(--mono); font-size: 0.82em;
  background: rgba(255,255,255,0.04); border: 1px solid var(--b1);
  padding: 1px 6px; border-radius: 5px; color: var(--t3);
}


/* ── 15. Terminal log ────────────────────────────────────────── */
.terminal {
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.7;
  color: var(--t4);
  background: var(--bg-depth-1);
  border: 1px solid var(--b1);
  border-radius: 10px;
  padding: 14px 16px;
  overflow: hidden;
  position: relative;
}
.terminal::before {
  content: '';
  position: absolute; top: 0; left: 0; right: 0; height: 1px;
  background: linear-gradient(90deg, transparent, var(--b3), transparent);
}
.terminal-line {
  opacity: 0.6;
  transition: opacity 0.3s var(--ease-smooth);
}
.terminal-line:last-child { opacity: 1; }
.terminal-line .ts { color: var(--t6); margin-right: 8px; }
.terminal-line .tag { color: var(--accent-text, var(--life-text)); margin-right: 6px; }


/* ── 16. Responsive ──────────────────────────────────────────── */
@media (max-width: 768px) {
  .msg-user, .msg-ai { max-width: 88%; font-size: 13px; }
}
@media (max-width: 480px) {
  .sidebar-link { padding: 6px 8px; font-size: 12px; }
}