:root {
  /* Brand + neutrals */
  --brand: #2a488c;
  --brand-blue: #1874ff;
  --text: #2a2a2a;
  --muted: #6b7280;
  --border: #dcdcdc;
  --bg: #f8fafc;
  --neutral-100: #f3f4f6;
  --neutral-200: #e5e7eb;
  --neutral-600: #4b5563;

  /* Layout */
  --bottom-nav-h: 60px;
  --sidebar-open: 250px;
  --sidebar-collapsed: 70px;
  --sidebar-w: var(--sidebar-open);

  /* Drawer */
  --drawer-gap: 12px;
  --drawer-bg: #eef4fa;
  --card-bg: #ffffff;
  --card-border: #e5e7eb;
  --title-muted: #4b5563;

  /* Sidebar */
  --side-bg: #f3f6fd;
  --side-hover: #e8f0ff;
  --side-label: #2a2a2a;
  --side-muted: #6b7280;
}
body.sidebar-collapsed {
  --sidebar-w: var(--sidebar-collapsed);
}

/* Base */
html,
body {
  min-height: 100%;
  height: auto;
  overflow-x: hidden;
}
main.student-main {
  position: relative;
  z-index: 1;
}

/* Header (≤768px) */
.student-header {
  position: sticky;
  top: 0;
  z-index: 1500;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.5rem 0.75rem;
  background: linear-gradient(
    135deg,
    var(--neutral-100) 0%,
    #eef2ff 60%,
    #eaf2ff 100%
  );
  border-bottom: 1px solid var(--neutral-200);
}
.student-header .brand-logo {
  width: 32px;
  height: 32px;
  border-radius: 6px;
  object-fit: cover;
}
.student-header .brand-title {
  font-weight: 800;
  letter-spacing: 0.05em;
  color: var(--brand);
  font-size: 1rem;
  text-transform: uppercase;
}
@media (min-width: 769px) {
  .student-header {
    display: none;
  }
}

/* Bottom Nav (≤768px) */
.student-bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 2000;
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 0.35rem 0.25rem;
  height: var(--bottom-nav-h);
  background: linear-gradient(
    135deg,
    var(--neutral-100) 0%,
    #eef2ff 60%,
    #eaf2ff 100%
  );
  border-top: 1px solid var(--neutral-200);
}
.student-bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.2rem;
  color: var(--text);
  font-size: 0.75rem;
  text-decoration: none;
  padding: 0.2rem 0;
}
.student-bottom-nav img {
  width: 22px;
  height: 22px;
  filter: grayscale(100%) brightness(0.55);
  opacity: 0.9;
}
.student-bottom-nav .label {
  display: block;
}
@media (min-width: 769px) {
  .student-bottom-nav {
    display: none;
  }
}

/* Mobile Drawer */
.mobile-drawer {
  position: fixed;
  inset: 0;
  z-index: 1800;
  display: none;
}
.mobile-drawer.show {
  display: block;
}
.mobile-drawer .scrim {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
}
.mobile-drawer .sheet {
  position: absolute;
  left: 0;
  right: 0;
  top: 0;
  bottom: var(--bottom-nav-h);
  background: var(--drawer-bg);
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.2);
}
.mobile-drawer .drawer-header {
  background: linear-gradient(135deg, #f3f4f6 0%, #eef2ff 60%, #eaf2ff 100%);
  border-bottom: 1px solid #e5e7eb;
  padding: 12px 16px 10px;
}
.mobile-drawer .main-title {
  font-size: 1.15rem;
  font-weight: 400;
  letter-spacing: 0.06em;
  color: var(--brand);
  text-transform: uppercase;
}
.mobile-drawer .header-spacer {
  height: 8px;
}
.mobile-drawer .drawer-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: var(--drawer-gap);
}
.mobile-drawer .group-box {
  background: var(--card-bg);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--card-border);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.06);
}
.mobile-drawer .group-box + .group-box {
  margin-top: var(--drawer-gap);
}
.mobile-drawer .card-title {
  padding: 0.7rem 1rem 0.55rem;
  color: var(--title-muted);
  font-size: 0.78rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  border-bottom: 1px solid var(--card-border);
}
.mobile-drawer .btn-item {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.8rem 1rem;
  text-decoration: none;
  color: var(--text);
  background: #fff;
}
.mobile-drawer .btn-item + .btn-item {
  border-top: 1px solid var(--card-border);
}
.mobile-drawer .btn-item img {
  width: 22px;
  height: 22px;
  display: block;
}
.mobile-drawer .profile-item img.avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
}
.mobile-drawer .profile-item .who {
  font-weight: 700;
}
.mobile-drawer .profile-item .email {
  color: #6b7280;
  font-size: 0.85rem;
  margin-top: -2px;
}
.mobile-drawer .section-spacer {
  height: var(--drawer-gap);
}

/* Sidebar */
.student-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-open);
  background: var(--side-bg);
  border-right: 1px solid var(--neutral-200);
  display: none;
  z-index: 1400;
  overflow-x: visible;
}
@media (min-width: 769px) {
  .student-sidebar {
    display: flex;
    flex-direction: column;
  }
}
.student-sidebar .brand {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.75rem 0.85rem;
  background: var(--side-bg);
  border-bottom: 1px solid var(--neutral-200);
}
.student-sidebar .brand img {
  width: 36px;
  height: 36px;
  border-radius: 6px;
}
.student-sidebar .brand .title {
  font-weight: 800;
  color: var(--brand);
}
.student-sidebar .brand .close-desktop {
  margin-left: auto;
  width: 34px;
  height: 34px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--bg);
}
.logo-wrap {
  position: relative;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 36px;
  height: 36px;
}
.logo-wrap img {
  transition: opacity 0.15s ease;
}
.logo-wrap .hint {
  position: absolute;
  inset: 0;
  opacity: 0;
  border: none;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s ease;
  cursor: pointer;
}
.logo-wrap .hint img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 6px;
}
body.sidebar-collapsed .student-sidebar .logo-wrap:hover .hint {
  opacity: 1;
}
body.sidebar-collapsed .student-sidebar .logo-wrap:hover > img {
  opacity: 0;
}
.student-sidebar nav {
  padding: 0.6rem 0.6rem 0.8rem;
  overflow-y: auto;
  overflow-x: visible;
  scrollbar-width: thin;
}
.student-sidebar nav::-webkit-scrollbar {
  width: 8px;
}
.student-sidebar nav::-webkit-scrollbar-thumb {
  background: transparent;
}
.student-sidebar nav:hover::-webkit-scrollbar-thumb {
  background: #d1d5db;
}
.student-sidebar .group-title {
  font-size: 0.72rem;
  letter-spacing: 0.02em;
  color: var(--neutral-600);
  margin: 0.55rem 0.25rem 0.35rem;
}
.student-sidebar .side-link {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.52rem 0.65rem;
  margin: 0 0.15rem;
  background: transparent;
  color: var(--side-label);
  border-radius: 10px;
  text-decoration: none;
  transition: background-color 0.12s ease;
}
.student-sidebar .side-link + .side-link {
  margin-top: 0.15rem;
}
.student-sidebar .side-link:hover {
  background: var(--side-hover);
}
.student-sidebar .side-link img {
  width: 22px;
  height: 22px;
}
.student-sidebar .side-link span {
  white-space: nowrap;
  font-size: 0.92rem;
  line-height: 1.2;
}
.student-sidebar .foot {
  margin-top: auto;
  background: var(--side-bg);
  border-top: 1px solid var(--neutral-200);
  padding: 0.85rem 0.9rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}
.student-sidebar .foot .avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
}
.student-sidebar .foot .name {
  font-weight: 700;
  font-size: 0.95rem;
}
.student-sidebar .foot .email {
  font-size: 0.78rem;
  color: var(--side-muted);
  margin-top: -2px;
}

/* Collapsed sidebar */
body.sidebar-collapsed .student-sidebar {
  width: var(--sidebar-collapsed);
}
body.sidebar-collapsed .student-sidebar .title,
body.sidebar-collapsed .student-sidebar .name,
body.sidebar-collapsed .student-sidebar .email,
body.sidebar-collapsed .student-sidebar .close-desktop,
body.sidebar-collapsed .student-sidebar .group-title {
  display: none;
}
body.sidebar-collapsed .student-sidebar .side-link {
  justify-content: center !important;
  gap: 0 !important;
  padding: 0.55rem 0 !important;
  margin: 0 0.15rem;
}
body.sidebar-collapsed .student-sidebar .side-link span {
  display: none !important;
}
body.sidebar-collapsed .student-sidebar .side-link img {
  width: 22px !important;
  height: 22px !important;
  display: block;
  margin: 0;
}
body.sidebar-collapsed .student-sidebar nav {
  overflow-y: auto !important;
  -ms-overflow-style: none !important;
  scrollbar-width: none !important;
}
body.sidebar-collapsed .student-sidebar nav::-webkit-scrollbar {
  width: 0 !important;
  height: 0 !important;
}
body.sidebar-collapsed .student-sidebar .side-link:hover::after {
  content: attr(data-label);
  position: absolute;
  left: 80px;
  top: 50%;
  transform: translateY(-50%);
  background: #111827;
  color: #fff;
  padding: 0.25rem 0.5rem;
  border-radius: 6px;
  font-size: 0.82rem;
  white-space: nowrap;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

/* Settings submenu */
.side-link.has-children {
  justify-content: space-between;
}
.side-link.has-children .chev {
  margin-left: auto;
  transition: transform 0.18s ease;
}
.side-link.has-children.open .chev {
  transform: rotate(180deg);
}
.side-children {
  display: none;
  margin-left: 2.1rem;
}
.side-link.open + .side-children {
  display: block;
}
body.sidebar-collapsed .student-sidebar .side-link.has-children .chev {
  display: none !important;
}
body.sidebar-collapsed .student-sidebar .side-link.has-children {
  justify-content: center !important;
}
body.sidebar-collapsed .student-sidebar .side-link.has-children > span {
  display: contents !important;
}

/* Main layout (follows live sidebar width) */
@media (min-width: 769px) {
  main.student-main {
    margin-left: var(--sidebar-w);
    width: calc(100% - var(--sidebar-w));
    padding: 1rem 1rem 1.25rem;
    box-sizing: border-box;
  }
}
@media (max-width: 768px) {
  main.student-main {
    margin-left: 0 !important;
    width: 100% !important;
    padding: 0 1rem calc(var(--bottom-nav-h) + 12px);
  }
}

/* Mobile typography */
@media (max-width: 768px) {
  html,
  body {
    font-size: 15.5px;
  }
  .student-header .brand-title {
    font-size: 0.95rem;
  }
  .student-bottom-nav .label {
    font-size: 0.78rem;
  }
  .mobile-drawer .btn-item span {
    font-size: 0.95rem;
  }
  .student-sidebar .side-link span {
    font-size: 0.95rem;
  }
}

/* Background logo (never cut by bottom nav on phones) */
body.has-bg-logo {
  background-image: url("/attendance/public/assets/img/logobg.jpg");
  background-repeat: no-repeat;
  background-size: 140px auto;
  background-position: right 12px bottom 12px;
}
@media (max-width: 768px) {
  body.has-bg-logo {
    background-size: 96px auto;
    background-position: right 8px bottom
      calc(var(--bottom-nav-h) + env(safe-area-inset-bottom, 0px) + 8px);
    background-attachment: local;
  }
}

/* Glassy dash-surface: fixed in place, internal scroll, wide on desktop */
.dash-surface {
  background: rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  border: 1px solid rgba(0, 0, 0, 0.06);
  border-radius: 20px;
  box-shadow:
    0 8px 24px rgba(0, 0, 0, 0.06),
    0 1px 3px rgba(0, 0, 0, 0.04);
  padding: 1.25rem;
  box-sizing: border-box;
}
@media (min-width: 769px) {
  .dash-surface {
    position: sticky;
    top: 1rem;
    height: calc(100vh - 1rem - 1.25rem);
    width: calc(100% - 2rem);
    max-width: none;
    margin: 1rem auto 1.25rem;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
}
@media (max-width: 768px) {
  .dash-surface {
    position: sticky;
    top: 0.75rem;
    height: calc(100vh - 0.75rem - (var(--bottom-nav-h) + 0.75rem));
    width: calc(100% - 1rem);
    margin: 0.75rem auto calc(var(--bottom-nav-h) + 0.75rem);
    overflow: auto;
    -webkit-overflow-scrolling: touch;
  }
}

/* --- Mobile fixed header --- */
:root {
  --mobile-header-h: 56px; /* adjust if your header is taller/shorter */
}

@media (max-width: 768px) {
  .student-header {
    position: fixed;
    top: env(safe-area-inset-top, 0px);
    left: 0;
    right: 0;
    z-index: 2000; /* above content */
    background: linear-gradient(
      135deg,
      var(--neutral-100) 0%,
      #eef2ff 60%,
      #eaf2ff 100%
    );
    border-bottom: 1px solid var(--neutral-200);
    min-height: var(--mobile-header-h);
    /* Ensure hardware-accelerated compositing on mobile */
    will-change: transform;
    transform: translateZ(0);
  }

  /* Push scrolling content below the fixed header */
  main.student-main {
    padding-top: calc(var(--mobile-header-h) + 8px);
  }

  /* If you use a sticky inner surface, bump it below the fixed header */
  .dash-surface {
    top: calc(var(--mobile-header-h) + 0.75rem);
    height: calc(
      100vh - (var(--mobile-header-h) + var(--bottom-nav-h) + 1.5rem)
    );
    /* keep your existing margins, but ensure top margin clears the header */
    margin-top: calc(var(--mobile-header-h) + 0.75rem);
  }
}

/* --- Fix spacing side-effects of fixed mobile header --- */
@media (max-width: 768px) {
  main.student-main {
    padding-top: calc(var(--mobile-header-h) + 8px);
  }

  .dash-surface {
    top: 0.75rem !important;
    margin-top: 0.75rem !important;
    height: calc(
      100vh - (var(--mobile-header-h) + var(--bottom-nav-h) + 1.5rem)
    ) !important;
  }

  main.student-main:has(.ses-shell) {
    padding-top: calc(var(--mobile-header-h) + 14px) !important;
  }

  .ses-shell {
    margin-top: 8px;
  }
}

/* --- Dashboard fix: make .dash-surface clear the fixed header --- */
@media (max-width: 768px) {
  main.student-main:has(.dash-surface) {
    padding-top: 0 !important;
  }

  .dash-surface {
    top: calc(var(--mobile-header-h) + 0.75rem) !important;
    margin-top: 0 !important;
    height: calc(
      100vh - (var(--mobile-header-h) + var(--bottom-nav-h) + 0.75rem)
    ) !important;
  }
}
