/* =========================================================================================================
   RF-3 (2026-10-11) — RapidForge colour modes: the GENERIC dark layer.
   _Layout.Base renders html[data-theme] = light | dark (and data-bs-theme for Bootstrap's own colour modes); the
   preference (light / dark / system) lives in the application's theme cookie (WebApp.Infrastructure.ThemePreference,
   js/rf-theme.js). The Theme Library profile (theme.active.css) supplies the LIGHT surfaces and the brand accents;
   this file re-maps only the template's semantic surface / text / border / input / table tokens to neutral dark
   values for html[data-theme="dark"]. Brand accents (--primary-*, --gold-*, --accent-*, the menu palette) are left
   to the profile, so no brand colour is defined here: a host that needs brand-specific dark values overrides these
   same tokens in its own stylesheet under html[data-theme="dark"].
   Specificity (0,1,1) beats the profile's :root (0,1,0) whatever the load order. Every text/background pair below
   meets WCAG AA 4.5:1 (checked by the RF-3 harness).
   ========================================================================================================= */
html[data-theme="light"] {
    color-scheme: light;
}

html[data-theme="dark"] {
    color-scheme: dark;

    /* Page / content */
    --background-color: #0f172a;
    --page-bg: #0f172a;
    --page-fg: #e5e7eb;
    --content-bg: #0f172a;
    --muted-fg: #a3b1c6;
    --body-text-base: #e5e7eb;
    --link-fg: #93c5fd;
    --link-fg-hover: #bfdbfe;

    /* Header bar (the side menu keeps the profile's own dark palette) */
    --header-bg: #111c2e;
    --header-fg: #e5e7eb;

    /* Panels and cards */
    --panel-bg: #111c2e;
    --panel-hover: #1a2740;
    --panel-border: #2a3a55;
    --card-bg: #111c2e;
    --card-fg: #e5e7eb;
    --card-border: #2a3a55;
    --card-hover-bg: #1a2740;
    --card-title-fg: #f1f5f9;
    --card-text-fg: #cbd5e1;
    --cardHeader-bg: #16233a;
    --cardHeader-fg: #e5e7eb;
    --glass-bg: rgba(255, 255, 255, 0.06);
    --glass-border: rgba(255, 255, 255, 0.14);
    --shadow-opacity: 0.55;

    /* Tables / DataTables */
    --table-header-bg: #16233a;
    --table-header-fg: #f1f5f9;
    --table-body-bg: #111c2e;
    --table-row-bg: #111c2e;
    --table-row-alt-bg: #0f1a2b;
    --table-row-hover-bg: #1a2740;
    --table-border: #2a3a55;
    --table-control-bg: #0f172a;
    --table-control-border: #3b4c68;
    --table-control-hover: #1a2740;
    --table-control-text: #e5e7eb;
    --dataTabel-text-base: #e5e7eb;
    --dataTabel-background-base: #111c2e;
    --dt-html-background: #0f172a;
    --dt-row-selected: #1e3a5f;
    --dt-row-selected-text: #f1f5f9;
    --dt-row-stripe: #0f1a2b;
    --dt-row-hover: #1a2740;

    /* Inputs and dropdowns */
    --input-bg: #0f1a2b;
    --input-fg: #e5e7eb;
    --input-border: #3b4c68;
    --input-placeholder: #8fa0b8;
    --dropdown-bg: #111c2e;
    --dropdown-fg: #e5e7eb;
    --dropdown-border: #2a3a55;

    /* Semantic layer (base/variables.css --rf-*) follows the tokens above automatically; the few literal ones: */
    --rf-color-text: #e5e7eb;
    --rf-color-surface-text: #cbd5e1;
    --rf-surface-text: #e5e7eb;
    --rf-muted-text: #a3b1c6;
    --rf-page-title-color: #f1f5f9;
    --rf-page-subtitle-color: #a3b1c6;
}

/* Surfaces that the template paints with fixed light colours rather than tokens. */
html[data-theme="dark"] body {
    background-color: var(--page-bg);
    color: var(--page-fg);
}

html[data-theme="dark"] .card,
html[data-theme="dark"] .modal-content,
html[data-theme="dark"] .dropdown-menu,
html[data-theme="dark"] .offcanvas {
    background-color: var(--card-bg);
    color: var(--card-fg);
    border-color: var(--card-border);
}

html[data-theme="dark"] .dropdown-item {
    color: var(--dropdown-fg);
}

html[data-theme="dark"] .dropdown-item:hover,
html[data-theme="dark"] .dropdown-item:focus {
    background-color: var(--panel-hover);
    color: var(--page-fg);
}

html[data-theme="dark"] .table {
    --bs-table-bg: var(--table-row-bg);
    --bs-table-color: var(--page-fg);
    --bs-table-striped-bg: var(--table-row-alt-bg);
    --bs-table-striped-color: var(--page-fg);
    --bs-table-hover-bg: var(--table-row-hover-bg);
    --bs-table-hover-color: var(--page-fg);
    --bs-table-border-color: var(--table-border);
}

html[data-theme="dark"] .form-control,
html[data-theme="dark"] .form-select,
html[data-theme="dark"] .input-group-text {
    background-color: var(--input-bg);
    color: var(--input-fg);
    border-color: var(--input-border);
}

html[data-theme="dark"] .form-control::placeholder {
    color: var(--input-placeholder);
}

/* The grey outline button keeps #6c757d text in dark mode (about 3.8:1 here): Bootstrap through --bs-btn-color and the
   template's buttons.css through color: var(--neutral-gray-base) !important. Scoping both tokens to the button lifts it
   to AA without touching other uses of --neutral-gray-base. */
html[data-theme="dark"] .btn-outline-secondary {
    --neutral-gray-base: #cbd5e1;
    --bs-btn-color: #cbd5e1;
    --bs-btn-border-color: #64748b;
    --bs-btn-hover-color: #f1f5f9;
    --bs-btn-hover-bg: #334155;
    --bs-btn-hover-border-color: #94a3b8;
    --bs-btn-active-color: #f1f5f9;
    --bs-btn-active-bg: #334155;
}

html[data-theme="dark"] .text-muted {
    color: var(--muted-fg) !important;
}

html[data-theme="dark"] .bg-body-tertiary,
html[data-theme="dark"] .bg-light,
html[data-theme="dark"] .bg-white {
    background-color: var(--panel-bg) !important;
}

/* The theme switch marks the active choice. */
.rf-theme-switch .dropdown-item.active,
.rf-theme-switch .dropdown-item[aria-checked="true"] {
    font-weight: 600;
}
