/* ================================================================
   DSA Lab Vault — Complete Design System
   Premium dark theme with glassmorphism & micro-animations
   ================================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg-deep:      #07070d;
  --bg-base:      #0c0c14;
  --bg-surface:   #111119;
  --bg-card:      #16161f;
  --bg-elevated:  #1c1c28;
  --bg-hover:     #22222f;
  --bg-input:     #13131c;

  --primary:      #6366f1;
  --primary-dim:  #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.15);
  --secondary:    #a78bfa;
  --accent:       #ec4899;
  --accent-glow:  rgba(236, 72, 153, 0.15);
  --success:      #22c55e;
  --warning:      #f59e0b;
  --danger:       #ef4444;
  --info:         #06b6d4;

  --text:         #e8eaf0;
  --text-dim:     #94a3b8;
  --text-muted:   #64748b;
  --border:       rgba(255, 255, 255, 0.06);
  --border-light: rgba(255, 255, 255, 0.1);

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

  --sidebar-w:    280px;
  --topbar-h:     60px;
  --radius-sm:    8px;
  --radius-md:    12px;
  --radius-lg:    16px;
  --radius-xl:    20px;

  --shadow-sm:  0 1px 3px rgba(0,0,0,0.4);
  --shadow-md:  0 4px 16px rgba(0,0,0,0.5);
  --shadow-lg:  0 8px 32px rgba(0,0,0,0.6);
  --shadow-glow: 0 0 30px var(--primary-glow);

  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --ease-spring: cubic-bezier(0.34, 1.56, 0.64, 1);
}

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

html {
  font-size: 15px;
  scroll-behavior: smooth;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

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

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--secondary); }

::selection { background: var(--primary); color: #fff; }
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--text-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text-dim); }

.hidden { display: none !important; }

/* ── Animations ────────────────────────────────────────────── */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInScale {
  from { opacity: 0; transform: scale(0.95) translateY(10px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}
@keyframes slideInRight {
  from { opacity: 0; transform: translateX(30px); }
  to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideInLeft {
  from { transform: translateX(-100%); }
  to   { transform: translateX(0); }
}
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-8px); }
}
@keyframes shimmer {
  0% { background-position: -200% 0; }
  100% { background-position: 200% 0; }
}
@keyframes spin {
  to { transform: rotate(360deg); }
}
@keyframes typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-4px); }
}
@keyframes borderGlow {
  0%, 100% { border-color: var(--primary); box-shadow: 0 0 8px var(--primary-glow); }
  50% { border-color: var(--secondary); box-shadow: 0 0 16px rgba(167,139,250,0.2); }
}
@keyframes toastIn {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  from { transform: translateX(0); opacity: 1; }
  to   { transform: translateX(120%); opacity: 0; }
}
@keyframes particleFloat {
  0% { transform: translateY(0) rotate(0deg); opacity: 0; }
  10% { opacity: 1; }
  90% { opacity: 1; }
  100% { transform: translateY(-100vh) rotate(720deg); opacity: 0; }
}

/* ══════════════════════════════════════════════════════════════
   LOGIN SCREEN
   ══════════════════════════════════════════════════════════════ */
.login-overlay {
  position: fixed; inset: 0; z-index: 9999;
  display: flex; align-items: center; justify-content: center;
  background: var(--bg-deep);
  background-image:
    radial-gradient(ellipse at 20% 50%, rgba(99,102,241,0.08) 0%, transparent 50%),
    radial-gradient(ellipse at 80% 50%, rgba(236,72,153,0.06) 0%, transparent 50%);
}

.login-particles {
  position: absolute; inset: 0; overflow: hidden; pointer-events: none;
}

.login-particle {
  position: absolute; bottom: -20px;
  width: 6px; height: 6px;
  background: var(--primary);
  border-radius: 50%;
  opacity: 0;
  animation: particleFloat linear infinite;
}

.login-card {
  position: relative; z-index: 1;
  width: 100%; max-width: 420px;
  padding: 48px 40px;
  background: var(--bg-surface);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg), var(--shadow-glow);
  animation: fadeInScale 0.6s var(--ease-out);
}

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

.login-logo-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 80px; height: 80px;
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  margin-bottom: 20px;
  box-shadow: var(--shadow-md);
  animation: float 4s ease-in-out infinite;
}

.login-logo h1 {
  font-size: 1.7rem; font-weight: 800;
  background: linear-gradient(135deg, var(--secondary), var(--primary));
  -webkit-background-clip: text; background-clip: text;
  -webkit-text-fill-color: transparent;
  letter-spacing: -0.5px;
}

.login-subtitle {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 4px;
}

.input-group {
  margin-bottom: 24px;
}

.input-group label {
  display: block;
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-dim);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.input-wrapper {
  position: relative;
  display: flex; align-items: center;
}

.input-icon {
  position: absolute; left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.input-wrapper input {
  width: 100%;
  padding: 14px 44px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.95rem;
  transition: all 0.25s ease;
}

.input-wrapper input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

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

.toggle-password {
  position: absolute; right: 12px;
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer; padding: 4px;
  transition: color 0.2s;
}
.toggle-password:hover { color: var(--text); }

.login-error {
  color: var(--danger);
  font-size: 0.82rem;
  margin-top: 8px;
  min-height: 1.2em;
  transition: opacity 0.2s;
}

.login-btn {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: 8px;
  padding: 14px 24px;
  background: linear-gradient(135deg, var(--primary), var(--primary-dim));
  color: #fff; border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-sans);
  font-size: 1rem; font-weight: 600;
  cursor: pointer;
  transition: all 0.25s var(--ease-out);
  box-shadow: 0 4px 16px rgba(99,102,241,0.3);
}

.login-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(99,102,241,0.4);
}
.login-btn:active { transform: translateY(0); }

.login-btn.loading {
  pointer-events: none; opacity: 0.8;
}

/* ══════════════════════════════════════════════════════════════
   APP LAYOUT
   ══════════════════════════════════════════════════════════════ */
.app {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ── Sidebar ───────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--bg-surface);
  border-right: 1px solid var(--border);
  display: flex; flex-direction: column;
  flex-shrink: 0;
  transition: transform 0.35s var(--ease-out);
  z-index: 100;
}

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

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

.sidebar-close {
  display: none;
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: 6px;
  transition: all 0.2s;
}
.sidebar-close:hover { color: var(--text); background: var(--bg-hover); }

.sidebar-search {
  display: flex; align-items: center; gap: 8px;
  margin: 14px 16px;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  transition: border-color 0.2s;
}
.sidebar-search:focus-within {
  border-color: var(--primary);
}
.sidebar-search svg { color: var(--text-muted); flex-shrink: 0; }
.sidebar-search input {
  background: none; border: none;
  color: var(--text); font-family: var(--font-sans);
  font-size: 0.88rem; width: 100%; outline: none;
}
.sidebar-search input::placeholder { color: var(--text-muted); }

.sidebar-nav {
  flex: 1; overflow-y: auto;
  padding: 8px 0;
}

.nav-group { margin-bottom: 8px; }

.nav-group-title {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 20px;
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 1px;
}
.nav-group-title svg { opacity: 0.6; }

.nav-group ul { list-style: none; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 20px 9px 28px;
  font-size: 0.88rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
  user-select: none;
}
.nav-item:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item.active {
  background: var(--primary-glow);
  color: var(--primary);
  border-left-color: var(--primary);
  font-weight: 500;
}

.nav-item .nav-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  flex-shrink: 0;
}

.nav-item .nav-label {
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.nav-item .nav-badge {
  font-size: 0.7rem;
  padding: 2px 7px;
  border-radius: 20px;
  background: var(--bg-elevated);
  color: var(--text-muted);
  font-weight: 600;
}

/* Special Nav Items */
.nav-special {
  border-top: 1px solid var(--border);
  padding-top: 8px;
  margin-top: 4px;
}

.nav-item-special {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 20px;
  font-size: 0.88rem;
  color: var(--text-dim);
  cursor: pointer;
  transition: all 0.2s ease;
  border-left: 3px solid transparent;
}
.nav-item-special:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.nav-item-special.active {
  background: var(--accent-glow);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 500;
}
.nav-item-special svg {
  flex-shrink: 0;
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border);
}

.logout-btn {
  display: flex; align-items: center; gap: 8px;
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.85rem;
  cursor: pointer;
  transition: all 0.2s;
}
.logout-btn:hover {
  background: rgba(239,68,68,0.1);
  border-color: rgba(239,68,68,0.3);
  color: var(--danger);
}

/* ── Main Content ──────────────────────────────────────────── */
.main-content {
  flex: 1;
  display: flex; flex-direction: column;
  overflow: hidden;
  min-width: 0;
}

.topbar {
  display: flex; align-items: center; gap: 16px;
  height: var(--topbar-h);
  padding: 0 28px;
  background: var(--bg-surface);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.menu-toggle {
  display: none;
  background: none; border: none;
  color: var(--text-dim); cursor: pointer;
  padding: 6px; border-radius: 6px;
  transition: all 0.2s;
}
.menu-toggle:hover { color: var(--text); background: var(--bg-hover); }

.topbar-title { flex: 1; }
.topbar-title h2 {
  font-size: 1.05rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}

.topbar-actions {
  display: flex; align-items: center; gap: 12px;
}

.complexity-badge {
  font-size: 0.78rem; font-weight: 600;
  padding: 4px 12px;
  border-radius: 20px;
  background: var(--primary-glow);
  color: var(--primary);
  border: 1px solid rgba(99,102,241,0.2);
}

.content-area {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
}

/* ══════════════════════════════════════════════════════════════
   DASHBOARD
   ══════════════════════════════════════════════════════════════ */
.dashboard {
  animation: fadeIn 0.5s var(--ease-out);
}

.welcome-hero {
  position: relative;
  padding: 48px 40px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-xl);
  margin-bottom: 28px;
  overflow: hidden;
}

.welcome-glow {
  position: absolute; top: -60px; right: -60px;
  width: 200px; height: 200px;
  background: radial-gradient(circle, var(--primary-glow) 0%, transparent 70%);
  border-radius: 50%;
  pointer-events: none;
}

.welcome-hero h1 {
  font-size: 2rem; font-weight: 800;
  margin-bottom: 8px;
  position: relative;
}

.welcome-hero p {
  color: var(--text-dim);
  font-size: 1rem;
  max-width: 500px;
  position: relative;
}

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 36px;
}

.stat-card {
  display: flex; align-items: center; gap: 16px;
  padding: 20px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  transition: all 0.3s var(--ease-out);
  animation: fadeIn 0.5s var(--ease-out) both;
}
.stat-card:nth-child(1) { animation-delay: 0.05s; }
.stat-card:nth-child(2) { animation-delay: 0.1s; }
.stat-card:nth-child(3) { animation-delay: 0.15s; }
.stat-card:nth-child(4) { animation-delay: 0.2s; }
.stat-card:hover {
  transform: translateY(-3px);
  border-color: var(--border-light);
  box-shadow: var(--shadow-md);
}

.stat-icon {
  width: 48px; height: 48px;
  display: flex; align-items: center; justify-content: center;
  background: color-mix(in srgb, var(--accent) 12%, transparent);
  border-radius: var(--radius-sm);
  color: var(--accent);
}
.stat-icon svg { stroke: var(--accent); }
.stat-icon[style*="--accent"] { color: var(--accent); }
.stat-icon[style*="--accent"] svg { stroke: var(--accent); }

.stat-info {
  display: flex; flex-direction: column;
}
.stat-number { font-size: 1.4rem; font-weight: 800; line-height: 1.2; }
.stat-label { font-size: 0.8rem; color: var(--text-muted); font-weight: 500; }

.categories-section h3 {
  font-size: 1rem; font-weight: 700;
  margin-bottom: 14px;
  color: var(--text-dim);
}

.category-chips {
  display: flex; flex-wrap: wrap; gap: 10px;
}

.category-chip {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 30px;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.85rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.25s ease;
}
.category-chip:hover {
  border-color: var(--border-light);
  background: var(--bg-elevated);
  color: var(--text);
  transform: translateY(-2px);
}
.category-chip.active {
  background: var(--primary-glow);
  border-color: rgba(99,102,241,0.3);
  color: var(--primary);
}

.chip-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
}

/* ══════════════════════════════════════════════════════════════
   EXPERIMENT VIEW
   ══════════════════════════════════════════════════════════════ */
.experiment-view {
  animation: fadeIn 0.4s var(--ease-out);
}

.experiment-content {
  max-width: 860px;
  margin: 0 auto;
}

.exp-section {
  margin-bottom: 28px;
  animation: fadeIn 0.5s var(--ease-out) both;
}
.exp-section:nth-child(1) { animation-delay: 0s; }
.exp-section:nth-child(2) { animation-delay: 0.05s; }
.exp-section:nth-child(3) { animation-delay: 0.1s; }
.exp-section:nth-child(4) { animation-delay: 0.15s; }
.exp-section:nth-child(5) { animation-delay: 0.2s; }
.exp-section:nth-child(6) { animation-delay: 0.25s; }

.section-header {
  display: flex; align-items: center; gap: 10px;
  margin-bottom: 14px;
}

.section-icon {
  display: flex; align-items: center; justify-content: center;
  width: 32px; height: 32px;
  background: var(--primary-glow);
  border-radius: var(--radius-sm);
  color: var(--primary);
  font-size: 0.9rem;
}

.section-header h3 {
  font-size: 0.95rem; font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text);
}

.section-body {
  padding: 20px 24px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

/* Aim */
.aim-text {
  font-size: 1rem;
  color: var(--text);
  line-height: 1.7;
}

/* Concept */
.concept-text {
  font-size: 0.95rem;
  color: var(--text-dim);
  line-height: 1.7;
  padding: 16px 20px;
  background: var(--bg-surface);
  border-left: 3px solid var(--secondary);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

/* Algorithm */
.algo-list {
  list-style: none;
  counter-reset: algo-step;
}
.algo-list li {
  counter-increment: algo-step;
  display: flex; gap: 14px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.92rem;
  color: var(--text-dim);
  line-height: 1.6;
}
.algo-list li:last-child { border-bottom: none; }
.algo-list li::before {
  content: counter(algo-step);
  display: flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px;
  background: var(--primary-glow);
  color: var(--primary);
  border-radius: 50%;
  font-size: 0.78rem; font-weight: 700;
  flex-shrink: 0;
  margin-top: 2px;
}
.algo-list code {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  padding: 2px 6px;
  background: var(--bg-elevated);
  border-radius: 4px;
  color: var(--secondary);
}

/* Diagram */
.diagram-box {
  overflow-x: auto;
}
.diagram-caption {
  font-size: 0.82rem;
  color: var(--text-muted);
  margin-bottom: 12px;
  font-style: italic;
}
.diagram-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}
.diagram-table th {
  padding: 10px 14px;
  background: var(--bg-surface);
  color: var(--text);
  font-weight: 600;
  text-align: left;
  border-bottom: 2px solid var(--primary);
}
.diagram-table td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  color: var(--text-dim);
}
.diagram-table tr:hover td {
  background: rgba(99,102,241,0.04);
}

.diagram-pre {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--secondary);
  line-height: 1.7;
  padding: 16px;
  background: var(--bg-surface);
  border-radius: var(--radius-sm);
  overflow-x: auto;
  white-space: pre;
}

/* Code Block */
.code-block-wrapper {
  position: relative;
}
.code-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: var(--radius-md) var(--radius-md) 0 0;
}
.code-lang {
  font-size: 0.78rem; font-weight: 600;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.code-actions {
  display: flex; gap: 6px;
}
.code-action-btn {
  display: flex; align-items: center; gap: 5px;
  padding: 5px 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.78rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.code-action-btn:hover {
  background: var(--bg-elevated);
  color: var(--text);
  border-color: var(--border-light);
}
.code-action-btn.copied {
  color: var(--success);
  border-color: rgba(34,197,94,0.3);
}
.code-action-btn svg { width: 14px; height: 14px; }

pre.code-pre {
  margin: 0;
  padding: 20px;
  background: #0d1117;
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 var(--radius-md) var(--radius-md);
  overflow-x: auto;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  color: #c9d1d9;
  tab-size: 4;
}

/* Output Box */
.output-box {
  padding: 20px;
  background: #0d1117;
  border: 1px solid var(--border);
  border-left: 3px solid var(--success);
  border-radius: var(--radius-md);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  color: #7ee787;
  white-space: pre-wrap;
}

/* ══════════════════════════════════════════════════════════════
   AI CHAT PANEL
   ══════════════════════════════════════════════════════════════ */
.chat-fab {
  position: fixed;
  bottom: 28px; right: 28px;
  width: 58px; height: 58px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border: none; border-radius: 50%;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  z-index: 200;
  box-shadow: 0 4px 20px rgba(99,102,241,0.4);
  transition: all 0.3s var(--ease-out);
}
.chat-fab:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 28px rgba(99,102,241,0.5);
}
.chat-fab.active {
  background: var(--bg-elevated);
  box-shadow: var(--shadow-md);
}
.chat-fab .fab-icon,
.chat-fab .fab-close { position: absolute; transition: all 0.3s; }
.chat-fab.active .fab-icon { transform: scale(0) rotate(90deg); opacity: 0; }
.chat-fab.active .fab-close { transform: scale(1) rotate(0); opacity: 1; }
.chat-fab .fab-close { transform: scale(0) rotate(-90deg); opacity: 0; }

.chat-panel {
  position: fixed;
  top: 0; right: 0;
  width: 440px; height: 100vh;
  background: var(--bg-surface);
  border-left: 1px solid var(--border);
  display: flex; flex-direction: column;
  z-index: 190;
  transform: translateX(100%);
  transition: transform 0.4s var(--ease-out);
  box-shadow: -8px 0 32px rgba(0,0,0,0.3);
}
.chat-panel.open {
  transform: translateX(0);
}

.chat-header {
  display: flex; align-items: center; gap: 12px;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-avatar {
  width: 38px; height: 38px;
  background: linear-gradient(135deg, var(--primary), var(--accent));
  border-radius: var(--radius-sm);
  display: flex; align-items: center; justify-content: center;
  font-size: 1.1rem;
}
.chat-header-info { flex: 1; }
.chat-header-info h3 {
  font-size: 0.95rem; font-weight: 700;
}
.chat-header-info p {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.chat-status-dot {
  width: 8px; height: 8px;
  background: var(--success);
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
  animation: pulse 2s infinite;
}
.chat-clear-btn {
  background: none; border: none;
  color: var(--text-muted);
  cursor: pointer; padding: 6px; border-radius: 6px;
  transition: all 0.2s;
}
.chat-clear-btn:hover { color: var(--danger); background: rgba(239,68,68,0.1); }

.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex; flex-direction: column; gap: 16px;
}

.chat-welcome {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
}
.chat-welcome-emoji {
  font-size: 3rem;
  margin-bottom: 12px;
  display: block;
}
.chat-welcome h4 {
  font-size: 1.1rem;
  color: var(--text);
  margin-bottom: 6px;
}
.chat-welcome p {
  font-size: 0.85rem;
  line-height: 1.6;
}

.chat-suggestions {
  display: flex; flex-direction: column; gap: 8px;
  margin-top: 16px;
}
.chat-suggest-btn {
  padding: 10px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.82rem;
  cursor: pointer;
  text-align: left;
  transition: all 0.2s;
}
.chat-suggest-btn:hover {
  background: var(--bg-elevated);
  border-color: var(--primary);
  color: var(--text);
}

/* Message Bubbles */
.chat-msg {
  display: flex; gap: 10px;
  max-width: 95%;
  animation: fadeIn 0.3s var(--ease-out);
}
.chat-msg.user { flex-direction: row-reverse; align-self: flex-end; }
.chat-msg.assistant { align-self: flex-start; }

.msg-avatar {
  width: 30px; height: 30px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-size: 0.8rem;
  flex-shrink: 0;
  margin-top: 2px;
}
.chat-msg.user .msg-avatar {
  background: var(--primary);
  color: #fff;
}
.chat-msg.assistant .msg-avatar {
  background: linear-gradient(135deg, var(--accent), var(--primary));
  color: #fff;
}

.msg-bubble {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  line-height: 1.6;
}
.chat-msg.user .msg-bubble {
  background: var(--primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.assistant .msg-bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  color: var(--text);
  border-bottom-left-radius: 4px;
}

.msg-bubble p { margin-bottom: 8px; }
.msg-bubble p:last-child { margin-bottom: 0; }
.msg-bubble strong { color: var(--text); font-weight: 600; }
.msg-bubble code:not(.code-block-code) {
  font-family: var(--font-mono);
  font-size: 0.83rem;
  padding: 2px 6px;
  background: rgba(0,0,0,0.3);
  border-radius: 4px;
  color: var(--secondary);
}
.msg-bubble ul, .msg-bubble ol {
  margin: 8px 0;
  padding-left: 20px;
}
.msg-bubble li { margin-bottom: 4px; }

/* AI Code Block inside chat */
.msg-code-block {
  margin: 10px 0;
  border-radius: var(--radius-sm);
  overflow: hidden;
}
.msg-code-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 6px 12px;
  background: #161b22;
  font-size: 0.75rem;
  color: var(--text-muted);
}
.msg-code-actions {
  display: flex; gap: 4px;
}
.msg-code-btn {
  padding: 3px 10px;
  background: rgba(255,255,255,0.06);
  border: none; border-radius: 4px;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.72rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.msg-code-btn:hover {
  background: rgba(255,255,255,0.12);
  color: var(--text);
}
.msg-code-btn.save-btn:hover {
  color: var(--success);
}
.msg-code-pre {
  margin: 0;
  padding: 14px;
  background: #0d1117;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  line-height: 1.6;
  color: #c9d1d9;
  overflow-x: auto;
  white-space: pre;
}

/* Typing indicator */
.typing-indicator {
  display: flex; gap: 10px;
  max-width: 95%;
  align-self: flex-start;
  animation: fadeIn 0.3s var(--ease-out);
}
.typing-dots {
  display: flex; gap: 5px;
  padding: 14px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  border-bottom-left-radius: 4px;
}
.typing-dot {
  width: 7px; height: 7px;
  background: var(--text-muted);
  border-radius: 50%;
  animation: typing 1.4s infinite;
}
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

.chat-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--border);
  flex-shrink: 0;
}
.chat-input-wrapper {
  display: flex; gap: 8px;
}
.chat-input {
  flex: 1;
  padding: 12px 16px;
  background: var(--bg-input);
  border: 1.5px solid var(--border-light);
  border-radius: var(--radius-md);
  color: var(--text);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  resize: none;
  outline: none;
  transition: border-color 0.2s;
  max-height: 120px;
}
.chat-input:focus {
  border-color: var(--primary);
}
.chat-input::placeholder { color: var(--text-muted); }

.chat-send-btn {
  width: 44px; height: 44px;
  background: var(--primary);
  border: none; border-radius: var(--radius-sm);
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: all 0.2s;
  flex-shrink: 0;
  align-self: flex-end;
}
.chat-send-btn:hover { background: var(--primary-dim); }
.chat-send-btn:disabled {
  opacity: 0.5; cursor: not-allowed;
}

/* ══════════════════════════════════════════════════════════════
   SAVED SNIPPETS / CODE VAULT
   ══════════════════════════════════════════════════════════════ */
.snippets-view {
  animation: fadeIn 0.4s var(--ease-out);
}

.snippets-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 24px;
}
.snippets-header h2 {
  font-size: 1.4rem; font-weight: 800;
  display: flex; align-items: center; gap: 10px;
}
.snippets-header h2 span {
  font-size: 1.6rem;
}
.snippets-count {
  font-size: 0.82rem;
  padding: 4px 12px;
  background: var(--primary-glow);
  color: var(--primary);
  border-radius: 20px;
  font-weight: 600;
}

.snippets-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-muted);
}
.snippets-empty-icon {
  font-size: 4rem;
  margin-bottom: 16px;
  display: block;
  opacity: 0.6;
}
.snippets-empty h3 {
  font-size: 1.1rem;
  color: var(--text-dim);
  margin-bottom: 8px;
}
.snippets-empty p {
  font-size: 0.9rem;
}

.snippets-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 16px;
}

.snippet-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  overflow: hidden;
  transition: all 0.3s var(--ease-out);
  animation: fadeInScale 0.4s var(--ease-out) both;
}
.snippet-card:hover {
  border-color: var(--border-light);
  transform: translateY(-3px);
  box-shadow: var(--shadow-md);
}

.snippet-card-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
}
.snippet-title {
  font-size: 0.9rem; font-weight: 600;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
  flex: 1;
}
.snippet-lang {
  font-size: 0.7rem; font-weight: 600;
  padding: 2px 8px;
  background: var(--primary-glow);
  color: var(--primary);
  border-radius: 12px;
  text-transform: uppercase;
  margin-left: 8px;
}

.snippet-preview {
  padding: 14px 16px;
  background: #0d1117;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  line-height: 1.6;
  color: #8b949e;
  max-height: 120px;
  overflow: hidden;
  position: relative;
  cursor: pointer;
}
.snippet-preview::after {
  content: '';
  position: absolute; bottom: 0; left: 0; right: 0;
  height: 40px;
  background: linear-gradient(transparent, #0d1117);
}

.snippet-meta {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 16px;
  border-top: 1px solid var(--border);
}
.snippet-date {
  font-size: 0.75rem;
  color: var(--text-muted);
}
.snippet-actions {
  display: flex; gap: 4px;
}
.snippet-action {
  padding: 4px 10px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 6px;
  color: var(--text-dim);
  font-family: var(--font-sans);
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}
.snippet-action:hover {
  background: var(--bg-hover);
  color: var(--text);
}
.snippet-action.delete-action:hover {
  color: var(--danger);
  border-color: rgba(239,68,68,0.3);
}

/* Snippet Modal */
.snippet-modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  backdrop-filter: blur(4px);
  display: flex; align-items: center; justify-content: center;
  z-index: 300;
  animation: fadeIn 0.2s;
}
.snippet-modal {
  width: 90%; max-width: 700px; max-height: 85vh;
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  display: flex; flex-direction: column;
  animation: fadeInScale 0.3s var(--ease-out);
  box-shadow: var(--shadow-lg);
}
.snippet-modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}
.snippet-modal-header h3 {
  font-size: 1rem; font-weight: 700;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.snippet-modal-close {
  background: none; border: none;
  color: var(--text-muted); cursor: pointer;
  padding: 4px; border-radius: 6px;
  transition: all 0.2s;
}
.snippet-modal-close:hover { color: var(--text); background: var(--bg-hover); }

.snippet-modal-body {
  flex: 1; overflow-y: auto;
}
.snippet-modal-body pre {
  margin: 0; padding: 20px;
  background: #0d1117;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  line-height: 1.7;
  color: #c9d1d9;
  overflow-x: auto;
}

.snippet-modal-footer {
  display: flex; gap: 8px; justify-content: flex-end;
  padding: 14px 20px;
  border-top: 1px solid var(--border);
}
.modal-btn {
  padding: 8px 18px;
  border-radius: var(--radius-sm);
  font-family: var(--font-sans);
  font-size: 0.85rem; font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  border: 1px solid var(--border);
}
.modal-btn-primary {
  background: var(--primary);
  color: #fff; border-color: var(--primary);
}
.modal-btn-primary:hover { background: var(--primary-dim); }
.modal-btn-danger {
  background: transparent;
  color: var(--danger); border-color: rgba(239,68,68,0.3);
}
.modal-btn-danger:hover { background: rgba(239,68,68,0.1); }
.modal-btn-secondary {
  background: var(--bg-card);
  color: var(--text-dim);
}
.modal-btn-secondary:hover { background: var(--bg-elevated); color: var(--text); }

/* ══════════════════════════════════════════════════════════════
   TOAST NOTIFICATIONS
   ══════════════════════════════════════════════════════════════ */
.toast-container {
  position: fixed;
  top: 20px; right: 20px;
  z-index: 9999;
  display: flex; flex-direction: column; gap: 8px;
}
.toast {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 18px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg);
  font-size: 0.88rem;
  color: var(--text);
  animation: toastIn 0.4s var(--ease-out);
  min-width: 260px;
  max-width: 400px;
}
.toast.removing {
  animation: toastOut 0.3s var(--ease-out) forwards;
}
.toast-icon {
  font-size: 1.1rem;
  flex-shrink: 0;
}
.toast.success { border-left: 3px solid var(--success); }
.toast.error   { border-left: 3px solid var(--danger); }
.toast.info    { border-left: 3px solid var(--info); }

/* ══════════════════════════════════════════════════════════════
   RESPONSIVE
   ══════════════════════════════════════════════════════════════ */
@media (max-width: 900px) {
  .sidebar {
    position: fixed; left: 0; top: 0;
    transform: translateX(-100%);
    box-shadow: none;
  }
  .sidebar.open {
    transform: translateX(0);
    box-shadow: 8px 0 32px rgba(0,0,0,0.5);
  }
  .sidebar-close { display: block; }
  .menu-toggle { display: block; }

  .content-area { padding: 20px; }

  .chat-panel {
    width: 100%;
  }
  .chat-fab {
    bottom: 20px; right: 20px;
    width: 52px; height: 52px;
  }

  .welcome-hero { padding: 30px 24px; }
  .welcome-hero h1 { font-size: 1.5rem; }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
  .snippets-grid {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 540px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }
  .login-card {
    margin: 16px;
    padding: 32px 24px;
  }
  .snippet-modal {
    width: 95%;
  }
}

/* Mobile overlay for sidebar */
.sidebar-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s;
}
.sidebar-overlay.active {
  opacity: 1;
  visibility: visible;
}

/* ══════════════════════════════════════════════════════════════
   SETUP & PORTABLE ENVIRONMENT SECTION
   ══════════════════════════════════════════════════════════════ */
.setup-section {
  margin-top: 40px;
  padding-top: 24px;
  border-top: 1px solid var(--border);
  animation: fadeIn 0.6s var(--ease-out) both;
}
.setup-section h3 {
  font-size: 1.25rem;
  font-weight: 700;
  margin-bottom: 20px;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: 8px;
}

/* Online Compiler Bar */
.online-compiler-bar {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
  transition: border-color 0.3s;
}
.online-compiler-bar:hover {
  border-color: var(--border-light);
}
.compiler-bar-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-dim);
}
.compiler-bar-label svg {
  color: var(--primary);
}
.compiler-buttons {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}
.compiler-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  font-size: 0.85rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s var(--ease-out);
}
.compiler-btn:hover {
  background: var(--bg-hover);
  border-color: var(--border-light);
  transform: translateY(-1px);
}
.compiler-btn-icon {
  font-size: 0.95rem;
}
.compiler-btn-primary {
  background: var(--primary-glow);
  border-color: rgba(99, 102, 241, 0.3);
  color: var(--text);
}
.compiler-btn-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  box-shadow: 0 0 12px rgba(99, 102, 241, 0.3);
}

/* Portable section */
.portable-section {
  background: var(--bg-surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 24px;
  position: relative;
  overflow: hidden;
  box-shadow: var(--shadow-md);
  transition: border-color 0.3s;
}
.portable-section:hover {
  border-color: var(--border-light);
}
.portable-header h4 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text);
  margin-bottom: 6px;
}
.portable-header p {
  font-size: 0.9rem;
  color: var(--text-dim);
  margin-bottom: 20px;
  max-width: 700px;
}

/* OS Tabs */
.os-tabs {
  display: flex;
  gap: 8px;
  margin-bottom: 24px;
  border-bottom: 1px solid var(--border);
  padding-bottom: 8px;
}
.os-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 18px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s;
  position: relative;
}
.os-tab:hover {
  color: var(--text-dim);
  background: var(--bg-hover);
}
.os-tab.active {
  color: var(--primary);
  background: var(--primary-glow);
}
.os-tab.active::after {
  content: '';
  position: absolute;
  bottom: -9px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
}

/* OS Content */
.os-content {
  display: none;
  animation: fadeIn 0.4s var(--ease-out) both;
}
.os-content.active {
  display: block;
}

/* Download Card */
.download-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px 20px;
  margin-bottom: 24px;
  gap: 16px;
  flex-wrap: wrap;
}
.download-card-left {
  display: flex;
  align-items: center;
  gap: 16px;
}
.download-icon {
  font-size: 1.8rem;
  background: var(--bg-elevated);
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 1px solid var(--border);
}
.download-card-left strong {
  display: block;
  font-size: 0.95rem;
  color: var(--text);
}
.download-meta {
  display: block;
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-top: 2px;
}
.download-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  background: linear-gradient(135deg, var(--primary), var(--secondary));
  color: #fff;
  border-radius: var(--radius-sm);
  font-size: 0.88rem;
  font-weight: 600;
  transition: all 0.3s;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.2);
}
.download-btn:hover {
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.4);
}

/* Setup Steps */
.setup-steps {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}
.step {
  display: flex;
  gap: 12px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}
.step-num {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: var(--primary-glow);
  border: 1px solid var(--primary);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  flex-shrink: 0;
}
.step-body strong {
  display: block;
  font-size: 0.9rem;
  color: var(--text);
  margin-bottom: 4px;
}
.step-body p {
  font-size: 0.82rem;
  color: var(--text-dim);
  line-height: 1.4;
}
.step-body code {
  background: var(--bg-elevated);
  padding: 1px 4px;
  border-radius: 4px;
  font-family: var(--font-mono);
  font-size: 0.78rem;
  color: var(--secondary);
}

/* Setup Note */
.setup-note {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(6, 182, 212, 0.05);
  border: 1px dashed rgba(6, 182, 212, 0.2);
  color: var(--text-dim);
  font-size: 0.82rem;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
}
.setup-note svg {
  color: var(--info);
  flex-shrink: 0;
}

@media (max-width: 768px) {
  .online-compiler-bar, .download-card {
    flex-direction: column;
    align-items: stretch;
  }
  .compiler-buttons {
    flex-direction: column;
  }
  .compiler-btn {
    justify-content: center;
  }
}

