/* ============================================================
   EduFern Portal — site-wide dark theme
   Scoped to html[data-theme="dark"] so light mode is untouched.
   Works on both the Bootstrap 5.1 layouts and the 5.3 ones.
   Tune the palette below in one place.
   ============================================================ */
html[data-theme="dark"]{
  color-scheme:dark;
  --efd-bg:#0c111c;
  --efd-surface:#141b28;
  --efd-surface-2:#1a2233;
  --efd-surface-3:#212b3f;
  --efd-border:#2a3446;
  --efd-text:#e8edf6;
  --efd-muted:#9aa8bf;
  --efd-accent:#25c8e0;
}

/* base */
html[data-theme="dark"] body{background:var(--efd-bg) !important;color:var(--efd-text) !important;}
html[data-theme="dark"] a{color:var(--efd-accent);}
html[data-theme="dark"] .bg-body,html[data-theme="dark"] .bg-body-tertiary{background:var(--efd-bg) !important;}

/* generic surfaces */
html[data-theme="dark"] .bg-white,
html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .card,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .list-group-item,
html[data-theme="dark"] .offcanvas,
html[data-theme="dark"] .accordion-item,
html[data-theme="dark"] .toast,
html[data-theme="dark"] .popover{
  background-color:var(--efd-surface) !important;
  color:var(--efd-text) !important;
  border-color:var(--efd-border) !important;
}
html[data-theme="dark"] .card-header,
html[data-theme="dark"] .card-footer,
html[data-theme="dark"] .modal-header,
html[data-theme="dark"] .modal-footer,
html[data-theme="dark"] .list-group-item.active,
html[data-theme="dark"] .accordion-button{
  background-color:var(--efd-surface-2) !important;
  color:var(--efd-text) !important;
  border-color:var(--efd-border) !important;
}
html[data-theme="dark"] .accordion-button:not(.collapsed){box-shadow:none !important;}

/* text */
html[data-theme="dark"] h1,html[data-theme="dark"] h2,html[data-theme="dark"] h3,
html[data-theme="dark"] h4,html[data-theme="dark"] h5,html[data-theme="dark"] h6,
html[data-theme="dark"] .text-dark,html[data-theme="dark"] .text-body,html[data-theme="dark"] .text-black{color:var(--efd-text) !important;}
html[data-theme="dark"] .text-muted,html[data-theme="dark"] .text-secondary{color:var(--efd-muted) !important;}

/* borders + rules */
html[data-theme="dark"] .border,html[data-theme="dark"] .border-top,html[data-theme="dark"] .border-bottom,
html[data-theme="dark"] .border-start,html[data-theme="dark"] .border-end,html[data-theme="dark"] hr{border-color:var(--efd-border) !important;}

/* tables */
html[data-theme="dark"] .table{color:var(--efd-text) !important;border-color:var(--efd-border) !important;--bs-table-bg:transparent;}
html[data-theme="dark"] .table thead th{background-color:var(--efd-surface-2) !important;color:var(--efd-text) !important;border-color:var(--efd-border) !important;}
html[data-theme="dark"] .table td,html[data-theme="dark"] .table th{border-color:var(--efd-border) !important;}
html[data-theme="dark"] .table-striped>tbody>tr:nth-of-type(odd)>*{background-color:rgba(255,255,255,.03) !important;color:var(--efd-text) !important;}
html[data-theme="dark"] .table-hover>tbody>tr:hover>*{background-color:rgba(255,255,255,.06) !important;}

/* forms */
html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .input-group-text{
  background-color:var(--efd-surface-2) !important;color:var(--efd-text) !important;border-color:var(--efd-border) !important;}
html[data-theme="dark"] .form-control::placeholder{color:var(--efd-muted) !important;opacity:.85;}
html[data-theme="dark"] .form-control:focus,html[data-theme="dark"] .form-select:focus{
  border-color:var(--efd-accent) !important;box-shadow:0 0 0 .2rem rgba(37,200,224,.20) !important;}
html[data-theme="dark"] .form-check-input{background-color:var(--efd-surface-2);border-color:var(--efd-border);}
html[data-theme="dark"] .form-check-input:checked{background-color:var(--efd-accent);border-color:var(--efd-accent);}

/* nav / tabs / breadcrumb / pagination / dropdown */
html[data-theme="dark"] .nav-tabs{border-color:var(--efd-border) !important;}
html[data-theme="dark"] .nav-tabs .nav-link{color:var(--efd-muted) !important;}
html[data-theme="dark"] .nav-tabs .nav-link.active{background:var(--efd-surface) !important;color:var(--efd-text) !important;
  border-color:var(--efd-border) var(--efd-border) var(--efd-surface) !important;}
html[data-theme="dark"] .breadcrumb{background:transparent !important;}
html[data-theme="dark"] .breadcrumb-item,html[data-theme="dark"] .breadcrumb-item a{color:var(--efd-muted) !important;}
html[data-theme="dark"] .page-link{background:var(--efd-surface) !important;color:var(--efd-text) !important;border-color:var(--efd-border) !important;}
html[data-theme="dark"] .page-item.active .page-link{background:var(--efd-accent) !important;border-color:var(--efd-accent) !important;color:#04222a !important;}
html[data-theme="dark"] .page-item.disabled .page-link{background:var(--efd-surface) !important;color:var(--efd-muted) !important;}
html[data-theme="dark"] .dropdown-item{color:var(--efd-text) !important;}
html[data-theme="dark"] .dropdown-item:hover,html[data-theme="dark"] .dropdown-item:focus{background:var(--efd-surface-2) !important;color:var(--efd-text) !important;}
html[data-theme="dark"] .dropdown-divider{border-color:var(--efd-border) !important;}

/* misc */
html[data-theme="dark"] .btn-close{filter:invert(1) grayscale(1) brightness(1.4);}
html[data-theme="dark"] code{background:var(--efd-surface-2) !important;color:#e9a8ff !important;}
html[data-theme="dark"] .btn-light{background:var(--efd-surface-2) !important;color:var(--efd-text) !important;border-color:var(--efd-border) !important;}
html[data-theme="dark"] .btn-outline-secondary{color:var(--efd-text) !important;border-color:var(--efd-border) !important;}
html[data-theme="dark"] .btn-outline-secondary:hover{background:var(--efd-surface-2) !important;}

/* ── EduFern custom shell ── */
html[data-theme="dark"] .ef-topbar,
html[data-theme="dark"] .modern-navbar,
html[data-theme="dark"] .navbar.bg-white,
html[data-theme="dark"] .navbar-light{
  background:var(--efd-surface) !important;color:var(--efd-text) !important;border-color:var(--efd-border) !important;}
html[data-theme="dark"] .navbar-light .navbar-nav .nav-link{color:var(--efd-text) !important;}
html[data-theme="dark"] .ef-sidebar{background:var(--efd-surface) !important;border-color:var(--efd-border) !important;}
html[data-theme="dark"] .ef-layout-body,
html[data-theme="dark"] .ef-content,
html[data-theme="dark"] .ef-main,
html[data-theme="dark"] .main-container{background:var(--efd-bg) !important;color:var(--efd-text) !important;}
html[data-theme="dark"] .ef-nav-section-label{color:var(--efd-muted) !important;}
html[data-theme="dark"] .ef-nav-section a,html[data-theme="dark"] .ef-sidebar a{color:var(--efd-text) !important;}
html[data-theme="dark"] .ef-nav-section a:hover,html[data-theme="dark"] .ef-sidebar a:hover,
html[data-theme="dark"] .ef-nav-section a.active{background:var(--efd-surface-2) !important;}
html[data-theme="dark"] .ef-school-badge,html[data-theme="dark"] .ef-avatar,html[data-theme="dark"] .user-avatar{
  background:var(--efd-surface-2) !important;color:var(--efd-text) !important;}
html[data-theme="dark"] .school-name,html[data-theme="dark"] .user-details,html[data-theme="dark"] .ef-sidebar-school-name{color:var(--efd-text) !important;}
html[data-theme="dark"] .school-abbrev,html[data-theme="dark"] .ef-sidebar-school-abbr{color:var(--efd-muted) !important;}
html[data-theme="dark"] .footer-content,html[data-theme="dark"] footer{
  background:var(--efd-surface) !important;color:var(--efd-muted) !important;border-color:var(--efd-border) !important;}
html[data-theme="dark"] .footer-links a{color:var(--efd-muted) !important;}

/* colored alerts — tinted, legible on dark */
html[data-theme="dark"] .alert-info{background:rgba(37,200,224,.12) !important;color:#bdeff8 !important;border-color:rgba(37,200,224,.30) !important;}
html[data-theme="dark"] .alert-success{background:rgba(62,208,126,.12) !important;color:#bff0d3 !important;border-color:rgba(62,208,126,.30) !important;}
html[data-theme="dark"] .alert-danger{background:rgba(247,112,102,.12) !important;color:#ffd0cc !important;border-color:rgba(247,112,102,.30) !important;}
html[data-theme="dark"] .alert-warning{background:rgba(244,186,74,.12) !important;color:#ffe6b0 !important;border-color:rgba(244,186,74,.30) !important;}
html[data-theme="dark"] .modern-alert{background:var(--efd-surface-2) !important;color:var(--efd-text) !important;border-color:var(--efd-border) !important;}

/* ── floating toggle button ── */
#ef-theme-toggle{position:fixed;left:20px;bottom:20px;z-index:20000;display:inline-flex;align-items:center;gap:8px;
  height:44px;padding:0 15px;border-radius:999px;cursor:pointer;border:1px solid rgba(140,160,190,.35);
  background:#ffffff;color:#22303f;box-shadow:0 6px 20px rgba(0,0,0,.18);
  font:600 13px/1 system-ui,-apple-system,Segoe UI,Roboto,sans-serif;transition:transform .15s ease,box-shadow .15s ease;}
#ef-theme-toggle:hover{transform:translateY(-2px);box-shadow:0 10px 26px rgba(0,0,0,.22);}
#ef-theme-toggle:focus-visible{outline:2px solid #0e8fa8;outline-offset:2px;}
#ef-theme-toggle svg{width:18px;height:18px;flex:0 0 auto;}
html[data-theme="dark"] #ef-theme-toggle{background:var(--efd-surface);color:var(--efd-text);border-color:var(--efd-border);box-shadow:0 6px 20px rgba(0,0,0,.5);}
@media (prefers-reduced-motion:reduce){#ef-theme-toggle{transition:none;}}
@media print{#ef-theme-toggle{display:none !important;}}

/* public pages (home, login, register) — these use the --ef-* palette from
   edufern-app-theme.css and some hard-coded light colours, so remap them too */
html[data-theme="dark"]{
  --ef-white:#141b28;
  --ef-body-bg:#0c111c;
  --ef-text:#e8edf6;
  --ef-text-light:#9aa8bf;
  --ef-text-muted:#9aa8bf;
  --ef-border:#2a3446;
  --ef-blue-pale:#1a2233;
  --ef-blue-light:#212b3f;
  --ef-shadow:0 2px 10px rgba(0,0,0,.45);
}
html[data-theme="dark"] .ef-hero,
html[data-theme="dark"] .ef-stat-card,
html[data-theme="dark"] .ef-feature-card,
html[data-theme="dark"] .ef-footer{background:var(--efd-surface) !important;color:var(--efd-text) !important;}
html[data-theme="dark"] .ef-hero{background:var(--efd-bg) !important;}
html[data-theme="dark"] .ef-feature-card,html[data-theme="dark"] .ef-stat-card{border-color:var(--efd-border);}
html[data-theme="dark"] [style*="color:#555"],
html[data-theme="dark"] [style*="color: #555"],
html[data-theme="dark"] [style*="color:#333"],
html[data-theme="dark"] [style*="color: #333"]{color:var(--efd-muted) !important;}
html[data-theme="dark"] [style*="background:#fff"],
html[data-theme="dark"] [style*="background: #fff"],
html[data-theme="dark"] [style*="background:white"],
html[data-theme="dark"] [style*="background: white"]{background:var(--efd-surface) !important;color:var(--efd-text);}
html[data-theme="dark"] h2[style*="color:var(--ef-blue-dark)"]{color:var(--ef-blue-mid) !important;}
