/* ===== RESET & BASE ===== */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html, body { height: 100%; overflow: hidden; }
body {
  font-family: 'DM Sans', sans-serif;
  background: #0f0f11;
  color: #e8e6e1;
  font-size: 14px;
  line-height: 1.6;
}
a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, textarea, select { font-family: inherit; }

/* ===== CSS VARIABLES ===== */
:root {
  --bg: #0f0f11;
  --bg-2: #17171b;
  --bg-3: #1e1e24;
  --bg-4: #26262e;
  --border: rgba(255,255,255,0.07);
  --border-2: rgba(255,255,255,0.12);
  --text: #e8e6e1;
  --text-2: #9e9b94;
  --text-3: #5c5a56;
  --accent: #7b6ef6;
  --accent-dim: rgba(123,110,246,0.15);
  --accent-2: #e8a838;
  --green: #4ade80;
  --green-dim: rgba(74,222,128,0.12);
  --red: #f87171;
  --red-dim: rgba(248,113,113,0.12);
  --blue: #60a5fa;
  --blue-dim: rgba(96,165,250,0.12);
  --amber: #fbbf24;
  --amber-dim: rgba(251,191,36,0.12);
  --pink: #f472b6;
  --pink-dim: rgba(244,114,182,0.12);
  --teal: #2dd4bf;
  --teal-dim: rgba(45,212,191,0.12);
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
  --sidebar-w: 220px;
  --transition: 0.18s ease;
}

/* ===== LAYOUT ===== */
.app-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: var(--sidebar-w);
  background: var(--bg-2);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
  padding: 0 0 12px;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px 18px;
  border-bottom: 1px solid var(--border);
  margin-bottom: 8px;
}
.logo-icon {
  font-size: 22px;
  color: var(--accent);
  flex-shrink: 0;
}
.logo-name { font-size: 15px; font-weight: 600; color: var(--text); }
.logo-user { font-size: 11px; color: var(--text-3); margin-top: 1px; }

.sidebar-nav { flex: 1; padding: 0 8px; }
.nav-section-label {
  font-size: 10px;
  font-weight: 600;
  color: var(--text-3);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 14px 8px 5px;
}
.nav-link {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: var(--radius-sm);
  color: var(--text-2);
  font-size: 13px;
  transition: all var(--transition);
  margin-bottom: 2px;
}
.nav-link:hover { background: var(--bg-3); color: var(--text); }
.nav-link.active { background: var(--accent-dim); color: var(--accent); font-weight: 500; }
.nav-link svg { flex-shrink: 0; opacity: 0.8; }

.sidebar-footer { padding: 8px 8px 0; border-top: 1px solid var(--border); margin-top: 8px; }

/* ===== MAIN CONTENT ===== */
.main-content {
  flex: 1;
  overflow-y: auto;
  background: var(--bg);
  padding: 28px 32px;
}

/* ===== PAGE HEADERS ===== */
.page-header { margin-bottom: 24px; }
.page-header h1 { font-size: 22px; font-weight: 600; color: var(--text); margin-bottom: 3px; }
.page-header p { font-size: 13px; color: var(--text-2); }

/* ===== CARDS ===== */
.card {
  background: var(--bg-2);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 18px 20px;
}
.card-sm { padding: 14px 16px; }
.card-title {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.07em;
  color: var(--text-3);
  margin-bottom: 12px;
}

/* ===== GRIDS ===== */
.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.grid-4 { display: grid; grid-template-columns: repeat(4,1fr); gap: 14px; }

/* ===== STAT CARDS ===== */
.stat-card { background: var(--bg-2); border: 1px solid var(--border); border-radius: var(--radius-lg); padding: 16px 18px; }
.stat-label { font-size: 11px; color: var(--text-3); font-weight: 500; text-transform: uppercase; letter-spacing: 0.06em; margin-bottom: 6px; }
.stat-value { font-size: 26px; font-weight: 600; color: var(--text); font-family: 'DM Mono', monospace; }
.stat-sub { font-size: 12px; color: var(--text-3); margin-top: 3px; }

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 8px 16px; border-radius: var(--radius-sm);
  font-size: 13px; font-weight: 500;
  border: 1px solid var(--border-2);
  background: var(--bg-3); color: var(--text);
  transition: all var(--transition);
}
.btn:hover { background: var(--bg-4); border-color: var(--border-2); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); border-color: var(--accent); color: white; }
.btn-primary:hover { background: #6a5de8; border-color: #6a5de8; }
.btn-danger { background: var(--red-dim); border-color: rgba(248,113,113,0.3); color: var(--red); }
.btn-sm { padding: 5px 12px; font-size: 12px; }
.btn-icon { padding: 7px; width: 32px; height: 32px; justify-content: center; }

/* ===== INPUTS ===== */
.input, .select, .textarea {
  width: 100%;
  background: var(--bg-3);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-size: 13px;
  padding: 9px 12px;
  transition: border-color var(--transition);
  font-family: inherit;
}
.input:focus, .select:focus, .textarea:focus {
  outline: none;
  border-color: var(--accent);
}
.input::placeholder, .textarea::placeholder { color: var(--text-3); }
.select { appearance: none; cursor: pointer; }
.textarea { resize: vertical; min-height: 100px; line-height: 1.6; }

label.form-label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-2);
  margin-bottom: 5px;
}
.form-group { margin-bottom: 14px; }
.form-row { display: flex; gap: 10px; }
.form-row .form-group { flex: 1; }

/* ===== BADGES ===== */
.badge {
  display: inline-flex; align-items: center;
  padding: 2px 8px; border-radius: 20px;
  font-size: 11px; font-weight: 500;
}
.badge-accent { background: var(--accent-dim); color: var(--accent); }
.badge-green { background: var(--green-dim); color: var(--green); }
.badge-red { background: var(--red-dim); color: var(--red); }
.badge-amber { background: var(--amber-dim); color: var(--amber); }
.badge-blue { background: var(--blue-dim); color: var(--blue); }
.badge-pink { background: var(--pink-dim); color: var(--pink); }
.badge-teal { background: var(--teal-dim); color: var(--teal); }

/* ===== PROGRESS BAR ===== */
.progress-track {
  height: 5px; background: var(--bg-4);
  border-radius: 3px; overflow: hidden;
}
.progress-fill {
  height: 100%; border-radius: 3px;
  transition: width 0.4s ease;
  background: var(--accent);
}

/* ===== CHECKBOX ===== */
.checkbox-wrap { display: flex; align-items: flex-start; gap: 10px; cursor: pointer; }
.checkbox-box {
  width: 17px; height: 17px; flex-shrink: 0; margin-top: 1px;
  border: 1.5px solid var(--border-2); border-radius: 4px;
  display: flex; align-items: center; justify-content: center;
  transition: all var(--transition); background: var(--bg-3);
}
.checkbox-box.checked { background: var(--accent); border-color: var(--accent); }
.checkbox-box.checked::after { content: '✓'; font-size: 10px; color: white; }

/* ===== TAGS / SUBJECT COLORS ===== */
.tag {
  display: inline-flex; align-items: center; padding: 3px 9px;
  border-radius: 20px; font-size: 11px; font-weight: 500;
}
.tag-math { background: rgba(96,165,250,0.15); color: #60a5fa; }
.tag-hist { background: rgba(251,191,36,0.15); color: #fbbf24; }
.tag-bio  { background: rgba(74,222,128,0.15); color: #4ade80; }
.tag-lit  { background: rgba(244,114,182,0.15); color: #f472b6; }
.tag-phys { background: rgba(123,110,246,0.15); color: #a78bfa; }
.tag-chem { background: rgba(45,212,191,0.15); color: #2dd4bf; }
.tag-geo  { background: rgba(248,113,113,0.15); color: #f87171; }
.tag-eng  { background: rgba(251,146,60,0.15); color: #fb923c; }
.tag-other{ background: rgba(255,255,255,0.08); color: var(--text-2); }

/* ===== DIVIDER ===== */
.divider { height: 1px; background: var(--border); margin: 16px 0; }

/* ===== MODAL ===== */
.modal-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(0,0,0,0.6); z-index: 1000;
  align-items: center; justify-content: center;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); width: 480px; max-width: 95vw;
  max-height: 85vh; display: flex; flex-direction: column;
  animation: modalIn 0.18s ease;
}
@keyframes modalIn { from { opacity:0; transform: scale(0.96) translateY(8px); } }
.modal-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 18px 20px; border-bottom: 1px solid var(--border);
}
.modal-title { font-size: 15px; font-weight: 600; color: var(--text); }
.modal-close {
  background: none; border: none; color: var(--text-3);
  font-size: 16px; padding: 4px 6px; border-radius: 4px;
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); background: var(--bg-4); }
.modal-body { padding: 20px; overflow-y: auto; flex: 1; }
.modal-footer { padding: 14px 20px; border-top: 1px solid var(--border); display: flex; gap: 8px; justify-content: flex-end; }

/* ===== EMPTY STATE ===== */
.empty-state {
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; padding: 40px 20px; text-align: center; gap: 8px;
}
.empty-state-icon { font-size: 32px; opacity: 0.3; }
.empty-state p { color: var(--text-3); font-size: 13px; }

/* ===== TOAST ===== */
.toast {
  position: fixed; bottom: 24px; right: 24px;
  background: var(--bg-3); border: 1px solid var(--border-2);
  border-radius: var(--radius); padding: 12px 18px;
  font-size: 13px; color: var(--text); z-index: 2000;
  animation: toastIn 0.2s ease;
  display: flex; align-items: center; gap: 8px;
}
@keyframes toastIn { from { opacity:0; transform: translateY(8px); } }
.toast-ok::before { content:'✓'; color: var(--green); }

/* ===== SCROLLBAR ===== */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 3px; }

/* ===== UTILITY ===== */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.mb-8 { margin-bottom: 8px; }
.mb-16 { margin-bottom: 16px; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.text-muted { color: var(--text-2); }
.text-dim { color: var(--text-3); }
.text-sm { font-size: 12px; }
.text-xs { font-size: 11px; }
.font-mono { font-family: 'DM Mono', monospace; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }

/* ===== POMODORO SPECIFIC ===== */
.pom-ring { display: flex; justify-content: center; margin: 20px 0; }
.pom-ring svg { filter: drop-shadow(0 0 12px rgba(123,110,246,0.3)); }

/* ===== FLASHCARD ===== */
.fc-card {
  perspective: 1000px; cursor: pointer; min-height: 180px;
  margin-bottom: 16px;
}
.fc-inner {
  position: relative; width: 100%; min-height: 180px;
  transform-style: preserve-3d; transition: transform 0.5s ease;
}
.fc-card.flipped .fc-inner { transform: rotateY(180deg); }
.fc-front, .fc-back {
  position: absolute; inset: 0; backface-visibility: hidden;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); padding: 24px;
  display: flex; flex-direction: column; align-items: center;
  justify-content: center; text-align: center; gap: 10px;
}
.fc-back { transform: rotateY(180deg); background: var(--bg-3); border-color: var(--accent); }
.fc-front-label { font-size: 10px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.08em; color: var(--text-3); }
.fc-question { font-size: 16px; font-weight: 500; color: var(--text); }
.fc-answer { font-size: 14px; color: var(--text-2); line-height: 1.6; }

/* ===== AGENDA TABLE ===== */
.agenda-grid {
  display: grid;
  grid-template-columns: 60px repeat(5, 1fr);
  gap: 1px;
  background: var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}
.agenda-cell {
  background: var(--bg-2);
  padding: 8px 10px;
  min-height: 56px;
  font-size: 12px;
  position: relative;
}
.agenda-cell.header {
  background: var(--bg-3);
  font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--text-2); padding: 10px;
  min-height: auto; display: flex; flex-direction: column; align-items: center;
}
.agenda-cell.time-col {
  background: var(--bg-3);
  font-family: 'DM Mono', monospace;
  font-size: 11px; color: var(--text-3);
  display: flex; align-items: center; justify-content: center;
  min-height: 50px;
}
.agenda-event-block {
  background: var(--accent-dim);
  border-left: 3px solid var(--accent);
  border-radius: 4px;
  padding: 4px 7px;
  font-size: 11px; font-weight: 500;
  color: var(--accent);
  margin-bottom: 3px;
  cursor: pointer;
  transition: opacity var(--transition);
}
.agenda-event-block:hover { opacity: 0.8; }

/* ===== TASK ITEMS ===== */
.task-item {
  display: flex; align-items: flex-start; gap: 12px;
  padding: 12px 0; border-bottom: 1px solid var(--border);
}
.task-item:last-child { border-bottom: none; }
.task-item.done .task-text { text-decoration: line-through; color: var(--text-3); }
.task-meta { font-size: 11px; color: var(--text-3); margin-top: 3px; display: flex; gap: 8px; align-items: center; }
.task-due-urgent { color: var(--red); }

/* ===== NOTE AREA ===== */
.note-editor {
  width: 100%; min-height: 300px; resize: vertical;
  background: var(--bg-2); border: 1px solid var(--border);
  border-radius: var(--radius); color: var(--text);
  font-size: 14px; line-height: 1.8; padding: 18px;
  font-family: 'DM Mono', monospace;
  transition: border-color var(--transition);
}
.note-editor:focus { outline: none; border-color: var(--accent); }

/* ===== SUBJECT SELECTOR ===== */
.subject-tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.subject-tab {
  padding: 5px 14px; border-radius: 20px; font-size: 12px;
  font-weight: 500; border: 1px solid var(--border); background: var(--bg-3);
  color: var(--text-2); cursor: pointer; transition: all var(--transition);
}
.subject-tab:hover { border-color: var(--border-2); color: var(--text); }
.subject-tab.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

/* ===== SETTINGS ===== */
.settings-section { margin-bottom: 28px; }
.settings-section h2 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ===== WEEK DAY INDICATOR ===== */
.day-badge {
  font-size: 10px; font-weight: 700; width: 24px; height: 24px;
  border-radius: 50%; background: var(--bg-4);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 3px;
}
.day-badge.today { background: var(--accent); color: white; }

/* ===== AUTH SCREEN ===== */
.auth-screen {
  display: flex; align-items: center; justify-content: center;
  min-height: 100vh; background: var(--bg);
}
.auth-card {
  width: 380px; background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); padding: 32px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
}
.auth-logo {
  font-size: 22px; font-weight: 700; color: var(--accent);
  text-align: center; margin-bottom: 24px; letter-spacing: -0.5px;
}
.auth-tabs {
  display: flex; gap: 0; margin-bottom: 24px;
  border: 1px solid var(--border); border-radius: var(--radius-sm); overflow: hidden;
}
.auth-tab {
  flex: 1; padding: 9px; background: none; border: none;
  color: var(--text-2); font-size: 13px; font-family: inherit;
  cursor: pointer; transition: all .15s;
}
.auth-tab.active { background: var(--accent); color: white; font-weight: 500; }
.auth-error { color: var(--red); font-size: 12px; min-height: 18px; margin-bottom: 8px; }

/* ===== LIGHT THEME ===== */
[data-theme="light"] {
  --bg: #f7f7f5;
  --bg-2: #ffffff;
  --bg-3: #f0f0ee;
  --bg-4: #e4e4e0;
  --border: rgba(0,0,0,0.08);
  --border-2: rgba(0,0,0,0.15);
  --text: #1a1a18;
  --text-2: #5a5a56;
  --text-3: #9a9a94;
  --accent: #6b5ef0;
  --accent-dim: rgba(107,94,240,0.1);
}
[data-theme="light"] .sidebar { box-shadow: 2px 0 12px rgba(0,0,0,0.05); }
[data-theme="light"] .auth-card { box-shadow: 0 8px 32px rgba(0,0,0,0.1); }

/* ===== AGENDA GRID UPDATE ===== */
.agenda-drop-target { transition: background .1s; }
.agenda-drop-target:hover { background: var(--bg-3); cursor: pointer; }

/* ===== CALENDAR ===== */
.cal-day:hover { background: var(--bg-3) !important; }

/* ===== AUTH SCROLLABLE FIX ===== */
.auth-screen {
  display: flex; align-items: flex-start; justify-content: center;
  min-height: 100vh; background: var(--bg);
  padding: 20px; overflow-y: auto;
}
.auth-card {
  width: 420px; max-width: 100%;
  background: var(--bg-2); border: 1px solid var(--border-2);
  border-radius: var(--radius-lg); padding: 28px;
  box-shadow: 0 24px 64px rgba(0,0,0,0.4);
  margin: auto 0;
}
/* Teacher register panel scrollable */
#panel-register {
  max-height: calc(100vh - 240px);
  overflow-y: auto;
  padding-right: 4px;
}
#panel-register::-webkit-scrollbar { width: 4px; }
#panel-register::-webkit-scrollbar-thumb { background: var(--bg-4); border-radius: 2px; }

/* ===== SETTINGS SECTIONS ===== */
.settings-section { margin-bottom: 28px; }
.settings-section h2 { font-size: 14px; font-weight: 600; color: var(--text); margin-bottom: 14px; padding-bottom: 8px; border-bottom: 1px solid var(--border); }

/* ===== AMBER DIM ===== */
.amber-dim { background: rgba(251,191,36,0.12); }
