/* Reset + base element styles + shared layout primitives (app shell, sidebar,
   topbar, bottom nav). Utility classes live in utilities.css; component
   styles (buttons, cards, etc.) live in components.css. */

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

html,
body {
  margin: 0;
  padding: 0;
}

html {
  -webkit-text-size-adjust: 100%;
}

body {
  font-family: var(--font-base);
  font-size: var(--font-size-base);
  line-height: var(--line-height-base);
  color: var(--color-text);
  background: var(--color-background);
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

img,
svg {
  max-width: 100%;
  display: block;
}

a {
  color: inherit;
  text-decoration: none;
}

button {
  font: inherit;
  color: inherit;
}

ul,
ol {
  margin: 0;
  padding: 0;
  list-style: none;
}

h1,
h2,
h3,
h4,
h5,
h6,
p {
  margin: 0;
}

h1,
h2,
h3,
h4 {
  line-height: var(--line-height-tight);
  font-weight: 600;
}

table {
  border-collapse: collapse;
  width: 100%;
}

fieldset {
  border: 0;
  margin: 0;
  padding: 0;
}

:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: 2px;
}

/* -------------------------------------------------------------------- */
/* App shell — shared skeleton every screen renders into.               */
/* -------------------------------------------------------------------- */

.app-shell {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.app-body {
  display: flex;
  flex: 1;
  min-height: 0;
}

/* Topbar */
.topbar {
  height: var(--topbar-height);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-4);
  padding: 0 var(--space-4);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
  position: sticky;
  top: 0;
  z-index: var(--z-nav);
  flex-wrap: wrap;
}

.topbar-left,
.topbar-right {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  min-width: 0;
}

.topbar-brand {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: 700;
  font-size: var(--font-size-md);
  color: var(--color-primary-dark);
  white-space: nowrap;
}

.topbar-brand .logo-mark {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: var(--color-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  flex-shrink: 0;
}

/* Sidebar (desktop admin / super-admin) */
.sidebar {
  width: var(--sidebar-width);
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  padding: var(--space-4) var(--space-3);
  overflow-y: auto;
  display: none;
}

.sidebar-group {
  margin-bottom: var(--space-5);
}

.sidebar-group-label {
  font-size: var(--font-size-xs);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-muted);
  padding: 0 var(--space-3);
  margin-bottom: var(--space-2);
  font-weight: 600;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border-radius: var(--radius-sm);
  color: var(--color-text);
  font-size: var(--font-size-sm);
  font-weight: 500;
  min-height: var(--touch-target);
}

.sidebar-link:hover {
  background: var(--color-surface-alt);
}

.sidebar-link.is-active {
  background: var(--color-primary-light);
  color: var(--color-primary-dark);
}

.sidebar-link svg {
  flex-shrink: 0;
  width: 20px;
  height: 20px;
}

/* Main content area */
.app-main {
  flex: 1;
  min-width: 0;
  padding: var(--space-4);
  padding-bottom: calc(var(--bottom-nav-height) + var(--space-6));
}

.page-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.page-title {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.page-subtitle {
  color: var(--color-muted);
  font-size: var(--font-size-sm);
  margin-top: var(--space-1);
}

/* Bottom navigation (Parent / Teacher mobile) */
.bottom-nav {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  height: var(--bottom-nav-height);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
  display: flex;
  z-index: var(--z-nav);
  padding-bottom: env(safe-area-inset-bottom, 0);
}

.bottom-nav-link {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  font-size: var(--font-size-xs);
  color: var(--color-muted);
  min-height: var(--touch-target);
}

.bottom-nav-link svg {
  width: 22px;
  height: 22px;
}

.bottom-nav-link.is-active {
  color: var(--color-primary);
  font-weight: 600;
}

/* Breadcrumbs */
.breadcrumbs {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--space-1);
  font-size: var(--font-size-sm);
  color: var(--color-muted);
  margin-bottom: var(--space-4);
}

.breadcrumbs a:hover {
  color: var(--color-primary-dark);
  text-decoration: underline;
}

.breadcrumbs .sep {
  opacity: 0.6;
}

/* Mobile menu (Admin/Super Admin off-canvas sidebar) */
.mobile-menu-backdrop {
  position: fixed;
  inset: 0;
  background: var(--color-overlay);
  z-index: var(--z-overlay);
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--duration-base) var(--ease-standard);
}

.mobile-menu-backdrop.is-open {
  opacity: 1;
  pointer-events: auto;
}

.sidebar.is-mobile-open {
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  bottom: 0;
  left: 0;
  z-index: var(--z-overlay);
  transform: translateX(0);
  transition: transform var(--duration-base) var(--ease-standard);
  box-shadow: var(--shadow-lg);
}

@media (min-width: 1024px) {
  .sidebar {
    display: flex;
    flex-direction: column;
  }

  .app-main {
    padding: var(--space-6) var(--space-8);
    padding-bottom: var(--space-8);
  }
}
