/* public/assets/css/style.css */
/* Core Layout and Stylesheet for EduSBA Cloud */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=Outfit:wght@600;700;800&display=swap');

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-sans);
  background: var(--bg-main);
  color: var(--text-body);
  line-height: 1.55;
  font-size: var(--text-base);
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

a {
  color: var(--text-link);
  text-decoration: none;
  transition: color var(--transition-fast);
}
a:hover {
  color: var(--accent-hover);
}

/* -------------------------------------------------------------
   Typography & Headers
   ------------------------------------------------------------- */
h1, h2, h3, h4, h5, h6 {
  font-family: var(--font-display);
  font-weight: 700;
  color: var(--text-heading);
  line-height: 1.25;
  letter-spacing: -0.02em;
}

h1 { font-size: clamp(1.5rem, 4vw, 1.875rem); margin-bottom: var(--space-2); }
h2 { font-size: var(--text-2xl); margin-bottom: var(--space-2); }
h3 { font-size: var(--text-xl); margin-bottom: var(--space-1); }

/* -------------------------------------------------------------
   Layout Structure (Mobile-First)
   ------------------------------------------------------------- */
.app-container {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.main-content {
  flex: 1;
  width: 100%;
  max-width: var(--content-max);
  margin: 0 auto;
  padding: var(--space-4);
  padding-bottom: calc(var(--bottom-nav-height) + var(--safe-bottom) + var(--space-4));
}

.app-main-shell {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  width: 100%;
  background: linear-gradient(180deg, var(--bg-subtle) 0%, var(--bg-main) 180px);
}

/* Sidebar school branding */
.sidebar-school-logo {
  width: 32px;
  height: 32px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.12);
  flex-shrink: 0;
}

.sidebar-school-name {
  font-size: 0.95rem;
  font-weight: 700;
  line-height: 1.25;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.sidebar .brand {
  align-items: center;
  flex-shrink: 0;
}

/* School branded top bar (desktop main column) */
.school-brand-bar {
  display: none;
}

.school-brand-bar-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  width: 100%;
  max-width: 100%;
}

.school-brand-bar-identity {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  min-width: 0;
  flex: 1;
}

.school-brand-bar-logo {
  width: 44px;
  height: 44px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.15);
  padding: 2px;
  flex-shrink: 0;
}

.school-brand-bar-logo-fallback {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.school-brand-bar-logo-fallback svg {
  width: 22px;
  height: 22px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
}

.school-brand-bar-text {
  min-width: 0;
}

.school-brand-bar-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: #ffffff;
  margin: 0;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.school-brand-bar-tagline {
  display: block;
  font-size: 0.68rem;
  font-weight: 500;
  color: rgba(255, 255, 255, 0.72);
  letter-spacing: 0.02em;
  margin-top: 0.1rem;
}

.school-brand-bar-edit {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-full);
  font-size: 0.78rem;
  font-weight: 600;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.14);
  border: 1px solid rgba(255, 255, 255, 0.28);
  text-decoration: none;
  transition: background var(--transition-fast), border-color var(--transition-fast);
}

.school-brand-bar-edit:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.22);
  border-color: rgba(255, 255, 255, 0.45);
}

.school-brand-bar-edit svg {
  width: 15px;
  height: 15px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
}

/* Sidebar - mobile off-canvas drawer */
.sidebar {
  display: flex;
  flex-direction: column;
  width: min(var(--sidebar-width), 88vw);
  background: var(--sidebar-bg);
  color: #ffffff;
  height: 100vh;
  height: 100dvh;
  position: fixed;
  top: 0;
  left: 0;
  z-index: var(--z-drawer);
  padding: var(--space-5);
  padding-top: calc(var(--space-5) + var(--safe-top));
  box-shadow: var(--shadow-lg);
  overflow-x: hidden;
  transform: translateX(-105%);
  transition: transform var(--transition-spring);
}

.sidebar.open {
  transform: translateX(0);
}

.sidebar .brand {
  font-weight: 700;
  font-size: 1.4rem;
  color: #ffffff;
  margin-bottom: 2rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-dismiss {
  margin-left: auto;
  background: none;
  border: none;
  color: #cbd5e1;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.sidebar-menu {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding-right: 0.15rem;
  margin-right: -0.15rem;
}

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.9rem;
  min-height: 44px;
  color: var(--sidebar-text);
  border-radius: var(--radius-md);
  font-weight: 500;
  font-size: var(--text-sm);
  text-decoration: none;
  transition: background var(--transition-fast), color var(--transition-fast);
}

.sidebar-link svg {
  width: 18px;
  height: 18px;
  fill: currentColor;
  flex-shrink: 0;
  opacity: 0.85;
}

.sidebar-link:hover {
  color: #ffffff;
  background: var(--sidebar-hover-bg);
}

.sidebar-link.active {
  color: var(--sidebar-active-text);
  background: var(--sidebar-active-bg);
  box-shadow: 0 2px 8px color-mix(in srgb, var(--sidebar-active-bg) 35%, transparent);
}

.sidebar-link.active svg {
  opacity: 1;
}

/* Collapsible grouped submenus */
.nav-group {
  display: flex;
  flex-direction: column;
}

.nav-group-toggle {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0.7rem 1rem;
  background: none;
  border: none;
  color: var(--sidebar-text-muted);
  font-weight: 600;
  font-size: 0.78rem;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  cursor: pointer;
  border-radius: var(--radius-md);
  transition: all var(--transition-fast);
  font-family: inherit;
}

.nav-group-toggle:hover {
  color: #ffffff;
  background-color: var(--sidebar-hover-bg);
}

.nav-group.open > .nav-group-toggle {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.1);
  box-shadow: inset 0 0 0 1px rgba(255, 255, 255, 0.12);
}

.nav-group-label {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.nav-group-label svg {
  width: 16px;
  height: 16px;
  fill: currentColor;
}

.nav-chevron svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
  transition: transform var(--transition-fast);
}

.nav-group.open .nav-chevron svg {
  transform: rotate(180deg);
}

.nav-submenu {
  list-style: none;
  display: none;
  flex-direction: column;
  gap: 0.25rem;
  margin: 0;
  padding: 0;
}

.nav-group.open .nav-submenu {
  display: flex;
  margin: 0.35rem 0 0.55rem;
  padding: 0.5rem 0.55rem 0.55rem 0.65rem;
  background: rgba(0, 0, 0, 0.24);
  border-radius: var(--radius-md);
  border-left: 3px solid rgba(255, 255, 255, 0.28);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.07),
    inset 0 2px 10px rgba(0, 0, 0, 0.12);
}

.nav-submenu .sidebar-link {
  padding: 0.55rem 0.75rem;
  font-size: 0.875rem;
  color: rgba(255, 255, 255, 0.92);
}

.nav-submenu .sidebar-link:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.sidebar-footer {
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  padding-top: var(--space-4);
  margin-top: auto;
}

.sidebar-profile-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.65rem 0.5rem;
  border-radius: var(--radius-md);
  text-decoration: none;
  color: inherit;
  transition: background var(--transition-fast);
}

.sidebar-profile-link:hover {
  background: var(--sidebar-hover-bg);
  color: #fff;
}

.sidebar-profile-link__avatar,
.sidebar-profile-link__photo {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  flex-shrink: 0;
}

.sidebar-profile-link__avatar {
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(255, 255, 255, 0.15);
  font-weight: 700;
  font-size: 0.95rem;
}

.sidebar-profile-link__photo {
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.sidebar-profile-link__meta {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
}

.sidebar-school-foot {
  margin-top: auto;
  padding: 0.85rem 0.5rem 0.35rem;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.55rem;
  text-align: center;
  flex-shrink: 0;
  width: 100%;
}

.sidebar-school-foot__logo-wrap {
  width: 100%;
  max-width: 9.5rem;
  padding: 0.5rem 0.65rem;
  border-radius: var(--radius-md);
  background: #ffffff;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 3.5rem;
}

.sidebar-school-foot__logo {
  display: block;
  width: auto;
  height: auto;
  max-width: 100%;
  max-height: 3.25rem;
  object-fit: contain;
  object-position: center;
}

.sidebar-school-foot__logo-fallback {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-md);
  background: rgba(255, 255, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
}

.sidebar-school-foot__logo-fallback svg {
  width: 28px;
  height: 28px;
  fill: none;
  stroke: #fff;
  stroke-width: 2;
}

.sidebar-school-foot__name {
  font-size: 0.72rem;
  font-weight: 600;
  color: rgba(255, 255, 255, 0.82);
  line-height: 1.35;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.sidebar-footer .user-info {
  font-size: var(--text-sm);
  margin-bottom: var(--space-3);
}

.sidebar-user-name {
  font-weight: 600;
  color: #fff;
}

.sidebar-user-role {
  font-size: var(--text-xs);
  color: var(--sidebar-text-muted);
  text-transform: capitalize;
  margin-top: 0.1rem;
}

.sidebar-footer .btn {
  width: 100%;
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.15);
  color: #fff;
}

.sidebar-footer .btn:hover {
  background: rgba(255, 255, 255, 0.16);
  color: #fff;
}

/* Dimmed backdrop shown behind the mobile drawer */
.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  z-index: var(--z-backdrop);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.sidebar-backdrop.show {
  display: block;
  opacity: 1;
}

/* Hamburger toggle in the mobile top bar */
.nav-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0.25rem;
  color: var(--primary-color);
  display: inline-flex;
}
.nav-toggle svg {
  width: 24px;
  height: 24px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
}

/* Bottom Nav (mobile) */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  min-height: var(--bottom-nav-height);
  padding-bottom: var(--safe-bottom);
  background: var(--nav-blur);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  z-index: var(--z-nav);
  box-shadow: var(--shadow-nav);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  min-height: 44px;
  padding: var(--space-2) var(--space-1);
  color: var(--secondary-color);
  font-size: 0.68rem;
  font-weight: 600;
  text-decoration: none;
  transition: color var(--transition-fast);
  background: none;
  border: none;
  font-family: inherit;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
  position: relative;
}

.bottom-nav-item svg {
  width: 22px;
  height: 22px;
  margin-bottom: 3px;
  fill: currentColor;
}

.bottom-nav-item.active {
  color: var(--accent-color);
}

.bottom-nav-item.active::before {
  content: '';
  position: absolute;
  top: 0;
  left: 50%;
  transform: translateX(-50%);
  width: 28px;
  height: 3px;
  background: var(--accent-color);
  border-radius: 0 0 3px 3px;
}

/* Top Navbar (mobile) */
.top-navbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  padding-top: calc(var(--space-3) + var(--safe-top));
  background: var(--nav-blur);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.top-navbar,
.school-brand-bar--portal,
.school-brand-bar--admin {
  background: var(--portal-chrome-bg) !important;
  border-bottom: 1px solid var(--portal-chrome-border) !important;
  box-shadow: 0 2px 14px rgba(15, 23, 42, 0.18);
}

.top-navbar--branded {
  backdrop-filter: none;
  -webkit-backdrop-filter: none;
}

.school-brand-bar--portal,
.school-brand-bar--admin {
  border-bottom-color: var(--portal-chrome-border) !important;
}

.portal-topbar-brand--school-only .portal-topbar-brand__school {
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--portal-chrome-title);
}

.top-navbar .brand {
  font-weight: 700;
  font-size: 1.2rem;
  color: var(--primary-color);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.top-navbar .user-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.top-navbar .avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-full);
  background-color: var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--secondary-color);
}

.top-navbar--branded .brand {
  flex: 1;
  min-width: 0;
  justify-content: flex-start;
}

.top-navbar--branded .portal-topbar-brand {
  width: 100%;
}

.top-navbar-school-logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

.top-navbar-school-name {
  font-size: 0.95rem;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}

.top-navbar-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex-shrink: 0;
}

.top-navbar-edit {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  color: var(--secondary-color);
  border: 1px solid var(--border-color);
  background: var(--bg-main);
}

.top-navbar-edit svg {
  width: 16px;
  height: 16px;
  fill: none;
  stroke: currentColor;
  stroke-width: 2.5;
}

.top-navbar-edit:hover {
  color: var(--accent-color);
  border-color: var(--accent-color);
}

/* -------------------------------------------------------------
   Desktop Styling (min-width: 768px)
   ------------------------------------------------------------- */
@media (min-width: 768px) {
  .app-container {
    flex-direction: row;
    align-items: stretch;
  }

  .app-main-shell {
    flex: 1;
    min-height: 100vh;
  }

  .school-brand-bar {
    display: block;
    position: sticky;
    top: 0;
    z-index: 85;
    padding: 0.85rem 1.5rem;
    background: var(--topbar-bg);
    border-bottom: 3px solid var(--topbar-border);
    box-shadow: var(--shadow-md);
  }

  .top-navbar {
    display: none; /* Sidebar + school brand bar on desktop */
  }

  .bottom-nav {
    display: none; /* Sidebar replaces bottom bar */
  }

  /* On desktop the sidebar is a permanent, sticky column (not a drawer) */
  .sidebar {
    position: sticky;
    top: 0;
    align-self: flex-start;
    width: var(--sidebar-width);
    max-width: var(--sidebar-width);
    height: 100vh;
    height: 100dvh;
    transform: none;
    transition: none;
    z-index: var(--z-base);
  }

  /* Mobile-only drawer controls are hidden on desktop */
  .sidebar-dismiss,
  .nav-toggle,
  .sidebar-backdrop,
  .sidebar-backdrop.show {
    display: none;
  }

  .main-content {
    padding: var(--space-8) var(--space-10);
    padding-bottom: var(--space-10);
  }
}

/* Teacher score entry: hide branded chrome on phones */
@media (max-width: 767px) {
  .app-container:has(.score-entry--teacher) .top-navbar,
  .app-container:has(.score-entry--teacher) .school-brand-bar {
    display: none !important;
  }
}

/* -------------------------------------------------------------
   UI Component Classes (Cards, Buttons, Modals)
   ------------------------------------------------------------- */
.card {
  background-color: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: var(--space-5);
  margin-bottom: var(--space-5);
  box-shadow: var(--shadow-sm);
  transition: box-shadow var(--transition-fast);
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-title {
  margin-bottom: var(--space-4);
  font-family: var(--font-display);
  font-size: var(--text-lg);
  font-weight: 700;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: var(--space-3);
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.625rem 1.125rem;
  min-height: 44px;
  font-size: var(--text-sm);
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: background var(--transition-fast), color var(--transition-fast), box-shadow var(--transition-fast), transform var(--transition-fast);
  gap: 0.5rem;
  text-decoration: none;
  -webkit-tap-highlight-color: transparent;
  white-space: nowrap;
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background: linear-gradient(180deg, var(--accent-color) 0%, var(--accent-hover) 100%);
  color: #ffffff;
  box-shadow: 0 2px 6px rgba(37, 99, 235, 0.25);
}

.btn-primary:hover {
  color: #ffffff;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}

.btn-secondary {
  background-color: var(--bg-subtle);
  color: var(--secondary-color);
  border-color: var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--border-color);
  color: var(--primary-color);
}

.btn-ghost {
  background: transparent;
  color: var(--secondary-color);
  border-color: transparent;
}

.btn-ghost:hover {
  background: var(--bg-subtle);
  color: var(--primary-color);
}

.btn-success {
  background: var(--success-color);
  color: #fff;
}

.btn-success:hover {
  opacity: 0.92;
  color: #fff;
}

.btn-danger {
  background-color: var(--danger-color);
  color: #ffffff;
}
.btn-danger:hover {
  opacity: 0.9;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.8rem;
  border-radius: var(--radius-sm);
}

/* Forms & Inputs */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.35rem;
  color: var(--secondary-color);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--secondary-color);
  margin-top: 0.25rem;
  line-height: 1.45;
}

.form-control {
  width: 100%;
  padding: 0.7rem 0.9rem;
  min-height: 44px;
  font-size: var(--text-base);
  border-radius: var(--radius-md);
  border: 1.5px solid var(--input-border);
  background-color: var(--input-bg);
  color: var(--primary-color);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 3px var(--focus-ring);
}

.form-select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=utf-8,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23475569' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px;
  padding-right: 2.5rem;
}

/* Grids */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .grid-2 { grid-template-columns: repeat(2, 1fr); }
  .grid-3 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 1024px) {
  .grid-3 { grid-template-columns: repeat(3, 1fr); }
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.6rem;
  font-size: 0.75rem;
  font-weight: 600;
  border-radius: var(--radius-full);
}

.badge-success { background-color: var(--success-bg); color: var(--success-text); }
.badge-warning { background-color: var(--warning-bg); color: var(--warning-text); }
.badge-danger { background-color: var(--danger-bg); color: var(--danger-text); }
.badge-secondary { background-color: var(--bg-subtle); color: var(--secondary-color); border: 1px solid var(--border-color); }

/* Alerts */
.alert {
  padding: var(--space-4);
  border-radius: var(--radius-md);
  margin-bottom: var(--space-4);
  font-size: var(--text-sm);
  font-weight: 500;
  display: flex;
  align-items: flex-start;
  gap: var(--space-3);
  line-height: 1.45;
}

.alert-success { background-color: var(--success-bg); color: var(--success-text); border: 1px solid var(--success-border); }
.alert-danger { background-color: var(--danger-bg); color: var(--danger-text); border: 1px solid var(--danger-border); }
.alert-info { background-color: var(--info-bg); color: var(--info-text); border: 1px solid var(--info-border); }
.alert-warning { background-color: var(--warning-bg); color: var(--warning-text); border: 1px solid var(--warning-border); }

/* Empty States */
.empty-state {
  text-align: center;
  padding: var(--space-10) var(--space-6);
  border: 2px dashed var(--border-color);
  border-radius: var(--radius-lg);
  color: var(--secondary-color);
  background: var(--bg-subtle);
}

.empty-state-icon {
  margin-bottom: var(--space-4);
  color: var(--muted-color);
}

.empty-state h3 {
  margin-bottom: var(--space-2);
}

/* Multi-select checkbox list (e.g. subject -> departments) */
.checkbox-list {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  max-height: 180px;
  overflow-y: auto;
  border: 1px solid var(--input-border);
  border-radius: var(--radius-sm);
  padding: 0.5rem 0.65rem;
  background: var(--input-bg);
}
.checkbox-item {
  display: flex;
  align-items: center;
  gap: 0.55rem;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  padding: 0.2rem 0;
}
.checkbox-item input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

/* Avatars (student/teacher profile pictures with initials fallback) */
.avatar-img {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 1px solid var(--border-color);
  background: #fff;
  flex-shrink: 0;
}
.initials-avatar {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 700;
  color: #fff;
  background: var(--accent-color);
  flex-shrink: 0;
  text-transform: uppercase;
}
.avatar-preview {
  width: 72px;
  height: 72px;
  border-radius: var(--radius-md);
  object-fit: cover;
  border: 1px solid var(--border-color);
  background: #fff;
}

/* Row action button groups (edit/delete in tables) */
.row-actions {
  display: inline-flex;
  gap: 0.4rem;
  flex-wrap: wrap;
  justify-content: flex-end;
}

/* Shared Modal Overlay + Card */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.18);
  backdrop-filter: blur(6px);
  -webkit-backdrop-filter: blur(6px);
  align-items: flex-start;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-4);
  padding-top: calc(var(--space-4) + var(--safe-top));
  padding-bottom: calc(var(--space-4) + var(--safe-bottom));
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.modal-overlay.is-open,
.modal-overlay[style*="flex"] {
  display: flex !important;
}

.modal-card {
  width: 100%;
  max-width: 540px;
  margin: auto;
  position: relative;
  flex-shrink: 0;
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: 0 20px 40px rgba(15, 23, 42, 0.14);
  animation: modal-in 0.22s ease;
  isolation: isolate;
}

/* Legacy single-panel modals (scroll entire card) */
.modal-card:not(.crud-modal) {
  max-height: none;
  overflow-y: visible;
  padding: var(--space-5);
}

@keyframes modal-in {
  from { opacity: 0; transform: scale(0.96) translateY(8px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

/* Excel score import wizard (rendered on body) */
.se-import-overlay {
  z-index: 1200;
}
.modal-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
  color: var(--secondary-color);
}

/* Responsive Table */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  background: var(--bg-card);
  box-shadow: var(--shadow-xs);
}

.table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: var(--text-sm);
}

.table th, .table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.table th {
  background-color: var(--bg-subtle);
  font-weight: 600;
  font-size: var(--text-xs);
  color: var(--secondary-color);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.table tbody tr {
  transition: background var(--transition-fast);
}

.table tbody tr:hover {
  background: var(--bg-subtle);
}

.table tr:last-child td {
  border-bottom: none;
}

.table code {
  font-size: var(--text-xs);
  background: var(--bg-subtle);
  padding: 0.15rem 0.4rem;
  border-radius: var(--radius-sm);
}

.app-footer-branding {
  width: 100%;
  flex-shrink: 0;
  border-top: 1px solid var(--portal-chrome-border);
  background: var(--portal-chrome-bg);
  padding: 0.5rem 1rem;
}

.app-footer-branding__inner {
  display: flex;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: center;
  gap: 0.45rem;
  max-width: var(--content-max);
  margin: 0 auto;
  white-space: nowrap;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  font-size: 0.78rem;
  line-height: 1.35;
}

.app-footer-branding__inner::-webkit-scrollbar {
  display: none;
}

.app-footer-branding__title {
  font-family: var(--font-display);
  font-weight: 800;
  color: var(--portal-chrome-title);
  font-size: inherit;
  letter-spacing: -0.01em;
  flex-shrink: 0;
}

.app-footer-branding__meta {
  color: var(--portal-chrome-text);
  font-size: inherit;
  font-weight: 500;
  flex-shrink: 0;
}

.app-footer-branding__sep {
  color: var(--portal-chrome-sep);
  font-weight: 700;
  flex-shrink: 0;
  user-select: none;
}
