/* ============================================================
   EduVexAI — Premium Dark Navy Theme
   Mobile-first, glassmorphism, purple/cyan gradients
   ============================================================ */

:root {
  --navy: #050816;
  --navy-2: #0a0f2a;
  --purple: #7c3aed;
  --purple-light: #a78bfa;
  --cyan: #06b6d4;
  --cyan-light: #67e8f9;
  --glass-bg: rgba(15, 23, 42, 0.65);
  --glass-border: rgba(148, 163, 184, 0.18);
  --text: #e2e8f0;
  --text-muted: #94a3b8;
  --success: #34d399;
  --danger: #f87171;
  --radius: 18px;
  --radius-sm: 12px;
  --shadow: 0 8px 32px rgba(0, 0, 0, 0.45);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  height: 100%;
  font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  background: var(--navy);
  color: var(--text);
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

body {
  background:
    radial-gradient(ellipse at 20% 0%, rgba(124, 58, 237, 0.25), transparent 55%),
    radial-gradient(ellipse at 80% 100%, rgba(6, 182, 212, 0.18), transparent 55%),
    var(--navy);
  min-height: 100vh;
}

/* ---------- Utility ---------- */
.hidden { display: none !important; }
.muted { color: var(--text-muted); font-size: 0.9rem; line-height: 1.5; }
.success-msg { color: var(--success); font-size: 0.9rem; margin-top: 8px; }
.divider { border: none; border-top: 1px solid var(--glass-border); margin: 16px 0; }

/* ---------- Glass Card ---------- */
.glass {
  background: var(--glass-bg);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card {
  padding: 18px;
  margin-bottom: 16px;
}

/* ---------- Splash ---------- */
.splash {
  position: fixed;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  background: var(--navy);
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
.splash-logo {
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -1px;
  background: linear-gradient(135deg, var(--purple-light), var(--cyan-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.splash-tag {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin-top: 8px;
  text-align: center;
  padding: 0 24px;
}
.spinner {
  margin-top: 28px;
  width: 36px;
  height: 36px;
  border: 3px solid rgba(148, 163, 184, 0.2);
  border-top-color: var(--purple-light);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ---------- Auth Screen ---------- */
.screen {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  z-index: 100;
}
.auth-card {
  width: 100%;
  max-width: 420px;
  padding: 32px 24px;
  text-align: center;
}
.brand {
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--purple-light), var(--cyan-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand span { color: var(--cyan-light); -webkit-text-fill-color: var(--cyan-light); }
.brand-sm {
  font-weight: 700;
  font-size: 1.1rem;
  background: linear-gradient(135deg, var(--purple-light), var(--cyan-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}
.brand-sm span { color: var(--cyan-light); -webkit-text-fill-color: var(--cyan-light); }
.tagline {
  color: var(--text-muted);
  font-size: 0.9rem;
  margin: 10px 0 24px;
  line-height: 1.5;
}
.fine-print {
  color: var(--text-muted);
  font-size: 0.75rem;
  margin-top: 20px;
}

/* Clerk mount area */
#clerk-auth { min-height: 120px; }

/* ---------- Top Bar ---------- */
.app {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  padding-top: 60px; /* topbar height */
}
.topbar {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 14px;
  border-radius: 0;
  z-index: 50;
}
.topbar-left, .topbar-right {
  display: flex;
  align-items: center;
  gap: 10px;
}
.icon-btn {
  background: transparent;
  border: none;
  color: var(--text);
  font-size: 1.2rem;
  padding: 8px;
  border-radius: 10px;
  cursor: pointer;
}
.icon-btn:active { background: rgba(255,255,255,0.08); }
.user-badge {
  font-size: 0.75rem;
  padding: 5px 10px;
  border-radius: 999px;
  background: rgba(124, 58, 237, 0.25);
  border: 1px solid rgba(124, 58, 237, 0.4);
  color: var(--purple-light);
}

/* ---------- Sidebar ---------- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  width: 260px;
  z-index: 200;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  border-radius: 0 var(--radius) var(--radius) 0;
  padding: 18px;
  overflow-y: auto;
}
.sidebar.open { transform: translateX(0); }
.sidebar-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}
.nav-list { list-style: none; display: flex; flex-direction: column; gap: 6px; }
.nav-link {
  display: block;
  width: 100%;
  text-align: left;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  background: transparent;
  border: 1px solid transparent;
  color: var(--text);
  font-size: 0.92rem;
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
}
.nav-link.active {
  background: linear-gradient(135deg, rgba(124,58,237,0.25), rgba(6,182,212,0.15));
  border-color: rgba(124, 58, 237, 0.35);
  color: #fff;
}
.nav-link:active { background: rgba(255,255,255,0.06); }

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  padding: 18px 14px 40px;
  max-width: 720px;
  width: 100%;
  margin: 0 auto;
}
.view { display: none; }
.view.active { display: block; animation: fadeUp 0.3s ease; }
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}
.section-title {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 16px;
  background: linear-gradient(135deg, var(--purple-light), var(--cyan-light));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* ---------- Grid & Stats ---------- */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.stat-card {
  display: flex;
  flex-direction: column;
  gap: 6px;
  text-align: center;
  padding: 16px 12px;
}
.stat-label { font-size: 0.78rem; color: var(--text-muted); }
.stat-value { font-size: 1.5rem; font-weight: 800; color: var(--cyan-light); }

/* ---------- Quick Access ---------- */
.quick-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 12px;
}
.quick-btn {
  padding: 14px 10px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(124, 58, 237, 0.12);
  color: var(--text);
  font-size: 0.85rem;
  cursor: pointer;
  transition: background 0.2s;
}
.quick-btn:active { background: rgba(124, 58, 237, 0.28); }

/* ---------- Inputs ---------- */
.input-group {
  display: flex;
  flex-direction: column;
  gap: 10px;
  margin-top: 12px;
}
input, textarea, select {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--glass-border);
  background: rgba(5, 8, 22, 0.6);
  color: var(--text);
  font-size: 0.92rem;
  font-family: inherit;
  outline: none;
  transition: border-color 0.2s;
}
input:focus, textarea:focus {
  border-color: var(--purple);
}
textarea { resize: vertical; }
.primary-btn {
  padding: 12px 18px;
  border: none;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--purple), var(--cyan));
  color: #fff;
  font-weight: 700;
  font-size: 0.92rem;
  cursor: pointer;
  transition: opacity 0.2s;
}
.primary-btn:active { opacity: 0.85; }

/* ---------- AI Response ---------- */
.ai-response {
  margin-top: 16px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(6, 182, 212, 0.08);
  border: 1px solid rgba(6, 182, 212, 0.2);
  color: var(--text);
  font-size: 0.9rem;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.ai-response:empty { display: none; }

/* ---------- Chat ---------- */
.chat-container { display: flex; flex-direction: column; height: 60vh; min-height: 360px; }
.chat-messages {
  flex: 1;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding-bottom: 10px;
}
.chat-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-break: break-word;
}
.chat-msg.bot {
  align-self: flex-start;
  background: rgba(124, 58, 237, 0.15);
  border: 1px solid rgba(124, 58, 237, 0.25);
}
.chat-msg.user {
  align-self: flex-end;
  background: rgba(6, 182, 212, 0.15);
  border: 1px solid rgba(6, 182, 212, 0.25);
}
.chat-input-row {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}
.chat-input-row input { flex: 1; }
.chat-input-row .primary-btn { flex-shrink: 0; }

/* ---------- Test Area ---------- */
.test-area {
  margin-top: 16px;
  line-height: 1.6;
}
.test-question {
  margin-bottom: 16px;
  padding: 14px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.5);
  border: 1px solid var(--glass-border);
}
.test-question h4 { font-size: 0.95rem; margin-bottom: 10px; }
.option-label {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  font-size: 0.88rem;
  cursor: pointer;
}
.option-label input { width: auto; }

/* ---------- Activity List ---------- */
.activity-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 10px;
}
.activity-list li {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  background: rgba(15, 23, 42, 0.5);
  font-size: 0.85rem;
}

/* ---------- Toast ---------- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  padding: 12px 20px;
  border-radius: 999px;
  background: rgba(15, 23, 42, 0.95);
  border: 1px solid var(--glass-border);
  color: var(--text);
  font-size: 0.85rem;
  z-index: 999;
  box-shadow: var(--shadow);
  max-width: 90vw;
  text-align: center;
}

/* ---------- Responsive ---------- */
@media (min-width: 600px) {
  .main-content { padding: 24px 24px 60px; }
  .grid-2 { gap: 16px; }
  .quick-grid { grid-template-columns: repeat(4, 1fr); }
}