/* ───────────── LOGIN ───────────── */
#login {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background:
    radial-gradient(1200px 600px at 80% 10%, rgba(79,70,229,.06), transparent 60%),
    radial-gradient(900px 500px at 10% 90%, rgba(15,138,95,.05), transparent 60%),
    var(--bg);
  padding: 40px 20px;
}
.login-card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  padding: 40px;
  width: 460px;
  box-shadow: var(--shadow);
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  font-family: 'Inter Tight';
  font-weight: 700;
  font-size: 18px;
  letter-spacing: -0.02em;
}
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--ink);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
}
.brand-mark::after { content: "S"; }
.login-card .brand { justify-content: center; margin-bottom: 6px; }
.login-tag { font-size: 13px; color: var(--ink-3); text-align: center; margin-bottom: 28px; }
.login-meta {
  display: flex;
  justify-content: center;
  gap: 14px;
  margin-bottom: 24px;
  font-size: 11px;
  color: var(--ink-4);
  font-family: 'JetBrains Mono';
  font-weight: 500;
}
.login-meta span.dot {
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--ok); display: inline-block;
  margin-right: 5px; vertical-align: middle;
}
.login-prompt {
  font-size: 12px; color: var(--ink-3); font-weight: 500;
  margin-bottom: 12px; text-align: center;
  text-transform: uppercase; letter-spacing: .08em;
}
.role-grid { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 22px; }
.role-btn {
  padding: 18px 14px; border-radius: var(--radius);
  border: 1px solid var(--line); background: var(--surface);
  cursor: pointer; transition: .18s; text-align: left;
}
.role-btn:hover { transform: translateY(-1px); border-color: var(--ink-5); box-shadow: var(--shadow-sm); }
.role-icon {
  width: 32px; height: 32px; border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 10px; background: var(--line-2); color: var(--ink-2);
}
.role-btn.admin:hover .role-icon { background: #EEF0FF; color: #4F46E5; }
.role-btn.teacher:hover .role-icon { background: #E6F4F4; color: #0E7C7B; }
.role-btn.parent:hover .role-icon { background: #E8F3EC; color: #0F8A5F; }
.role-name { font-size: 13px; font-weight: 600; color: var(--ink); }
.role-desc { font-size: 11px; color: var(--ink-4); margin-top: 2px; }
.login-foot {
  text-align: center; font-size: 11px; color: var(--ink-4);
  border-top: 1px solid var(--line); padding-top: 16px;
  font-family: 'JetBrains Mono';
}

/* ───────────── MFA OVERLAY ───────────── */
#mfa {
  position: fixed; inset: 0;
  background: rgba(14,14,16,.45);
  backdrop-filter: blur(4px);
  display: none; align-items: center; justify-content: center;
  z-index: 50;
}
#mfa.show { display: flex; }
.mfa-card {
  background: var(--surface); border-radius: var(--radius-lg);
  padding: 32px; width: 380px; text-align: center;
  box-shadow: var(--shadow);
}
.mfa-icon {
  width: 48px; height: 48px; border-radius: 12px;
  background: var(--accent-soft); color: var(--accent);
  display: inline-flex; align-items: center; justify-content: center;
  margin-bottom: 16px;
}
.mfa-title { font-family: 'Inter Tight'; font-size: 18px; font-weight: 600; margin-bottom: 6px; }
.mfa-sub { font-size: 13px; color: var(--ink-3); margin-bottom: 24px; }
.otp-row { display: flex; gap: 8px; justify-content: center; margin-bottom: 22px; }
.otp-row input {
  width: 42px; height: 48px; border: 1px solid var(--line);
  border-radius: 8px; font-size: 18px; text-align: center;
  font-weight: 600; outline: none;
  background: var(--surface); color: var(--ink);
}
.otp-row input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }

/* ───────────── APP SHELL ───────────── */
#app-shell {
  display: flex;
  height: 100vh;
  flex-direction: column;
}

/* ───────────── TOPBAR ───────────── */
#topbar {
  height: 60px; display: flex; align-items: center;
  justify-content: space-between; padding: 0 24px;
  border-bottom: 1px solid var(--line);
  background: var(--surface); flex-shrink: 0; z-index: 5;
}
.tb-left { display: flex; align-items: center; gap: 16px; }
.tb-divider { width: 1px; height: 20px; background: var(--line); }
.tb-role {
  font-size: 11px; font-weight: 500; padding: 4px 10px;
  border-radius: 20px; background: var(--accent-soft);
  color: var(--accent-ink); letter-spacing: 0;
}
.tb-status {
  display: flex; align-items: center; gap: 8px;
  font-size: 12px; color: var(--ink-3);
}
.tb-status .dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--ok); display: inline-block;
}
.tb-right { display: flex; align-items: center; gap: 8px; }
.tb-search {
  display: flex; align-items: center; gap: 8px;
  background: var(--bg); border: 1px solid var(--line);
  border-radius: 8px; padding: 7px 12px; width: 280px;
  color: var(--ink-3); font-size: 13px; cursor: text;
}
.tb-search:focus-within {
  border-color: var(--accent); background: var(--surface);
  box-shadow: 0 0 0 3px var(--accent-soft);
}
.tb-search input {
  border: none; background: none; outline: none;
  flex: 1; font-size: 13px; color: var(--ink);
}
.tb-search kbd {
  font-family: 'JetBrains Mono'; font-size: 10px;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 4px; padding: 1px 5px; color: var(--ink-4);
}
.tb-icon {
  width: 34px; height: 34px; border-radius: 8px;
  border: 1px solid transparent;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; color: var(--ink-2); position: relative;
  transition: .15s;
}
.tb-icon:hover { background: var(--hover); color: var(--ink); }
.tb-icon .dot-red {
  position: absolute; top: 7px; right: 7px;
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--err); border: 2px solid var(--surface);
}
.tb-icon .dot-red.hidden { display: none; }

/* Phase 11.5 — Notification panel (anchored to #tb-bell via JS) */
.notif-panel {
  width: 320px; max-height: 420px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 28px rgba(0,0,0,.18);
  z-index: 1000; font-size: 13px;
}
.notif-panel .notif-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  font-weight: 600; color: var(--ink);
}
.notif-panel .notif-clear {
  background: none; border: none; color: var(--ink-3);
  font-size: 12px; cursor: pointer; padding: 2px 6px; border-radius: 4px;
}
.notif-panel .notif-clear:hover { background: var(--hover); color: var(--ink); }
.notif-panel .notif-empty {
  padding: 28px 14px; text-align: center; color: var(--ink-4); font-size: 13px;
}
.notif-panel .notif-list { list-style: none; margin: 0; padding: 0; }
.notif-panel .notif-item {
  padding: 10px 14px; border-bottom: 1px solid var(--line);
  display: flex; flex-direction: column; gap: 2px;
}
.notif-panel .notif-item:last-child { border-bottom: none; }
.notif-panel .notif-item.unread { background: var(--hover); }
.notif-panel .notif-title { font-weight: 600; color: var(--ink); }
.notif-panel .notif-body { color: var(--ink-3); font-size: 12px; }
.notif-panel .notif-time { color: var(--ink-5); font-size: 11px; margin-top: 2px; }

/* Phase 11.6 — Profile panel (anchored to .tb-user via JS) */
.profile-panel {
  width: 320px; max-height: 480px; overflow-y: auto;
  background: var(--surface); border: 1px solid var(--line);
  border-radius: 10px; box-shadow: 0 12px 28px rgba(0,0,0,.18);
  z-index: 1000; font-size: 13px;
}
.profile-panel .profile-head {
  display: flex; gap: 12px; align-items: center;
  padding: 14px; border-bottom: 1px solid var(--line);
}
.profile-panel .profile-avatar {
  width: 44px; height: 44px; border-radius: 50%;
  background: var(--accent); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; font-size: 16px;
}
.profile-panel .profile-headinfo { display: flex; flex-direction: column; gap: 2px; }
.profile-panel .profile-name { font-weight: 600; color: var(--ink); font-size: 14px; }
.profile-panel .profile-role { color: var(--ink-3); font-size: 12px; }
.profile-panel .profile-body { padding: 10px 14px 14px; }
.profile-panel .profile-row {
  display: flex; justify-content: space-between; align-items: center;
  padding: 6px 0; border-bottom: 1px dashed var(--line);
}
.profile-panel .profile-row:last-child { border-bottom: none; }
.profile-panel .profile-label { color: var(--ink-4); font-size: 12px; }
.profile-panel .profile-value { color: var(--ink); font-size: 13px; }
.profile-panel .profile-muted { color: var(--ink-5); font-style: italic; }
.profile-panel .profile-section-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: .04em;
  color: var(--ink-4); margin: 10px 0 4px;
}
.profile-panel .profile-children { list-style: none; margin: 0; padding: 0; }
.profile-panel .profile-children li {
  padding: 6px 0; border-bottom: 1px dashed var(--line);
  display: flex; justify-content: space-between; align-items: center;
}
.profile-panel .profile-children li:last-child { border-bottom: none; }
.profile-panel .profile-child-name { color: var(--ink); font-weight: 500; }
.profile-panel .profile-child-grade { color: var(--ink-3); font-size: 12px; }
.profile-panel .profile-empty { color: var(--ink-4); font-size: 12px; padding: 6px 0; }
.profile-panel .profile-loading,
.profile-panel .profile-error {
  padding: 24px 14px; text-align: center; color: var(--ink-4); font-size: 13px;
}
.profile-panel .profile-error { color: var(--err); }
.tb-user {
  display: flex; align-items: center; gap: 9px;
  font-size: 13px; color: var(--ink); cursor: pointer;
  padding: 5px 10px; border-radius: 8px; font-weight: 500;
}
.tb-user:hover { background: var(--hover); }
.tb-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  background: var(--accent);
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600; color: #fff;
}
.logout {
  font-size: 12px; color: var(--ink-3); cursor: pointer;
  padding: 6px 11px; border-radius: 7px;
  border: 1px solid var(--line); background: var(--surface);
  font-weight: 500;
}
.logout:hover { background: var(--hover); color: var(--ink); }
.sos-btn {
  font-size: 12px; font-weight: 600; padding: 7px 14px;
  border-radius: 8px; background: var(--err); color: #fff;
  display: flex; align-items: center; gap: 6px;
  letter-spacing: .02em; border: none; cursor: pointer;
}
.sos-btn:hover { background: #A82917; }
.sos-btn::before {
  content: ""; width: 7px; height: 7px;
  border-radius: 50%; background: #fff;
  animation: pulse 1.4s infinite;
}

/* ───────────── BODY WRAP ───────────── */
#body-wrap { display: flex; flex: 1; overflow: hidden; }

/* ───────────── SIDEBAR ───────────── */
#sidebar {
  width: 236px; background: var(--surface);
  border-right: 1px solid var(--line);
  display: flex; flex-direction: column; flex-shrink: 0;
  overflow-y: auto; padding: 14px 12px;
}
.nav-section {
  font-size: 10px; color: var(--ink-4);
  text-transform: uppercase; letter-spacing: .1em;
  padding: 14px 10px 6px; font-weight: 600;
}
.nav-item {
  display: flex; align-items: center; gap: 11px;
  padding: 9px 10px; cursor: pointer; font-size: 13px;
  color: var(--ink-2); border-radius: 7px;
  transition: .12s; font-weight: 500;
}
.nav-item:hover { background: var(--hover); color: var(--ink); }
.nav-item.active { background: var(--accent-soft); color: var(--accent-ink); font-weight: 600; }
.nav-item.active .nav-ic { color: var(--accent); }
.nav-ic { width: 16px; height: 16px; color: var(--ink-3); flex-shrink: 0; }
.nav-item:hover .nav-ic { color: var(--ink-2); }
.nav-badge {
  margin-left: auto; font-size: 10px; font-weight: 600;
  padding: 2px 7px; border-radius: 20px;
  background: var(--err); color: #fff; line-height: 1.4;
}
.nav-item.danger { color: var(--err); }
.nav-item.danger:hover { background: #FCEEEA; }
.nav-item.danger.active { background: #FCEEEA; color: var(--err); }
.nav-item.danger.active .nav-ic { color: var(--err); }
.sidebar-footer {
  margin-top: auto; padding: 14px 10px 6px;
  border-top: 1px solid var(--line);
  font-size: 11px; color: var(--ink-4);
}
.sf-status {
  display: flex; align-items: center; gap: 7px;
  color: var(--ink-3); font-weight: 500;
}
.sf-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--ok); }
.sf-sync {
  font-size: 10px; color: var(--ink-4); margin-top: 4px;
  font-family: 'JetBrains Mono';
}

/* ───────────── CONTENT ───────────── */
#content { flex: 1; overflow-y: auto; padding: 28px 32px; }

/* ───────────── PAGE STRUCTURE ───────────── */
.page-head {
  display: flex; align-items: flex-start;
  justify-content: space-between; margin-bottom: 24px;
  flex-wrap: wrap; gap: 12px;
}
.page-title {
  font-family: 'Inter Tight'; font-size: 24px;
  font-weight: 600; letter-spacing: -0.02em; color: var(--ink);
}
.page-sub { font-size: 13px; color: var(--ink-3); margin-top: 4px; }

/* ───────────── FOOTER ───────────── */
.app-footer {
  padding: 8px 24px; background: var(--surface);
  border-top: 1px solid var(--line);
  display: flex; justify-content: space-between;
  font-size: 11px; color: var(--ink-4);
  font-family: 'JetBrains Mono'; flex-wrap: wrap; gap: 10px;
}
.app-footer span {
  display: inline-flex; align-items: center; gap: 5px;
}
.app-footer span::before {
  content: ""; width: 5px; height: 5px;
  border-radius: 50%; background: var(--ok);
}
.app-footer span.no-dot::before { display: none; }

/* ───────────── MOBILE SIDEBAR DRAWER (Phase 11.7) ───────────── */

/* Hamburger toggle button — far-left of the topbar */
.tb-hamburger {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--ink-2);
  border: 1px solid transparent;
  flex-shrink: 0;
  transition: .15s;
}
.tb-hamburger:hover { background: var(--hover); color: var(--ink); border-color: var(--line); }

/* Smooth sidebar transitions on toggle (both axes — desktop slides, mobile transforms) */
#sidebar { transition: margin-left .2s ease, transform .2s ease; }

/* Desktop collapsed: sidebar slides left out of flex flow; content reclaims 236px */
#app-shell.sidebar-collapsed #sidebar { margin-left: -236px; }

/* Backdrop element: present in DOM always but hidden until mobile + drawer open */
.sidebar-backdrop { display: none; }

/* Mobile (≤768px): sidebar becomes a fixed overlay drawer */
@media (max-width: 768px) {
  #sidebar {
    position: fixed;
    top: 60px;
    bottom: 0;
    left: 0;
    width: 236px;
    z-index: 50;
    transform: translateX(0);
    box-shadow: 2px 0 16px rgba(0, 0, 0, .18);
    margin-left: 0; /* Override desktop collapsed rule — mobile uses transform */
  }
  #app-shell.sidebar-collapsed #sidebar { transform: translateX(-100%); }

  /* Backdrop visible only when drawer is open (class absent) */
  #app-shell:not(.sidebar-collapsed) .sidebar-backdrop {
    display: block;
    position: fixed;
    inset: 60px 0 0 0;
    background: rgba(0, 0, 0, .4);
    z-index: 40;
    cursor: pointer;
  }

  /* Mobile topbar density: hide status pill + search to free horizontal space */
  .tb-status,
  .tb-search { display: none; }
  #topbar { padding: 0 12px; }
}

/* ───────────── SHELL-LEVEL SOS BANNER (Phase 11.9 follow-up) ───────────── */
.sos-banner {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--err);
  color: #fff;
  padding: 9px 18px;
  font-size: 13px;
  font-weight: 500;
  border-bottom: 1px solid rgba(0, 0, 0, .12);
  cursor: pointer;
  user-select: none;
  z-index: 4;
  animation: sos-banner-pulse 1.8s ease-in-out infinite;
}
.sos-banner:hover { filter: brightness(1.05); }
.sos-banner-icon { font-size: 16px; line-height: 1; }
.sos-banner-sev {
  font-weight: 700;
  letter-spacing: .04em;
  background: rgba(0, 0, 0, .18);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
}
.sos-banner-msg { flex: 0 1 auto; }
.sos-banner-who { opacity: .85; font-weight: 400; }
.sos-banner-cta {
  margin-left: auto;
  font-weight: 600;
  white-space: nowrap;
}
@keyframes sos-banner-pulse {
  0%, 100% { box-shadow: inset 0 0 0 0 rgba(255, 255, 255, 0); }
  50%      { box-shadow: inset 0 0 0 9999px rgba(255, 255, 255, .04); }
}
@media (max-width: 768px) {
  .sos-banner { padding: 8px 12px; font-size: 12px; gap: 8px; }
  .sos-banner-who { display: none; }
}
