/* =============================================================
   Theme glue for shared and vendor components.

   Colours come from the tokens in app/themes/themes.css; this file only
   points the pieces that do not read those tokens on their own at them:
   the logo pair, Bootstrap 5.3 utilities that hard-code light colours,
   scrollbars and focus. Loaded after the component stylesheets.

   !important appears only where the Bootstrap utility being answered
   uses it itself (.bg-white, .text-dark and friends).
   ============================================================= */

/* ---------- Logo: one variant per theme ----------
   The sidebar and mobile top bar render both images; the light-text
   variant (images/png/synexusone-logo-dark.png) is the same artwork with
   the wordmark recoloured, not a filter. */
.app-logo.app-logo--dark {
    display: none;
}

[data-bs-theme="dark"] .app-logo.app-logo--light {
    display: none;
}

[data-bs-theme="dark"] .app-logo.app-logo--dark {
    display: block;
}

/* ---------- Page canvas, scrollbars, focus ---------- */
[data-bs-theme="dark"] {
    scrollbar-color: var(--scrollbar-thumb) transparent;
}

[data-bs-theme="dark"] ::selection {
    background: rgba(96, 165, 250, .35);
    color: var(--app-text);
}

/* A visible default ring for anything that does not draw its own. Zero
   specificity, so every component focus style still wins. */
:where([data-bs-theme="dark"]) :where(a, button, input, select, textarea, [tabindex]):focus-visible {
    outline: 2px solid var(--app-focus);
    outline-offset: 2px;
}

/* ---------- Bootstrap utilities with fixed light colours ---------- */
[data-bs-theme="dark"] .bg-white {
    background-color: var(--app-card) !important;
}

[data-bs-theme="dark"] .bg-light,
[data-bs-theme="dark"] .text-bg-light {
    background-color: var(--app-surface-subtle) !important;
    color: var(--app-text) !important;
}

[data-bs-theme="dark"] .text-dark,
[data-bs-theme="dark"] .text-black,
[data-bs-theme="dark"] .link-dark {
    color: var(--app-text) !important;
}

/* Bootstrap's dark .text-primary (#3b82f6) is 4:1 on cards; the theme's
   link blue reads at 5.6:1. Same for the other text colours. */
[data-bs-theme="dark"] .text-primary {
    color: var(--app-primary-text) !important;
}

[data-bs-theme="dark"] .text-success {
    color: var(--app-success-text) !important;
}

[data-bs-theme="dark"] .text-danger {
    color: var(--app-danger-text) !important;
}

[data-bs-theme="dark"] .text-warning {
    color: var(--app-warning-text) !important;
}

[data-bs-theme="dark"] .text-info {
    color: var(--app-info-text) !important;
}

[data-bs-theme="dark"] .text-muted,
[data-bs-theme="dark"] .text-secondary {
    color: var(--app-muted) !important;
}

/* Outline buttons in a colour: the label and edge use the lighter theme
   text colours (Bootstrap's dark outline-danger label is 3.2:1); the hover
   fill is button-hover.css. */
[data-bs-theme="dark"] .btn-outline-danger {
    --bs-btn-color: var(--app-danger-text);
    --bs-btn-border-color: var(--app-danger-border);
}

[data-bs-theme="dark"] .btn-outline-success {
    --bs-btn-color: var(--app-success-text);
    --bs-btn-border-color: var(--app-success-border);
}

[data-bs-theme="dark"] .btn-outline-warning {
    --bs-btn-color: var(--app-warning-text);
    --bs-btn-border-color: var(--app-warning-border);
}

[data-bs-theme="dark"] .btn-outline-info {
    --bs-btn-color: var(--app-info-text);
    --bs-btn-border-color: var(--app-info-border);
}

[data-bs-theme="dark"] .border-light {
    border-color: var(--app-border) !important;
}

/* ---------- Tailwind-style colour utilities ----------
   Calendar, Engagement, the Leave employee calendar and the employee forms
   define these classes in their own <style> with fixed light colours (grey
   off-month cells, near-black headings, pastel event chips). In the dark
   theme they take the matching tokens. */
[data-bs-theme="dark"] :is(.bg-gray-50, .bg-gray-100) {
    background-color: var(--app-surface-muted) !important;
}

[data-bs-theme="dark"] .hover\:bg-gray-50:hover {
    background-color: var(--app-hover) !important;
}

[data-bs-theme="dark"] :is(.text-gray-900, .text-gray-800) {
    color: var(--app-text) !important;
}

[data-bs-theme="dark"] :is(.text-gray-700, .text-gray-600, .hover\:text-gray-700:hover) {
    color: var(--app-text-secondary) !important;
}

[data-bs-theme="dark"] :is(.text-gray-500, .text-gray-400) {
    color: var(--app-muted) !important;
}

[data-bs-theme="dark"] :is(.border-gray-100, .border-gray-200, .border-gray-300) {
    border-color: var(--app-border) !important;
}

/* Side-only edges (Calendar's Month / Week / Day switch) default to gray-200. */
[data-bs-theme="dark"] :is(.border-l, .border-r, .border-t, .border-b) {
    border-color: var(--app-border);
}

[data-bs-theme="dark"] :is(.bg-yellow-50, .bg-yellow-100, .bg-amber-50, .bg-amber-100) {
    background-color: var(--app-warning-subtle) !important;
}

[data-bs-theme="dark"] :is(.text-yellow-700, .text-yellow-800, .text-amber-700, .text-amber-800) {
    color: var(--app-warning-text) !important;
}

[data-bs-theme="dark"] :is(.border-yellow-200, .border-amber-200) {
    border-color: var(--app-warning-border) !important;
}

[data-bs-theme="dark"] :is(.bg-red-50, .bg-red-100) {
    background-color: var(--app-danger-subtle) !important;
}

[data-bs-theme="dark"] :is(.text-red-700, .text-red-800) {
    color: var(--app-danger-text) !important;
}

[data-bs-theme="dark"] .border-red-200 {
    border-color: var(--app-danger-border) !important;
}

[data-bs-theme="dark"] :is(.bg-green-50, .bg-green-100, .bg-emerald-50, .bg-emerald-100) {
    background-color: var(--app-success-subtle) !important;
}

[data-bs-theme="dark"] :is(.text-green-700, .text-green-800, .text-emerald-700, .text-emerald-800) {
    color: var(--app-success-text) !important;
}

[data-bs-theme="dark"] :is(.border-green-200, .border-emerald-200) {
    border-color: var(--app-success-border) !important;
}

[data-bs-theme="dark"] :is(.bg-blue-50, .bg-blue-100) {
    background-color: var(--app-primary-subtle) !important;
}

[data-bs-theme="dark"] :is(.text-blue-700, .text-blue-800) {
    color: var(--app-primary-text) !important;
}

[data-bs-theme="dark"] .border-blue-200 {
    border-color: var(--app-primary-border) !important;
}

[data-bs-theme="dark"] :is(.bg-indigo-50, .bg-indigo-100, .bg-purple-50, .bg-purple-100) {
    background-color: var(--app-accent-subtle) !important;
}

[data-bs-theme="dark"] :is(.text-indigo-700, .text-indigo-800, .text-purple-700, .text-purple-800) {
    color: var(--app-accent-text) !important;
}

[data-bs-theme="dark"] :is(.border-indigo-200, .border-purple-200) {
    border-color: var(--app-accent-border) !important;
}

[data-bs-theme="dark"] .text-red-600 {
    color: var(--app-danger-text) !important;
}

[data-bs-theme="dark"] :is(.text-green-600, .text-emerald-600) {
    color: var(--app-success-text) !important;
}

[data-bs-theme="dark"] :is(.text-yellow-600, .text-amber-600) {
    color: var(--app-warning-text) !important;
}

[data-bs-theme="dark"] .text-blue-600 {
    color: var(--app-primary-text) !important;
}

[data-bs-theme="dark"] .hover\:bg-red-100:hover {
    background-color: var(--app-danger-subtle) !important;
}

/* The Calendar legend's pending swatch mirrors the indigo chips above. */
[data-bs-theme="dark"] .cal-legend-swatch--pending {
    background: var(--app-accent-subtle);
    border-color: var(--app-accent-border);
}

/* ---------- Fixed light edges ----------
   site.css gives bare inputs and selects a lightgrey border; this matches
   that rule's weight, so any component input style still wins. Inline
   "lightgrey" borders (New Employee's form card) take the theme border. */
:where([data-bs-theme="dark"]) :is(select, input) {
    border-color: var(--app-input-border);
}

[data-bs-theme="dark"] [style*="lightgrey"] {
    border-color: var(--app-border) !important;
}

/* ---------- Workforce Admin (WorkforceMobility/Admin) ----------
   Its hero is a pale blue and pink wash, and the subtitle reads --muted,
   which is a background colour in this app. */
[data-bs-theme="dark"] .wf-shell {
    background:
        radial-gradient(75rem 55rem at 10% -15%, rgba(59, 130, 246, .14) 0%, transparent 45%),
        radial-gradient(65rem 40rem at 110% 5%, rgba(236, 72, 153, .08) 0%, transparent 52%),
        var(--app-bg);
}

[data-bs-theme="dark"] .wf-shell :is(.app-meta, .wf-sub) {
    color: var(--app-muted);
}

[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] .thead-light {
    --bs-table-bg: var(--app-surface-muted);
    --bs-table-color: var(--app-text);
    --bs-table-border-color: var(--app-border);
    color: var(--app-text);
}

/* Bootstrap tables paint cells from --bs-table-bg (default: body bg).
   Cards are lighter than the page in dark, so tables follow the card. */
[data-bs-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-color: var(--app-text);
    --bs-table-border-color: var(--app-border);
    --bs-table-striped-bg: rgba(255, 255, 255, .03);
    --bs-table-striped-color: var(--app-text);
    --bs-table-hover-bg: rgba(255, 255, 255, .05);
    --bs-table-hover-color: var(--app-text);
}

[data-bs-theme="dark"] .btn-light {
    --bs-btn-bg: var(--app-surface-subtle);
    --bs-btn-border-color: var(--app-border);
    --bs-btn-color: var(--app-text);
    --bs-btn-hover-bg: var(--app-hover);
    --bs-btn-hover-border-color: var(--app-border-strong);
    --bs-btn-hover-color: var(--app-text);
    --bs-btn-active-bg: var(--app-hover);
    --bs-btn-active-color: var(--app-text);
}

/* Bootstrap's #6c757d outline buttons are 3:1 on a dark card. */
[data-bs-theme="dark"] .btn-outline-secondary {
    --bs-btn-color: var(--app-text-secondary);
    --bs-btn-border-color: var(--app-border-strong);
    --bs-btn-hover-bg: var(--app-hover);
    --bs-btn-hover-border-color: var(--app-border-strong);
    --bs-btn-hover-color: var(--app-text);
    --bs-btn-active-bg: var(--app-hover);
    --bs-btn-active-color: var(--app-text);
}

[data-bs-theme="dark"] .btn-outline-dark {
    --bs-btn-color: var(--app-text);
    --bs-btn-border-color: var(--app-border-strong);
    --bs-btn-hover-bg: var(--app-text);
    --bs-btn-hover-border-color: var(--app-text);
    --bs-btn-hover-color: var(--app-bg);
}

/* Menus, popovers and dialogs sit one step above the card. */
[data-bs-theme="dark"] .dropdown-menu,
[data-bs-theme="dark"] .popover {
    --bs-dropdown-bg: var(--app-elevated);
    --bs-dropdown-link-color: var(--app-text);
    --bs-dropdown-link-hover-bg: var(--app-hover);
    --bs-dropdown-link-hover-color: var(--app-text);
    --bs-dropdown-border-color: var(--app-border);
    --bs-popover-bg: var(--app-elevated);
    --bs-popover-border-color: var(--app-border);
    --bs-popover-header-bg: var(--app-surface-subtle);
}

[data-bs-theme="dark"] .modal {
    --bs-modal-bg: var(--app-card);
    --bs-modal-color: var(--app-text);
    --bs-modal-border-color: var(--app-border);
    --bs-modal-header-border-color: var(--app-border);
    --bs-modal-footer-border-color: var(--app-border);
}

[data-bs-theme="dark"] .modal-backdrop {
    --bs-backdrop-bg: #020617;
    --bs-backdrop-opacity: .7;
}

[data-bs-theme="dark"] .form-control::placeholder,
[data-bs-theme="dark"] textarea::placeholder,
[data-bs-theme="dark"] input::placeholder {
    color: var(--app-input-placeholder);
    opacity: 1;
}

[data-bs-theme="dark"] .form-control:disabled,
[data-bs-theme="dark"] .form-select:disabled {
    background-color: var(--app-input-disabled-bg);
    color: var(--app-muted);
}

[data-bs-theme="dark"] .form-check-input {
    background-color: var(--app-input-bg);
    border-color: var(--app-input-border);
}

[data-bs-theme="dark"] .form-check-input:checked {
    background-color: var(--app-primary);
    border-color: var(--app-primary);
}

[data-bs-theme="dark"] .nav-tabs {
    --bs-nav-tabs-border-color: var(--app-border);
    --bs-nav-tabs-link-hover-border-color: var(--app-border) var(--app-border) var(--app-border);
    --bs-nav-tabs-link-active-bg: var(--app-card);
    --bs-nav-tabs-link-active-color: var(--app-text);
    --bs-nav-tabs-link-active-border-color: var(--app-border) var(--app-border) var(--app-card);
}

[data-bs-theme="dark"] .list-group {
    --bs-list-group-bg: var(--app-card);
    --bs-list-group-color: var(--app-text);
    --bs-list-group-border-color: var(--app-border);
    --bs-list-group-action-hover-bg: var(--app-hover);
}

[data-bs-theme="dark"] .progress {
    --bs-progress-bg: var(--app-surface-subtle);
}

/* ---------- Document and image previews ----------
   Documents and pictures are content: they keep a light page, framed so
   the frame reads as part of the dark UI. */
[data-bs-theme="dark"] :is(iframe, embed, object)[src] {
    background: #ffffff;
    color-scheme: light;
}
