/* ══════════════════════════════════════════════════════════
   PrepFlow — Design System
   Study-calm teal-green glassmorphic dark theme
   ══════════════════════════════════════════════════════════ */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
  --bg: hsl(230, 20%, 8%);
  --bg-surface: hsl(230, 18%, 11%);
  --glass: rgba(255,255,255,0.04);
  --glass-border: rgba(255,255,255,0.08);
  --accent: hsl(168, 80%, 50%);
  --accent-dim: rgba(52, 211, 153, 0.12);
  --accent-glow: rgba(52, 211, 153, 0.25);
  --warning: hsl(38, 92%, 60%);
  --warning-dim: rgba(251, 191, 36, 0.12);
  --danger: hsl(0, 72%, 60%);
  --danger-dim: rgba(239, 68, 68, 0.12);
  --success: hsl(142, 72%, 55%);
  --success-dim: rgba(34, 197, 94, 0.12);
  --text-primary: rgba(255,255,255,0.92);
  --text-secondary: rgba(255,255,255,0.55);
  --text-muted: rgba(255,255,255,0.3);
  --radius-sm: 10px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --nav-height: 64px;
  --header-height: 56px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  -webkit-font-smoothing: antialiased;
  -webkit-tap-highlight-color: transparent;
}

.hidden { display: none !important; }

/* ── App Shell ──────────────────────────────────────────── */
.app {
  display: flex; flex-direction: column;
  height: 100vh; height: 100dvh;
  max-width: 480px; margin: 0 auto;
  position: relative; overflow: hidden;
}

/* ── Header ─────────────────────────────────────────────── */
.app-header {
  height: var(--header-height);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 20px; flex-shrink: 0;
  background: rgba(15, 18, 25, 0.85);
  backdrop-filter: blur(20px); -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--glass-border);
  z-index: 10;
}
.header-title { font-size: 18px; font-weight: 700; }
.header-countdown {
  display: flex; align-items: baseline; gap: 5px;
}
.countdown-num { font-size: 20px; font-weight: 800; color: var(--accent); }
.countdown-label { font-size: 11px; color: var(--text-secondary); font-weight: 500; }

/* ── Page Container ─────────────────────────────────────── */
.page-container {
  flex: 1; overflow-y: auto; overflow-x: hidden;
  padding: 16px 16px calc(var(--nav-height) + var(--safe-bottom) + 16px) 16px;
  scroll-behavior: smooth;
  -webkit-overflow-scrolling: touch;
}
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.2s ease; }
@keyframes fadeIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }

/* ── Bottom Nav ─────────────────────────────────────────── */
.bottom-nav {
  position: fixed; bottom: 0; left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  height: calc(var(--nav-height) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  display: flex; align-items: center; justify-content: space-around;
  background: rgba(15, 18, 25, 0.92);
  backdrop-filter: blur(24px); -webkit-backdrop-filter: blur(24px);
  border-top: 1px solid var(--glass-border);
  z-index: 100;
}
.nav-item {
  display: flex; flex-direction: column; align-items: center; gap: 3px;
  background: none; border: none; color: var(--text-muted);
  font-size: 10px; font-weight: 600; font-family: inherit;
  cursor: pointer; padding: 6px 0; min-width: 52px;
  transition: color 0.2s, transform 0.15s;
}
.nav-item.active { color: var(--accent); }
.nav-item:active { transform: scale(0.9); }
.nav-item svg { transition: stroke 0.2s; }

/* ── Countdown Card ─────────────────────────────────────── */
.countdown-card {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 24px 16px; margin-bottom: 16px;
  background: linear-gradient(145deg, rgba(52,211,153,0.08), rgba(52,211,153,0.02));
  border: 1px solid rgba(52,211,153,0.15);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(24px);
}
.countdown-ring-wrap { position: relative; width: 140px; height: 140px; }
.countdown-ring { width: 100%; height: 100%; transform: rotate(-90deg); }
.ring-bg { fill: none; stroke: rgba(255,255,255,0.06); stroke-width: 6; }
.ring-fill {
  fill: none; stroke: var(--accent); stroke-width: 6;
  stroke-linecap: round;
  stroke-dasharray: 326.73; stroke-dashoffset: 326.73;
  transition: stroke-dashoffset 1.2s ease, stroke 0.5s;
}
.countdown-inner {
  position: absolute; inset: 0;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
}
.countdown-big { font-size: 40px; font-weight: 800; line-height: 1; color: var(--accent); }
.countdown-sub { font-size: 12px; color: var(--text-secondary); font-weight: 500; margin-top: 2px; }
.countdown-meta { font-size: 12px; color: var(--text-secondary); }

/* ── Phase Bar ──────────────────────────────────────────── */
.phase-bar {
  display: flex; align-items: center; justify-content: center; gap: 0;
  margin-bottom: 16px; padding: 10px 16px;
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: var(--radius-md);
}
.phase-segment {
  display: flex; align-items: center; gap: 5px;
  font-size: 11px; font-weight: 600; color: var(--text-muted);
  padding: 4px 8px; border-radius: 8px;
  transition: all 0.3s;
}
.phase-segment.active {
  color: var(--accent); background: var(--accent-dim);
}
.phase-segment.completed { color: var(--success); }
.phase-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted); transition: background 0.3s;
}
.phase-segment.active .phase-dot { background: var(--accent); box-shadow: 0 0 8px var(--accent-glow); }
.phase-segment.completed .phase-dot { background: var(--success); }
.phase-connector {
  width: 24px; height: 2px; background: rgba(255,255,255,0.08);
  margin: 0 2px; border-radius: 1px;
}

/* ── Stats Row ──────────────────────────────────────────── */
.stats-row { display: flex; gap: 8px; margin-bottom: 16px; }
.stat-pill {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 2px;
  padding: 10px 8px; border-radius: var(--radius-md);
  background: var(--glass); border: 1px solid var(--glass-border);
}
.stat-icon { font-size: 16px; }
.stat-val { font-size: 16px; font-weight: 700; }
.stat-lbl { font-size: 10px; color: var(--text-secondary); font-weight: 500; text-transform: uppercase; letter-spacing: 0.3px; }

/* ── Week Strip ─────────────────────────────────────────── */
.week-strip {
  display: flex; gap: 6px; margin-bottom: 16px;
}
.week-day {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 3px;
  padding: 8px 4px; border-radius: var(--radius-sm);
  background: var(--glass); border: 1px solid transparent;
  transition: all 0.2s;
}
.week-day.today { border-color: var(--accent); background: var(--accent-dim); }
.week-day-name { font-size: 10px; font-weight: 600; color: var(--text-muted); text-transform: uppercase; }
.week-day-num { font-size: 14px; font-weight: 700; }
.week-day-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--text-muted); }
.week-day.done .week-day-dot { background: var(--success); }
.week-day.missed .week-day-dot { background: var(--danger); }
.week-day.today .week-day-dot { background: var(--accent); }

/* ── Section Card ───────────────────────────────────────── */
.section-card {
  background: linear-gradient(145deg, rgba(255,255,255,0.04), rgba(255,255,255,0.01));
  border-radius: var(--radius-md); padding: 16px; margin-bottom: 14px;
  border: 1px solid var(--glass-border);
  backdrop-filter: blur(24px);
}
.section-title { font-size: 14px; font-weight: 700; margin-bottom: 12px; }
.section-header-row {
  display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px;
}
.section-header-row .section-title { margin-bottom: 0; }
.empty-state {
  text-align: center; font-size: 13px; color: var(--text-muted); padding: 16px 0;
}

/* ── Today Task Card ────────────────────────────────────── */
.today-task {
  display: flex; flex-direction: column; gap: 10px;
}
.today-task-module {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--text-secondary); font-weight: 600;
}
.today-task-module .module-dot {
  width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0;
}
.today-task-title { font-size: 16px; font-weight: 700; }
.today-task-actions {
  display: flex; gap: 8px; margin-top: 4px;
}
.task-btn {
  flex: 1; padding: 10px 14px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 600; font-family: inherit;
  border: 1px solid var(--glass-border); background: var(--glass);
  color: var(--text-primary); cursor: pointer;
  display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: all 0.2s;
}
.task-btn:active { transform: scale(0.97); }
.task-btn-fb { background: rgba(24,119,242,0.15); border-color: rgba(24,119,242,0.3); color: #4599ff; }
.task-btn-fb:hover { background: rgba(24,119,242,0.25); }
.task-btn-done { background: var(--success-dim); border-color: rgba(34,197,94,0.3); color: var(--success); }
.task-btn-done:hover { background: rgba(34,197,94,0.2); }
.task-btn-done.completed {
  background: var(--success); color: #fff; border-color: var(--success);
}
.today-task-notes {
  margin-top: 4px;
}
.today-task-notes textarea {
  width: 100%; padding: 8px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.04); border: 1px solid var(--glass-border);
  color: var(--text-primary); font-size: 12px; font-family: inherit;
  resize: vertical; min-height: 50px; outline: none;
}
.today-task-notes textarea:focus { border-color: var(--accent); }

/* ── Module Progress Mini ───────────────────────────────── */
.mod-prog-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.mod-prog-item:last-child { border-bottom: none; }
.mod-prog-emoji { font-size: 18px; width: 28px; text-align: center; }
.mod-prog-info { flex: 1; }
.mod-prog-name { font-size: 13px; font-weight: 600; }
.mod-prog-bar-wrap {
  width: 100%; height: 4px; border-radius: 2px;
  background: rgba(255,255,255,0.06); margin-top: 4px; overflow: hidden;
}
.mod-prog-bar-fill {
  height: 100%; border-radius: 2px; transition: width 0.5s ease;
}
.mod-prog-count { font-size: 11px; color: var(--text-secondary); font-weight: 600; white-space: nowrap; }

/* ── Modules Page ───────────────────────────────────────── */
.page-actions {
  display: flex; justify-content: flex-end; margin-bottom: 12px;
}
.action-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 14px; border-radius: var(--radius-sm);
  background: var(--accent-dim); border: 1px solid rgba(52,211,153,0.3);
  color: var(--accent); font-size: 13px; font-weight: 600; font-family: inherit;
  cursor: pointer; transition: all 0.2s;
}
.action-btn:active { transform: scale(0.96); }
.action-btn-full { width: 100%; justify-content: center; margin-top: 8px; }
.action-btn-danger { background: var(--danger-dim); border-color: rgba(239,68,68,0.3); color: var(--danger); }

.icon-btn {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-dim); border: 1px solid rgba(52,211,153,0.3);
  color: var(--accent); font-size: 16px; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; transition: all 0.15s; font-family: inherit;
}
.icon-btn:active { transform: scale(0.9); }

/* Module Cards */
.module-card {
  background: var(--glass); border: 1px solid var(--glass-border);
  border-radius: var(--radius-md); margin-bottom: 10px; overflow: hidden;
  transition: all 0.2s;
}
.module-card-header {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 14px; cursor: pointer;
  transition: background 0.2s;
}
.module-card-header:active { background: rgba(255,255,255,0.02); }
.module-card-emoji { font-size: 22px; }
.module-card-info { flex: 1; }
.module-card-name { font-size: 14px; font-weight: 700; }
.module-card-progress { font-size: 11px; color: var(--text-secondary); font-weight: 500; margin-top: 2px; }
.module-card-bar {
  width: 100%; height: 3px; border-radius: 2px;
  background: rgba(255,255,255,0.06); margin-top: 4px; overflow: hidden;
}
.module-card-bar-fill { height: 100%; border-radius: 2px; transition: width 0.4s; }
.module-card-chevron {
  color: var(--text-muted); transition: transform 0.2s; font-size: 16px;
}
.module-card.expanded .module-card-chevron { transform: rotate(90deg); }
.module-card-actions {
  display: flex; gap: 6px;
}
.module-card-actions button {
  padding: 4px 8px; border-radius: 6px; font-size: 11px;
  background: transparent; border: 1px solid var(--glass-border);
  color: var(--text-secondary); cursor: pointer; font-family: inherit;
  transition: all 0.15s;
}
.module-card-actions button:hover { background: var(--glass); }
.module-card-actions .del-btn:hover { color: var(--danger); border-color: rgba(239,68,68,0.3); }

/* Video List inside Module */
.module-videos {
  display: none; padding: 0 14px 14px;
}
.module-card.expanded .module-videos { display: block; }
.video-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-top: 1px solid rgba(255,255,255,0.04);
}
.video-check {
  width: 22px; height: 22px; border-radius: 6px;
  border: 2px solid rgba(255,255,255,0.15); background: transparent;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.2s; flex-shrink: 0; font-size: 12px; color: transparent;
}
.video-check.done { background: var(--success); border-color: var(--success); color: #fff; }
.video-info { flex: 1; min-width: 0; }
.video-title { font-size: 13px; font-weight: 500; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.video-title.done { text-decoration: line-through; color: var(--text-muted); }
.video-actions { display: flex; gap: 4px; flex-shrink: 0; }
.video-actions button {
  padding: 4px 6px; border-radius: 5px; font-size: 12px;
  background: transparent; border: none; cursor: pointer;
  transition: all 0.15s;
}
.video-fb-btn { color: #4599ff; }
.video-edit-btn { color: var(--text-secondary); }
.video-del-btn { color: var(--text-muted); }
.video-del-btn:hover { color: var(--danger); }
.add-video-btn {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 0; font-size: 12px; color: var(--accent);
  background: none; border: none; cursor: pointer; font-family: inherit; font-weight: 600;
}

/* ── Calendar ───────────────────────────────────────────── */
.cal-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 12px;
}
.cal-title { font-size: 16px; font-weight: 700; }
.cal-arrow {
  width: 36px; height: 36px; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--glass-border);
  color: var(--text-primary); font-size: 18px; font-weight: 600;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all 0.15s;
}
.cal-arrow:active { transform: scale(0.92); background: var(--accent-dim); }
.cal-grid {
  display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px;
  margin-bottom: 16px;
}
.cal-day-header {
  text-align: center; font-size: 10px; font-weight: 700;
  color: var(--text-muted); padding: 4px 0; text-transform: uppercase;
}
.cal-day {
  aspect-ratio: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 2px;
  border-radius: 8px; font-size: 12px; font-weight: 600;
  cursor: pointer; transition: all 0.15s;
  color: var(--text-secondary); background: transparent;
  border: 1px solid transparent;
}
.cal-day.other-month { color: var(--text-muted); opacity: 0.4; }
.cal-day.today { border-color: var(--accent); color: var(--accent); }
.cal-day.selected { background: var(--accent-dim); border-color: var(--accent); }
.cal-day.has-task { font-weight: 700; color: var(--text-primary); }
.cal-day-dot { width: 4px; height: 4px; border-radius: 50%; }
.cal-day.done .cal-day-dot { background: var(--success); }
.cal-day.missed .cal-day-dot { background: var(--danger); }
.cal-day.pending .cal-day-dot { background: var(--warning); }
.cal-day:active { transform: scale(0.92); }

/* ── Day Detail ─────────────────────────────────────────── */
#day-detail-title { font-size: 13px; }
.day-task-item {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.day-task-item:last-child { border-bottom: none; }

/* ── Revision Page ──────────────────────────────────────── */
.subject-card {
  margin-bottom: 10px;
}
.subject-header {
  display: flex; align-items: center; gap: 8px; padding: 8px 0;
  cursor: pointer;
}
.subject-emoji { font-size: 18px; }
.subject-name { flex: 1; font-size: 14px; font-weight: 600; }
.subject-count { font-size: 11px; color: var(--text-secondary); font-weight: 600; }
.subject-actions { display: flex; gap: 4px; }
.subject-tasks { padding-left: 10px; }
.subject-task-item {
  display: flex; align-items: center; gap: 8px; padding: 7px 0;
  border-bottom: 1px solid rgba(255,255,255,0.03);
}
.subject-task-item:last-child { border-bottom: none; }
.task-check {
  width: 20px; height: 20px; border-radius: 5px;
  border: 2px solid rgba(255,255,255,0.12); background: transparent;
  cursor: pointer; flex-shrink: 0; font-size: 11px; color: transparent;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.2s;
}
.task-check.done { background: var(--success); border-color: var(--success); color: #fff; }
.task-title { flex: 1; font-size: 13px; font-weight: 500; }
.task-title.done { text-decoration: line-through; color: var(--text-muted); }

/* Review list items */
.review-item {
  display: flex; align-items: center; gap: 10px; padding: 8px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.review-item:last-child { border-bottom: none; }
.review-emoji { font-size: 16px; }
.review-name { flex: 1; font-size: 13px; font-weight: 500; }

/* Mock exam items */
.exam-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}
.exam-item:last-child { border-bottom: none; }
.exam-score {
  font-size: 16px; font-weight: 800; min-width: 50px; text-align: center;
}
.exam-info { flex: 1; }
.exam-title { font-size: 13px; font-weight: 600; }
.exam-date { font-size: 11px; color: var(--text-secondary); }

/* ── Settings ───────────────────────────────────────────── */
.setting-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 0; border-bottom: 1px solid rgba(255,255,255,0.04);
}
.setting-row:last-child { border-bottom: none; }
.setting-row label { font-size: 13px; font-weight: 500; }
.setting-input {
  padding: 6px 10px; border-radius: 8px;
  background: rgba(255,255,255,0.05); border: 1px solid var(--glass-border);
  color: var(--text-primary); font-size: 13px; font-family: inherit;
  text-align: right; outline: none; max-width: 160px;
  color-scheme: dark; appearance: none; -webkit-appearance: none;
}
.setting-input:focus { border-color: var(--accent); }
select.setting-input { padding-right: 24px; }

/* ── Modal ──────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 200;
  background: rgba(0,0,0,0.6); backdrop-filter: blur(6px);
  display: flex; align-items: flex-end; justify-content: center;
  animation: fadeIn 0.15s ease;
}
.modal-box {
  width: 100%; max-width: 480px; max-height: 85vh;
  background: var(--bg-surface);
  border: 1px solid var(--glass-border);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  overflow-y: auto; padding: 20px;
  animation: slideUp 0.25s ease;
}
@keyframes slideUp { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.modal-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; }
.modal-header h3 { font-size: 16px; font-weight: 700; }
.modal-close {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--glass); border: 1px solid var(--glass-border);
  color: var(--text-secondary); font-size: 14px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.modal-body { display: flex; flex-direction: column; gap: 12px; }
.modal-input {
  width: 100%; padding: 10px 12px; border-radius: var(--radius-sm);
  background: rgba(255,255,255,0.04); border: 1px solid var(--glass-border);
  color: var(--text-primary); font-size: 14px; font-family: inherit; outline: none;
}
.modal-input:focus { border-color: var(--accent); }
.modal-input::placeholder { color: var(--text-muted); }
.modal-label { font-size: 12px; font-weight: 600; color: var(--text-secondary); margin-bottom: -6px; }
.modal-row { display: flex; gap: 8px; }
.modal-row .modal-input { flex: 1; }
.modal-submit {
  padding: 12px; border-radius: var(--radius-sm);
  background: var(--accent); border: none;
  color: #000; font-size: 14px; font-weight: 700; font-family: inherit;
  cursor: pointer; transition: all 0.15s;
}
.modal-submit:active { transform: scale(0.97); }

/* ── Toast ──────────────────────────────────────────────── */
.toast {
  position: fixed; bottom: calc(var(--nav-height) + var(--safe-bottom) + 16px);
  left: 50%; transform: translateX(-50%);
  padding: 10px 20px; border-radius: 12px;
  background: var(--accent); color: #000;
  font-size: 13px; font-weight: 600;
  z-index: 300; white-space: nowrap;
  animation: toastIn 0.3s ease;
}
@keyframes toastIn { from { opacity: 0; transform: translate(-50%, 10px); } to { opacity: 1; transform: translate(-50%, 0); } }

/* ── Emoji Picker Row ───────────────────────────────────── */
.emoji-row {
  display: flex; gap: 6px; flex-wrap: wrap;
}
.emoji-opt {
  width: 36px; height: 36px; border-radius: 8px;
  background: var(--glass); border: 1px solid transparent;
  font-size: 18px; cursor: pointer; display: flex;
  align-items: center; justify-content: center;
  transition: all 0.15s;
}
.emoji-opt.selected { border-color: var(--accent); background: var(--accent-dim); }

/* ── Completion Animation ───────────────────────────────── */
@keyframes checkPop {
  0% { transform: scale(0.5); } 50% { transform: scale(1.3); } 100% { transform: scale(1); }
}
.check-pop { animation: checkPop 0.3s ease; }
