@import url('https://fonts.googleapis.com/css2?family=Syne:wght@400;600;700;800&family=DM+Sans:ital,wght@0,300;0,400;0,500;1,300&display=swap');

:root {
  --bg: #0a0f1e;
  --surface: #111827;
  --surface2: #1a2236;
  --border: #1e2d45;
  --accent: #00d4ff;
  --accent2: #7c3aed;
  --accent3: #10b981;
  --warn: #f59e0b;
  --danger: #ef4444;
  --text: #e8edf5;
  --muted: #6b7a99;
  --card: #141e30;
}

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

body {
  font-family: 'DM Sans', sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

h1, h2, h3, h4 { font-family: 'Syne', sans-serif; }

/* NAV */
.top-nav {
  position: fixed; top: 0; left: 0; right: 0; z-index: 100;
  background: rgba(10,15,30,0.92);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  display: flex; align-items: center; justify-content: space-between;
  padding: 0 24px; height: 56px;
}
.nav-logo {
  font-family: 'Syne', sans-serif; font-weight: 800;
  font-size: 1.2rem; color: var(--accent); letter-spacing: -0.5px;
  text-decoration: none;
}
.nav-logo span { color: var(--text); }
.nav-links { display: flex; gap: 12px; align-items: center; }
.nav-link {
  color: var(--muted); font-size: 0.85rem; text-decoration: none;
  padding: 6px 12px; border-radius: 6px; transition: all 0.2s;
  border: 1px solid transparent;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--accent); border-color: var(--accent); background: var(--surface2); }

/* HAMBURGER MENU */
.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 1001;
}
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}
.hamburger-btn.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.open span:nth-child(2) {
  opacity: 0;
}
.hamburger-btn.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-drawer {
  position: fixed;
  top: 0; right: -300px;
  width: 280px;
  height: 100vh;
  background: var(--card);
  border-left: 1px solid var(--border);
  z-index: 1000;
  transition: right 0.3s ease;
  padding: 80px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.nav-drawer.open {
  right: 0;
}
.nav-drawer a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
}
.nav-drawer a:hover,
.nav-drawer a.active {
  background: rgba(0,212,255,0.08);
  color: var(--accent);
}
.nav-drawer .drawer-section {
  font-size: 0.68rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 16px 16px 4px;
  font-weight: 600;
}
.nav-drawer .drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}
.nav-drawer .drawer-logout {
  margin-top: auto;
  color: var(--danger) !important;
}
.nav-drawer .drawer-logout:hover {
  background: rgba(239,68,68,0.1) !important;
  color: var(--danger) !important;
}

.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}
.drawer-overlay.open {
  display: block;
}

/* BUTTONS */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 9px 18px; border-radius: 8px;
  font-family: 'DM Sans', sans-serif; font-size: 0.85rem;
  font-weight: 500; cursor: pointer; border: none; transition: all 0.2s;
  text-decoration: none;
}
.btn-primary { background: var(--accent); color: #0a0f1e; }
.btn-primary:hover { background: #00b8d9; }
.btn-secondary { background: var(--surface2); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); color: var(--accent); }
.btn-large { padding: 13px 28px; font-size: 0.95rem; border-radius: 10px; }
.btn-full { width: 100%; justify-content: center; }

/* CARD */
.card {
  background: var(--card); border: 1px solid var(--border);
  border-radius: 12px; padding: 20px;
}

/* FORM */
.form-group { margin-bottom: 16px; }
.form-label { font-size: 0.8rem; color: var(--muted); margin-bottom: 6px; display: block; }
.form-input {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem; outline: none;
  transition: border-color 0.2s;
}
.form-input:focus { border-color: var(--accent); }
.form-select {
  width: 100%; background: var(--surface2); border: 1px solid var(--border);
  border-radius: 8px; padding: 10px 14px; color: var(--text);
  font-family: 'DM Sans', sans-serif; font-size: 0.9rem; outline: none;
}

/* ALERT */
.alert {
  padding: 12px 16px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 16px;
}
.alert-error { background: rgba(239,68,68,0.1); border: 1px solid rgba(239,68,68,0.3); color: #f87171; }
.alert-success { background: rgba(16,185,129,0.1); border: 1px solid rgba(16,185,129,0.3); color: var(--accent3); }

/* CONTAINER */
.container { max-width: 1100px; margin: 0 auto; padding: 32px 24px; }

/* BADGE */
.badge {
  display: inline-block; padding: 2px 10px; border-radius: 20px;
  font-size: 0.7rem; font-weight: 600; letter-spacing: 0.5px;
}
.badge-blue { background: rgba(0,212,255,0.12); color: var(--accent); }
.badge-green { background: rgba(16,185,129,0.12); color: var(--accent3); }

/* PROGRESS */
.progress-wrap { background: var(--surface2); border-radius: 999px; height: 6px; overflow: hidden; }
.progress-bar { height: 100%; border-radius: 999px; transition: width 0.5s; }

/* GRIDS */
.grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.grid3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 16px; }
.grid4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }
@media(max-width: 700px) { .grid2, .grid3, .grid4 { grid-template-columns: 1fr; } }

/* UTILITY */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mt-32 { margin-top: 32px; }
.text-muted { color: var(--muted); font-size: 0.85rem; }
.text-accent { color: var(--accent); }
.text-center { text-align: center; }

/* Add to assets/css/style.css */
.nav-links { display: flex; gap: 8px; align-items: center; }
.nav-link {
  color: var(--muted); font-size: 0.85rem; text-decoration: none;
  padding: 6px 14px; border-radius: 6px; transition: all 0.2s;
  border: 1px solid transparent;
}
.nav-link:hover { color: var(--text); background: var(--surface2); }
.nav-link.active { color: var(--accent); border-color: var(--accent); background: var(--surface2); }

/* Toggle Switch */
.switch {
  position: relative;
  display: inline-block;
  width: 50px;
  height: 26px;
}

.switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: var(--surface2);
  transition: .3s;
  border-radius: 26px;
  border: 1px solid var(--border);
}

.slider:before {
  position: absolute;
  content: "";
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: var(--text);
  transition: .3s;
  border-radius: 50%;
}

input:checked + .slider {
  background-color: var(--accent);
  border-color: var(--accent);
}

input:checked + .slider:before {
  transform: translateX(24px);
  background-color: #0a0f1e;
}

/* Notification Badge */
.notification-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--danger);
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Exam Timer Additional Styles */
.timer-btn {
  background: var(--surface2);
  border: 1px solid var(--border);
  color: var(--text);
  padding: 16px;
  border-radius: 12px;
  cursor: pointer;
  font-weight: 600;
  transition: all 0.2s;
  font-size: 0.95rem;
}

.timer-btn:hover {
  border-color: var(--accent);
  background: rgba(0,212,255,0.1);
  transform: translateY(-2px);
}

.timer-control-btn {
  background: var(--accent);
  color: #0a0f1e;
  border: none;
  padding: 12px 24px;
  border-radius: 10px;
  font-weight: 600;
  cursor: pointer;
  font-size: 1rem;
  transition: all 0.2s;
}

.timer-control-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0,212,255,0.3);
}

#timer-fab:hover {
  transform: scale(1.1);
}

@media (max-width: 600px) {
  #timer-fab {
    bottom: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    font-size: 1.2rem;
  }
  
  #mini-timer {
    bottom: 20px;
    right: 80px;
    padding: 10px 16px;
    font-size: 1rem;
  }
  
  #timer-countdown {
    font-size: 2.5rem !important;
  }
}

/* ── HAMBURGER MENU ── */
.hamburger-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  display: flex;
  flex-direction: column;
  gap: 5px;
  z-index: 1001;
}
.hamburger-btn span {
  display: block;
  width: 22px;
  height: 2px;
  background: var(--text);
  border-radius: 2px;
  transition: all 0.3s ease;
}
.hamburger-btn.open span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.open span:nth-child(2) {
  opacity: 0;
}
.hamburger-btn.open span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.nav-drawer {
  position: fixed;
  top: 0; right: -300px;
  width: 280px;
  height: 100vh;
  background: var(--card);
  border-left: 1px solid var(--border);
  z-index: 1000;
  transition: right 0.3s ease;
  padding: 80px 24px 32px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  overflow-y: auto;
}
.nav-drawer.open {
  right: 0;
}
.nav-drawer a {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-radius: 10px;
  color: var(--muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  font-family: 'DM Sans', sans-serif;
}
.nav-drawer a:hover,
.nav-drawer a.active {
  background: rgba(0,212,255,0.08);
  color: var(--accent);
}
.nav-drawer .drawer-section {
  font-size: 0.68rem;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--muted);
  padding: 16px 16px 4px;
  font-weight: 600;
}
.nav-drawer .drawer-divider {
  height: 1px;
  background: var(--border);
  margin: 8px 0;
}
.nav-drawer .drawer-logout {
  margin-top: auto;
  color: var(--danger) !important;
}
.nav-drawer .drawer-logout:hover {
  background: rgba(239,68,68,0.1) !important;
  color: var(--danger) !important;
}

.drawer-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 999;
}
.drawer-overlay.open {
  display: block;
}

/* ============================================
   STUDYLYNK MOBILE RESPONSIVENESS FIXES
   ============================================ */

/* ── Base mobile resets ── */
@media (max-width: 768px) {

  /* Container padding so content never touches screen edge */
  .container {
    padding: 20px 16px;
  }

  /* Top nav: tighten padding on small screens */
  .top-nav {
    padding: 0 16px;
    height: 52px;
  }

  /* Push page content below fixed nav */
  body > div[class*="-wrap"],
  .my-notes-wrap,
  .papers-wrap,
  .exam-guide-wrap,
  .notes-wrap,
  .dashboard-wrap,
  .planner-wrap,
  .progress-wrap,
  .settings-wrap,
  .videos-wrap {
    padding-top: 64px;
  }

  /* ── Typography scale-down ── */
  h1, .notes-title, .papers-title, .exam-title { 
    font-size: 1.3rem !important; 
  }
  h2 { font-size: 1.1rem !important; }
  h3 { font-size: 1rem !important; }

  /* ── Buttons: make sure they're finger-friendly (min 44px tall) ── */
  .btn,
  .ai-btn,
  .save-btn,
  .paper-btn,
  .action-btn,
  .note-btn,
  .admin-btn,
  .filter-chip,
  .read-aloud-btn {
    min-height: 44px;
    padding: 10px 16px;
    font-size: 0.88rem;
    touch-action: manipulation;
  }

  /* Full-width CTA buttons on mobile */
  .ai-btn,
  .btn-full {
    width: 100%;
    justify-content: center;
  }

  /* ── Cards: remove horizontal overflow, normalise padding ── */
  .card,
  .paper-card,
  .note-card,
  .subject-card,
  .input-section,
  .output-section,
  .qa-section,
  .ai-explainer,
  .filters-section {
    padding: 16px;
    border-radius: 12px;
  }

  /* ── Grid overrides: single column on phones ── */
  .grid2,
  .grid3,
  .grid4,
  .notes-layout,
  .papers-grid,
  .subjects-grid,
  .notes-list,
  .stats-overview,
  .admin-grid {
    grid-template-columns: 1fr !important;
    gap: 12px;
  }

  /* ── Stats bar: wrap neatly ── */
  .stats-bar {
    gap: 16px;
    flex-wrap: wrap;
    padding: 14px 16px;
  }
  .stat-num {
    font-size: 1.8rem;
  }

  /* ── Filter chips: allow wrapping and scrolling ── */
  .filter-row {
    gap: 8px;
    flex-wrap: wrap;
  }
  .filter-chip {
    font-size: 0.78rem;
    padding: 7px 12px;
  }
  .filter-select {
    min-width: unset;
    width: 100%;
  }
  .filter-group {
    width: 100%;
  }

  /* ── Paper cards: full-width action buttons ── */
  .paper-actions {
    flex-direction: column;
    gap: 8px;
  }
  .paper-btn {
    width: 100%;
    text-align: center;
    padding: 11px 12px;
  }

  /* ── Note cards: fix preview clamp ── */
  .note-preview {
    -webkit-line-clamp: 2;
    font-size: 0.82rem;
  }
  .note-actions {
    gap: 6px;
  }
  .note-btn {
    padding: 9px 6px;
    font-size: 0.78rem;
  }

  /* ── Score rows in exam guide: stack cleanly ── */
  .score-row {
    flex-wrap: wrap;
    gap: 8px;
  }
  .score-input {
    width: 60px;
    font-size: 1rem;
  }

  /* ── Upload zones: tighten padding ── */
  .upload-zone,
  .upload-area {
    padding: 28px 16px;
  }
  .upload-icon {
    font-size: 2.2rem;
  }

  /* ── Input tabs: equal width ── */
  .input-tabs,
  .ai-tabs {
    flex-direction: column;
    gap: 8px;
  }
  .input-tab,
  .ai-tab {
    width: 100%;
    text-align: center;
    padding: 12px;
    font-size: 0.85rem;
  }

  /* ── Output content: scrollable, not overflowing ── */
  .output-content {
    max-height: 380px;
    overflow-y: auto;
  }

  /* ── Action bar below AI output: stack on very small screens ── */
  .action-bar {
    flex-direction: column;
    gap: 10px;
  }
  .action-btn {
    width: 100%;
  }

  /* ── Read aloud bar: stack hint below button ── */
  .read-aloud-bar {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .read-aloud-btn {
    width: 100%;
    justify-content: center;
  }

  /* ── Admin panel: full-width inputs ── */
  .admin-input,
  .file-input-label {
    width: 100%;
    display: block;
    box-sizing: border-box;
  }
  .file-input-wrapper {
    width: 100%;
  }
  .admin-btn {
    grid-column: 1 !important;
    width: 100%;
  }

  /* ── PDF modal: full screen on mobile ── */
  .pdf-header {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }
  .pdf-actions {
    flex-wrap: wrap;
    gap: 6px;
  }
  .pdf-btn {
    font-size: 0.75rem;
    padding: 7px 12px;
  }

  /* ── QA section textareas: comfortable height ── */
  .qa-textarea {
    min-height: 80px;
    font-size: 0.88rem;
  }

  /* ── Confidence bar: add spacing ── */
  .confidence-bar {
    margin: 12px 0;
  }

  /* ── Nav drawer: full width on very small screens ── */
  .nav-drawer {
    width: 100%;
    right: -100%;
  }

  /* ── Floating timer: make sure it doesn't overlap content ── */
  #timer-fab {
    bottom: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    font-size: 1.1rem;
  }
  #mini-timer {
    bottom: 16px;
    right: 74px;
    font-size: 0.95rem;
    padding: 9px 14px;
  }
}

/* ── Medium screens (tablets 769px–1024px) ── */
@media (min-width: 769px) and (max-width: 1024px) {

  .container {
    padding: 24px 20px;
  }

  /* Two columns instead of three/four on tablets */
  .grid3,
  .grid4,
  .subjects-grid,
  .notes-list {
    grid-template-columns: 1fr 1fr !important;
    gap: 14px;
  }

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

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

  /* Notes layout: tighter sidebar on tablet */
  .notes-layout {
    grid-template-columns: 1fr 1fr;
    gap: 16px;
  }

  /* Filters: allow natural wrapping */
  .filter-row {
    flex-wrap: wrap;
    gap: 10px;
  }

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

/* ── Very small phones (below 380px) ── */
@media (max-width: 380px) {

  .top-nav {
    padding: 0 12px;
  }

  .nav-logo {
    font-size: 1rem;
  }

  .container {
    padding: 16px 12px;
  }

  .btn,
  .ai-btn,
  .paper-btn,
  .action-btn {
    font-size: 0.82rem;
    padding: 9px 12px;
  }

  .stat-num {
    font-size: 1.5rem;
  }

  .paper-year {
    font-size: 1.3rem;
  }

  /* Timer modal: tighten on tiny screens */
  #exam-timer-modal > div {
    padding: 24px 16px !important;
  }
}