/* ═══════════════════════════════════════════════════════════════════════════
   SchoolMS — Main CSS
   ═══════════════════════════════════════════════════════════════════════════ */

:root {
  --primary:        #1B4F72;
  --primary-light:  #2471A3;
  --primary-dark:   #0A2342;
  --secondary:      #E74C3C;
  --success:        #27AE60;
  --warning:        #F39C12;
  --info:           #2980B9;
  --sidebar-width:  260px;
  --topbar-height:  60px;
  --sidebar-bg:     #1B4F72;
  --sidebar-text:   rgba(255,255,255,0.85);
  --sidebar-hover:  rgba(255,255,255,0.12);
  --sidebar-active: rgba(255,255,255,0.18);
  --body-bg:        #F0F4F8;
  --card-radius:    12px;
  --transition:     0.25s ease;
}

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

html { scroll-behavior: smooth; }

body {
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  background-color: var(--body-bg);
  color: #2C3E50;
  font-size: 1rem;
  line-height: 1.6;
}

/* Dynamic font size from accessibility settings */
body[data-font-size="14"] { font-size: 14px; }
body[data-font-size="16"] { font-size: 16px; }
body[data-font-size="18"] { font-size: 18px; }
body[data-font-size="20"] { font-size: 20px; }
body[data-font-size="22"] { font-size: 22px; }

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-light); }

/* ── ACCESSIBILITY BAR ────────────────────────────────────────────────────── */
.accessibility-bar {
  background: #2C3E50;
  color: #fff;
  padding: 0.35rem 1rem;
  font-size: 0.8rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.a11y-label { opacity: 0.75; }

.a11y-btn {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.2rem 0.55rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.78rem;
  transition: background var(--transition);
  line-height: 1.4;
}

.a11y-btn:hover,
.a11y-btn[aria-pressed="true"] {
  background: rgba(255,255,255,0.18);
  border-color: rgba(255,255,255,0.6);
}

.a11y-group { display: flex; gap: 0.25rem; }

.a11y-select {
  background: transparent;
  color: #fff;
  border: 1px solid rgba(255,255,255,0.3);
  padding: 0.2rem 0.4rem;
  border-radius: 4px;
  font-size: 0.78rem;
  cursor: pointer;
}
.a11y-select option { background: #2C3E50; color: #fff; }

.a11y-lang-form { display: inline; }

/* ── LOGIN PAGE ───────────────────────────────────────────────────────────── */
body.login-page {
  min-height: 100vh;
  background: var(--body-bg);
}

.login-wrapper {
  display: flex;
  min-height: calc(100vh - 36px); /* minus accessibility bar */
}

.login-left {
  flex: 1;
  background: linear-gradient(145deg, var(--primary-dark) 0%, var(--primary) 50%, var(--primary-light) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  position: relative;
  overflow: hidden;
}

.login-left::before {
  content: '';
  position: absolute;
  inset: 0;
  background: url("data:image/svg+xml,%3Csvg width='60' height='60' viewBox='0 0 60 60' xmlns='http://www.w3.org/2000/svg'%3E%3Cg fill='none' fill-rule='evenodd'%3E%3Cg fill='%23ffffff' fill-opacity='0.05'%3E%3Cpath d='M36 34v-4h-2v4h-4v2h4v4h2v-4h4v-2h-4zm0-30V0h-2v4h-4v2h4v4h2V6h4V4h-4zM6 34v-4H4v4H0v2h4v4h2v-4h4v-2H6zM6 4V0H4v4H0v2h4v4h2V6h4V4H6z'/%3E%3C/g%3E%3C/g%3E%3C/svg%3E");
}

.login-left-content {
  position: relative;
  z-index: 1;
  max-width: 380px;
}

.login-school-name {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin-bottom: 0.5rem;
}

.login-tagline {
  font-size: 1.1rem;
  opacity: 0.85;
  margin-bottom: 0;
}

.login-features { display: flex; flex-direction: column; gap: 1rem; }

.login-feature-item {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.95rem;
  opacity: 0.9;
}

.login-feature-item i { font-size: 1.2rem; opacity: 0.85; }

.login-right {
  width: 100%;
  max-width: 520px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background: #fff;
}

@media (min-width: 992px) {
  .login-right { min-height: calc(100vh - 36px); }
}

.login-form-container { width: 100%; max-width: 420px; }

.login-card { background: #fff; }

.login-card-header { margin-bottom: 2rem; }

.login-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0.25rem;
}

.login-subtitle { color: #6B7280; margin-bottom: 0; }

.login-submit-btn {
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  border: none;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 0.75rem;
}
.login-submit-btn:hover {
  background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

.password-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: none;
  border: none;
  color: #9CA3AF;
  padding: 0.25rem 0.5rem;
}
.password-toggle:hover { color: var(--primary); }

.role-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  justify-content: center;
}

.role-badge {
  background: #EFF6FF;
  color: var(--primary);
  border: 1px solid #BFDBFE;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 500;
}

/* ── DASHBOARD LAYOUT ─────────────────────────────────────────────────────── */
body.dashboard-body {
  overflow-x: hidden;
}

.dashboard-wrapper {
  display: flex;
}

/* ── SIDEBAR ──────────────────────────────────────────────────────────────── */
.sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  color: #fff;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 200;
  display: flex;
  flex-direction: column;
  transition: transform var(--transition), width var(--transition);
  box-shadow: 4px 0 20px rgba(0,0,0,0.15);
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.2) transparent;
}

.sidebar::-webkit-scrollbar { width: 4px; }
.sidebar::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.2); border-radius: 2px; }

.sidebar-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo-icon {
  font-size: 1.75rem;
  color: rgba(255,255,255,0.95);
}

.sidebar-brand-text {
  font-size: 1.25rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.3px;
}

.sidebar-user {
  padding: 1rem 1.25rem;
  background: rgba(0,0,0,0.15);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.sidebar-user-avatar .avatar-initials {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.sidebar-user-name {
  font-weight: 600;
  font-size: 0.9rem;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 0.75rem;
  color: rgba(255,255,255,0.65);
}

.sidebar-nav {
  flex: 1;
  padding: 0.75rem 0;
}

.nav-section-label {
  padding: 0.6rem 1.5rem 0.25rem;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: rgba(255,255,255,0.45);
  margin-top: 0.5rem;
}

.sidebar-nav .nav-item { list-style: none; }

.sidebar-nav .nav-link {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  padding: 0.65rem 1.5rem;
  color: var(--sidebar-text);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all var(--transition);
  border-radius: 0;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-nav .nav-link i {
  font-size: 1rem;
  flex-shrink: 0;
  width: 20px;
  text-align: center;
}

.sidebar-nav .nav-link:hover {
  background: var(--sidebar-hover);
  color: #fff;
  padding-left: 1.85rem;
}

.sidebar-nav .nav-link.active {
  background: var(--sidebar-active);
  color: #fff;
  border-left: 3px solid rgba(255,255,255,0.8);
}

.sidebar-footer {
  padding: 1rem 1.25rem;
  border-top: 1px solid rgba(255,255,255,0.1);
  flex-shrink: 0;
}

.sidebar-logout-btn {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  color: rgba(255,255,255,0.7);
  font-size: 0.9rem;
  padding: 0.5rem 0.25rem;
  transition: color var(--transition);
  text-decoration: none;
  width: 100%;
}

.sidebar-logout-btn:hover { color: #fff; }

/* ── MAIN CONTENT ────────────────────────────────────────────────────────── */
.main-content {
  margin-left: var(--sidebar-width);
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  transition: margin-left var(--transition);
}

.topbar {
  height: var(--topbar-height);
  background: #fff;
  border-bottom: 1px solid #E5E7EB;
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}

.topbar-toggle {
  background: none;
  border: none;
  color: #6B7280;
  padding: 0.5rem;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.topbar-toggle:hover { background: #F3F4F6; color: var(--primary); }

.topbar .breadcrumb { font-size: 0.875rem; }
.topbar .breadcrumb-item a { color: var(--primary); }
.topbar .breadcrumb-item.active { color: #6B7280; }

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-left: auto;
}

.topbar-icon-btn {
  width: 38px;
  height: 38px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #6B7280;
  font-size: 1.1rem;
  transition: all var(--transition);
  text-decoration: none;
}
.topbar-icon-btn:hover { background: #F3F4F6; color: var(--primary); }

.notification-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  font-size: 0.65rem;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
}

.content-body {
  padding: 1.75rem 2rem;
  flex: 1;
}

.content-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: 1rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--primary-dark);
  margin-bottom: 0;
}

/* ── CARDS & STATS ────────────────────────────────────────────────────────── */
.card {
  border-radius: var(--card-radius);
}

.stat-card {
  border-radius: var(--card-radius);
  padding: 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.06);
  border: 1px solid rgba(0,0,0,0.04);
  transition: transform var(--transition), box-shadow var(--transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(0,0,0,0.1);
}

.stat-label {
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #9CA3AF;
  font-weight: 600;
  margin-bottom: 0.5rem;
}

.stat-number {
  font-size: 2rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-bottom: 0;
  line-height: 1;
}

.stat-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  flex-shrink: 0;
}

/* ── QUICK ACTION CARDS ───────────────────────────────────────────────────── */
.quick-action-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  padding: 1.25rem 0.75rem;
  background: #F9FAFB;
  border: 1px solid #E5E7EB;
  border-radius: 10px;
  color: var(--primary);
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  transition: all var(--transition);
}

.quick-action-card i { font-size: 1.5rem; }
.quick-action-card:hover {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(27,79,114,0.25);
}

/* ── AVATARS ──────────────────────────────────────────────────────────────── */
.avatar-sm,
.avatar-initials-sm {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}

.avatar-initials-sm {
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.8rem;
}

.profile-avatar {
  width: 120px;
  height: 120px;
  object-fit: cover;
}

.profile-avatar-initials,
.profile-avatar-wrap .profile-avatar-initials {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary) 0%, var(--primary-light) 100%);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 2.5rem;
  font-weight: 700;
  margin: 0 auto;
}

/* ── ROLE BADGES ──────────────────────────────────────────────────────────── */
.role-badge-superadmin  { background: #7C3AED; color: #fff; }
.role-badge-headteacher { background: #1B4F72; color: #fff; }
.role-badge-dos         { background: #0E7490; color: #fff; }
.role-badge-accountant  { background: #065F46; color: #fff; }
.role-badge-teacher     { background: #1D4ED8; color: #fff; }
.role-badge-student     { background: #92400E; color: #fff; }
.role-badge-parent      { background: #B45309; color: #fff; }
.role-badge-librarian   { background: #831843; color: #fff; }
.role-badge-itadmin     { background: #374151; color: #fff; }

[class^="role-badge-"] {
  display: inline-block;
  padding: 0.2rem 0.6rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* ── NOTIFICATIONS ────────────────────────────────────────────────────────── */
.notification-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
}
.notification-icon-info    { background: #EFF6FF; color: #2563EB; }
.notification-icon-success { background: #F0FDF4; color: #16A34A; }
.notification-icon-warning { background: #FFFBEB; color: #D97706; }
.notification-icon-danger  { background: #FEF2F2; color: #DC2626; }

/* ── TABLES ───────────────────────────────────────────────────────────────── */
.table { font-size: 0.9rem; }
.table thead th {
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  white-space: nowrap;
}
.table-hover tbody tr { transition: background var(--transition); }

/* ── MOBILE RESPONSIVE ────────────────────────────────────────────────────── */
@media (max-width: 991.98px) {
  .sidebar {
    transform: translateX(-100%);
  }
  .sidebar.sidebar-open {
    transform: translateX(0);
  }
  .main-content {
    margin-left: 0 !important;
  }
  .content-body {
    padding: 1rem;
  }
  .sidebar-backdrop {
    display: block !important;
  }
}

.sidebar-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 199;
  backdrop-filter: blur(2px);
}

@media (min-width: 992px) {
  .sidebar.sidebar-collapsed {
    width: 70px;
  }
  .sidebar.sidebar-collapsed .sidebar-brand-text,
  .sidebar.sidebar-collapsed .sidebar-user-info,
  .sidebar.sidebar-collapsed .nav-section-label,
  .sidebar.sidebar-collapsed .nav-link span,
  .sidebar.sidebar-collapsed .sidebar-footer span {
    display: none;
  }
  .sidebar.sidebar-collapsed + .main-content {
    margin-left: 70px;
  }
}

/* ── PRINT ────────────────────────────────────────────────────────────────── */
@media print {
  .sidebar, .topbar, .accessibility-bar { display: none !important; }
  .main-content { margin-left: 0 !important; }
}

/* ── TIMETABLE SLOTS ──────────────────────────────────────────────────────── */
.timetable-slot {
  background: #EFF6FF;
  border: 1px solid #BFDBFE;
  border-radius: 8px;
  padding: 0.5rem 0.75rem;
  min-width: 120px;
  text-align: center;
}

/* ── INFO ITEMS ───────────────────────────────────────────────────────────── */
.info-item {
  padding: 0.5rem 0;
  border-bottom: 1px solid #F3F4F6;
}
.info-item label {
  display: block;
  font-size: 0.75rem;
  margin-bottom: 0.1rem;
}

/* ── MOBILE RESPONSIVENESS FIXES ─────────────────────────────────────────── */
@media (max-width: 767.98px) {
  /* Accessibility bar wraps properly */
  .accessibility-bar {
    flex-wrap: wrap;
    height: auto !important;
    padding: 6px 12px;
    gap: 4px;
  }

  /* Topbar on mobile */
  .topbar {
    padding: 0 0.75rem;
  }
  .topbar .breadcrumb {
    display: none;
  }

  /* Content padding smaller on mobile */
  .content-body {
    padding: 1rem 0.75rem;
  }

  /* Content header wraps on mobile */
  .content-header {
    flex-direction: column;
    align-items: flex-start !important;
    gap: 0.75rem;
  }
  .content-header .btn,
  .content-header a.btn {
    width: 100%;
    text-align: center;
  }

  /* Cards full width */
  .card { margin-bottom: 1rem; }

  /* Tables scroll horizontally */
  .table-responsive { overflow-x: auto; }

  /* Forms full width */
  .form-select, .form-control { font-size: 16px !important; }

  /* Stats cards stack */
  .row.g-4 > [class*="col-"] { margin-bottom: 0.5rem; }

  /* Page title smaller */
  h2, .page-title { font-size: 1.3rem !important; }

  /* Hide long text in topbar actions */
  .topbar-actions .d-none-mobile { display: none !important; }
}

@media (max-width: 575.98px) {
  .content-body { padding: 0.75rem 0.5rem; }
  .card-body { padding: 1rem; }
  .btn-lg { font-size: 1rem; padding: 0.6rem 1.2rem; }
}
/* ===== EXISTING CSS ABOVE ===== */

/* ===== MOBILE FIX ===== */
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden;
  }

  .dashboard-wrapper {
    display: block;
  }

  .sidebar {
    left: 0;
    transform: translateX(-100%);
    width: 260px;
    max-width: 85vw;
    height: 100vh;
    z-index: 1050;
  }

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

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px !important;
  }

  .container,
  .container-fluid,
  .row {
    max-width: 100%;
  }

  .table-responsive {
    overflow-x: auto;
  }

  img,
  table,
  canvas,
  svg {
    max-width: 100%;
    height: auto;
  }

  .sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.35);
    z-index: 1040;
  }

  .sidebar-backdrop.show {
    display: block;
  }
}
@media (max-width: 768px) {
  html, body {
    overflow-x: hidden !important;
  }

  .dashboard-wrapper {
    display: block !important;
  }

  .sidebar {
    left: 0 !important;
    transform: translateX(-100%) !important;
    width: 260px !important;
    max-width: 85vw !important;
    height: 100vh !important;
    z-index: 1050 !important;
  }

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

  .main-content {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
    padding: 12px !important;
  }

  .topbar,
  .content-body,
  .container,
  .container-fluid,
  .row {
    max-width: 100% !important;
  }

  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
  }

  [class*="col-"] {
    padding-left: 6px !important;
    padding-right: 6px !important;
  }

  .card,
  .stats-card,
  .dashboard-card {
    width: 100% !important;
    max-width: 100% !important;
  }

  .table-responsive {
    overflow-x: auto !important;
  }

  img,
  table,
  canvas,
  svg {
    max-width: 100% !important;
    height: auto !important;
  }
}
