/**
 * W3C-style accessibility toolbar: font-size (continuous zoom, adjustable
 * progressively via the K/S/B buttons) and a 3-way theme cycle (light ->
 * dark -> high-contrast -> light), ported from iprograms'
 * admin-layout-theme.php / system/theme_toggle.php.
 *
 * Activated purely via [data-theme] on <html> and the --a11y-zoom custom
 * property (set inline on <html>), both stamped server-side from a cookie
 * (see header.php / guest.php) so there is no flash of the wrong theme/size
 * on first paint.
 */

/* ---- US-ACC-01: adjustable font size. zoom (not transform:scale or a root
   font-size change) so fixed-position chrome (.topbar, .left-sidebar,
   .footer) scales in place instead of breaking its positioning context -
   this app's layout is largely px-based, not rem-based. --a11y-zoom is a
   continuous value (not a fixed small/normal/large bucket): clicking the
   small (K) or large (B) button repeatedly steps it progressively further
   in that direction, clicking medium (S) resets it to 1 - see
   assets/js/a11y-toolbar.js. Falls back to 1 (no zoom) when the custom
   property isn't set at all (e.g. a page that doesn't stamp it inline). ---- */
:root {
    zoom: var(--a11y-zoom, 1);
}

/* ---- Dark mode palette ---- */
:root[data-theme="dark"] body {
    background: linear-gradient(180deg, #0a1524, #0f1e33) !important;
    color: #e6edf7;
}

:root[data-theme="dark"] .topbar,
:root[data-theme="dark"] .navbar.top-navbar {
    background: #0d1a2e !important;
}

:root[data-theme="dark"] .left-sidebar {
    background: #0d1a2e !important;
}

:root[data-theme="dark"] .page-wrapper {
    background: transparent !important;
}

/* .page-titles (the title/breadcrumb row at the top of nearly every page)
   hardcodes background: #fff in dist/css/style.css - without this override,
   dark-mode's light heading text renders illegibly on that leftover white
   band. Transparent lets the dark body gradient show through, matching
   .page-wrapper above. */
:root[data-theme="dark"] .page-titles {
    background: transparent !important;
}

/* .text-muted's default gray (#6c757d) has enough contrast against light
   backgrounds but falls to ~3.4:1 against dark card backgrounds - brighten
   it for dark mode. .score-meta (interview-score attribution/timestamp
   lines) hardcodes the same gray directly rather than using .text-muted,
   so it needs the same fix explicitly. */
:root[data-theme="dark"] .text-muted,
:root[data-theme="dark"] .score-meta {
    color: #94a7c4 !important;
}

:root[data-theme="dark"] .card,
:root[data-theme="dark"] .panel,
:root[data-theme="dark"] .right-sidebar,
:root[data-theme="dark"] .modal-content {
    background: #16223a !important;
    color: #e6edf7;
    border-color: #2a3a54;
}

/* .slot-section (the "Maklumat Slot & Pemohon" applicant-detail modal cards -
   copy-pasted with a hardcoded white background across several views) sits
   nested inside .modal-content with its own opaque background, so the
   .modal-content dark override above never reaches it: its light text kept
   inheriting onto that leftover white card, and .slot-section-title's own
   hardcoded dark-indigo color went dark-on-dark against the fix below. One
   override here covers every view that reuses this class instead of patching
   each copy separately. */
:root[data-theme="dark"] .slot-section {
    background: #16223a !important;
    border-color: #2a3a54 !important;
    color: #e6edf7;
}

:root[data-theme="dark"] .slot-section-title {
    color: #e6edf7 !important;
    border-color: #2a3a54 !important;
}

/* .deleted-record-body (the "this record is soft-deleted" banner body in the
   applicant account modal) - same opaque-white-card-inside-a-dark-modal
   problem as .slot-section above. */
:root[data-theme="dark"] .deleted-record-body {
    background-color: #16223a !important;
    color: #e6edf7 !important;
}

/* Applicant-search autocomplete panel (admin-add-application-form.php) -
   every one of these hardcodes a light background with no text color of its
   own, so they inherited the ancestor modal's forced-light dark-mode text
   straight onto their unchanged light backgrounds. */
:root[data-theme="dark"] .autocomplete-left-col,
:root[data-theme="dark"] .autocomplete-right-col,
:root[data-theme="dark"] .dropdown-header,
:root[data-theme="dark"] .autocomplete-history-table th {
    background: #16223a !important;
    color: #e6edf7 !important;
}

:root[data-theme="dark"] .dropdown-item.hovered {
    background-color: #1b2b4a !important;
}

/* Select2 dropdown panel (filter multi-selects across the admin side) has no
   theme awareness at all by default, so it stayed plain white/black-on-white
   regardless of [data-theme] - same illegible-in-a-dark-UI pattern as the
   plain .form-control fix above, just for Select2's own separately-rendered
   elements. */
:root[data-theme="dark"] .select2-dropdown,
:root[data-theme="dark"] .select2-search__field,
:root[data-theme="dark"] .select2-results__option,
:root[data-theme="dark"] .select2-results__footer,
:root[data-theme="dark"] .select2-container--default .select2-selection--single,
:root[data-theme="dark"] .select2-container--default .select2-selection--multiple {
    background: #12233d !important;
    color: #e6edf7 !important;
    border-color: #2a3a54 !important;
}

:root[data-theme="dark"] .select2-results__option--highlighted {
    background: #1b2b4a !important;
    color: #e6edf7 !important;
}

:root[data-theme="dark"] .select2-selection__choice {
    background: #1b2b4a !important;
    color: #e6edf7 !important;
    border-color: #2a3a54 !important;
}

/* sejarah_pentauliahan.php's status-highlight table rows - background-only
   (!important) with no text color of their own, so the blanket dark-mode
   td/th color override above landed light-on-light on each of these. */
:root[data-theme="dark"] .sejarah-row.table-info td {
    background-color: #163449 !important;
    color: #e6edf7 !important;
}

:root[data-theme="dark"] .gap-row {
    background-color: rgba(255, 255, 255, .04) !important;
    color: #94a7c4 !important;
}

:root[data-theme="dark"] .warning-row {
    background-color: #4a3b12 !important;
    color: #e6edf7 !important;
}

:root[data-theme="dark"] .audit-row,
:root[data-theme="dark"] .audit-row td {
    background-color: #16223a !important;
    color: #94a7c4 !important;
}

/* jadual_pengajaran.php's schedule-table cell highlights - same
   background-only pattern as the sejarah_pentauliahan.php rows above. */
:root[data-theme="dark"] .bg-light-cell,
:root[data-theme="dark"] .new-location-edit-row td {
    background-color: rgba(255, 255, 255, .04) !important;
    color: #e6edf7 !important;
}

/* .flash-highlight's amber flash keyframe (row-changed indicator, 1s x3) is
   light regardless of theme; force dark text just for those 3 flashes so it
   doesn't briefly go light-on-light. */
:root[data-theme="dark"] .flash-highlight,
:root[data-theme="contrast"] .flash-highlight {
    color: #1a1a1a !important;
}

/* DataTables child-row expansion panels (tracker requirements/user-stories) -
   background-only, rendered as real <td> content so the blanket td/th color
   override above forces light text onto their unchanged light background. */
:root[data-theme="dark"] .rtr-child-row,
:root[data-theme="dark"] .ust-child-row {
    background: #16223a !important;
    color: #e6edf7 !important;
}

/* .wf-row (tracker waterfall chart rows) sits inside a .card, whose dark
   override already forces its text light - only the :hover background was
   left light, going light-on-light while hovered. */
:root[data-theme="dark"] .wf-row:hover {
    background-color: #1b2b4a !important;
}

/* Batch editor's mobile-view header bar - same opaque-light-bar-inside-a-
   dark-card pattern as .deleted-record-body/.slot-section above. */
:root[data-theme="dark"] .mobile-header {
    background: #16223a !important;
    color: #e6edf7 !important;
}

/* #admin-controls (email log detail modal's status-update panel) hardcodes
   a light-yellow background with no text color of its own, nested inside
   .modal-content - same pattern as .deleted-record-body above. */
:root[data-theme="dark"] #admin-controls {
    background-color: #4a3b12 !important;
    color: #e6edf7 !important;
}

/* .disclaimer-docs hardcodes .text-muted's light-mode gray directly instead
   of using the class - same fix as .score-meta above. */
:root[data-theme="dark"] .disclaimer-docs {
    color: #94a7c4 !important;
}

/* #sejarahTabsContent (penemuduga slot detail's tab body) hardcodes bg-white
   with no text color, nested inside the already-fixed .slot-section - same
   forced-light-text-onto-unmoved-background pattern. */
:root[data-theme="dark"] #sejarahTabsContent {
    background: #16223a !important;
    color: #e6edf7 !important;
}

/* KPI figures on reports/statistics_fragment.php force Bootstrap's
   .text-dark (~#212529) inside .card, whose dark override repaints the
   card but can't override this child's own !important color - dark-on-dark. */
:root[data-theme="dark"] .stats-card .text-dark {
    color: #e6edf7 !important;
}

/* Select2 chip remove (x) icons hardcode a dark maroon/green assuming the
   parent chip keeps its pastel light background - the already-fixed
   .select2-selection__choice override repaints the chip dark, leaving these
   icons dark-on-dark. */
:root[data-theme="dark"] .select2-tag-exclude .select2-selection__choice__remove {
    color: #f5c2c7 !important;
}

:root[data-theme="dark"] .select2-tag-include .select2-selection__choice__remove {
    color: #a3cfbb !important;
}

/* .documents-placeholder hardcodes .text-muted's gray directly - same fix
   as .score-meta/.disclaimer-docs above. */
:root[data-theme="dark"] .penemuduga-slot-details .documents-placeholder {
    color: #94a7c4 !important;
}

/* The "Pemohon yang akan Ditemuduga" assigned-applicant list items
   (renderAssignedList() in secretariat/interview_schedule.php) hardcode
   bg-white with no text color, inside a BootstrapDialog .modal-content. */
:root[data-theme="dark"] [data-role="assigned-list"] li {
    background: #16223a !important;
    color: #e6edf7 !important;
}

/* visual_templates/form.php's "no background set yet" page-thumbnail
   placeholder - naked "Tiada Latar" text with no color of its own on a
   hardcoded #eee box inside .card. */
:root[data-theme="dark"] .no-background-placeholder {
    color: #1a1a1a !important;
}

/* public/semakan.php's .semakan-card is a fully self-contained public page
   (own hardcoded white background/dark headings via its own <style> block,
   never meant to follow the admin theme toggle) - reset .text-muted back to
   its normal light-mode gray here specifically, since the global dark-mode
   .text-muted override above assumes a dark ancestor this card never has. */
:root[data-theme="dark"] .semakan-card .text-muted {
    color: #6c757d !important;
}

:root[data-theme="dark"] .form-control,
:root[data-theme="dark"] .form-select,
:root[data-theme="dark"] input,
:root[data-theme="dark"] select,
:root[data-theme="dark"] textarea {
    background-color: #12233d !important;
    color: #e6edf7 !important;
    border-color: #2a3a54 !important;
}

:root[data-theme="dark"] .form-control::placeholder,
:root[data-theme="dark"] textarea::placeholder {
    color: #94a7c4;
}

:root[data-theme="dark"] table.dataTable thead th,
:root[data-theme="dark"] .table thead th {
    background-color: #12233d !important;
    color: #e6edf7 !important;
}

:root[data-theme="dark"] td,
:root[data-theme="dark"] th {
    border-color: #2a3a54 !important;
    color: #e6edf7 !important;
}

/* Bootstrap 5 paints every cell's background via CSS custom properties
   (--bs-table-bg as the base, --bs-table-striped-bg/-hover-bg/-active-bg
   layered on top through an inset box-shadow "accent" trick on the cell,
   not background-color on the <tr>) - a plain tr-level background override
   paints underneath that box-shadow layer and never actually shows.
   Redeclaring the variables here is what Bootstrap's own .table-striped/
   .table-hover/.table-active selectors already read, so it reaches every
   row correctly regardless of DataTables' generated markup; the direct
   td/th background right below is a second, unambiguous safety net (same
   belt-and-suspenders approach as the thead th override above). */
:root[data-theme="dark"] .table {
    color: #e6edf7 !important;
    --bs-table-bg: transparent;
    --bs-table-accent-bg: transparent;
    --bs-table-striped-color: #e6edf7;
    --bs-table-striped-bg: rgba(255, 255, 255, .04);
    --bs-table-active-color: #e6edf7;
    --bs-table-active-bg: rgba(255, 255, 255, .08);
    --bs-table-hover-color: #e6edf7;
    --bs-table-hover-bg: rgba(255, 255, 255, .06);
    border-color: #2a3a54;
}

:root[data-theme="dark"] .table tbody td,
:root[data-theme="dark"] .table tbody th {
    background-color: #16223a !important;
}

:root[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) td,
:root[data-theme="dark"] .table-striped tbody tr:nth-of-type(odd) th {
    background-color: #1c2c4a !important;
}

:root[data-theme="dark"] footer.footer {
    background: #0a1524 !important;
    color: #94a7c4;
}

/* .customtab/.profile-tab tab labels (e.g. the admin Notifications page's
   "Pengumuman (Broadcast)" / "Mesej Langsung (Direct)" tabs) hardcode
   color: #212529 (near-black) for inactive tabs directly on the <a>, so it
   never inherits the .card dark-mode override above - inactive labels render
   at ~1:1 contrast against the dark card background, effectively invisible.
   The active label's salmon (#fb9678) already reads fine on dark (~5:1), so
   only inactive/hover needs a color here. */
:root[data-theme="dark"] .customtab li a.nav-link,
:root[data-theme="dark"] .profile-tab li a.nav-link {
    color: #e6edf7 !important;
}

:root[data-theme="dark"] .customtab li a.nav-link.active,
:root[data-theme="dark"] .profile-tab li a.nav-link.active,
:root[data-theme="dark"] .customtab li a.nav-link:hover,
:root[data-theme="dark"] .profile-tab li a.nav-link:hover {
    color: #fb9678 !important;
}

/* Plain Bootstrap .nav-tabs (email logs, teaching locations, tracker user
   stories, interview schedule history, applicant-details modals) hardcode the
   *active* tab as a white pill (background: #fff, color: #4F5467) that's
   never overridden for dark mode - not the vanishing-text failure above
   (dark-gray-on-white stays self-consistently legible), but the same
   leftover-hardcoded-light-surface pattern the rest of this file guards
   against, so it's swept here too rather than left as a bright white box
   floating in an otherwise dark UI. */
:root[data-theme="dark"] .nav-tabs .nav-link.active,
:root[data-theme="dark"] .nav-tabs .nav-item.show .nav-link {
    color: #e6edf7 !important;
    background-color: #16223a !important;
    border-color: #2a3a54 #2a3a54 #16223a !important;
}

/* ---- US-ACC-02: high-contrast palette - flat pure-black surfaces (no
   gradients/translucency, which dilute contrast ratios), pure-white text,
   one yellow accent for links/primary actions/focus. Standard WCAG-AAA
   "high contrast mode" combination (black/white ~21:1, black/yellow ~17:1). ---- */
:root[data-theme="contrast"] * {
    text-shadow: none !important;
    box-shadow: none !important;
}

:root[data-theme="contrast"] body {
    background: #000000 !important;
    color: #ffffff !important;
}

/* .page-wrapper and .page-titles both need the same transparent treatment
   here as dark mode above - .page-titles hardcodes background: #fff in
   dist/css/style.css, which without this override left the page heading's
   white contrast-mode text on a literal white band (0 contrast). */
:root[data-theme="contrast"] .page-wrapper,
:root[data-theme="contrast"] .page-titles {
    background: transparent !important;
}

/* .text-muted's default gray (#6c757d) drops to ~4.5:1 against pure black -
   right at the AA line and not the AAA-ish standard the rest of this
   palette holds to. .score-meta hardcodes the same gray directly - see the
   dark-mode rule above for why it needs its own selector too. */
:root[data-theme="contrast"] .text-muted,
:root[data-theme="contrast"] .score-meta {
    color: #cccccc !important;
}

:root[data-theme="contrast"] .topbar,
:root[data-theme="contrast"] .navbar.top-navbar,
:root[data-theme="contrast"] .left-sidebar,
:root[data-theme="contrast"] .right-sidebar,
:root[data-theme="contrast"] .modal-header {
    background: #000000 !important;
    border-color: #ffffff !important;
    color: #ffffff;
}

:root[data-theme="contrast"] .sidebar-nav a,
:root[data-theme="contrast"] .sidebar-nav .nav-small-cap {
    color: #ffffff !important;
}

:root[data-theme="contrast"] .sidebar-nav li.active > a,
:root[data-theme="contrast"] .sidebar-nav a:hover {
    color: #ffdd00 !important;
    background: #1a1a1a !important;
}

:root[data-theme="contrast"] .card,
:root[data-theme="contrast"] .panel,
:root[data-theme="contrast"] .modal-content {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

/* Same leftover-hardcoded-white-card problem as the dark-mode .slot-section
   override above, but worse here: contrast mode's forced-white modal text
   inherited onto a still-white card background, i.e. ~1:1 contrast -
   effectively invisible. See the dark-mode override's comment for why this
   lives here once instead of per-view. */
:root[data-theme="contrast"] .slot-section {
    background: #000000 !important;
    border: 2px solid #ffffff !important;
    color: #ffffff !important;
}

:root[data-theme="contrast"] .slot-section-title {
    color: #ffffff !important;
    border-color: #444444 !important;
}

:root[data-theme="contrast"] .deleted-record-body {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

:root[data-theme="contrast"] .autocomplete-left-col,
:root[data-theme="contrast"] .autocomplete-right-col,
:root[data-theme="contrast"] .dropdown-header,
:root[data-theme="contrast"] .autocomplete-history-table th {
    background: #000000 !important;
    color: #ffffff !important;
}

:root[data-theme="contrast"] .dropdown-item.hovered {
    background-color: #1a1a1a !important;
    color: #ffdd00 !important;
}

:root[data-theme="contrast"] .select2-dropdown,
:root[data-theme="contrast"] .select2-search__field,
:root[data-theme="contrast"] .select2-results__option,
:root[data-theme="contrast"] .select2-results__footer,
:root[data-theme="contrast"] .select2-container--default .select2-selection--single,
:root[data-theme="contrast"] .select2-container--default .select2-selection--multiple {
    background: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

:root[data-theme="contrast"] .select2-results__option--highlighted {
    background: #1a1a1a !important;
    color: #ffdd00 !important;
}

:root[data-theme="contrast"] .select2-selection__choice {
    background: #1a1a1a !important;
    color: #ffffff !important;
    border-color: #ffdd00 !important;
}

:root[data-theme="contrast"] .sejarah-row.table-info td {
    background-color: #000000 !important;
    color: #ffdd00 !important;
    border: 1px solid #ffdd00 !important;
}

:root[data-theme="contrast"] .gap-row {
    background-color: #000000 !important;
    color: #cccccc !important;
}

:root[data-theme="contrast"] .warning-row {
    background-color: #1a1a1a !important;
    color: #ffdd00 !important;
}

:root[data-theme="contrast"] .audit-row,
:root[data-theme="contrast"] .audit-row td {
    background-color: #000000 !important;
    color: #ffffff !important;
}

:root[data-theme="contrast"] .bg-light-cell,
:root[data-theme="contrast"] .new-location-edit-row td {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 1px solid #444444 !important;
}

:root[data-theme="contrast"] .rtr-child-row,
:root[data-theme="contrast"] .ust-child-row {
    background: #000000 !important;
    color: #ffffff !important;
}

:root[data-theme="contrast"] .wf-row:hover {
    background-color: #1a1a1a !important;
}

:root[data-theme="contrast"] .mobile-header {
    background: #000000 !important;
    color: #ffffff !important;
}

:root[data-theme="contrast"] #admin-controls {
    background-color: #1a1a1a !important;
    color: #ffdd00 !important;
}

:root[data-theme="contrast"] .disclaimer-docs {
    color: #cccccc !important;
}

:root[data-theme="contrast"] #sejarahTabsContent {
    background: #000000 !important;
    color: #ffffff !important;
}

:root[data-theme="contrast"] .stats-card .text-dark {
    color: #ffffff !important;
}

:root[data-theme="contrast"] .select2-tag-exclude .select2-selection__choice__remove {
    color: #ffdd00 !important;
}

:root[data-theme="contrast"] .select2-tag-include .select2-selection__choice__remove {
    color: #ffdd00 !important;
}

:root[data-theme="contrast"] .penemuduga-slot-details .documents-placeholder {
    color: #cccccc !important;
}

:root[data-theme="contrast"] [data-role="assigned-list"] li {
    background: #000000 !important;
    color: #ffffff !important;
    border-color: #444444 !important;
}

:root[data-theme="contrast"] .no-background-placeholder {
    color: #1a1a1a !important;
}

:root[data-theme="contrast"] .semakan-card .text-muted {
    color: #6c757d !important;
}

:root[data-theme="contrast"] .form-control,
:root[data-theme="contrast"] .form-select,
:root[data-theme="contrast"] input,
:root[data-theme="contrast"] select,
:root[data-theme="contrast"] textarea {
    background-color: #000000 !important;
    color: #ffffff !important;
    border: 2px solid #ffffff !important;
}

:root[data-theme="contrast"] .form-control::placeholder,
:root[data-theme="contrast"] textarea::placeholder {
    color: #cccccc;
}

:root[data-theme="contrast"] a {
    color: #ffdd00 !important;
    text-decoration: underline;
}

:root[data-theme="contrast"] .btn-primary {
    background: #ffdd00 !important;
    border-color: #ffdd00 !important;
    color: #000000 !important;
    font-weight: 700;
}

:root[data-theme="contrast"] .btn:focus-visible,
:root[data-theme="contrast"] a:focus-visible,
:root[data-theme="contrast"] input:focus-visible,
:root[data-theme="contrast"] select:focus-visible {
    outline: 3px solid #ffdd00 !important;
    outline-offset: 2px;
}

:root[data-theme="contrast"] table.dataTable thead th,
:root[data-theme="contrast"] .table thead th {
    background-color: #000000 !important;
    color: #ffdd00 !important;
    border-bottom: 2px solid #ffffff !important;
}

:root[data-theme="contrast"] td,
:root[data-theme="contrast"] th {
    border-color: #444444 !important;
    color: #ffffff;
}

/* Same CSS-custom-property paint mechanism as the dark-mode .table override
   above - see its comment for why a plain tr-level background never worked.
   Combined with td/th's forced white text above, the un-fixed version of
   this left every row rendering white-on-near-white (~1:1 ratio). */
:root[data-theme="contrast"] .table {
    color: #ffffff !important;
    --bs-table-bg: transparent;
    --bs-table-accent-bg: transparent;
    --bs-table-striped-color: #ffffff;
    --bs-table-striped-bg: #1a1a1a;
    --bs-table-active-color: #ffffff;
    --bs-table-active-bg: #262626;
    --bs-table-hover-color: #ffffff;
    --bs-table-hover-bg: #1a1a1a;
    border-color: #444444;
}

:root[data-theme="contrast"] .table tbody td,
:root[data-theme="contrast"] .table tbody th {
    background-color: #000000 !important;
}

:root[data-theme="contrast"] .table-striped tbody tr:nth-of-type(odd) td,
:root[data-theme="contrast"] .table-striped tbody tr:nth-of-type(odd) th {
    background-color: #1a1a1a !important;
}

:root[data-theme="contrast"] .badge {
    background: #000000 !important;
    color: #ffdd00 !important;
    border: 1px solid #ffdd00;
}

:root[data-theme="contrast"] footer.footer {
    background: #000000 !important;
    border-top: 1px solid #ffffff;
    color: #ffffff;
}

/* Same .customtab/.profile-tab hardcoded-inactive-label problem as the
   dark-mode override above, but against contrast mode's pure-black card
   (see the US-ACC-02 palette block above) - equally invisible, ~1:1. */
:root[data-theme="contrast"] .customtab li a.nav-link,
:root[data-theme="contrast"] .profile-tab li a.nav-link {
    color: #ffffff !important;
}

:root[data-theme="contrast"] .customtab li a.nav-link.active,
:root[data-theme="contrast"] .profile-tab li a.nav-link.active,
:root[data-theme="contrast"] .customtab li a.nav-link:hover,
:root[data-theme="contrast"] .profile-tab li a.nav-link:hover {
    color: #ffdd00 !important;
    border-bottom-color: #ffdd00 !important;
}

/* Same leftover-hardcoded-white-pill problem as the dark-mode .nav-tabs
   override above. */
:root[data-theme="contrast"] .nav-tabs .nav-link.active,
:root[data-theme="contrast"] .nav-tabs .nav-item.show .nav-link {
    color: #ffdd00 !important;
    background-color: #000000 !important;
    border-color: #ffffff #ffffff #000000 !important;
}

/* ---- Toolbar widget: theme cycle button ---- */
.a11y-toolbar {
    display: flex;
    align-items: center;
    /* The sibling .nav-item <li>s (bell/gear) are auto-stretched by the parent
       .navbar-nav flex row to whatever height their own padding+line-height
       (dist/css/style.css) computes to - not a fixed value we can hardcode
       reliably. Filling 100% of our own (equally-stretched) <li> and centering
       within it keeps us vertically aligned with them regardless of that value. */
    height: 100%;
    gap: 10px;
    padding: 2px;
    opacity: 1;
    background: #0d1c36;
    border-radius: 999px;
}

.a11y-theme-toggle {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 28px;
    padding: 0;
    border: 0;
    border-radius: 999px;
    cursor: pointer;
    background: linear-gradient(135deg, #7fb2ff, #f4bb2a);
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, .35);
    -webkit-tap-highlight-color: transparent;
}

.a11y-theme-toggle:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

:root[data-theme="dark"] .a11y-theme-toggle {
    background: linear-gradient(135deg, #1b2b4a, #24406f);
}

:root[data-theme="contrast"] .a11y-theme-toggle {
    background: #000000;
    border: 2px solid #ffdd00;
}

.a11y-theme-toggle .a11y-theme-icon {
    display: none;
    font-size: 13px;
    line-height: 1;
    pointer-events: none;
}

.a11y-theme-toggle .a11y-theme-icon-light {
    color: #806000;
}

.a11y-theme-toggle .a11y-theme-icon-dark {
    color: #cfe0ff;
}

.a11y-theme-toggle .a11y-theme-icon-contrast {
    color: #ffdd00;
}

:root[data-theme="light"] .a11y-theme-toggle .a11y-theme-icon-light,
:root[data-theme="dark"] .a11y-theme-toggle .a11y-theme-icon-dark,
:root[data-theme="contrast"] .a11y-theme-toggle .a11y-theme-icon-contrast {
    display: inline-block;
}

/* ---- Toolbar widget: font-size group ---- */
.a11y-fontsize-toggle {
    display: inline-flex;
    align-items: center;
    gap: 2px;
    padding: 2px;
    border-radius: 999px;
    background: #304565;
}

.a11y-fontsize-toggle button {
    position: relative;
    min-width: 24px;
    height: 24px;
    padding: 0 5px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 0;
    border-radius: 999px;
    background: transparent;
    color: #fff;
    font-weight: 700;
    cursor: pointer;
}

/* The K/S/B glyph itself is rendered at a size proportional to what it
   selects (Kecil/Sederhana/Besar) so the label doubles as a visual preview,
   not just text - the button box stays a uniform height for a tidy row. */
.a11y-fontsize-toggle button[data-size="small"] {
    font-size: 10px;
}

.a11y-fontsize-toggle button[data-size="normal"] {
    font-size: 13px;
}

.a11y-fontsize-toggle button[data-size="large"] {
    font-size: 16px;
}

.a11y-fontsize-toggle button[aria-pressed="true"] {
    background: #fff;
    color: #333;
}

.a11y-fontsize-toggle button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 1px;
}

/* ---- Floating variant, for the guest/login shell which has no navbar to
   dock the toolbar into. ---- */
.a11y-toolbar-floating {
    position: fixed;
    top: 14px;
    right: 14px;
    z-index: 2000; /* Replaced at runtime with the highest loaded z-index + 1. */
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    border-radius: 999px;
    opacity: 1;
    background: #081c46;
    box-shadow: 0 6px 18px rgba(8, 28, 70, .35);
}

/* The header toolbar is portalled to <body> at runtime so it is not trapped
   below a modal by the header's stacking context. Its placeholder keeps the
   navbar layout unchanged while JS tracks the placeholder's screen position. */
.a11y-toolbar.a11y-toolbar-portal {
    position: fixed;
    width: max-content;
    height: auto;
    min-height: 0;
    margin: 0;
    opacity: 1;
}

.a11y-toolbar-placeholder {
    display: block;
    flex: 0 0 auto;
}

.a11y-toolbar.a11y-toolbar-overlaid,
.a11y-toolbar-floating.a11y-toolbar-overlaid {
    background: #092b61 !important;
    box-shadow: 0 0 0 2px #36a3ff, 0 0 18px 5px rgba(54, 163, 255, .78) !important;
}

:root[data-theme="dark"] .a11y-toolbar.a11y-toolbar-overlaid,
:root[data-theme="dark"] .a11y-toolbar-floating.a11y-toolbar-overlaid {
    background: #07172f !important;
    box-shadow: 0 0 0 2px #40e0ff, 0 0 20px 6px rgba(64, 224, 255, .82) !important;
}

:root[data-theme="contrast"] .a11y-toolbar,
:root[data-theme="contrast"] .a11y-toolbar-floating {
    background: #000 !important;
    border: 0;
}

:root[data-theme="contrast"] .a11y-toolbar.a11y-toolbar-overlaid,
:root[data-theme="contrast"] .a11y-toolbar-floating.a11y-toolbar-overlaid {
    background: #000 !important;
    box-shadow: 0 0 0 3px #ff2bd6, 0 0 22px 7px rgba(255, 43, 214, .9) !important;
}
