/*
 * Theme-safe contrast layer
 *
 * The admin uses Bootstrap's dark and blue themes, while a number of shared
 * views use Bootstrap's light-mode utility classes.  Bootstrap intentionally
 * keeps those utility colours fixed, which can make text such as `.text-dark`
 * unreadable on a dark card.  Keep the utilities semantic in dark themes so
 * existing pages and components remain readable without markup changes.
 */
[data-bs-theme="dark"],
[data-bs-theme="blue-theme"] {
    color-scheme: dark;
}

[data-bs-theme="dark"] .text-dark,
[data-bs-theme="dark"] .text-black,
[data-bs-theme="dark"] .text-body,
[data-bs-theme="blue-theme"] .text-dark,
[data-bs-theme="blue-theme"] .text-black,
[data-bs-theme="blue-theme"] .text-body {
    color: #f8fafc !important;
}

[data-bs-theme="dark"] .text-secondary,
[data-bs-theme="dark"] .text-muted,
[data-bs-theme="blue-theme"] .text-secondary,
[data-bs-theme="blue-theme"] .text-muted {
    color: #b8c2cc !important;
}

[data-bs-theme="dark"] .form-text,
[data-bs-theme="blue-theme"] .form-text {
    color: #b8c2cc !important;
}

/* Bright semantic surfaces need dark text for a readable, accessible label. */
[data-bs-theme="dark"] .bg-warning.text-dark,
[data-bs-theme="dark"] .bg-info.text-dark,
[data-bs-theme="dark"] .btn-warning.text-dark,
[data-bs-theme="dark"] .btn-info.text-dark,
[data-bs-theme="blue-theme"] .bg-warning.text-dark,
[data-bs-theme="blue-theme"] .bg-info.text-dark,
[data-bs-theme="blue-theme"] .btn-warning.text-dark,
[data-bs-theme="blue-theme"] .btn-info.text-dark {
    color: #17212b !important;
}

/* Ensure inherited text remains legible in common dark UI surfaces. */
[data-bs-theme="dark"] .card,
[data-bs-theme="dark"] .modal-content,
[data-bs-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .offcanvas,
[data-bs-theme="blue-theme"] .card,
[data-bs-theme="blue-theme"] .modal-content,
[data-bs-theme="blue-theme"] .dropdown-menu,
[data-bs-theme="blue-theme"] .offcanvas {
    color: var(--bs-body-color);
}

[data-bs-theme="dark"] .table,
[data-bs-theme="blue-theme"] .table {
    --bs-table-color: var(--bs-body-color);
    --bs-table-striped-color: var(--bs-body-color);
    --bs-table-hover-color: var(--bs-body-color);
}

/* Native select menus are otherwise rendered in a light colour scheme. */
[data-bs-theme="dark"] .form-select,
[data-bs-theme="blue-theme"] .form-select {
    color-scheme: dark;
}
