/* =====================================================================
   layout.css - the application shell (header, sidebar, bottom nav)
   Shared by the admin panel and the student area.
   ===================================================================== */

.app {
  display: flex;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ================================================================ sidebar */
.app-sidebar {
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: var(--z-drawer);
  display: flex;
  flex-direction: column;
  width: var(--sidebar-w);
  background: var(--surface);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform var(--dur-slow) var(--ease-out), width var(--dur) var(--ease);
}
.app-sidebar.is-open { transform: translateX(0); box-shadow: var(--shadow-xl); }

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 11px;
  height: var(--header-h);
  padding: 0 var(--sp-5);
  border-bottom: 1px solid var(--border);
  flex: none;
}
.sidebar-brand .brand-mark {
  flex: none;
  display: grid; place-items: center;
  width: 34px; height: 34px;
  border-radius: var(--radius-sm);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 13px;
  letter-spacing: -0.02em;
}
.sidebar-brand .brand-mark img { width: 100%; height: 100%; object-fit: contain; }
.sidebar-brand .brand-name {
  font-size: var(--fs-md);
  font-weight: 700;
  letter-spacing: -0.015em;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
}
.sidebar-brand .brand-close { margin-left: auto; }

.sidebar-nav {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: var(--sp-4) var(--sp-3) var(--sp-5);
}

.nav-group + .nav-group { margin-top: var(--sp-5); }
.nav-group-label {
  padding: 0 12px var(--sp-2);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.09em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

.nav-item {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  margin-bottom: 2px;
  border-radius: var(--radius-sm);
  color: var(--text-secondary);
  font-size: var(--fs-base);
  font-weight: 550;
  white-space: nowrap;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.nav-item:hover { background: var(--surface-2); color: var(--text-primary); }
.nav-item .ico { flex: none; color: var(--text-muted); transition: color var(--dur-fast) var(--ease); }
.nav-item:hover .ico { color: var(--text-secondary); }
.nav-item.is-active {
  background: var(--primary-soft);
  color: var(--primary);
  font-weight: 650;
}
.nav-item.is-active .ico { color: var(--primary); }
.nav-item.is-active::before {
  content: "";
  position: absolute;
  left: -12px; top: 50%;
  transform: translateY(-50%);
  width: 3px; height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--primary);
}
.nav-item .nav-count {
  margin-left: auto;
  padding: 1px 7px;
  border-radius: var(--radius-pill);
  background: var(--surface-3);
  color: var(--text-secondary);
  font-size: 11px;
  font-weight: 700;
}
.nav-item.is-active .nav-count { background: var(--primary); color: #fff; }

.sidebar-footer {
  flex: none;
  padding: var(--sp-3);
  border-top: 1px solid var(--border);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 9px 10px;
  border-radius: var(--radius-sm);
  transition: background var(--dur-fast) var(--ease);
}
.sidebar-user:hover { background: var(--surface-2); }
.sidebar-user .u-name { font-size: var(--fs-base); font-weight: 600; color: var(--text-primary); }
.sidebar-user .u-role { font-size: var(--fs-xs); color: var(--text-muted); }

/* sidebar scrim on mobile */
.sidebar-scrim {
  position: fixed;
  inset: 0;
  z-index: calc(var(--z-drawer) - 1);
  background: var(--overlay);
  opacity: 0;
  visibility: hidden;
  transition: opacity var(--dur) var(--ease), visibility var(--dur);
}
.sidebar-scrim.is-open { opacity: 1; visibility: visible; }

/* ================================================================= shell */
.app-body {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 100vh;
  min-height: 100dvh;
}

/* ================================================================ header */
.app-header {
  position: sticky;
  top: 0;
  z-index: var(--z-header);
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  height: calc(var(--header-h) + var(--safe-top));
  padding: var(--safe-top) var(--sp-4) 0;
  background: var(--surface);
  border-bottom: 1px solid var(--border);
}
.app-header.is-transparent {
  background: color-mix(in srgb, var(--surface) 86%, transparent);
  backdrop-filter: saturate(180%) blur(12px);
  -webkit-backdrop-filter: saturate(180%) blur(12px);
}

.header-title { font-size: var(--fs-lg); font-weight: 700; letter-spacing: -0.015em; }
.header-sub { font-size: var(--fs-xs); color: var(--text-muted); }
.header-actions { display: flex; align-items: center; gap: 6px; margin-left: auto; }

.icon-btn {
  position: relative;
  display: grid;
  place-items: center;
  width: 40px; height: 40px;
  border: 0;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--text-secondary);
  cursor: pointer;
  transition: background var(--dur-fast) var(--ease), color var(--dur-fast) var(--ease);
}
.icon-btn:hover { background: var(--surface-2); color: var(--text-primary); }
.icon-btn .dot {
  position: absolute;
  top: 8px; right: 9px;
  min-width: 8px; height: 8px;
  padding: 0 3px;
  border-radius: var(--radius-pill);
  background: var(--danger);
  border: 2px solid var(--surface);
}
.icon-btn .dot.has-count {
  top: 4px; right: 4px;
  height: 16px;
  min-width: 16px;
  display: grid;
  place-items: center;
  color: #fff;
  font-size: 9.5px;
  font-weight: 700;
  line-height: 1;
}

/* header search (desktop) */
.header-search { position: relative; flex: 1; max-width: 420px; }
.header-search .input { height: 40px; min-height: 40px; padding-left: 40px; background: var(--surface-2); border-color: transparent; }
.header-search .input:focus { background: var(--surface); border-color: var(--primary); }
.header-search .ico { position: absolute; top: 50%; left: 13px; transform: translateY(-50%); color: var(--text-muted); pointer-events: none; }

/* ================================================================== main */
.app-main {
  flex: 1;
  min-width: 0;
  padding: var(--sp-5) var(--sp-4);
  padding-bottom: calc(var(--bottomnav-h) + var(--safe-bottom) + var(--sp-6));
}
.app-main.is-flush { padding: 0; }

.page-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--sp-4);
  flex-wrap: wrap;
  margin-bottom: var(--sp-5);
}
.page-head h1 { font-size: var(--fs-xl); }
.page-head .page-sub { margin-top: 3px; font-size: var(--fs-sm); color: var(--text-muted); }
.page-actions { display: flex; align-items: center; gap: var(--sp-2); flex-wrap: wrap; }

/* ============================================================ bottom nav */
.bottom-nav {
  position: fixed;
  left: 0; right: 0; bottom: 0;
  z-index: var(--z-bottomnav);
  display: flex;
  align-items: stretch;
  height: calc(var(--bottomnav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--surface) 92%, transparent);
  backdrop-filter: saturate(180%) blur(14px);
  -webkit-backdrop-filter: saturate(180%) blur(14px);
  border-top: 1px solid var(--border);
}

.bottom-nav-item {
  position: relative;
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 3px;
  min-width: 0;
  color: var(--text-muted);
  font-size: 10.5px;
  font-weight: 600;
  transition: color var(--dur-fast) var(--ease);
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav-item .ico { transition: transform var(--dur) var(--ease-out); }
.bottom-nav-item:active .ico { transform: scale(0.88); }
.bottom-nav-item.is-active { color: var(--primary); }
.bottom-nav-item.is-active .ico { transform: translateY(-1px); }
.bottom-nav-item .nav-dot {
  position: absolute;
  top: 9px; left: 50%;
  margin-left: 7px;
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--danger);
  border: 1.5px solid var(--surface);
}

/* =============================================================== auth page */
.auth-page {
  display: grid;
  min-height: 100vh;
  min-height: 100dvh;
  grid-template-columns: 1fr;
  background: var(--bg);
}

.auth-visual {
  display: none;
  position: relative;
  padding: var(--sp-12);
  background: linear-gradient(150deg, var(--primary) 0%, var(--secondary) 100%);
  color: #fff;
  overflow: hidden;
}
.auth-visual::after {
  content: "";
  position: absolute;
  right: -140px; bottom: -170px;
  width: 460px; height: 460px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.09);
}
.auth-visual::before {
  content: "";
  position: absolute;
  left: -90px; top: -110px;
  width: 300px; height: 300px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.07);
}
.auth-visual-inner { position: relative; z-index: 1; display: flex; flex-direction: column; height: 100%; }
.auth-visual h2 { color: #fff; font-size: var(--fs-3xl); line-height: 1.25; max-width: 420px; }
.auth-visual p { color: rgba(255, 255, 255, 0.86); max-width: 400px; font-size: var(--fs-md); }
.auth-feature { display: flex; align-items: center; gap: 12px; margin-top: var(--sp-4); }
.auth-feature .ico-wrap {
  display: grid; place-items: center;
  width: 38px; height: 38px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.16);
}

.auth-panel {
  display: flex;
  flex-direction: column;
  justify-content: center;
  padding: var(--sp-6) var(--sp-5);
  padding-top: calc(var(--sp-6) + var(--safe-top));
  padding-bottom: calc(var(--sp-6) + var(--safe-bottom));
}
.auth-card { width: 100%; max-width: 400px; margin-inline: auto; }
.auth-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: var(--sp-6);
}
.auth-logo .brand-mark {
  display: grid; place-items: center;
  width: 46px; height: 46px;
  border-radius: var(--radius);
  background: var(--primary);
  color: #fff;
  font-weight: 800;
  font-size: 15px;
}
.auth-logo .brand-mark img { width: 100%; height: 100%; object-fit: contain; border-radius: inherit; }
.auth-card h1 { font-size: var(--fs-2xl); margin-bottom: 6px; }
.auth-card > p { color: var(--text-secondary); margin-bottom: var(--sp-6); }
.auth-foot { margin-top: var(--sp-6); text-align: center; font-size: var(--fs-sm); color: var(--text-muted); }

/* ============================================================== dividers */
.page-loader {
  position: fixed;
  top: 0; left: 0; right: 0;
  z-index: var(--z-toast);
  height: 3px;
  background: transparent;
  overflow: hidden;
  opacity: 0;
  transition: opacity var(--dur) var(--ease);
}
.page-loader.is-active { opacity: 1; }
.page-loader::after {
  content: "";
  display: block;
  width: 40%;
  height: 100%;
  background: var(--primary);
  animation: loader-slide 1s var(--ease) infinite;
}
@keyframes loader-slide {
  0%   { transform: translateX(-100%); }
  100% { transform: translateX(350%); }
}
