/* ==========================================================================
   Dark mode for the student portal, admin panel and login/register pages.
   Active when <html data-bs-theme="dark"> (set by the theme switch in the
   sidebar, remembered in the browser). Light mode is untouched.
   Bootstrap 5.3 already darkens its own components; this file fixes the
   site's custom colours, Bootstrap's fixed helpers (bg-white, bg-light,
   text-dark, table-light) and the biology decorations.
   ========================================================================== */
[data-bs-theme="dark"] {
    color-scheme: dark;

    /* Dark palette */
    --dk-bg: #0e1a11;
    --dk-surface: #16261a;
    --dk-surface-2: #1d3121;
    --dk-hover: #22392a;
    --dk-border: #2c4631;
    --dk-text: #e2efe0;
    --dk-muted: #9fb89c;
    --dk-heading: #d4f2cc;
    --dk-accent: #5cc94a;

    /* Site variables (custom.css) */
    --body-bg: var(--dk-bg);
    --text-main: var(--dk-text);
    --text-muted: var(--dk-muted);
    --primary-pale: #1b3520;          /* table headers, navbar edge */
    --primary-darkest: var(--dk-heading); /* headings, labels, card titles */

    /* Bootstrap variables */
    --bs-body-bg: var(--dk-bg);
    --bs-body-color: var(--dk-text);
    --bs-secondary-color: var(--dk-muted);
    --bs-border-color: var(--dk-border);
    --bs-secondary-bg: var(--dk-surface-2);
    --bs-tertiary-bg: var(--dk-surface);
    --bs-emphasis-color: #ffffff;
    --bs-heading-color: var(--dk-heading);
    --bs-primary-rgb: 92, 201, 74;     /* brighter green so green text stays readable */
    --bs-link-color: var(--dk-accent);
    --bs-link-color-rgb: 92, 201, 74;
    --bs-link-hover-color: #8fe07f;
    --bs-link-hover-color-rgb: 143, 224, 127;
    --bs-primary-text-emphasis: #bff0b5;
    --bs-primary-bg-subtle: #1c3a1f;
    --bs-primary-border-subtle: #2f5a2c;
}

[data-bs-theme="dark"] body { background: var(--dk-bg); color: var(--dk-text); }
[data-bs-theme="dark"] h1, [data-bs-theme="dark"] h2, [data-bs-theme="dark"] h3,
[data-bs-theme="dark"] h4, [data-bs-theme="dark"] h5, [data-bs-theme="dark"] h6 { color: var(--dk-heading); }

/* Bootstrap's fixed light helpers */
[data-bs-theme="dark"] .bg-white,
[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .navbar.bg-light { background-color: var(--dk-surface) !important; }
[data-bs-theme="dark"] .bg-light-subtle { background-color: var(--dk-surface-2) !important; }
[data-bs-theme="dark"] .text-dark { color: var(--dk-text) !important; }

/* Student payments page: bank details card and class price box (light + dark) */
.bank-card { background-color: #f8fcf8; }
.bank-details { background: #fff; color: #333; font-size: 1.1rem; line-height: 1.6; }
.price-info-box { background: #e8fce8; border: 1.5px solid #089000; }
.price-info-label { color: #063b00; }
[data-bs-theme="dark"] .bank-card { background-color: var(--dk-surface) !important; }
[data-bs-theme="dark"] .bank-details { background: var(--dk-surface-2); color: var(--dk-text); border-color: var(--dk-border) !important; }
[data-bs-theme="dark"] .price-info-box { background: #1c3a1f; border-color: #3f9a32; }
[data-bs-theme="dark"] .price-info-label { color: #bff0b5; }

/* Outline buttons: brighter green so they stay readable on dark surfaces */
[data-bs-theme="dark"] .btn-outline-primary {
    --bs-btn-color: var(--dk-accent);
    --bs-btn-border-color: #3f9a32;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #089000;
    --bs-btn-hover-border-color: #089000;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #0a6b00;
    --bs-btn-active-border-color: #0a6b00;
}
[data-bs-theme="dark"] .btn-check:checked + .btn-outline-primary,
[data-bs-theme="dark"] .btn-outline-primary.active { color: #fff; background-color: #089000; border-color: #089000; }
[data-bs-theme="dark"] .btn-outline-success { --bs-btn-color: var(--dk-accent); --bs-btn-border-color: #3f9a32; }
[data-bs-theme="dark"] .btn-outline-secondary { --bs-btn-color: #c3d6c0; --bs-btn-border-color: #4a6a4e; }
[data-bs-theme="dark"] .text-black-50 { color: var(--dk-muted) !important; }
[data-bs-theme="dark"] .border-white { border-color: var(--dk-border) !important; }
[data-bs-theme="dark"] .navbar.bg-light { border-bottom-color: var(--dk-border); }

/* Cards, modals, dropdowns */
[data-bs-theme="dark"] .card {
    --bs-card-bg: var(--dk-surface);
    --bs-card-cap-bg: var(--dk-surface);
    --bs-card-border-color: var(--dk-border);
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}
[data-bs-theme="dark"] .modal { --bs-modal-bg: var(--dk-surface); --bs-modal-border-color: var(--dk-border); }
[data-bs-theme="dark"] .dropdown-menu { --bs-dropdown-bg: var(--dk-surface); }
[data-bs-theme="dark"] .list-group { --bs-list-group-bg: var(--dk-surface); }

/* Forms */
[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: var(--dk-surface-2);
    border-color: var(--dk-border);
    color: var(--dk-text);
}
[data-bs-theme="dark"] .form-control::placeholder { color: #7f977c; }
[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-control[readonly] { background-color: #142118; }
[data-bs-theme="dark"] .input-group-text { background-color: var(--dk-surface-2); border-color: var(--dk-border); color: var(--dk-text); }

/* Tables */
[data-bs-theme="dark"] .table {
    --bs-table-bg: var(--dk-surface);
    --bs-table-color: var(--dk-text);
    --bs-table-border-color: var(--dk-border);
    --bs-table-striped-bg: var(--dk-surface-2);
    --bs-table-hover-bg: var(--dk-hover);
    --bs-table-hover-color: var(--dk-text);
}
[data-bs-theme="dark"] .table-light {
    --bs-table-bg: var(--dk-surface-2);
    --bs-table-color: var(--dk-heading);
    --bs-table-border-color: var(--dk-border);
}
[data-bs-theme="dark"] .table thead th { border-bottom-color: var(--dk-border); }
[data-bs-theme="dark"] .table-responsive table thead th { box-shadow: 0 2px 0 var(--dk-border); }
[data-bs-theme="dark"] .table-hover tbody tr:hover { background: var(--dk-hover); }
[data-bs-theme="dark"] .table-responsive table th:last-child,
[data-bs-theme="dark"] .table-responsive table td:last-child { background: var(--dk-surface); box-shadow: -3px 0 8px rgba(0, 0, 0, 0.35); }
[data-bs-theme="dark"] .table-hover tbody tr:hover td:last-child { background: var(--dk-hover); }
[data-bs-theme="dark"] .table-responsive { scrollbar-color: var(--dk-accent) var(--dk-surface-2); }

/* Alerts, accordion, autocomplete */
[data-bs-theme="dark"] .alert-success { background: #17361b; color: #bff0b5; border-color: #2f5a2c; }
[data-bs-theme="dark"] .alert-info { background: #13303a; color: #a8e2f0; border-color: #1f4d5a; }
[data-bs-theme="dark"] .accordion { --bs-accordion-bg: var(--dk-surface); --bs-accordion-active-bg: #1c3a1f; --bs-accordion-active-color: #bff0b5; --bs-accordion-border-color: var(--dk-border); }
[data-bs-theme="dark"] .autocomplete-items { background: var(--dk-surface); border-color: var(--dk-border); }
[data-bs-theme="dark"] .autocomplete-items div { background: var(--dk-surface); border-bottom-color: var(--dk-border); color: var(--dk-text); }
[data-bs-theme="dark"] .autocomplete-items div:hover,
[data-bs-theme="dark"] .autocomplete-active { background: var(--dk-hover) !important; }
[data-bs-theme="dark"] .price-badge { color: #fff; }

/* Inline light backgrounds used on a few pages */
[data-bs-theme="dark"] [style*="#f8f9fa"],
[data-bs-theme="dark"] [style*="#f8fcf8"],
[data-bs-theme="dark"] [style*="#e8fce8"],
[data-bs-theme="dark"] [style*="#f0f8ff"] { background: var(--dk-surface-2) !important; border-color: var(--dk-border) !important; }
[data-bs-theme="dark"] [style*="color:#063b00"],
[data-bs-theme="dark"] [style*="color: #063b00"] { color: var(--dk-heading) !important; }

/* Student hall filter cards (inline styles in student pages) */
[data-bs-theme="dark"] .hall-card { background: var(--dk-surface-2); border-color: var(--dk-border); color: var(--dk-text); }
[data-bs-theme="dark"] .hall-card .hall-name { color: var(--dk-text); }
[data-bs-theme="dark"] .hall-card-icon { background: #1c3a1f; }

/* Login / register background */
[data-bs-theme="dark"] .hero-gradient {
    background-image: url("../img/bio-sketch-white.svg"), linear-gradient(135deg, #031f00 0%, #0a4a00 100%);
}
[data-bs-theme="dark"] .auth-card { background: var(--dk-surface); }

/* ─── Biology decorations & new components ──────────────────────────── */
[data-bs-theme="dark"] #content::before {
    background-image: url("../img/bio-sketch-white.svg");
    opacity: 0.55;
}
[data-bs-theme="dark"] .bio-fact-card { box-shadow: 0 6px 18px rgba(0, 0, 0, 0.4); }

/* Pagination */
[data-bs-theme="dark"] .lms-pager { border-top-color: var(--dk-border); }
[data-bs-theme="dark"] .lms-pager-info,
[data-bs-theme="dark"] .lms-pager-size { color: var(--dk-muted); }
[data-bs-theme="dark"] .lms-pager-info b { color: var(--dk-text); }
[data-bs-theme="dark"] .lms-pager-size .form-select { border-color: var(--dk-border); }
[data-bs-theme="dark"] .pagination .page-link { background: var(--dk-surface-2); border-color: var(--dk-border); color: var(--dk-text); }
[data-bs-theme="dark"] .pagination .page-link:hover { background: var(--dk-surface-2); border-color: var(--dk-accent); color: var(--dk-accent); }
[data-bs-theme="dark"] .pagination .page-item.active .page-link { background: #089000; border-color: #089000; color: #fff; box-shadow: 0 0 0 4px #1c3a1f, 0 4px 10px rgba(0, 0, 0, 0.4); }
[data-bs-theme="dark"] .pagination .page-item.disabled .page-link { background: transparent; border-color: transparent; color: #5f765c; }

/* Student specimen cards */
[data-bs-theme="dark"] .spec-card { background: var(--dk-surface); border-color: var(--dk-border); box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35); }
[data-bs-theme="dark"] .spec-icon { background: var(--dk-surface); border-color: #1c3a1f; color: var(--dk-accent); }
[data-bs-theme="dark"] .spec-price { color: #8fe07f; }
[data-bs-theme="dark"] .spec-price small,
[data-bs-theme="dark"] .spec-stats,
[data-bs-theme="dark"] .spec-zoom { color: var(--dk-muted); }
[data-bs-theme="dark"] .spec-stats b,
[data-bs-theme="dark"] .spec-zoom b { color: var(--dk-text); }
[data-bs-theme="dark"] .spec-joined { color: #7f977c; }
[data-bs-theme="dark"] .spec-status.spec-ok   { background: #17361b; color: #9be68b; }
[data-bs-theme="dark"] .spec-status.spec-due  { background: #3a2f12; color: #f2c66b; }
[data-bs-theme="dark"] .spec-status.spec-wait { background: #18294a; color: #a9c2ff; }
[data-bs-theme="dark"] .spec-status.spec-info { background: var(--dk-surface-2); color: #b9d8b4; }

/* Admin class health cards */
[data-bs-theme="dark"] .ach-grid { background: var(--dk-bg); }
[data-bs-theme="dark"] .ach-card { background: var(--dk-surface); border-color: var(--dk-border); box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35); }
[data-bs-theme="dark"] .ach-ico { background: #1c3a1f; color: var(--dk-accent); }
[data-bs-theme="dark"] .ach-title h6 { color: var(--dk-heading); }
[data-bs-theme="dark"] .ach-sub,
[data-bs-theme="dark"] .ach-note,
[data-bs-theme="dark"] .ach-bar-label,
[data-bs-theme="dark"] .ach-metric span { color: var(--dk-muted); }
[data-bs-theme="dark"] .ach-note b,
[data-bs-theme="dark"] .ach-metric b { color: var(--dk-text); }
[data-bs-theme="dark"] .ach-metric { background: var(--dk-surface-2); }
[data-bs-theme="dark"] .ach-metric.ach-warn { background: #3a2f12; }
[data-bs-theme="dark"] .ach-metric.ach-warn b { color: #f2c66b; }
[data-bs-theme="dark"] .ach-bar-track { background: #1c3a1f; }
[data-bs-theme="dark"] .ach-switch[aria-checked="false"] { background: #3d5240; }
[data-bs-theme="dark"] .ach-actions .btn { background: var(--dk-surface-2); border-color: var(--dk-border); color: var(--dk-text); }
[data-bs-theme="dark"] .ach-actions .btn i { color: var(--dk-accent); }
[data-bs-theme="dark"] .ach-actions .btn:hover { border-color: var(--dk-accent); color: var(--dk-accent); }
[data-bs-theme="dark"] .ach-actions .ach-danger i { color: #ff6b7a; }

/* ─── The theme switch itself (sidebar) ─────────────────────────────── */
.theme-switch {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin-top: 12px;
    padding: 5px 12px 5px 6px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.25);
    background: rgba(255, 255, 255, 0.08);
    color: #fff;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.theme-switch:hover { background: rgba(255, 255, 255, 0.16); }
.theme-switch:focus-visible { outline: 2px solid #b8f27c; outline-offset: 2px; }
.theme-switch-knob {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f6c945;
    color: #6b4b00;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
}
[data-bs-theme="dark"] .theme-switch-knob { background: #2c4631; color: #d4f2cc; }
