/* =============================================================================
   shell.css — kerangka aplikasi
   -----------------------------------------------------------------------------
   Sidebar (desktop), topbar, bottom tabbar (mobile), dan drawer "Lainnya".
   Hanya kerangka: isi halaman tetap diatur style.css.

   Model interaksinya berbeda per layar, bukan hanya ukurannya:
     < 1024px  : konten satu kolom penuh + bottom tabbar + drawer
     >= 1024px : sidebar tetap di kiri, tabbar hilang
   ========================================================================== */

.skip-link {
  position: absolute;
  left: var(--sp-2);
  top: -60px;
  z-index: 100;
  padding: var(--sp-2) var(--sp-4);
  background: var(--primary);
  color: var(--text-invert);
  border-radius: var(--r-sm);
  font-weight: var(--fw-semibold);
  transition: top var(--t-fast) var(--ease);
}
.skip-link:focus { top: var(--sp-2); }

/* =============================== RANGKA =============================== */

.app {
  display: flex;
  align-items: flex-start;
  min-height: 100vh;
}

.app__col {
  flex: 1;
  min-width: 0;             /* tanpa ini, tabel lebar memaksa body melebar */
  display: flex;
  flex-direction: column;
}

/*
 * Ruang untuk tabbar; di desktop dikosongkan kembali.
 * Halaman siswa (submit.html) memakai topbar yang sama tetapi tanpa tabbar,
 * jadi dikecualikan agar tidak ada ruang kosong di bawahnya.
 */
body:not(.body--siswa) { padding-bottom: calc(var(--tabbar-h) + var(--safe-bottom)); }

.view {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--sp-4) var(--sp-4) var(--sp-8);
  display: flex;
  flex-direction: column;
  gap: var(--sp-4);
}

/* Halaman siswa: satu formulir, tidak perlu selebar dashboard */
.body--siswa .view { max-width: 640px; }

/* =============================== TOPBAR =============================== */

.topbar {
  position: sticky;
  top: 0;
  z-index: var(--z-topbar);
  display: flex;
  align-items: center;
  gap: var(--sp-1);
  min-height: var(--topbar-h);
  padding: 0 var(--sp-2) 0 var(--sp-3);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}

.topbar__title { flex: 1; min-width: 0; }

.topbar__title h1 {
  font-size: var(--fs-h2);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
  line-height: var(--lh-tight);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__sub {
  font-size: var(--fs-xs);
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.topbar__progress {
  position: absolute;
  left: 0; right: 0; bottom: -1px;
  height: 3px;
  overflow: hidden;
}

.topbar__progress.is-active::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(90deg, transparent, var(--primary), transparent);
  animation: slide 1.1s linear infinite;
}

/* ------------------------- konteks akademik ---------------------------- */

.topbar__meta {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
}

.ctx {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 30px;
  padding: 0 var(--sp-3);
  border: 1px solid var(--border);
  border-radius: var(--r-full);
  background: var(--surface-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-semibold);
  color: var(--text-2);
  white-space: nowrap;
}
.ctx:hover { border-color: var(--border-strong); }
.ctx [data-lucide] { width: 14px; height: 14px; }

.ctx__sem {
  padding-left: 6px;
  margin-left: 2px;
  border-left: 1px solid var(--border-strong);
  color: var(--text-muted);
  font-weight: var(--fw-medium);
}

.ctx--pekan { color: var(--primary); background: var(--primary-soft-2); border-color: var(--primary-soft); }
.ctx--pekan-b { color: var(--accent-b); background: var(--accent-b-soft); border-color: transparent; }

.ctx__dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: currentColor;
}

/* Di HP, konteks akademik ditampilkan Dashboard — topbar dijaga tetap lega */
@media (max-width: 767px) {
  .topbar__meta { display: none; }
}

/* =============================== SIDEBAR ============================== */

.sidebar { display: none; }

@media (min-width: 1024px) {
  .sidebar {
    position: sticky;
    top: 0;
    z-index: var(--z-sidebar);
    display: flex;
    flex-direction: column;
    flex: none;
    width: var(--sidebar-w);
    height: 100vh;
    background: var(--surface);
    border-right: 1px solid var(--border);
  }

  :root.sidebar-lipat .sidebar { width: var(--sidebar-w-collapsed); }
}

.sidebar__brand {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--topbar-h);
  padding: 0 var(--sp-3);
  border-bottom: 1px solid var(--border);
}

.brand__logo {
  display: grid;
  place-items: center;
  flex: none;
  width: 34px; height: 34px;
  border-radius: var(--r-sm);
  background: var(--primary);
  color: var(--text-invert);
}
.brand__logo [data-lucide] { width: 19px; height: 19px; }

.brand__teks {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}
.brand__teks strong { font-size: var(--fs-h3); letter-spacing: var(--tracking-tight); }

/* ------------------------------- menu --------------------------------- */

.sidebar__nav {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-3) var(--sp-2);
  display: flex;
  flex-direction: column;
  gap: var(--sp-1);
}

.navgroup { display: flex; flex-direction: column; gap: 2px; }
.navgroup + .navgroup { margin-top: var(--sp-3); }

.navgroup__judul {
  padding: var(--sp-2) var(--sp-3) var(--sp-1);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}

.navitem {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: 40px;
  padding: 0 var(--sp-3);
  border-radius: var(--r-sm);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
  color: var(--text-2);
  transition: background var(--t-fast) var(--ease), color var(--t-fast) var(--ease);
}
.navitem [data-lucide] { width: 18px; height: 18px; }
.navitem__label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.navitem:hover { background: var(--surface-3); color: var(--text); }

.navitem.is-active {
  background: var(--primary-soft-2);
  color: var(--primary);
  font-weight: var(--fw-semibold);
}
:root[data-theme="dark"] .navitem.is-active { background: var(--primary-soft); color: var(--text); }

/* --------------------------- mode terlipat ----------------------------- */

:root.sidebar-lipat .brand__teks,
:root.sidebar-lipat .navitem__label,
:root.sidebar-lipat .navgroup__judul,
:root.sidebar-lipat .sidebar__profil-teks { display: none; }

:root.sidebar-lipat .sidebar__brand { justify-content: center; padding: 0 var(--sp-2); }
:root.sidebar-lipat .navitem { justify-content: center; padding: 0; }
:root.sidebar-lipat .navgroup + .navgroup {
  margin-top: var(--sp-2);
  padding-top: var(--sp-2);
  border-top: 1px solid var(--border);   /* pengganti judul kelompok */
}
:root.sidebar-lipat .sidebar__profil { justify-content: center; }

/*
 * Kolom terlipat hanya selebar satu ikon, jadi logo dan tombol tidak bisa
 * berdampingan. Yang disembunyikan adalah logonya, bukan tombolnya —
 * menyembunyikan tombol (mis. hanya muncul saat hover) membuat sidebar tidak
 * bisa dilebarkan kembali lewat keyboard atau layar sentuh.
 */
:root.sidebar-lipat .brand__logo { display: none; }

/* ------------------------------ profil -------------------------------- */

.sidebar__profil {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
}

.sidebar__profil-teks {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  line-height: 1.25;
}
.sidebar__profil-teks strong { font-size: var(--fs-sm); }

.avatar {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--primary-soft);
  color: var(--primary);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
}
:root[data-theme="dark"] .avatar { color: var(--text); }

/* =============================== TABBAR =============================== */

.tabbar {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-tabbar);
  display: flex;
  height: calc(var(--tabbar-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: var(--surface);
  border-top: 1px solid var(--border);
}

.tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  padding: 0 2px;
  border: 0;
  background: none;
  font-size: var(--fs-xs);
  font-weight: var(--fw-medium);
  color: var(--text-muted);
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.tab [data-lucide] { width: 21px; height: 21px; }
.tab__label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.tab.is-active { color: var(--primary); font-weight: var(--fw-semibold); }
.tab:active { background: var(--surface-2); }

@media (max-width: 360px) {
  .tab { font-size: 10px; }
  .tab [data-lucide] { width: 19px; height: 19px; }
}

@media (min-width: 1024px) {
  .tabbar { display: none; }
  body:not(.body--siswa) { padding-bottom: 0; }
}

/* =============================== DRAWER =============================== */

.drawer-backdrop {
  position: fixed;
  inset: 0;
  z-index: var(--z-drawer);
  display: flex;
  align-items: flex-end;
  background: rgba(15, 23, 42, .5);
  animation: fadeIn var(--t-fast) var(--ease);
}

.drawer {
  width: 100%;
  max-height: 82vh;
  display: flex;
  flex-direction: column;
  background: var(--surface);
  border-radius: var(--r-lg) var(--r-lg) 0 0;
  padding-bottom: var(--safe-bottom);
  animation: sheetUp var(--t-base) var(--ease);
}

.drawer__head {
  display: flex;
  align-items: center;
  gap: var(--sp-2);
  padding: var(--sp-4) var(--sp-3) var(--sp-3) var(--sp-4);
  border-bottom: 1px solid var(--border);
}
.drawer__head h2 {
  flex: 1;
  font-size: var(--fs-h2);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-tight);
}

.drawer__body {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--sp-2) var(--sp-3) var(--sp-4);
}

.drawergroup + .drawergroup { margin-top: var(--sp-3); }

.drawergroup__judul {
  padding: var(--sp-3) var(--sp-2) var(--sp-2);
  font-size: var(--fs-xs);
  font-weight: var(--fw-bold);
  letter-spacing: var(--tracking-wide);
  text-transform: uppercase;
  color: var(--text-muted);
}

.drawergroup__isi {
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: var(--r-md);
  background: var(--surface);
}

.drawerlink {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  min-height: var(--tap);
  padding: var(--sp-2) var(--sp-3);
  font-size: var(--fs-body);
  font-weight: var(--fw-medium);
}
.drawerlink + .drawerlink { border-top: 1px solid var(--border); }
.drawerlink:active { background: var(--surface-2); }

.drawerlink__ikon {
  display: grid;
  place-items: center;
  flex: none;
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  background: var(--surface-3);
  color: var(--text-2);
}
.drawerlink__ikon [data-lucide] { width: 17px; height: 17px; }

.drawerlink__label { flex: 1; min-width: 0; }

.drawerlink__chev { width: 16px; height: 16px; color: var(--text-muted); }

.drawerlink.is-active { color: var(--primary); }
.drawerlink.is-active .drawerlink__ikon { background: var(--primary-soft); color: var(--primary); }
:root[data-theme="dark"] .drawerlink.is-active .drawerlink__ikon { color: var(--text); }

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes sheetUp { from { transform: translateY(12px); } to { transform: translateY(0); } }

/* ==================== AKSES TERBATAS (tanpa otorisasi) ================= */

/*
 * Tanpa token, tidak ada halaman guru yang dapat dirender — jadi menu dan
 * pencariannya pun tidak ditampilkan. Ini bukan pengaman (batasnya ada di
 * Apps Script), melainkan supaya layar ini terbaca sebagai halaman yang
 * memang tertutup, bukan aplikasi yang gagal memuat.
 */
:root[data-akses="terbatas"] .sidebar,
:root[data-akses="terbatas"] .tabbar,
:root[data-akses="terbatas"] #btnSearch { display: none !important; }

:root[data-akses="terbatas"] body { padding-bottom: 0; }

/* ========================= PENYESUAIAN LAYAR ========================== */

@media (min-width: 768px) {
  .view { padding: var(--sp-5) var(--sp-5) var(--sp-10); gap: var(--sp-5); }
  .topbar { padding-left: var(--sp-5); padding-right: var(--sp-4); }
  .topbar__title h1 { font-size: var(--fs-h1); }
}

@media (min-width: 1024px) {
  .view { padding: var(--sp-6) var(--sp-6) var(--sp-12); gap: var(--sp-5); }
  .topbar { padding-left: var(--sp-6); padding-right: var(--sp-5); }
}

@media print {
  .sidebar, .topbar, .tabbar, .drawer-backdrop,
  .toast-wrap, .modal-backdrop, .sheet-backdrop, .skip-link { display: none !important; }

  body { background: #fff; padding: 0; }
  .app { display: block; }
  .view { max-width: none; padding: 0; }
}
