/* ==========================================================================
   Apex School Management System - Modern 2026 SaaS Design System
   ========================================================================== */

:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --primary-gradient: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%);
  
  --secondary: #64748b;
  --success: #10b981;
  --success-light: #ecfdf5;
  --warning: #f59e0b;
  --warning-light: #fffbeb;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --info: #0ea5e9;
  --info-light: #f0f9ff;

  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --bg-sidebar: #0f172a;
  --bg-topbar: rgba(255, 255, 255, 0.85);

  --border-subtle: #f1f5f9;
  --border-light: #e2e8f0;
  --border-focus: #c7d2fe;

  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --sidebar-w: 260px;
  --topbar-h: 70px;
  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-xl: 20px;

  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.03);
  --shadow-card: 0 4px 6px -1px rgba(0, 0, 0, 0.04), 0 2px 4px -2px rgba(0, 0, 0, 0.02);
  --shadow-lg: 0 20px 25px -5px rgba(0, 0, 0, 0.06), 0 8px 10px -6px rgba(0, 0, 0, 0.02);
  --shadow-primary: 0 8px 20px -4px rgba(99, 102, 241, 0.35);
}

* {
  box-sizing: border-box;
}

html {
  font-size: 16px; /* High-readability standard baseline across devices */
}

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  font-size: 0.88rem; /* Highly readable SaaS body baseline */
  line-height: 1.55;
  letter-spacing: -0.011em;
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Readable Typography Scale - Calibrated for desktop & mobile */
h1, .h1 { font-size: 1.45rem; font-weight: 700; letter-spacing: -0.02em; }
h2, .h2 { font-size: 1.28rem; font-weight: 700; letter-spacing: -0.02em; }
h3, .h3 { font-size: 1.12rem; font-weight: 700; letter-spacing: -0.015em; }
h4, .h4 { font-size: 1.02rem; font-weight: 600; letter-spacing: -0.01em; }
h5, .h5 { font-size: 0.94rem; font-weight: 600; }
h6, .h6 { font-size: 0.88rem; font-weight: 600; }

.fs-1 { font-size: 1.85rem !important; }
.fs-2 { font-size: 1.60rem !important; }
.fs-3 { font-size: 1.35rem !important; }
.fs-4 { font-size: 1.18rem !important; }
.fs-5 { font-size: 1.05rem !important; }
.fs-6 { font-size: 0.95rem !important; }
.fs-7 { font-size: 0.88rem !important; }
.fs-8 { font-size: 0.82rem !important; } /* Upgraded readable 0.82rem */
.fs-9 { font-size: 0.80rem !important; } /* Clear readable badge size */
.fs-10 { font-size: 0.78rem !important; } /* Minimum meta tag size */

/* ==========================================================================
   Modern Sidebar Layout
   ========================================================================== */
.modern-sidebar {
  width: var(--sidebar-w);
  background: var(--bg-sidebar);
  height: 100vh;
  height: 100dvh;
  max-height: 100vh;
  max-height: 100dvh;
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  z-index: 1040;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 4px 0 24px rgba(0, 0, 0, 0.12);
  border-right: 1px solid rgba(255, 255, 255, 0.05);
}

.sidebar-header {
  height: var(--topbar-h);
  min-height: var(--topbar-h);
  flex-shrink: 0;
  padding: 0 1.25rem;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  text-decoration: none;
}

.brand-icon {
  width: 38px;
  height: 38px;
  background: var(--primary-gradient);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 1.15rem;
  box-shadow: var(--shadow-primary);
}

.brand-title {
  color: #ffffff;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: -0.2px;
  line-height: 1.2;
}

.brand-subtitle {
  color: #64748b;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.sidebar-nav {
  padding: 1rem 0.75rem 4rem;
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior-y: contain;
  list-style: none;
  margin: 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.2) transparent;
}

.sidebar-nav::-webkit-scrollbar {
  width: 5px;
}

.sidebar-nav::-webkit-scrollbar-track {
  background: transparent;
}

.sidebar-nav::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.18);
  border-radius: 9999px;
}

.sidebar-nav::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.35);
}

.sidebar-heading {
  color: #475569;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  padding: 0.85rem 0.65rem 0.25rem;
}

.nav-item-link {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.48rem 0.7rem;
  color: #94a3b8;
  text-decoration: none;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  font-weight: 500;
  margin-bottom: 2px;
  transition: all 0.2s ease;
  position: relative;
}

.nav-item-link i {
  width: 20px;
  font-size: 1rem;
  text-align: center;
  transition: transform 0.2s;
  color: #64748b;
}

.nav-item-link:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.05);
}

.nav-item-link:hover i {
  color: #818cf8;
  transform: scale(1.1);
}

.nav-item-link.active {
  color: #ffffff;
  background: var(--primary-gradient);
  font-weight: 600;
  box-shadow: var(--shadow-primary);
}

.nav-item-link.active i {
  color: #ffffff;
}

/* ==========================================================================
   Main Content Wrapper & Modern Topbar
   ========================================================================== */
.main-viewport {
  margin-left: var(--sidebar-w);
  width: calc(100% - var(--sidebar-w));
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: margin-left 0.3s ease, width 0.3s ease;
  position: relative;
}

.modern-topbar {
  height: var(--topbar-h);
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  padding: 0 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky;
  top: 0;
  z-index: 1020;
  box-shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.04);
}

.content-canvas {
  padding: 2rem;
  flex: 1;
  width: 100%;
}

/* ==========================================================================
   Modern Role Switcher Banner
   ========================================================================== */
.role-switcher-banner {
  background: linear-gradient(90deg, #1e1b4b 0%, #312e81 50%, #1e1b4b 100%);
  color: #e0e7ff;
  padding: 0.35rem 1.25rem;
  font-size: 0.80rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  position: relative;
  z-index: 1025;
  width: 100%;
}

.role-pill-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.2rem 0.65rem;
  border-radius: 9999px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #c7d2fe;
  font-size: 0.78rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.role-pill-btn:hover {
  background: #ffffff;
  color: #312e81;
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.role-pill-btn.current {
  background: #ffffff;
  color: #312e81;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* ==========================================================================
   Cards & Modern SaaS Elements
   ========================================================================== */
.modern-card {
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-card);
  transition: box-shadow 0.2s ease, transform 0.2s ease;
  overflow: hidden;
  margin-bottom: 1.25rem;
}

.modern-card:hover {
  box-shadow: 0 10px 25px -3px rgba(0, 0, 0, 0.06), 0 4px 6px -4px rgba(0, 0, 0, 0.02);
}

.modern-card-header {
  padding: 0.85rem 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  background: #ffffff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 0.86rem;
  color: var(--text-main);
}

.modern-card-body {
  padding: 1.15rem;
}

/* Stat Widget Cards with Gradient Backdrops */
.metric-card {
  padding: 1.15rem;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  color: #ffffff;
  position: relative;
  overflow: hidden;
  box-shadow: 0 8px 18px -4px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 12px 24px -4px rgba(0, 0, 0, 0.14);
}

.metric-card.indigo { background: linear-gradient(135deg, #4f46e5 0%, #6366f1 100%); }
.metric-card.emerald { background: linear-gradient(135deg, #059669 0%, #10b981 100%); }
.metric-card.sky { background: linear-gradient(135deg, #0284c7 0%, #38bdf8 100%); }
.metric-card.purple { background: linear-gradient(135deg, #7c3aed 0%, #a855f7 100%); }
.metric-card.rose { background: linear-gradient(135deg, #e11d48 0%, #f43f5e 100%); }

.metric-card .icon-box {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.15rem;
  color: #ffffff;
}

.metric-card .metric-val {
  font-size: 1.65rem;
  font-weight: 800;
  line-height: 1.1;
  letter-spacing: -0.4px;
}

/* ==========================================================================
   Modern Clean Tables
   ========================================================================== */
.table-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
}

.modern-table thead th {
  background: #f8fafc;
  color: #475569;
  font-size: 0.78rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  padding: 0.6rem 0.95rem;
  border-bottom: 1px solid var(--border-light);
  white-space: nowrap;
}

.modern-table tbody td {
  padding: 0.65rem 0.95rem;
  font-size: 0.84rem;
  border-bottom: 1px solid var(--border-subtle);
  color: var(--text-main);
  vertical-align: middle;
}

.modern-table tbody tr {
  transition: background-color 0.15s ease;
}

.modern-table tbody tr:hover {
  background-color: #f8fafc;
}

/* ==========================================================================
   Modern Badges & Pills
   ========================================================================== */
.status-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.22rem 0.6rem;
  border-radius: 9999px;
  font-size: 0.78rem;
  font-weight: 600;
  line-height: 1;
}

.status-pill.success { background: #ecfdf5; color: #047857; border: 1px solid #a7f3d0; }
.status-pill.warning { background: #fffbeb; color: #b45309; border: 1px solid #fde68a; }
.status-pill.danger { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }
.status-pill.primary { background: #eef2ff; color: #4338ca; border: 1px solid #c7d2fe; }
.status-pill.info { background: #f0f9ff; color: #0369a1; border: 1px solid #bae6fd; }

.avatar-circle {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--primary-gradient);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.82rem;
  flex-shrink: 0;
  box-shadow: var(--shadow-sm);
}

.avatar-lg {
  width: 54px;
  height: 54px;
  border-radius: var(--radius-md);
  font-size: 1.3rem;
}

.avatar-xl {
  width: 76px;
  height: 76px;
  border-radius: var(--radius-lg);
  font-size: 1.8rem;
}

/* ==========================================================================
   Modern Buttons & UI Controls
   ========================================================================== */
.btn {
  font-family: inherit;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  line-height: 1.4;
  font-size: 0.84rem;
}

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

.btn-modern-primary, .btn-primary {
  background: var(--primary-gradient);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  padding: 0.42rem 1rem;
  font-weight: 600;
  font-size: 0.84rem;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  transition: all 0.2s ease;
  text-decoration: none;
}

.btn-modern-primary:hover, .btn-primary:hover {
  background: linear-gradient(135deg, #4f46e5 0%, #4338ca 100%);
  color: #ffffff;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.btn-modern-secondary, .btn-outline-primary {
  background: #ffffff;
  color: var(--primary);
  border: 1px solid var(--border-focus);
  padding: 0.42rem 1rem;
  font-size: 0.84rem;
}

.btn-modern-secondary:hover, .btn-outline-primary:hover {
  background: var(--primary-light);
  color: var(--primary-hover);
  border-color: var(--primary);
  transform: translateY(-1px);
}

.btn-light {
  background: #ffffff;
  border: 1px solid var(--border-light);
  color: var(--text-main);
  padding: 0.42rem 0.85rem;
  font-size: 0.84rem;
}

.btn-light:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--text-main);
}

/* ==========================================================================
   Modern Inputs, Selects & Form Controls
   ========================================================================== */
.form-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: #475569;
  margin-bottom: 0.25rem;
  text-transform: capitalize;
}

.form-control, .form-select {
  border: 1px solid var(--border-light);
  border-radius: var(--radius-sm);
  padding: 0.44rem 0.75rem;
  font-size: 0.85rem;
  color: var(--text-main);
  background-color: #ffffff;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.form-control:focus, .form-select:focus {
  border-color: var(--primary);
  outline: 0;
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.15);
}

.input-group-text {
  background-color: #f8fafc;
  border: 1px solid var(--border-light);
  color: #64748b;
  font-size: 0.85rem;
  padding: 0.44rem 0.75rem;
  border-radius: var(--radius-sm);
}

/* Page Header Box */
.page-header-box {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.85rem;
  margin-bottom: 1.35rem;
}

.page-title {
  font-size: 1.35rem;
  font-weight: 800;
  color: var(--text-main);
  letter-spacing: -0.3px;
  margin-bottom: 0.15rem;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 0.84rem;
  margin-bottom: 0;
}

/* Filter Card Toolbar */
.filter-card {
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

/* Empty State Widget */
.empty-state {
  text-align: center;
  padding: 2.75rem 1.25rem;
}

.empty-state-icon {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #f1f5f9;
  color: #94a3b8;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  margin-bottom: 0.85rem;
}

.empty-state-title {
  font-weight: 700;
  color: var(--text-main);
  font-size: 0.98rem;
  margin-bottom: 0.25rem;
}

.empty-state-text {
  color: var(--text-muted);
  font-size: 0.84rem;
  max-width: 420px;
  margin: 0 auto 1.15rem auto;
}

/* Tab modern pill styles */
.nav-pills-modern {
  gap: 0.4rem;
  border-bottom: 1px solid var(--border-light);
  padding-bottom: 0.65rem;
}

.nav-pills-modern .nav-link {
  color: var(--text-muted);
  font-weight: 600;
  font-size: 0.84rem;
  padding: 0.4rem 0.85rem;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
}

.nav-pills-modern .nav-link.active {
  background: var(--primary-gradient);
  color: #ffffff;
  box-shadow: var(--shadow-primary);
}

/* ==========================================================================
   Responsive Drawer Layout
   ========================================================================== */
@media (max-width: 991.98px) {
  body.sidebar-open {
    overflow: hidden;
  }
  .modern-sidebar {
    transform: translateX(-100%);
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    bottom: 0;
  }
  .modern-sidebar.open {
    transform: translateX(0);
  }
  .main-viewport {
    margin-left: 0 !important;
    width: 100% !important;
    max-width: 100% !important;
  }
  .sidebar-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1035;
  }
  .sidebar-backdrop.active {
    display: block;
  }
}

/* ==========================================================================
   Mobile & Responsive Readability Overrides
   ========================================================================== */
@media (max-width: 768px) {
  html {
    font-size: 16px;
  }
  body {
    font-size: 0.88rem;
    line-height: 1.55;
  }
  /* Ensure readable 0.82rem baseline on mobile devices */
  .fs-8, .fs-9, .fs-10 {
    font-size: 0.82rem !important;
  }
  .form-label {
    font-size: 0.84rem !important;
  }
  .form-control, .form-select {
    font-size: 0.90rem !important; /* Prevents auto-zoom on mobile inputs */
    padding: 0.5rem 0.75rem;
  }
  .btn {
    font-size: 0.85rem !important;
    padding: 0.45rem 0.95rem;
  }
  .modern-table thead th {
    font-size: 0.78rem !important;
  }
  .modern-table tbody td {
    font-size: 0.84rem !important;
  }
  .status-pill, .badge {
    font-size: 0.80rem !important;
  }
  .content-canvas {
    padding: 1.25rem 1rem !important;
  }
}

/* ==========================================================================
   Print Optimization for Certificates, Report Cards & Fee Receipts
   ========================================================================== */
@media print {
  .no-print, 
  .modern-sidebar, 
  .modern-topbar, 
  .role-switcher-banner, 
  .sidebar-backdrop, 
  .btn, 
  .filter-card,
  nav {
    display: none !important;
  }
  .main-viewport {
    margin-left: 0 !important;
    padding: 0 !important;
    width: 100% !important;
  }
  .content-canvas {
    padding: 0 !important;
    margin: 0 !important;
  }
  body {
    background-color: #ffffff !important;
    color: #000000 !important;
    print-color-adjust: exact;
    -webkit-print-color-adjust: exact;
  }
  .modern-card {
    box-shadow: none !important;
    border: 1px solid #e2e8f0 !important;
    page-break-inside: avoid;
  }
}
