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

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

:root {
  --bg: #f5f4f0;
  --surface: #ffffff;
  --surface2: #f0efe9;
  --border: rgba(0,0,0,0.1);
  --border-md: rgba(0,0,0,0.18);
  --text: #1a1918;
  --text2: #6b6a65;
  --text3: #9e9d97;
  --accent: #534AB7;
  --accent-light: #EEEDFE;
  --accent-mid: #AFA9EC;
  --green: #3B6D11; --green-bg: #EAF3DE;
  --amber: #854F0B; --amber-bg: #FAEEDA;
  --red: #A32D2D;   --red-bg: #FCEBEB;
  --blue: #185FA5;  --blue-bg: #E6F1FB;
  --teal: #0F6E56;  --teal-bg: #E1F5EE;
  --r-sm: 6px; --r-md: 10px; --r-lg: 14px; --r-xl: 20px;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 0 0 0.5px rgba(0,0,0,0.07);
  font-size: 14px;
}

@media (prefers-color-scheme: dark) {
  :root {
    --bg: #17161a; --surface: #1f1e24; --surface2: #27262e;
    --border: rgba(255,255,255,0.08); --border-md: rgba(255,255,255,0.15);
    --text: #f0eff4; --text2: #9896a4; --text3: #5c5b67;
    --accent: #7F77DD; --accent-light: #26215C; --accent-mid: #534AB7;
    --green: #9FE1CB; --green-bg: #04342C;
    --amber: #FAC775; --amber-bg: #412402;
    --red: #F09595;   --red-bg: #501313;
    --blue: #85B7EB;  --blue-bg: #042C53;
    --teal: #5DCAA5;  --teal-bg: #085041;
    --shadow: 0 1px 3px rgba(0,0,0,0.3), 0 0 0 0.5px rgba(255,255,255,0.05);
  }
}

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

/* ── LAYOUT ─────────────────────────────────── */
#app { display: flex; height: 100vh; }
.sidebar { width: 230px; background: var(--surface); border-right: 0.5px solid var(--border); display: flex; flex-direction: column; flex-shrink: 0; transition: transform 0.3s; z-index: 50; }
.main { flex: 1; display: flex; flex-direction: column; overflow: hidden; min-width: 0; }
.content { flex: 1; overflow-y: auto; padding: 20px 24px; }

/* ── SIDEBAR ─────────────────────────────────── */
.sidebar-logo { padding: 18px 18px 14px; border-bottom: 0.5px solid var(--border); }
.logo-mark { display: flex; align-items: center; gap: 10px; }
.logo-icon { width: 32px; height: 32px; background: var(--accent); border-radius: var(--r-md); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.logo-icon svg { width: 18px; height: 18px; }
.logo-title { font-size: 14px; font-weight: 500; color: var(--text); }
.logo-sub { font-size: 11px; color: var(--text3); margin-top: 1px; }
.nav { padding: 8px 0; flex: 1; overflow-y: auto; }
.nav-section { font-size: 10px; font-weight: 500; color: var(--text3); text-transform: uppercase; letter-spacing: 0.1em; padding: 14px 18px 5px; }
.nav-item { display: flex; align-items: center; gap: 10px; padding: 9px 18px; cursor: pointer; font-size: 13px; color: var(--text2); transition: all 0.12s; position: relative; }
.nav-item:hover { color: var(--text); background: var(--surface2); }
.nav-item.active { color: var(--accent); background: var(--accent-light); font-weight: 500; }
.nav-item.active::before { content: ''; position: absolute; left: 0; top: 4px; bottom: 4px; width: 3px; background: var(--accent); border-radius: 0 3px 3px 0; }
.nav-icon { width: 16px; height: 16px; flex-shrink: 0; opacity: 0.8; }
.nav-badge { margin-left: auto; font-size: 10px; font-weight: 500; background: var(--accent); color: white; padding: 1px 6px; border-radius: 20px; }
.sidebar-footer { padding: 12px 18px; border-top: 0.5px solid var(--border); }
.user-card { display: flex; align-items: center; gap: 10px; }
.avatar { width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; flex-shrink: 0; }
.av-purple { background: var(--accent-light); color: var(--accent); }
.av-green  { background: var(--green-bg);    color: var(--green);  }
.av-blue   { background: var(--blue-bg);     color: var(--blue);   }
.av-amber  { background: var(--amber-bg);    color: var(--amber);  }
.av-teal   { background: var(--teal-bg);     color: var(--teal);   }
.av-red    { background: var(--red-bg);      color: var(--red);    }
.user-name { font-size: 13px; font-weight: 500; }
.user-role { font-size: 11px; color: var(--text3); }

/* ── TOPBAR ─────────────────────────────────── */
.topbar { background: var(--surface); border-bottom: 0.5px solid var(--border); padding: 12px 24px; display: flex; align-items: center; gap: 12px; flex-shrink: 0; }
.hamburger { display: none; flex-direction: column; gap: 4px; cursor: pointer; padding: 4px; }
.hamburger span { width: 18px; height: 1.5px; background: var(--text2); border-radius: 2px; }
.page-title { font-size: 15px; font-weight: 500; flex: 1; }
.topbar-actions { display: flex; align-items: center; gap: 8px; }
.role-toggle { display: flex; gap: 2px; background: var(--surface2); padding: 3px; border-radius: var(--r-md); }
.toggle-btn { padding: 5px 14px; border-radius: 8px; font-size: 12px; cursor: pointer; border: none; background: transparent; color: var(--text2); font-family: inherit; transition: all 0.12s; }
.toggle-btn.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow); }

/* ── BUTTONS ─────────────────────────────────── */
.btn { padding: 7px 14px; border-radius: var(--r-md); font-size: 13px; cursor: pointer; border: 0.5px solid var(--border-md); background: var(--surface); color: var(--text); font-family: inherit; transition: all 0.12s; white-space: nowrap; }
.btn:hover { background: var(--surface2); }
.btn:active { transform: scale(0.98); }
.btn-primary { background: var(--accent); color: #fff; border-color: var(--accent); }
.btn-primary:hover { opacity: 0.9; background: var(--accent); }
.btn-sm { padding: 4px 10px; font-size: 12px; }
.btn-icon { width: 32px; height: 32px; padding: 0; display: flex; align-items: center; justify-content: center; }
.btn-danger { background: var(--red-bg); color: var(--red); border-color: transparent; }

/* ── CARDS ─────────────────────────────────── */
.card { background: var(--surface); border-radius: var(--r-lg); border: 0.5px solid var(--border); padding: 16px 18px; }
.card-header { display: flex; align-items: center; justify-content: space-between; margin-bottom: 14px; gap: 8px; }
.card-title { font-size: 13px; font-weight: 500; }
.stats-row { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 10px; margin-bottom: 18px; }
.stat-card { background: var(--surface2); border-radius: var(--r-md); padding: 14px 16px; }
.stat-label { font-size: 11px; color: var(--text2); margin-bottom: 5px; }
.stat-value { font-size: 24px; font-weight: 500; line-height: 1; }
.stat-sub { font-size: 11px; color: var(--text3); margin-top: 4px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; margin-bottom: 14px; }

/* ── BADGES ─────────────────────────────────── */
.badge { display: inline-flex; align-items: center; font-size: 11px; font-weight: 500; padding: 3px 8px; border-radius: 20px; white-space: nowrap; }
.badge-purple { background: var(--accent-light); color: var(--accent); }
.badge-green  { background: var(--green-bg); color: var(--green); }
.badge-amber  { background: var(--amber-bg); color: var(--amber); }
.badge-red    { background: var(--red-bg);   color: var(--red);   }
.badge-blue   { background: var(--blue-bg);  color: var(--blue);  }
.badge-teal   { background: var(--teal-bg);  color: var(--teal);  }

/* ── NOTIFICATION BANNER ─────────────────────── */
.notif-banner { display: flex; align-items: center; gap: 10px; padding: 10px 14px; border-radius: var(--r-md); margin-bottom: 16px; font-size: 13px; animation: slideDown 0.3s ease; }
.notif-banner.change { background: var(--amber-bg); color: var(--amber); border: 0.5px solid rgba(186,117,23,0.3); }
.notif-banner.info   { background: var(--accent-light); color: var(--accent); border: 0.5px solid var(--accent-mid); }
.notif-close { margin-left: auto; cursor: pointer; opacity: 0.6; font-size: 18px; line-height: 1; background: none; border: none; color: inherit; }
@keyframes slideDown { from { opacity:0; transform: translateY(-8px); } to { opacity:1; transform: none; } }

/* ── SCHEDULE / LESSON ROWS ─────────────────── */
.schedule-list { display: flex; flex-direction: column; gap: 6px; }
.lesson-row { display: flex; align-items: center; gap: 10px; }
.time-col { font-size: 11px; color: var(--text3); font-family: 'DM Mono', monospace; width: 52px; flex-shrink: 0; }
.lesson-block { flex: 1; border-radius: var(--r-md); padding: 8px 12px; }
.lb-purple { background: var(--accent-light); }
.lb-green  { background: var(--green-bg); }
.lb-amber  { background: var(--amber-bg); }
.lesson-block .ln { font-size: 13px; font-weight: 500; }
.lesson-block .lm { font-size: 11px; margin-top: 1px; opacity: 0.8; }
.lb-purple .ln { color: #3C3489; } .lb-purple .lm { color: var(--accent); }
.lb-green  .ln { color: #27500A; } .lb-green  .lm { color: var(--green); }
.lb-amber  .ln { color: #633806; } .lb-amber  .lm { color: var(--amber); }

/* ── WEEK GRID ─────────────────────────────── */
.week-nav { display: flex; align-items: center; gap: 10px; margin-bottom: 14px; }
.week-label { font-size: 13px; font-weight: 500; flex: 1; text-align: center; }
.week-table { width: 100%; border-collapse: collapse; }
.week-table th { font-size: 11px; font-weight: 500; color: var(--text2); padding: 8px 6px; text-align: center; background: var(--surface2); border-bottom: 0.5px solid var(--border); }
.week-table td { vertical-align: top; padding: 4px; border-right: 0.5px solid var(--border); border-bottom: 0.5px solid var(--border); width: calc(100% / 6); }
.week-table td.time-cell { font-size: 10px; color: var(--text3); padding: 6px 6px; text-align: right; font-family: 'DM Mono', monospace; width: 46px; }
.w-event { border-radius: var(--r-sm); padding: 5px 7px; margin-bottom: 3px; cursor: pointer; }
.w-event:hover { filter: brightness(0.96); }
.w-event .we-n { font-size: 11px; font-weight: 500; }
.w-event .we-t { font-size: 10px; opacity: 0.8; }

/* ── STUDENT TABLE ─────────────────────────── */
.s-table { width: 100%; border-collapse: collapse; }
.s-table th { text-align: left; font-size: 11px; font-weight: 500; color: var(--text2); padding: 8px 10px; border-bottom: 0.5px solid var(--border); }
.s-table td { padding: 10px 10px; border-bottom: 0.5px solid var(--border); vertical-align: middle; }
.s-table tr:last-child td { border-bottom: none; }
.s-table tr:hover td { background: var(--surface2); }
.progress-bar { height: 4px; background: var(--surface2); border-radius: 2px; overflow: hidden; width: 80px; }
.progress-fill { height: 100%; background: var(--accent); border-radius: 2px; }

/* ── ATTENDANCE GRID ─────────────────────────── */
.att-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 4px; margin-top: 8px; }
.att-day-label { font-size: 10px; color: var(--text3); text-align: center; padding: 2px 0; }
.att-cell { height: 28px; border-radius: 5px; display: flex; align-items: center; justify-content: center; font-size: 11px; font-weight: 500; }
.att-present { background: var(--green-bg);   color: var(--green); }
.att-absent  { background: var(--red-bg);     color: var(--red); }
.att-future  { background: var(--surface2);   color: var(--text3); }
.att-empty   { background: transparent; }

/* ── ALERTS LIST ─────────────────────────────── */
.alert-list { display: flex; flex-direction: column; }
.alert-item { display: flex; align-items: flex-start; gap: 10px; padding: 10px 0; border-bottom: 0.5px solid var(--border); }
.alert-item:last-child { border-bottom: none; }
.alert-dot { width: 7px; height: 7px; border-radius: 50%; flex-shrink: 0; margin-top: 4px; }
.ad-purple { background: var(--accent); }
.ad-amber  { background: var(--amber); }
.ad-green  { background: var(--green); }
.alert-body { flex: 1; }
.alert-text { font-size: 13px; }
.alert-time { font-size: 11px; color: var(--text3); margin-top: 2px; }

/* ── MODAL ─────────────────────────────────── */
.modal-bg { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.35); z-index: 200; align-items: center; justify-content: center; padding: 16px; }
.modal-bg.open { display: flex; }
.modal { background: var(--surface); border-radius: var(--r-xl); border: 0.5px solid var(--border); padding: 24px; width: 400px; max-width: 100%; max-height: 90vh; overflow-y: auto; animation: popIn 0.18s ease; }
@keyframes popIn { from { opacity:0; transform: scale(0.96) translateY(8px); } to { opacity:1; transform: none; } }
.modal-title { font-size: 16px; font-weight: 500; margin-bottom: 18px; }
.form-field { margin-bottom: 14px; }
.form-label { font-size: 12px; color: var(--text2); margin-bottom: 5px; display: block; }
.form-input, .form-select, .form-textarea { width: 100%; padding: 8px 12px; border-radius: var(--r-md); border: 0.5px solid var(--border-md); background: var(--surface2); color: var(--text); font-size: 13px; font-family: inherit; }
.form-input:focus, .form-select:focus, .form-textarea:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(83,74,183,0.15); }
.form-textarea { min-height: 80px; resize: vertical; }
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.modal-footer { display: flex; gap: 8px; justify-content: flex-end; margin-top: 20px; }

/* ── LOGIN SCREEN ─────────────────────────────── */
#login-screen { display: none; position: fixed; inset: 0; background: var(--bg); z-index: 300; align-items: center; justify-content: center; padding: 24px; }
#login-screen.show { display: flex; }
.login-wrap { width: 340px; }
.login-logo-big { display: flex; align-items: center; gap: 12px; margin-bottom: 32px; justify-content: center; }
.login-logo-icon { width: 48px; height: 48px; background: var(--accent); border-radius: 14px; display: flex; align-items: center; justify-content: center; }
.login-logo-icon svg { width: 26px; height: 26px; }
.login-title { font-size: 22px; font-weight: 500; }
.login-card { background: var(--surface); border-radius: var(--r-xl); border: 0.5px solid var(--border); padding: 28px; }
.login-heading { font-size: 16px; font-weight: 500; margin-bottom: 20px; }
.login-tabs { display: flex; gap: 4px; background: var(--surface2); padding: 3px; border-radius: var(--r-md); margin-bottom: 20px; }
.login-tab { flex: 1; text-align: center; padding: 6px; border-radius: 8px; font-size: 13px; cursor: pointer; border: none; background: transparent; color: var(--text2); font-family: inherit; }
.login-tab.active { background: var(--surface); color: var(--text); font-weight: 500; box-shadow: var(--shadow); }
.demo-users { display: flex; flex-direction: column; gap: 8px; margin-top: 14px; }
.demo-user { display: flex; align-items: center; gap: 10px; padding: 10px 12px; border-radius: var(--r-md); cursor: pointer; border: 0.5px solid var(--border); background: var(--surface2); transition: all 0.12s; }
.demo-user:hover { border-color: var(--accent); background: var(--accent-light); }
.demo-info { flex: 1; }
.demo-name { font-size: 13px; font-weight: 500; }
.demo-role { font-size: 11px; color: var(--text2); }

/* ── INSTALL BANNER ─────────────────────────────── */
#install-banner { display: none; position: fixed; bottom: 16px; left: 50%; transform: translateX(-50%); background: var(--surface); border: 0.5px solid var(--border); border-radius: var(--r-xl); padding: 12px 18px; box-shadow: 0 8px 32px rgba(0,0,0,0.15); z-index: 400; display: flex; align-items: center; gap: 12px; max-width: 380px; width: calc(100% - 32px); animation: slideUp 0.3s ease; }
@keyframes slideUp { from { opacity:0; transform: translateX(-50%) translateY(16px); } to { opacity:1; transform: translateX(-50%) translateY(0); } }
.install-text { flex: 1; }
.install-title { font-size: 13px; font-weight: 500; }
.install-sub { font-size: 11px; color: var(--text2); margin-top: 2px; }

/* ── TOAST ─────────────────────────────────── */
#toast { position: fixed; bottom: 24px; right: 24px; background: var(--text); color: var(--surface); padding: 10px 16px; border-radius: var(--r-md); font-size: 13px; opacity: 0; transform: translateY(8px); transition: all 0.2s; z-index: 500; pointer-events: none; }
#toast.show { opacity: 1; transform: none; }

/* ── MOBILE ─────────────────────────────────── */
@media (max-width: 700px) {
  .sidebar { position: fixed; left: 0; top: 0; bottom: 0; transform: translateX(-100%); }
  .sidebar.open { transform: none; box-shadow: 4px 0 24px rgba(0,0,0,0.2); }
  .sidebar-overlay { display: none; position: fixed; inset: 0; background: rgba(0,0,0,0.4); z-index: 49; }
  .sidebar-overlay.show { display: block; }
  .hamburger { display: flex; }
  .stats-row { grid-template-columns: repeat(2, 1fr); }
  .grid-2 { grid-template-columns: 1fr; }
  .content { padding: 14px 16px; }
  .topbar { padding: 10px 16px; }
  #install-banner { bottom: 8px; }
}

/* ── PAGES ─────────────────────────────────── */
.page { display: none; }
.page.active { display: block; animation: fadeIn 0.15s ease; }
@keyframes fadeIn { from { opacity:0; } to { opacity:1; } }
.section-gap { margin-bottom: 14px; }
.full-card { background: var(--surface); border-radius: var(--r-lg); border: 0.5px solid var(--border); padding: 16px 18px; margin-bottom: 14px; }
