/* ============================================================
   CFA Level 2 Prep System — Global Styles
   ============================================================ */

:root {
  --primary: #1a237e;
  --primary-light: #3949ab;
  --primary-dark: #0d1b6e;
  --accent: #0288d1;
  --accent-light: #29b6f6;
  --success: #2e7d32;
  --success-light: #e8f5e9;
  --error: #c62828;
  --error-light: #ffebee;
  --warning: #e65100;
  --warning-light: #fff3e0;
  --neutral: #f5f5f5;
  --border: #e0e0e0;
  --text-primary: #1a1a2e;
  --text-secondary: #555577;
  --text-muted: #9e9eb0;
  --bg: #f8f9fc;
  --bg-card: #ffffff;
  --bg-header: #1a237e;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.13);
  --radius-sm: 6px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --font-body: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
  --transition: 0.18s ease;

  /* Topic colors */
  --ethics-color: #6a1b9a;
  --quant-color: #1565c0;
  --econ-color: #00695c;
  --fsa-color: #ad1457;
  --ci-color: #4e342e;
  --equity-color: #2e7d32;
  --fi-color: #1a237e;
  --deriv-color: #e65100;
  --alts-color: #6d4c41;
  --pm-color: #0277bd;
}

/* Dark Mode */
body.dark-mode {
  --bg: #0f1117;
  --bg-card: #1a1d2a;
  --bg-header: #0d1040;
  --text-primary: #e8e9f3;
  --text-secondary: #a0a3c4;
  --text-muted: #5c5e80;
  --border: #2a2d45;
  --neutral: #1e2030;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.3);
  --shadow-md: 0 4px 16px rgba(0,0,0,0.35);
  --shadow-lg: 0 8px 32px rgba(0,0,0,0.4);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  transition: background var(--transition), color var(--transition);
}

.container {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
}

/* ============================================================
   HEADER
   ============================================================ */
.app-header {
  background: var(--bg-header);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: var(--shadow-md);
}

.header-inner {
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 24px;
  height: 64px;
  display: flex;
  align-items: center;
  gap: 32px;
}

.logo {
  display: flex;
  align-items: center;
  gap: 12px;
  text-decoration: none;
  flex-shrink: 0;
}

.logo-badge {
  background: #fdd835;
  color: #1a237e;
  font-weight: 800;
  font-size: 13px;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.logo-text {
  display: flex;
  flex-direction: column;
  line-height: 1.1;
}

.logo-level {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
}

.logo-sub {
  font-size: 11px;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.3px;
}

.header-nav {
  display: flex;
  gap: 4px;
  margin-left: auto;
}

.nav-link {
  color: rgba(255,255,255,0.8);
  text-decoration: none;
  padding: 8px 14px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 500;
  transition: all var(--transition);
}

.nav-link:hover,
.nav-link.active {
  color: #fff;
  background: rgba(255,255,255,0.15);
}

.theme-toggle {
  background: none;
  border: 1px solid rgba(255,255,255,0.3);
  color: #fff;
  border-radius: var(--radius-sm);
  padding: 6px 10px;
  cursor: pointer;
  font-size: 16px;
  transition: all var(--transition);
  flex-shrink: 0;
}

.theme-toggle:hover {
  background: rgba(255,255,255,0.15);
}

/* ============================================================
   DASHBOARD
   ============================================================ */
.dashboard {
  padding-bottom: 60px;
}

.hero-stats {
  background: linear-gradient(135deg, var(--primary) 0%, #283593 60%, #1565c0 100%);
  color: #fff;
  padding: 40px 0 48px;
}

.hero-stats .container {
  display: flex;
  flex-direction: column;
  gap: 28px;
}

.hero-text h1 {
  font-size: 28px;
  font-weight: 700;
  margin-bottom: 8px;
}

.hero-text p {
  font-size: 15px;
  color: rgba(255,255,255,0.8);
  max-width: 600px;
}

.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.stat-card {
  background: rgba(255,255,255,0.12);
  border: 1px solid rgba(255,255,255,0.2);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  text-align: center;
  backdrop-filter: blur(10px);
}

.stat-value {
  font-size: 32px;
  font-weight: 800;
  color: #fff;
  line-height: 1;
  margin-bottom: 6px;
  font-variant-numeric: tabular-nums;
}

.stat-label {
  font-size: 12px;
  color: rgba(255,255,255,0.7);
  letter-spacing: 0.3px;
  text-transform: uppercase;
}

/* ============================================================
   MODES SECTION
   ============================================================ */
.modes-section {
  margin-top: 40px;
}

.section-title {
  font-size: 20px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 20px;
}

.mode-cards {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
}

.mode-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px 24px;
  text-decoration: none;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
  position: relative;
  overflow: hidden;
}

.mode-card::before {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 4px;
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}

.mode-study::before { background: var(--accent); }
.mode-exam::before { background: var(--error); }
.mode-weak::before { background: var(--warning); }
.mode-formula::before { background: var(--success); }

.mode-card:hover {
  transform: translateY(-3px);
  box-shadow: var(--shadow-lg);
}

.mode-icon {
  font-size: 32px;
  margin-bottom: 4px;
}

.mode-card h3 {
  font-size: 17px;
  font-weight: 700;
  color: var(--text-primary);
}

.mode-card p {
  font-size: 13.5px;
  color: var(--text-secondary);
  line-height: 1.5;
  flex: 1;
}

.mode-cta {
  font-size: 13px;
  font-weight: 600;
  color: var(--primary);
  margin-top: 8px;
}

.mode-exam .mode-cta { color: var(--error); }
.mode-weak .mode-cta { color: var(--warning); }
.mode-formula .mode-cta { color: var(--success); }

/* ============================================================
   TOPIC GRID
   ============================================================ */
.topics-section {
  margin-top: 40px;
}

.topics-header {
  display: flex;
  align-items: baseline;
  gap: 16px;
  margin-bottom: 20px;
}

.topics-subtitle {
  font-size: 13px;
  color: var(--text-muted);
}

.topic-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 14px;
}

.topic-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  cursor: pointer;
  text-decoration: none;
  display: block;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.topic-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.topic-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: 100px;
  display: inline-block;
  margin-bottom: 10px;
  color: #fff;
}

.topic-card h3 {
  font-size: 14px;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 6px;
  line-height: 1.3;
}

.topic-weight {
  font-size: 11px;
  color: var(--text-muted);
  margin-bottom: 12px;
}

.topic-progress-bar {
  height: 5px;
  background: var(--border);
  border-radius: 100px;
  overflow: hidden;
  margin-bottom: 8px;
}

.topic-progress-fill {
  height: 100%;
  border-radius: 100px;
  transition: width 0.5s ease;
}

.topic-stats {
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: var(--text-muted);
}

/* ============================================================
   BOTTOM SECTION
   ============================================================ */
.bottom-section {
  margin-top: 40px;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
}

.recent-activity,
.recommended-next {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 28px;
  box-shadow: var(--shadow-sm);
}

.activity-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.activity-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  background: var(--neutral);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
}

.activity-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.activity-text {
  flex: 1;
  color: var(--text-primary);
}

.activity-meta {
  font-size: 11px;
  color: var(--text-muted);
  text-align: right;
}

.activity-empty,
.empty-state {
  font-size: 14px;
  color: var(--text-muted);
  text-align: center;
  padding: 24px 18px;
  border: 1px dashed var(--border);
  background: linear-gradient(180deg, rgba(26,35,126,0.02), rgba(26,35,126,0.04));
  border-radius: var(--radius-md);
  line-height: 1.6;
}

.recommend-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recommend-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px;
  background: linear-gradient(180deg, var(--neutral), rgba(26,35,126,0.02));
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  cursor: pointer;
  text-decoration: none;
  transition: all var(--transition);
  box-shadow: 0 1px 2px rgba(0,0,0,0.02);
}

.recommend-item:hover {
  background: rgba(26, 35, 126, 0.03);
  border-color: rgba(26, 35, 126, 0.18);
  transform: translateY(-1px);
}

.recommend-info h4 {
  font-size: 14px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 2px;
}

.recommend-info p {
  font-size: 12px;
  color: var(--text-muted);
}

.recommend-badge {
  font-size: 11px;
  font-weight: 700;
  padding: 4px 10px;
  border-radius: 100px;
  background: var(--primary);
  color: #fff;
}

/* ============================================================
   FOOTER
   ============================================================ */
.app-footer {
  background: var(--text-primary);
  color: rgba(255,255,255,0.5);
  padding: 20px 0;
  text-align: center;
  font-size: 12px;
}

/* ============================================================
   UTILITY
   ============================================================ */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all var(--transition);
  font-family: var(--font-body);
}

.btn-primary {
  background: var(--primary);
  color: #fff;
}
.btn-primary:hover { background: var(--primary-light); }

.btn-danger {
  background: var(--error);
  color: #fff;
}
.btn-danger:hover { opacity: 0.9; }

.btn-ghost {
  background: transparent;
  color: var(--text-primary);
  border: 1px solid var(--border);
}
.btn-ghost:hover { background: var(--neutral); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 100px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.3px;
}

.badge-correct {
  background: var(--success-light);
  color: var(--success);
}

.badge-incorrect {
  background: var(--error-light);
  color: var(--error);
}

.badge-unanswered {
  background: var(--neutral);
  color: var(--text-muted);
}

/* ============================================================
   MODAL OVERLAYS
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(12, 16, 28, 0.52);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  z-index: 200;
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity 0.18s ease, visibility 0.18s ease;
}

.modal-overlay.show {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

.modal-box {
  width: min(520px, 100%);
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 24px;
}

.modal-title {
  font-size: 22px;
  font-weight: 800;
  margin-bottom: 12px;
  color: var(--text-primary);
}

.modal-body {
  color: var(--text-secondary);
  font-size: 15px;
  line-height: 1.6;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  margin-top: 22px;
}

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (max-width: 1100px) {
  .topic-grid { grid-template-columns: repeat(4, 1fr); }
  .mode-cards { grid-template-columns: repeat(2, 1fr); }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
  .header-nav { display: none; }
  .topic-grid { grid-template-columns: repeat(2, 1fr); }
  .mode-cards { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .bottom-section { grid-template-columns: 1fr; }
}

@media (max-width: 480px) {
  .topic-grid { grid-template-columns: 1fr; }
  .stats-row { grid-template-columns: 1fr; }
}
