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

:root {
  --bg: #0f1117;
  --bg2: #171b26;
  --bg3: #1e2333;
  --border: #2a2f45;
  --accent: #6c63ff;
  --accent2: #4ecdc4;
  --accent3: #ff6b6b;
  --accent4: #ffd93d;
  --text: #e8eaf0;
  --text2: #8b90a7;
  --text3: #5a5f75;
  --success: #4caf50;
  --warning: #ff9800;
  --danger: #f44336;
  --sidebar-w: 240px;
  --radius: 12px;
  --radius-sm: 8px;
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  display: flex;
  min-height: 100vh;
  font-size: 14px;
}

/* ── Sidebar ── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
  overflow-y: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border);
}
.logo-icon { font-size: 22px; }
.logo-text { font-size: 16px; font-weight: 700; color: var(--text); letter-spacing: 0.3px; }

.nav-links { list-style: none; padding: 12px 0; flex: 1; }

.nav-item {
  border-radius: var(--radius-sm);
  margin: 2px 8px;
  transition: background 0.15s, color 0.15s;
}
.nav-item a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 12px;
  color: var(--text2);
  font-size: 13.5px;
  font-weight: 500;
  text-decoration: none;
  border-radius: var(--radius-sm);
  width: 100%;
}
.nav-item:hover { background: var(--bg3); }
.nav-item:hover a { color: var(--text); }
.nav-item.active { background: rgba(108,99,255,0.15); }
.nav-item.active a { color: var(--accent); }
.nav-icon { width: 20px; display: flex; align-items: center; justify-content: center; }
.nav-icon svg { width: 16px; height: 16px; stroke-width: 2; flex-shrink: 0; }
.logo-icon { display: flex; align-items: center; }
.logo-icon svg { width: 20px; height: 20px; stroke: var(--accent); stroke-width: 2; }
.stat-icon { display: flex; justify-content: center; margin-bottom: 8px; }
.stat-icon svg { width: 20px; height: 20px; stroke: var(--accent); opacity: 0.75; stroke-width: 2; }
.empty-icon { margin-bottom: 14px; display: flex; justify-content: center; }
.empty-icon svg { width: 52px; height: 52px; stroke: var(--text3); stroke-width: 1.5; }
.my-exam-badge svg { width: 11px; height: 11px; display: inline; vertical-align: middle; stroke: var(--accent); fill: var(--accent); margin-right: 2px; }

.sidebar-bottom {
  padding: 16px;
  border-top: 1px solid var(--border);
}
.sidebar-bottom label { font-size: 11px; font-weight: 600; color: var(--text3); text-transform: uppercase; letter-spacing: 0.8px; display: block; margin-bottom: 8px; }

#subject-tags { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 8px; }
.subject-tag {
  background: rgba(108,99,255,0.2);
  color: var(--accent);
  border: 1px solid rgba(108,99,255,0.3);
  padding: 3px 8px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 4px;
}
.subject-tag .remove-tag { cursor: pointer; opacity: 0.6; font-size: 10px; }
.subject-tag .remove-tag:hover { opacity: 1; }

/* ── Main Content ── */
.main-content {
  margin-left: var(--sidebar-w);
  flex: 1;
  padding: 32px 36px;
  max-width: calc(100vw - var(--sidebar-w));
}

.page { display: none; }
.page.active { display: block; }

.page-header { margin-bottom: 28px; }
.page-header h1 { font-size: 26px; font-weight: 700; color: var(--text); }
.page-header .subtitle { color: var(--text2); margin-top: 4px; font-size: 14px; }

/* ── Cards ── */
.card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
}
.card h3 { font-size: 15px; font-weight: 600; margin-bottom: 14px; color: var(--text); }

/* ── Stats Row ── */
.stats-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 14px;
  margin-bottom: 24px;
}
.stat-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px 20px;
  text-align: center;
}
.stat-value { font-size: 30px; font-weight: 800; color: var(--accent); line-height: 1.1; }
.stat-label { font-size: 12px; color: var(--text2); margin-top: 4px; }

/* ── Dashboard Grid ── */
.dashboard-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  grid-template-rows: auto auto;
  gap: 16px;
}
.progress-card { grid-column: 1 / -1; }

/* Upcoming exams */
.exam-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.exam-item:last-child { border-bottom: none; }
.exam-name { font-weight: 500; font-size: 13px; }
.exam-date-badge {
  font-size: 11px;
  padding: 3px 9px;
  border-radius: 20px;
  font-weight: 600;
  white-space: nowrap;
}
.badge-soon { background: rgba(244,67,54,0.2); color: #ff6b6b; }
.badge-near { background: rgba(255,152,0,0.2); color: var(--warning); }
.badge-far  { background: rgba(76,175,80,0.2); color: var(--success); }

/* Today tasks */
.task-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 0;
  border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-checkbox {
  width: 18px; height: 18px;
  border: 2px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, border-color 0.15s;
}
.task-checkbox.checked { background: var(--accent); border-color: var(--accent); }
.task-checkbox.checked::after { content: '✓'; color: white; font-size: 11px; }
.task-text { font-size: 13px; flex: 1; }
.task-text.done { text-decoration: line-through; color: var(--text3); }
.task-badge {
  font-size: 10px;
  padding: 2px 7px;
  border-radius: 10px;
  font-weight: 600;
}
.badge-study    { background: rgba(108,99,255,0.2); color: var(--accent); }
.badge-practice { background: rgba(255,107,107,0.2); color: var(--accent3); }
.badge-review   { background: rgba(78,205,196,0.2); color: var(--accent2); }
.badge-other    { background: rgba(255,217,61,0.2); color: var(--accent4); }
.task-delete { cursor: pointer; color: var(--text3); font-size: 12px; opacity: 0; transition: opacity 0.15s; }
.task-item:hover .task-delete { opacity: 1; }

/* Progress bars */
.progress-item { margin-bottom: 14px; }
.progress-label {
  display: flex;
  justify-content: space-between;
  font-size: 12px;
  margin-bottom: 5px;
}
.progress-label span:first-child { color: var(--text); font-weight: 500; }
.progress-label span:last-child { color: var(--text2); }
.progress-bar-bg {
  background: var(--bg3);
  border-radius: 10px;
  height: 8px;
  overflow: hidden;
}
.progress-bar-fill {
  height: 100%;
  border-radius: 10px;
  background: linear-gradient(90deg, var(--accent), var(--accent2));
  transition: width 0.4s ease;
}

/* ── Roadmap ── */
.roadmap-controls { margin-bottom: 24px; }
.roadmap-timeline { position: relative; padding-left: 32px; }
.roadmap-timeline::before {
  content: '';
  position: absolute;
  left: 10px; top: 0; bottom: 0;
  width: 2px;
  background: linear-gradient(to bottom, var(--accent), var(--accent2));
  border-radius: 2px;
}
.roadmap-phase { position: relative; margin-bottom: 28px; }
.roadmap-dot {
  position: absolute;
  left: -26px; top: 14px;
  width: 14px; height: 14px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid var(--bg);
  box-shadow: 0 0 0 3px rgba(108,99,255,0.3);
}
.roadmap-dot.done { background: var(--success); box-shadow: 0 0 0 3px rgba(76,175,80,0.3); }
.roadmap-dot.current { background: var(--accent4); box-shadow: 0 0 0 3px rgba(255,217,61,0.3); animation: pulse 2s infinite; }
@keyframes pulse { 0%,100% { box-shadow: 0 0 0 3px rgba(255,217,61,0.3); } 50% { box-shadow: 0 0 0 6px rgba(255,217,61,0.1); } }
.roadmap-phase-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 16px 18px;
}
.roadmap-phase-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 8px; }
.roadmap-phase-title { font-weight: 700; font-size: 14px; }
.roadmap-phase-time { font-size: 11px; color: var(--text2); background: var(--bg3); padding: 3px 8px; border-radius: 20px; }
.roadmap-phase-desc { font-size: 13px; color: var(--text2); margin-bottom: 10px; }
.roadmap-topics { display: flex; flex-wrap: wrap; gap: 6px; }
.roadmap-topic {
  font-size: 11px;
  padding: 3px 9px;
  background: var(--bg3);
  border-radius: 20px;
  color: var(--text2);
  border: 1px solid var(--border);
}

/* ── Schedule ── */
.schedule-layout { display: grid; grid-template-columns: 300px 1fr; gap: 16px; }
.form-group { margin-bottom: 12px; }
.form-group label { display: block; font-size: 12px; font-weight: 600; color: var(--text2); margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.5px; }
.input-field, .select-input {
  width: 100%;
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  font-size: 13px;
  outline: none;
  transition: border-color 0.15s;
}
.input-field:focus, .select-input:focus { border-color: var(--accent); }
.select-input { cursor: pointer; }

.tasks-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; }
.tasks-header h3 { margin-bottom: 0; }
.search-input {
  background: var(--bg3);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: 7px 12px;
  font-size: 12px;
  outline: none;
  width: 160px;
}
.search-input.wide { width: 300px; }
.search-input:focus { border-color: var(--accent); }

.task-date-group { margin-bottom: 16px; }
.task-date-label { font-size: 11px; font-weight: 700; color: var(--text3); text-transform: uppercase; letter-spacing: 0.8px; margin-bottom: 6px; }

/* ── Practice ── */
.practice-controls { display: flex; gap: 12px; margin-bottom: 24px; }
.practice-controls .select-input { max-width: 300px; }

.question-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px;
  margin-bottom: 16px;
}
.question-number { font-size: 11px; color: var(--text3); margin-bottom: 8px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.5px; }
.question-text { font-size: 15px; font-weight: 500; margin-bottom: 18px; line-height: 1.6; }
.options-list { list-style: none; display: flex; flex-direction: column; gap: 8px; }
.option-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 11px 14px;
  background: var(--bg3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
  font-size: 13px;
}
.option-item:hover { background: rgba(108,99,255,0.1); border-color: var(--accent); }
.option-item.selected { background: rgba(108,99,255,0.2); border-color: var(--accent); color: var(--accent); }
.option-item.correct { background: rgba(76,175,80,0.2); border-color: var(--success); color: var(--success); }
.option-item.wrong { background: rgba(244,67,54,0.2); border-color: var(--danger); color: var(--accent3); }
.option-letter { font-weight: 700; min-width: 20px; }

.explanation-box {
  margin-top: 14px;
  padding: 12px 14px;
  background: rgba(108,99,255,0.08);
  border: 1px solid rgba(108,99,255,0.2);
  border-radius: var(--radius-sm);
  font-size: 13px;
  color: var(--text2);
  line-height: 1.6;
}
.explanation-box strong { color: var(--accent); }

.practice-nav { display: flex; justify-content: space-between; align-items: center; margin-top: 8px; }

.results-card { max-width: 480px; margin: 0 auto; text-align: center; }
.result-score { font-size: 52px; font-weight: 800; color: var(--accent); margin: 16px 0; }
#result-breakdown { font-size: 13px; color: var(--text2); margin-bottom: 20px; }

/* ── Exam Dates ── */
.exam-filter { display: flex; gap: 12px; margin-bottom: 24px; }
.exam-week-section { margin-bottom: 28px; }
.exam-week-title {
  font-size: 13px;
  font-weight: 700;
  color: var(--text3);
  text-transform: uppercase;
  letter-spacing: 1px;
  margin-bottom: 10px;
}
.exam-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 10px; }
.exam-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 14px 16px;
  transition: border-color 0.15s;
}
.exam-card:hover { border-color: var(--accent); }
.exam-card.my-exam { border-color: rgba(108,99,255,0.4); background: rgba(108,99,255,0.06); }
.exam-card-name { font-size: 13px; font-weight: 600; margin-bottom: 4px; }
.exam-card-date { font-size: 12px; color: var(--text2); }
.exam-card-time { font-size: 11px; color: var(--text3); margin-top: 2px; }
.my-exam-badge { font-size: 10px; color: var(--accent); font-weight: 700; margin-top: 5px; }
.exam-card-countdown { font-size: 11px; color: var(--accent4); font-weight: 600; margin-top: 3px; }

/* ── Buttons ── */
.btn-primary {
  background: var(--accent);
  color: white;
  border: none;
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
  width: 100%;
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }
.btn-secondary {
  background: transparent;
  color: var(--accent);
  border: 1px solid var(--accent);
  border-radius: var(--radius-sm);
  padding: 10px 18px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  margin-right: 8px;
}
.btn-secondary:hover { background: rgba(108,99,255,0.1); }
.btn-small {
  background: var(--bg3);
  color: var(--text2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 5px 10px;
  font-size: 11px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  width: 100%;
}
.btn-small:hover { background: var(--accent); color: white; border-color: var(--accent); }

/* ── Modal ── */
.modal {
  position: fixed;
  top: 50%; left: 50%;
  transform: translate(-50%, -50%);
  z-index: 300;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  width: 480px;
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0,0,0,0.5);
}
.modal-overlay {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.6);
  z-index: 200;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 20px;
  border-bottom: 1px solid var(--border);
}
.modal-header h3 { font-size: 15px; }
.modal-close { background: none; border: none; color: var(--text2); cursor: pointer; font-size: 16px; padding: 2px 6px; border-radius: 4px; }
.modal-close:hover { background: var(--bg3); color: var(--text); }
.modal-body { padding: 16px 20px; overflow-y: auto; }
.modal-body .input-field { margin-bottom: 12px; }

.subject-list { display: flex; flex-direction: column; gap: 4px; }
.subject-option {
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 13px;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.subject-option:hover { background: var(--bg3); }
.subject-option.selected { background: rgba(108,99,255,0.15); color: var(--accent); }
.subject-option .check { font-size: 12px; }

/* ── Utilities ── */
.hidden { display: none !important; }
.empty-state { color: var(--text3); font-size: 13px; padding: 12px 0; }
.empty-state-large { text-align: center; padding: 60px 20px; }
.empty-icon { font-size: 48px; margin-bottom: 12px; }
.empty-state-large p { color: var(--text2); font-size: 14px; }

/* ── Scrollbar ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: var(--bg); }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--text3); }
