/* ================================================================
   Taskify — Dark Mode
   Colour layer only. Every rule is scoped to html[data-app-theme="dark"],
   so light mode is untouched. Toggled by assets/js/dark-mode.js; the
   attribute is set by an inline script in layout.blade.php <head>
   before first paint (no white flash).
================================================================ */

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

    /* Surfaces — deep near-black with a cool purple tint; each layer a step lighter */
    --dm-bg: #0d0d14;
    --dm-surface-1: #121219;       /* sidebar, navbar */
    --dm-surface-2: #17171f;       /* cards */
    --dm-surface-3: #1d1d28;       /* modals, dropdowns, popovers */
    --dm-surface-4: #242431;       /* inputs, hover, raised */
    --dm-hover: rgba(255, 255, 255, 0.04);

    /* Borders instead of shadows */
    --dm-border: rgba(255, 255, 255, 0.07);
    --dm-border-strong: rgba(255, 255, 255, 0.11);

    /* Text — never pure white. Contrast on --dm-surface-2:
       heading ≈15:1, body ≈9:1, muted ≈5:1 (all ≥ WCAG AA 4.5:1) */
    --dm-heading: #ececf3;
    --dm-text: #b9b9cb;
    --dm-muted: #8b8ba3;

    /* Brand */
    --dm-primary: #7a2bf2;
    --dm-primary-hover: #8b45f5;
    --dm-primary-text: #ac85ff;    /* purple used AS text/icon — 5.8:1 on cards */
    --dm-primary-soft: rgba(122, 43, 242, 0.16);
    --dm-primary-ring: rgba(122, 43, 242, 0.38);
    --dm-glow: 0 0 0 1px rgba(122, 43, 242, 0.45), 0 4px 18px -2px rgba(122, 43, 242, 0.45);

    /* Bootstrap variables */
    --bs-body-bg: var(--dm-bg);
    --bs-body-bg-rgb: 13, 13, 20;
    --bs-body-color: var(--dm-text);
    --bs-body-color-rgb: 185, 185, 203;
    --bs-light: #1d1d28;
    --bs-light-rgb: 29, 29, 40;

    background-color: var(--dm-bg);
}

/* ---------- Theme-switch transition (class added only while switching) ---------- */
html.theme-transition,
html.theme-transition *,
html.theme-transition *::before,
html.theme-transition *::after {
    transition: background-color 200ms ease, border-color 200ms ease,
        color 200ms ease, fill 200ms ease, box-shadow 200ms ease !important;
    transition-delay: 0s !important;
}

@media (prefers-reduced-motion: reduce) {
    html.theme-transition,
    html.theme-transition * {
        transition: none !important;
    }
}

/* ---------- Base ---------- */
html[data-app-theme="dark"] body,
html[data-app-theme="dark"] .layout-wrapper,
html[data-app-theme="dark"] .layout-page,
html[data-app-theme="dark"] .content-wrapper {
    background-color: var(--dm-bg);
    color: var(--dm-text);
}

html[data-app-theme="dark"] h1, html[data-app-theme="dark"] .h1,
html[data-app-theme="dark"] h2, html[data-app-theme="dark"] .h2,
html[data-app-theme="dark"] h3, html[data-app-theme="dark"] .h3,
html[data-app-theme="dark"] h4, html[data-app-theme="dark"] .h4,
html[data-app-theme="dark"] h5, html[data-app-theme="dark"] .h5,
html[data-app-theme="dark"] h6, html[data-app-theme="dark"] .h6,
html[data-app-theme="dark"] .card-title,
html[data-app-theme="dark"] .modal-title,
html[data-app-theme="dark"] .fw-bold,
html[data-app-theme="dark"] .fw-semibold,
html[data-app-theme="dark"] strong,
html[data-app-theme="dark"] b {
    color: var(--dm-heading);
}

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

html[data-app-theme="dark"] .text-muted,
html[data-app-theme="dark"] .text-secondary,
html[data-app-theme="dark"] .form-text,
html[data-app-theme="dark"] small.text-muted,
html[data-app-theme="dark"] .breadcrumb-item,
html[data-app-theme="dark"] .breadcrumb-item::before {
    color: var(--dm-muted) !important;
}

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

html[data-app-theme="dark"] a {
    color: var(--dm-primary-text);
}

html[data-app-theme="dark"] a:hover {
    color: #c3a6ff;
}

html[data-app-theme="dark"] .breadcrumb-item a,
html[data-app-theme="dark"] .breadcrumb-item.active {
    color: var(--dm-text) !important;
}

html[data-app-theme="dark"] hr,
html[data-app-theme="dark"] .dropdown-divider {
    border-color: var(--dm-border);
    color: var(--dm-border);
    opacity: 1;
}

html[data-app-theme="dark"] ::selection {
    background: rgba(122, 43, 242, 0.45);
    color: #fff;
}

html[data-app-theme="dark"] ::-webkit-scrollbar-thumb {
    background: #2c2c3a;
}

html[data-app-theme="dark"] ::-webkit-scrollbar-track {
    background: transparent;
}

/* ---------- Utilities with hard-coded light colours ---------- */
html[data-app-theme="dark"] .bg-white,
html[data-app-theme="dark"] .bg-body {
    background-color: var(--dm-surface-2) !important;
}

html[data-app-theme="dark"] .bg-light,
html[data-app-theme="dark"] .bg-lighter,
html[data-app-theme="dark"] .bg-lightest {
    background-color: var(--dm-surface-4) !important;
}

html[data-app-theme="dark"] .border,
html[data-app-theme="dark"] .border-top,
html[data-app-theme="dark"] .border-bottom,
html[data-app-theme="dark"] .border-start,
html[data-app-theme="dark"] .border-end,
html[data-app-theme="dark"] .border-light {
    border-color: var(--dm-border) !important;
}

html[data-app-theme="dark"] .shadow,
html[data-app-theme="dark"] .shadow-sm,
html[data-app-theme="dark"] .shadow-lg {
    box-shadow: none !important;
}

/* ---------- Navbar ---------- */
html[data-app-theme="dark"] .bg-navbar-theme,
html[data-app-theme="dark"] .layout-navbar {
    background-color: var(--dm-surface-1) !important;
    color: var(--dm-text);
}

html[data-app-theme="dark"] .layout-navbar {
    border: 1px solid var(--dm-border);
    box-shadow: none !important;
}

html[data-app-theme="dark"] .layout-navbar .nav-link,
html[data-app-theme="dark"] .layout-navbar .navbar-nav-right,
html[data-app-theme="dark"] .layout-navbar #global-search,
html[data-app-theme="dark"] .layout-navbar .bx {
    color: var(--dm-text);
}

html[data-app-theme="dark"] .btn.btn-icon-subtle {
    color: var(--dm-primary-text) !important;
}

html[data-app-theme="dark"] .btn.btn-icon-subtle:hover,
html[data-app-theme="dark"] .btn.btn-icon-subtle:active {
    color: #fff !important;
    background: var(--dm-primary) !important;
    box-shadow: var(--dm-glow);
}

/* Avatar status dot: its ring matches whatever surface it sits on */
html[data-app-theme="dark"] .avatar.avatar-online::after,
html[data-app-theme="dark"] .avatar.avatar-offline::after,
html[data-app-theme="dark"] .avatar.avatar-away::after,
html[data-app-theme="dark"] .avatar.avatar-busy::after {
    box-shadow: 0 0 0 2px var(--dm-surface-2);
}

html[data-app-theme="dark"] .layout-navbar .avatar.avatar-online::after {
    box-shadow: 0 0 0 2px var(--dm-surface-1);
}

/* Stacked avatars (project cards, tables) had a white separator ring */
html[data-app-theme="dark"] .avatar-group .avatar img,
html[data-app-theme="dark"] .avatar-group .avatar .avatar-initial {
    border-color: var(--dm-surface-2);
}

/* Theme toggle button (light + dark) */
.theme-toggle .theme-icon-sun {
    display: none;
}

html[data-app-theme="dark"] .theme-toggle .theme-icon-sun {
    display: inline-block;
}

html[data-app-theme="dark"] .theme-toggle .theme-icon-moon {
    display: none;
}

/* ---------- Footer ---------- */
html[data-app-theme="dark"] .bg-footer-theme,
html[data-app-theme="dark"] .content-footer {
    background-color: var(--dm-bg) !important;
    color: var(--dm-muted);
}

/* ---------- Sidebar ---------- */
html[data-app-theme="dark"] #layout-menu.menu-container {
    --sidebar-primary: var(--dm-primary-text);
    --sidebar-primary-soft: var(--dm-primary-soft);
    --sidebar-primary-ring: var(--dm-primary-ring);
    --sidebar-text: var(--dm-text);
    --sidebar-muted: var(--dm-muted);
    --sidebar-border: var(--dm-border);
    --sidebar-surface: var(--dm-surface-1);
    --sidebar-hover: var(--dm-hover);
    --sidebar-active-shadow: var(--dm-glow);

    background:
        radial-gradient(circle at 20% 0%, rgba(122, 43, 242, 0.10), transparent 240px),
        var(--dm-surface-1) !important;
    border-right: 1px solid var(--dm-border);
    box-shadow: none;
    color: var(--dm-text);
}

html[data-app-theme="dark"] #layout-menu .app-brand,
html[data-app-theme="dark"] #layout-menu .menu-sidebar-header {
    background: rgba(18, 18, 25, 0.88);
    border-bottom-color: var(--dm-border);
    box-shadow: none;
}

html[data-app-theme="dark"] #layout-menu .menu-workspace-toggle > button,
html[data-app-theme="dark"] #layout-menu #clear-search,
html[data-app-theme="dark"] #layout-menu .menu-collapse-link {
    color: var(--dm-muted) !important;
}

html[data-app-theme="dark"] #layout-menu .menu-collapse-link,
html[data-app-theme="dark"] #layout-menu #menu-search {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

html[data-app-theme="dark"] #layout-menu #menu-search:hover,
html[data-app-theme="dark"] #layout-menu #menu-search:focus {
    background-color: var(--dm-surface-4);
    border-color: rgba(122, 43, 242, 0.55);
}

html[data-app-theme="dark"] #layout-menu #menu-search + span kbd {
    background: var(--dm-surface-3);
    color: var(--dm-muted);
    border: 1px solid var(--dm-border);
}

html[data-app-theme="dark"] #layout-menu .menu-inner {
    scrollbar-color: #2c2c3a transparent;
}

html[data-app-theme="dark"] #layout-menu .menu-inner::-webkit-scrollbar-thumb {
    background: #2c2c3a;
}

html[data-app-theme="dark"] #layout-menu .menu-header-text::before {
    background: #5b3f8c;
}

html[data-app-theme="dark"] #layout-menu .menu-link,
html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link {
    color: var(--dm-text);
}

html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link .menu-icon,
html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link > svg,
html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link > i {
    color: var(--dm-muted);
}

html[data-app-theme="dark"] .menu-inner .menu-link:hover,
html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link:hover,
html[data-app-theme="dark"] #layout-menu .menu-sub .menu-link:hover {
    color: var(--dm-heading) !important;
    background: var(--dm-hover) !important;
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link:hover .menu-icon,
html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link:hover > svg,
html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link:hover > i {
    color: var(--dm-primary-text) !important;
}

html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link:not(.menu-toggle)::after {
    background: linear-gradient(100deg, rgba(255, 255, 255, 0.03), transparent 55%);
}

/* Active item — the one place the purple glows */
html[data-app-theme="dark"] .menu-inner .menu-item.active > .menu-link,
html[data-app-theme="dark"] #layout-menu .menu-inner .menu-item.active > .menu-link,
html[data-app-theme="dark"] #layout-menu .menu-inner .menu-item.open.active > .menu-link {
    color: var(--dm-heading) !important;
    background: linear-gradient(100deg, rgba(122, 43, 242, 0.30) 0%, rgba(122, 43, 242, 0.10) 100%) !important;
    border-color: rgba(122, 43, 242, 0.40);
    box-shadow: 0 4px 18px -4px rgba(122, 43, 242, 0.45);
}

html[data-app-theme="dark"] #layout-menu .menu-inner .menu-item.active > .menu-link .menu-icon,
html[data-app-theme="dark"] #layout-menu .menu-inner .menu-item.active > .menu-link > svg,
html[data-app-theme="dark"] #layout-menu .menu-inner .menu-item.active > .menu-link > i {
    color: var(--dm-primary-text) !important;
}

html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item.active > .menu-link::before {
    background: var(--dm-primary-text) !important;
    box-shadow: 0 0 10px rgba(122, 43, 242, 0.8);
}

html[data-app-theme="dark"] #layout-menu .menu-sub::before {
    background: var(--dm-border-strong);
}

html[data-app-theme="dark"] #layout-menu .menu-sub .menu-link {
    color: var(--dm-muted);
}

html[data-app-theme="dark"] #layout-menu .menu-sub .menu-link::before {
    background: #3a3a4c;
}

html[data-app-theme="dark"] .menu-inner .menu-sub .menu-item.active > .menu-link,
html[data-app-theme="dark"] #layout-menu .menu-sub .menu-item.active > .menu-link {
    color: var(--dm-primary-text) !important;
    background: var(--dm-primary-soft) !important;
    box-shadow: none;
    border-color: transparent;
}

html[data-app-theme="dark"] #layout-menu .menu-link .badge {
    border-color: var(--dm-surface-1);
    box-shadow: none;
}

html[data-app-theme="dark"] .bg-menu-theme {
    background-color: var(--dm-surface-1) !important;
    color: var(--dm-text);
}

html[data-app-theme="dark"] .layout-overlay {
    background: rgba(0, 0, 0, 0.6);
}

/* ---------- Cards ---------- */
html[data-app-theme="dark"] .card {
    background-color: var(--dm-surface-2);
    border: 1px solid var(--dm-border);
    box-shadow: none;
    color: var(--dm-text);
}

html[data-app-theme="dark"] .card-header,
html[data-app-theme="dark"] .card-footer {
    background-color: transparent;
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .card.card-hover-border-gray:hover,
html[data-app-theme="dark"] .card .card-hover-border-gray:hover {
    border-color: var(--dm-border-strong);
}

/* ---------- Buttons ---------- */
html[data-app-theme="dark"] .btn-primary {
    background-color: var(--dm-primary);
    border-color: var(--dm-primary);
    color: #fff;
}

html[data-app-theme="dark"] .btn-primary:hover,
html[data-app-theme="dark"] .btn-primary:focus,
html[data-app-theme="dark"] .btn-primary.active,
html[data-app-theme="dark"] .btn-primary:active {
    background-color: var(--dm-primary-hover);
    border-color: var(--dm-primary-hover);
    color: #fff;
    box-shadow: var(--dm-glow);
}

html[data-app-theme="dark"] .btn-outline-primary {
    color: var(--dm-primary-text);
    border-color: rgba(122, 43, 242, 0.6);
}

html[data-app-theme="dark"] .btn-outline-primary:hover,
html[data-app-theme="dark"] .btn-outline-primary.active {
    color: #fff;
    background-color: var(--dm-primary);
    border-color: var(--dm-primary);
}

html[data-app-theme="dark"] .btn-secondary,
html[data-app-theme="dark"] .btn-light {
    color: var(--dm-heading);
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .btn-secondary:hover,
html[data-app-theme="dark"] .btn-light:hover {
    color: var(--dm-heading);
    background-color: #2d2d3c;
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .btn-outline-secondary,
html[data-app-theme="dark"] .btn-outline-dark,
html[data-app-theme="dark"] .btn-outline-light {
    color: var(--dm-text);
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .btn-outline-secondary:hover,
html[data-app-theme="dark"] .btn-outline-dark:hover,
html[data-app-theme="dark"] .btn-outline-light:hover {
    color: var(--dm-heading);
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .btn-dark {
    color: #12121a;
    background-color: #d8d8e4;
    border-color: #d8d8e4;
}

html[data-app-theme="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(1.6);
}

/* ---------- Forms ---------- */
html[data-app-theme="dark"] .form-control,
html[data-app-theme="dark"] .form-select,
html[data-app-theme="dark"] .input-group-text,
html[data-app-theme="dark"] textarea,
html[data-app-theme="dark"] input[type="text"],
html[data-app-theme="dark"] input[type="email"],
html[data-app-theme="dark"] input[type="number"],
html[data-app-theme="dark"] input[type="password"],
html[data-app-theme="dark"] input[type="search"],
html[data-app-theme="dark"] input[type="date"],
html[data-app-theme="dark"] input[type="tel"],
html[data-app-theme="dark"] input[type="url"] {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border-strong);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .form-control::placeholder,
html[data-app-theme="dark"] textarea::placeholder,
html[data-app-theme="dark"] input::placeholder {
    color: #6f6f86;
}

html[data-app-theme="dark"] .form-control:focus,
html[data-app-theme="dark"] .form-select:focus,
html[data-app-theme="dark"] textarea:focus,
html[data-app-theme="dark"] input:focus {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-primary);
    color: var(--dm-heading);
    box-shadow: 0 0 0 3px var(--dm-primary-ring);
}

html[data-app-theme="dark"] .input-group:focus-within .input-group-text {
    border-color: var(--dm-primary);
}

html[data-app-theme="dark"] .form-control:disabled,
html[data-app-theme="dark"] .form-control[readonly],
html[data-app-theme="dark"] .form-select:disabled {
    background-color: #1a1a24;
    color: var(--dm-muted);
}

html[data-app-theme="dark"] .form-select {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%238b8ba3' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

html[data-app-theme="dark"] .form-select option,
html[data-app-theme="dark"] select option {
    background-color: var(--dm-surface-3);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .form-label,
html[data-app-theme="dark"] label,
html[data-app-theme="dark"] .col-form-label {
    color: var(--dm-text);
}

html[data-app-theme="dark"] .form-check-input {
    background-color: var(--dm-surface-4);
    border-color: #4a4a5e;
}

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

html[data-app-theme="dark"] .form-check-input:focus {
    box-shadow: 0 0 0 3px var(--dm-primary-ring);
}

html[data-app-theme="dark"] .form-switch .form-check-input:not(:checked) {
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='-4 -4 8 8'%3e%3ccircle r='3' fill='%238b8ba3'/%3e%3c/svg%3e");
}

/* File inputs — the "Choose File" button was white */
html[data-app-theme="dark"] .form-control::file-selector-button,
html[data-app-theme="dark"] input[type="file"]::file-selector-button {
    color: var(--dm-text);
    background-color: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .form-control:hover:not(:disabled):not([readonly])::file-selector-button {
    background-color: #2d2d3c;
}

html[data-app-theme="dark"] input[type="date"]::-webkit-calendar-picker-indicator,
html[data-app-theme="dark"] input[type="time"]::-webkit-calendar-picker-indicator {
    filter: invert(0.7);
}

/* Select2 */
html[data-app-theme="dark"] .select2-container--default .select2-selection--single,
html[data-app-theme="dark"] .select2-container--default .select2-selection--multiple {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .select2-container--default.select2-container--focus .select2-selection--multiple,
html[data-app-theme="dark"] .select2-container--default.select2-container--open .select2-selection--single,
html[data-app-theme="dark"] .select2-container--default.select2-container--open .select2-selection--multiple {
    border-color: var(--dm-primary);
}

html[data-app-theme="dark"] .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .select2-container--default .select2-selection__placeholder {
    color: #6f6f86;
}

html[data-app-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice {
    background-color: var(--dm-primary-soft);
    border-color: rgba(122, 43, 242, 0.35);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .select2-container--default .select2-selection--multiple .select2-selection__choice__remove {
    color: var(--dm-primary-text);
    border-color: rgba(122, 43, 242, 0.35);
}

html[data-app-theme="dark"] .select2-dropdown {
    background-color: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .select2-container--default .select2-search--dropdown .select2-search__field,
html[data-app-theme="dark"] .select2-container--default .select2-search--inline .select2-search__field {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border-strong);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .select2-container--default .select2-results__option[aria-selected="true"],
html[data-app-theme="dark"] .select2-container--default .select2-results__option--selected {
    background-color: var(--dm-surface-4);
}

html[data-app-theme="dark"] .select2-container--default .select2-results__option--highlighted[aria-selected],
html[data-app-theme="dark"] .select2-container--default .select2-results__option--highlighted.select2-results__option--selectable {
    background-color: var(--dm-primary);
    color: #fff;
}

/* intl-tel-input */
html[data-app-theme="dark"] .iti__country-list {
    background-color: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .iti__country.iti__highlight {
    background-color: var(--dm-surface-4);
}

html[data-app-theme="dark"] .iti__divider {
    border-color: var(--dm-border);
}

/* ---------- Tables (incl. bootstrap-table) ---------- */
html[data-app-theme="dark"] .table {
    --bs-table-bg: transparent;
    --bs-table-accent-bg: transparent;
    --bs-table-striped-bg: rgba(255, 255, 255, 0.02);
    --bs-table-striped-color: var(--dm-text);
    --bs-table-hover-bg: rgba(255, 255, 255, 0.035);
    --bs-table-hover-color: var(--dm-heading);
    --bs-table-active-bg: var(--dm-primary-soft);
    color: var(--dm-text);
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .table > :not(caption) > * > * {
    border-bottom-color: var(--dm-border);
    color: inherit;
}

html[data-app-theme="dark"] .table > :not(:first-child) {
    border-top-color: var(--dm-border);
}

html[data-app-theme="dark"] .table th,
html[data-app-theme="dark"] .table thead th,
html[data-app-theme="dark"] .table-light,
html[data-app-theme="dark"] .table-light > * > * {
    background-color: transparent;
    color: var(--dm-muted);
}

html[data-app-theme="dark"] .table thead th {
    background-color: rgba(255, 255, 255, 0.025) !important;
}

html[data-app-theme="dark"] .table-bordered > :not(caption) > *,
html[data-app-theme="dark"] .table-bordered > :not(caption) > * > * {
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .bootstrap-table .fixed-table-container,
html[data-app-theme="dark"] .bootstrap-table .fixed-table-container .table thead th,
html[data-app-theme="dark"] .bootstrap-table .fixed-table-container.fixed-height:not(.has-footer),
html[data-app-theme="dark"] .bootstrap-table .fixed-table-container .fixed-table-body {
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .bootstrap-table .fixed-table-container .fixed-table-body .fixed-table-loading {
    background-color: var(--dm-surface-2);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .bootstrap-table .fixed-table-pagination,
html[data-app-theme="dark"] .bootstrap-table .fixed-table-toolbar {
    color: var(--dm-text);
}

html[data-app-theme="dark"] .fixed-table-toolbar .keep-open .dropdown-menu label,
html[data-app-theme="dark"] .fixed-table-toolbar .dropdown-menu .dropdown-item {
    color: var(--dm-text);
}

/* ---------- Dropdowns ---------- */
html[data-app-theme="dark"] .dropdown-menu {
    background-color: var(--dm-surface-3);
    border: 1px solid var(--dm-border-strong);
    box-shadow: 0 12px 32px rgba(0, 0, 0, 0.45);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .dropdown-item,
html[data-app-theme="dark"] .dropdown-menu a:not(.btn) {
    color: var(--dm-text);
}

html[data-app-theme="dark"] .dropdown-item:hover,
html[data-app-theme="dark"] .dropdown-item:focus {
    background-color: var(--dm-surface-4);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .dropdown-item.active,
html[data-app-theme="dark"] .dropdown-item:active {
    background-color: var(--dm-primary-soft);
    color: var(--dm-primary-text);
}

html[data-app-theme="dark"] .dropdown-header,
html[data-app-theme="dark"] .dropdown-header-highlighted {
    color: var(--dm-heading);
    background-color: transparent;
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .dropdown-notifications-item,
html[data-app-theme="dark"] .dropdown-notifications-list .list-group-item {
    background-color: transparent;
    border-color: var(--dm-border);
}

/* ---------- Modals / offcanvas / popovers / tooltips ---------- */
html[data-app-theme="dark"] .modal-content,
html[data-app-theme="dark"] .offcanvas {
    background-color: var(--dm-surface-3);
    border: 1px solid var(--dm-border-strong);
    box-shadow: 0 24px 60px rgba(0, 0, 0, 0.55);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .modal-header,
html[data-app-theme="dark"] .modal-footer,
html[data-app-theme="dark"] .offcanvas-header {
    border-color: var(--dm-border);
}

/* colour on the backdrop itself, not only .show: Bootstrap removes .show
   first and then fades opacity out, so a .show-only colour made the
   backdrop flash core.css's blue-grey (#435971) while opening/closing */
html[data-app-theme="dark"] .modal-backdrop {
    background-color: #050508;
}

html[data-app-theme="dark"] .modal-backdrop.show {
    opacity: 0.7;
}

html[data-app-theme="dark"] .popover {
    background-color: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .popover-header {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .popover-body {
    color: var(--dm-text);
}

html[data-app-theme="dark"] .bs-popover-top > .popover-arrow::after,
html[data-app-theme="dark"] .bs-popover-auto[data-popper-placement^="top"] > .popover-arrow::after {
    border-top-color: var(--dm-surface-3);
}

html[data-app-theme="dark"] .bs-popover-bottom > .popover-arrow::after,
html[data-app-theme="dark"] .bs-popover-auto[data-popper-placement^="bottom"] > .popover-arrow::after {
    border-bottom-color: var(--dm-surface-4);
}

html[data-app-theme="dark"] .tooltip-inner {
    background-color: #2b2b3a;
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .bs-tooltip-top .tooltip-arrow::before,
html[data-app-theme="dark"] .bs-tooltip-auto[data-popper-placement^="top"] .tooltip-arrow::before {
    border-top-color: #2b2b3a;
}

html[data-app-theme="dark"] .bs-tooltip-bottom .tooltip-arrow::before,
html[data-app-theme="dark"] .bs-tooltip-auto[data-popper-placement^="bottom"] .tooltip-arrow::before {
    border-bottom-color: #2b2b3a;
}

html[data-app-theme="dark"] .bs-tooltip-start .tooltip-arrow::before,
html[data-app-theme="dark"] .bs-tooltip-auto[data-popper-placement^="left"] .tooltip-arrow::before {
    border-left-color: #2b2b3a;
}

html[data-app-theme="dark"] .bs-tooltip-end .tooltip-arrow::before,
html[data-app-theme="dark"] .bs-tooltip-auto[data-popper-placement^="right"] .tooltip-arrow::before {
    border-right-color: #2b2b3a;
}

/* ---------- Navs, list groups, pagination, accordion ---------- */
html[data-app-theme="dark"] .nav-tabs {
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .nav-tabs .nav-link,
html[data-app-theme="dark"] .nav-pills .nav-link {
    color: var(--dm-muted);
}

html[data-app-theme="dark"] .nav-tabs .nav-link:hover,
html[data-app-theme="dark"] .nav-pills .nav-link:hover {
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .nav-tabs .nav-link.active,
html[data-app-theme="dark"] .nav-tabs .nav-item.show .nav-link {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border) var(--dm-border) var(--dm-surface-2);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .nav-pills .nav-link.active,
html[data-app-theme="dark"] .nav-pills .show > .nav-link {
    background-color: var(--dm-primary);
    color: #fff;
    box-shadow: var(--dm-glow);
}

html[data-app-theme="dark"] .tab-content {
    background-color: transparent;
}

html[data-app-theme="dark"] .list-group-item {
    background-color: transparent;
    border-color: var(--dm-border);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .list-group-item-action:hover,
html[data-app-theme="dark"] .list-group-item-action:focus {
    background-color: var(--dm-surface-4);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .list-group-item.active {
    background-color: var(--dm-primary-soft);
    border-color: rgba(122, 43, 242, 0.4);
    color: var(--dm-primary-text);
}

html[data-app-theme="dark"] .page-link {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .page-link:hover {
    background-color: #2d2d3c;
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .page-item.active .page-link,
html[data-app-theme="dark"] .page-item.active .page-link:hover {
    background-color: var(--dm-primary);
    border-color: var(--dm-primary);
    color: #fff;
    box-shadow: var(--dm-glow);
}

html[data-app-theme="dark"] .page-item.disabled .page-link {
    background-color: var(--dm-surface-2);
    color: #55556a;
}

html[data-app-theme="dark"] .accordion-item {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .accordion-button {
    background-color: var(--dm-surface-2);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .accordion-button:not(.collapsed) {
    background-color: var(--dm-surface-4);
    color: var(--dm-primary-text);
    box-shadow: inset 0 -1px 0 var(--dm-border);
}

html[data-app-theme="dark"] .accordion-button::after {
    filter: invert(0.8);
}

html[data-app-theme="dark"] .progress {
    background-color: var(--dm-surface-4);
}

/* ---------- Badges & alerts — soft tint, brighter text ---------- */
/* custom.css drives every .badge.bg-* and .bg-label-* through these variables;
   dark versions keep the same hues with lighter text and a slightly stronger tint. */
html[data-app-theme="dark"] {
    --modern-primary: #b794ff;
    --modern-primary-bg: rgba(122, 43, 242, 0.18);
    --modern-primary-border: rgba(122, 43, 242, 0.32);
    --modern-success: #34d399;
    --modern-success-bg: rgba(16, 185, 129, 0.14);
    --modern-success-border: rgba(16, 185, 129, 0.28);
    --modern-danger: #f87171;
    --modern-danger-bg: rgba(239, 68, 68, 0.15);
    --modern-danger-border: rgba(239, 68, 68, 0.30);
    --modern-warning: #fbbf24;
    --modern-warning-bg: rgba(245, 158, 11, 0.14);
    --modern-warning-border: rgba(245, 158, 11, 0.28);
    --modern-info: #22d3ee;
    --modern-info-bg: rgba(6, 182, 212, 0.14);
    --modern-info-border: rgba(6, 182, 212, 0.28);
    --modern-secondary: #a8b3c4;
    --modern-secondary-bg: rgba(100, 116, 139, 0.18);
    --modern-secondary-border: rgba(100, 116, 139, 0.32);
    --modern-dark: #d4d4e0;
    --modern-dark-bg: rgba(255, 255, 255, 0.08);
    --modern-dark-border: rgba(255, 255, 255, 0.14);
    --modern-light: #b9b9cb;
    --modern-light-bg: rgba(255, 255, 255, 0.06);
    --modern-light-border: rgba(255, 255, 255, 0.10);
    --modern-gray: #b4bfcf;
    --modern-gray-bg: rgba(148, 163, 184, 0.14);
    --modern-gray-border: rgba(148, 163, 184, 0.26);
}

/* Selected status/priority tag: the gap ring was white */
html[data-app-theme="dark"] .status-tag.selected,
html[data-app-theme="dark"] .priority-tag.selected {
    box-shadow: 0 0 0 2px var(--dm-surface-2), 0 0 0 4px currentColor;
}

html[data-app-theme="dark"] .alert-primary   { background-color: rgba(122, 43, 242, 0.14); border-color: rgba(122, 43, 242, 0.30); color: #c1a3ff; }
html[data-app-theme="dark"] .alert-secondary { background-color: rgba(133, 146, 163, 0.12); border-color: rgba(133, 146, 163, 0.25); color: #c4ccd6; }
html[data-app-theme="dark"] .alert-success   { background-color: rgba(113, 221, 55, 0.10);  border-color: rgba(113, 221, 55, 0.25);  color: #9de877; }
html[data-app-theme="dark"] .alert-info      { background-color: rgba(3, 195, 236, 0.10);   border-color: rgba(3, 195, 236, 0.25);   color: #6fdef8; }
html[data-app-theme="dark"] .alert-warning   { background-color: rgba(255, 171, 0, 0.10);   border-color: rgba(255, 171, 0, 0.25);   color: #ffd06b; }
html[data-app-theme="dark"] .alert-danger    { background-color: rgba(255, 62, 29, 0.10);   border-color: rgba(255, 62, 29, 0.25);   color: #ff9483; }
html[data-app-theme="dark"] .alert-dark,
html[data-app-theme="dark"] .alert-light     { background-color: rgba(255, 255, 255, 0.05); border-color: var(--dm-border-strong);    color: var(--dm-text); }

html[data-app-theme="dark"] .alert .alert-link {
    color: inherit;
}

/* ---------- Third-party widgets ---------- */
/* Date range picker */
html[data-app-theme="dark"] .daterangepicker {
    background-color: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .daterangepicker::before {
    border-bottom-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .daterangepicker::after {
    border-bottom-color: var(--dm-surface-3);
}

html[data-app-theme="dark"] .daterangepicker .calendar-table {
    background-color: var(--dm-surface-3);
    border-color: var(--dm-surface-3);
}

html[data-app-theme="dark"] .daterangepicker .calendar-table .next span,
html[data-app-theme="dark"] .daterangepicker .calendar-table .prev span {
    border-color: var(--dm-text);
}

html[data-app-theme="dark"] .daterangepicker td.off,
html[data-app-theme="dark"] .daterangepicker td.off.in-range,
html[data-app-theme="dark"] .daterangepicker td.off.start-date,
html[data-app-theme="dark"] .daterangepicker td.off.end-date {
    background-color: transparent;
    color: #55556a;
}

html[data-app-theme="dark"] .daterangepicker td.available:hover,
html[data-app-theme="dark"] .daterangepicker th.available:hover {
    background-color: var(--dm-surface-4);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .daterangepicker td.in-range {
    background-color: var(--dm-primary-soft);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .daterangepicker td.active,
html[data-app-theme="dark"] .daterangepicker td.active:hover {
    background-color: var(--dm-primary);
    color: #fff;
}

html[data-app-theme="dark"] .daterangepicker .ranges li:hover {
    background-color: var(--dm-surface-4);
}

html[data-app-theme="dark"] .daterangepicker .ranges li.active {
    background-color: var(--dm-primary);
    color: #fff;
}

html[data-app-theme="dark"] .daterangepicker .drp-buttons,
html[data-app-theme="dark"] .daterangepicker.show-ranges.ltr .drp-calendar.left {
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .daterangepicker select.hourselect,
html[data-app-theme="dark"] .daterangepicker select.minuteselect,
html[data-app-theme="dark"] .daterangepicker select.secondselect,
html[data-app-theme="dark"] .daterangepicker select.ampmselect,
html[data-app-theme="dark"] .daterangepicker select.monthselect,
html[data-app-theme="dark"] .daterangepicker select.yearselect {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border-strong);
    color: var(--dm-heading);
}

/* Bootstrap datetimepicker */
html[data-app-theme="dark"] .bootstrap-datetimepicker-widget.dropdown-menu {
    background-color: var(--dm-surface-3);
}

html[data-app-theme="dark"] .bootstrap-datetimepicker-widget table td.day:hover,
html[data-app-theme="dark"] .bootstrap-datetimepicker-widget table td.hour:hover,
html[data-app-theme="dark"] .bootstrap-datetimepicker-widget table td.minute:hover,
html[data-app-theme="dark"] .bootstrap-datetimepicker-widget table thead tr:first-child th:hover {
    background-color: var(--dm-surface-4);
}

/* FullCalendar (v4) */
html[data-app-theme="dark"] .fc-unthemed th,
html[data-app-theme="dark"] .fc-unthemed td,
html[data-app-theme="dark"] .fc-unthemed thead,
html[data-app-theme="dark"] .fc-unthemed tbody,
html[data-app-theme="dark"] .fc-unthemed .fc-divider,
html[data-app-theme="dark"] .fc-unthemed .fc-row,
html[data-app-theme="dark"] .fc-unthemed .fc-content,
html[data-app-theme="dark"] .fc-unthemed .fc-popover,
html[data-app-theme="dark"] .fc-unthemed .fc-list-view,
html[data-app-theme="dark"] .fc-unthemed .fc-list-heading td {
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .fc-unthemed .fc-popover,
html[data-app-theme="dark"] .fc-unthemed .fc-list-empty {
    background-color: var(--dm-surface-3);
}

html[data-app-theme="dark"] .fc-unthemed .fc-divider,
html[data-app-theme="dark"] .fc-unthemed .fc-popover .fc-header,
html[data-app-theme="dark"] .fc-unthemed .fc-list-heading td {
    background-color: var(--dm-surface-4);
}

html[data-app-theme="dark"] .fc-unthemed td.fc-today {
    background-color: rgba(122, 43, 242, 0.10);
}

html[data-app-theme="dark"] .fc-unthemed .fc-list-item:hover td {
    background-color: var(--dm-surface-4);
}

html[data-app-theme="dark"] .fc-day-number,
html[data-app-theme="dark"] .fc-day-header,
html[data-app-theme="dark"] .fc-toolbar h2 {
    color: var(--dm-text);
}

html[data-app-theme="dark"] .fc-button-primary:not(.fc-button-active) {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border-strong);
    color: var(--dm-text);
}

/* Dropzone */
html[data-app-theme="dark"] .dropzone {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border-strong);
    color: var(--dm-text);
}

/* Toastr — keep the coloured toasts, just soften the shadow */
html[data-app-theme="dark"] #toast-container > div {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
}

/* ================================================================
   Charts (ApexCharts) — colour layer for every chart in the app.
   Apex writes colours as SVG presentation attributes, which CSS
   overrides, so this re-themes charts instantly on toggle.
================================================================ */
html[data-app-theme="dark"] .apexcharts-canvas,
html[data-app-theme="dark"] .apexcharts-svg {
    background: transparent !important;
}

html[data-app-theme="dark"] .apexcharts-xaxis-label,
html[data-app-theme="dark"] .apexcharts-yaxis-label,
html[data-app-theme="dark"] .apexcharts-xaxis-title-text,
html[data-app-theme="dark"] .apexcharts-yaxis-title-text,
html[data-app-theme="dark"] .apexcharts-subtitle-text,
html[data-app-theme="dark"] .apexcharts-datalabel-label {
    fill: var(--dm-muted);
}

html[data-app-theme="dark"] .apexcharts-title-text {
    fill: var(--dm-heading);
}

/* Donut / radial centre number — a key number, so it gets the brand purple */
html[data-app-theme="dark"] .apexcharts-datalabel-value {
    fill: var(--dm-primary-text);
}

html[data-app-theme="dark"] .apexcharts-legend-text {
    color: var(--dm-text) !important;
}

/* Faint grid and axes */
html[data-app-theme="dark"] .apexcharts-gridline,
html[data-app-theme="dark"] .apexcharts-grid line,
html[data-app-theme="dark"] .apexcharts-grid-borders line {
    stroke: rgba(255, 255, 255, 0.06);
}

html[data-app-theme="dark"] .apexcharts-xaxis line,
html[data-app-theme="dark"] .apexcharts-yaxis line,
html[data-app-theme="dark"] .apexcharts-xaxis-tick,
html[data-app-theme="dark"] .apexcharts-yaxis-tick {
    stroke: rgba(255, 255, 255, 0.09);
}

html[data-app-theme="dark"] .apexcharts-grid-row {
    fill: transparent;
}

html[data-app-theme="dark"] .apexcharts-xcrosshairs,
html[data-app-theme="dark"] .apexcharts-ycrosshairs {
    stroke: rgba(255, 255, 255, 0.15);
}

/* Slice separators and markers blend into the card instead of white */
html[data-app-theme="dark"] .apexcharts-pie-area {
    stroke: var(--dm-surface-2);
}

html[data-app-theme="dark"] .apexcharts-marker {
    stroke: var(--dm-surface-2);
}

html[data-app-theme="dark"] .apexcharts-radialbar-track .apexcharts-radialbar-area {
    stroke: var(--dm-surface-4);
}

/* Dark tooltips (both of Apex's tooltip themes) */
html[data-app-theme="dark"] .apexcharts-tooltip.apexcharts-theme-light,
html[data-app-theme="dark"] .apexcharts-tooltip.apexcharts-theme-dark {
    background: rgba(29, 29, 40, 0.96);
    border: 1px solid var(--dm-border-strong);
    box-shadow: 0 10px 28px rgba(0, 0, 0, 0.5);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .apexcharts-tooltip.apexcharts-theme-light .apexcharts-tooltip-title,
html[data-app-theme="dark"] .apexcharts-tooltip.apexcharts-theme-dark .apexcharts-tooltip-title {
    background: var(--dm-surface-4);
    border-bottom: 1px solid var(--dm-border);
    color: var(--dm-muted);
}

html[data-app-theme="dark"] .apexcharts-tooltip-text-y-value,
html[data-app-theme="dark"] .apexcharts-tooltip-text-goals-value,
html[data-app-theme="dark"] .apexcharts-tooltip-text-z-value {
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .apexcharts-xaxistooltip,
html[data-app-theme="dark"] .apexcharts-yaxistooltip {
    background: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .apexcharts-xaxistooltip-bottom::before,
html[data-app-theme="dark"] .apexcharts-xaxistooltip-bottom::after {
    border-bottom-color: var(--dm-surface-3);
}

html[data-app-theme="dark"] .apexcharts-xaxistooltip-top::before,
html[data-app-theme="dark"] .apexcharts-xaxistooltip-top::after {
    border-top-color: var(--dm-surface-3);
}

html[data-app-theme="dark"] .apexcharts-menu {
    background: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .apexcharts-menu-item:hover {
    background: var(--dm-surface-4);
}

html[data-app-theme="dark"] .apexcharts-toolbar svg {
    fill: var(--dm-muted);
}

/* ================================================================
   Page-specific overrides for light colours hard-coded in views
================================================================ */

/* Dashboard: themed by assets/css/dashboard.css (it carries its own dark tokens) */

/* ---------- List pages: inline light table heads & cards ---------- */
html[data-app-theme="dark"] thead[style*="#F3F4F6"],
html[data-app-theme="dark"] thead[style*="#f3f4f6"] {
    background: rgba(255, 255, 255, 0.025) !important;
}

html[data-app-theme="dark"] .card[style*="#fafbff"] {
    background: var(--dm-surface-2) !important;
}

html[data-app-theme="dark"] .form-select[style*="#e9ecef"] {
    background-color: #1a1a24 !important;
    color: var(--dm-muted);
}

/* Grouped task list (components/group-task-list.blade.php) */
html[data-app-theme="dark"] .table tbody tr {
    background-color: transparent !important;
}

/* ---------- custom.css components with hard-coded light colours ---------- */
/* The outer select2 container is the visible box (custom.css gives it a light
   border with !important) — match it to the other inputs. */
html[data-app-theme="dark"] .select2.select2-container.select2-container--default:not(#global-search + .select2-container) {
    background-color: var(--dm-surface-4) !important;
    border-color: var(--dm-border-strong) !important;
    color: var(--dm-heading) !important;
}

html[data-app-theme="dark"] .select2.select2-container.select2-container--default.select2-container--focus:not(#global-search + .select2-container),
html[data-app-theme="dark"] .select2.select2-container.select2-container--default.select2-container--open:not(#global-search + .select2-container) {
    border-color: var(--dm-primary) !important;
}

html[data-app-theme="dark"] #mapping-body .select2-container--default .select2-selection--single,
html[data-app-theme="dark"] #mapping-body .select2-container--default .select2-dropdown {
    background-color: var(--dm-surface-4);
}

/* Timeline (activity, recent activity) */
html[data-app-theme="dark"] .timeline .timeline-item .timeline-event,
html[data-app-theme="dark"] .timeline .timeline-item .timeline-indicator-advanced,
html[data-app-theme="dark"] .timeline.timeline-center .timeline-item::after {
    background-color: var(--dm-surface-2);
}

html[data-app-theme="dark"] .timeline.timeline-outline .timeline-item .timeline-point {
    background-color: var(--dm-surface-2) !important;
}

html[data-app-theme="dark"] .timeline .timeline-item {
    border-left-color: var(--dm-border) !important;
}

html[data-app-theme="dark"] .timeline .timeline-end-indicator i {
    color: #3a3a4c;
}

html[data-app-theme="dark"] .timeline .timeline-indicator-dark i {
    color: #d4d4e0 !important;
}

/* Todos */
html[data-app-theme="dark"] .todo-card {
    background-color: var(--dm-surface-2);
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .todo-card:hover {
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.35);
}

html[data-app-theme="dark"] .todo-item {
    background-color: var(--dm-surface-4);
}

html[data-app-theme="dark"] .todo-title {
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .todo-check-input {
    border-color: #4a4a5e;
}

html[data-app-theme="dark"] .todo-action-btn {
    background-color: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .todo-action-btn:hover {
    background-color: var(--dm-surface-4);
}

html[data-app-theme="dark"] .todo-action-btn.todo-delete:hover {
    background-color: rgba(255, 62, 29, 0.15);
}

html[data-app-theme="dark"] .todo-action-btn.todo-edit:hover {
    background-color: var(--dm-primary-soft);
}

html[data-app-theme="dark"] .todo-progress-bar,
html[data-app-theme="dark"] .todo-list-container::-webkit-scrollbar-track {
    background-color: var(--dm-surface-4);
}

html[data-app-theme="dark"] .todo-list-container::-webkit-scrollbar-thumb {
    background: #3a3a4c;
}

/* Comments, attachments, mentions */
html[data-app-theme="dark"] .comment-form-container,
html[data-app-theme="dark"] .attachment-preview {
    background-color: var(--dm-surface-4);
    border-color: var(--dm-border);
}

html[data-app-theme="dark"] .comment-body button {
    background-color: var(--dm-surface-4);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .comment-body button:active {
    background-color: #2d2d3c;
}

html[data-app-theme="dark"] .tribute-container {
    background-color: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .tribute-container li {
    color: var(--dm-text);
}

html[data-app-theme="dark"] .tribute-container li:hover,
html[data-app-theme="dark"] .tribute-container .menu-highlighted {
    background-color: var(--dm-primary-soft);
}

html[data-app-theme="dark"] .tribute-container li span,
html[data-app-theme="dark"] .tribute-container li:hover span {
    color: var(--dm-primary-text);
}

/* Misc. small widgets */
html[data-app-theme="dark"] .selectgroup-button {
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .payment-option:hover,
html[data-app-theme="dark"] .btn-check:checked + .payment-option {
    background-color: var(--dm-primary-soft);
}

html[data-app-theme="dark"] .submenu > li,
html[data-app-theme="dark"] #color-legend,
html[data-app-theme="dark"] .category-header {
    background-color: var(--dm-surface-4);
}

html[data-app-theme="dark"] .submenu > li:hover {
    background-color: #2d2d3c;
}

html[data-app-theme="dark"] .legend-title {
    color: var(--dm-heading);
}

html[data-app-theme="dark"] .card.card-border-shadow-light::after {
    border-bottom-color: var(--dm-border-strong);
}

/* ---------- Project kanban (project-kanban.css) ---------- */
html[data-app-theme="dark"] .kanban-column {
    background: var(--dm-surface-2);
    border: 1px solid var(--dm-border);
    box-shadow: none;
}

html[data-app-theme="dark"] .kanban-board {
    color: var(--dm-text);
}

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

html[data-app-theme="dark"] .tag-color-dark {
    border-left-color: #8b8ba3;
}

html[data-app-theme="dark"] .gu-mirror {
    box-shadow: 0 16px 40px rgba(0, 0, 0, 0.55);
}

/* ---------- Gantt (frappe-gantt) ---------- */
html[data-app-theme="dark"] .gantt .grid-header {
    fill: var(--dm-surface-2);
    stroke: var(--dm-border);
}

html[data-app-theme="dark"] .gantt .grid-row {
    fill: transparent;
}

html[data-app-theme="dark"] .gantt .grid-row:nth-child(even) {
    fill: rgba(255, 255, 255, 0.02);
}

html[data-app-theme="dark"] .gantt .row-line,
html[data-app-theme="dark"] .gantt .tick {
    stroke: rgba(255, 255, 255, 0.07);
}

html[data-app-theme="dark"] .gantt .today-highlight {
    fill: rgba(122, 43, 242, 0.18);
    opacity: 1;
}

html[data-app-theme="dark"] .gantt .arrow {
    stroke: #6f6f86;
}

html[data-app-theme="dark"] .gantt .bar,
html[data-app-theme="dark"] .gantt .bar-wrapper:hover .bar,
html[data-app-theme="dark"] .gantt .bar-wrapper.active .bar {
    fill: #3a3a4e;
}

html[data-app-theme="dark"] .gantt .bar-progress {
    fill: var(--dm-primary);
}

html[data-app-theme="dark"] .gantt .bar-wrapper:hover .bar-progress,
html[data-app-theme="dark"] .gantt .bar-wrapper.active .bar-progress {
    fill: var(--dm-primary-hover);
}

html[data-app-theme="dark"] .gantt .bar-label.big,
html[data-app-theme="dark"] .gantt .bar-invalid ~ .bar-label,
html[data-app-theme="dark"] .gantt .lower-text {
    fill: var(--dm-text);
}

html[data-app-theme="dark"] .gantt .upper-text {
    fill: var(--dm-muted);
}

html[data-app-theme="dark"] .gantt .handle {
    fill: #6f6f86;
}

html[data-app-theme="dark"] .gantt-container .popup-wrapper {
    background: var(--dm-surface-3);
    border: 1px solid var(--dm-border-strong);
    color: var(--dm-text);
}

/* ---------- Mind map (mind-map.css) — plain nodes only; coloured themes stay ---------- */
html[data-app-theme="dark"] jmnodes:not([class*="theme-"]) jmnode:not(.selected) {
    background-color: var(--dm-surface-4);
    color: var(--dm-heading);
    box-shadow: 0 0 0 1px var(--dm-border-strong);
}

html[data-app-theme="dark"] jmnodes:not([class*="theme-"]) jmnode:not(.selected):hover {
    background-color: #2d2d3c;
}

html[data-app-theme="dark"] jmexpander {
    background-color: var(--dm-surface-3);
    border-color: #6f6f86;
    color: var(--dm-text);
}

/* ---------- File manager — new-folder dialog was the only light surface ---------- */
html[data-app-theme="dark"] .file-folder-dialog {
    background: var(--dm-surface-3);
    color: var(--dm-text);
}

html[data-app-theme="dark"] .file-folder-header,
html[data-app-theme="dark"] .file-folder-footer {
    border-color: var(--dm-border);
}

/* ---------- TinyMCE chrome (the editing area stays white, like paper) ---------- */
html[data-app-theme="dark"] .tox.tox-tinymce {
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] .tox .tox-editor-header,
html[data-app-theme="dark"] .tox .tox-menubar,
html[data-app-theme="dark"] .tox .tox-toolbar,
html[data-app-theme="dark"] .tox .tox-toolbar__primary,
html[data-app-theme="dark"] .tox .tox-toolbar__overflow,
html[data-app-theme="dark"] .tox .tox-statusbar {
    background: var(--dm-surface-3) !important;
    border-color: var(--dm-border) !important;
}

html[data-app-theme="dark"] .tox .tox-tbtn,
html[data-app-theme="dark"] .tox .tox-mbtn,
html[data-app-theme="dark"] .tox .tox-statusbar a,
html[data-app-theme="dark"] .tox .tox-statusbar__path-item,
html[data-app-theme="dark"] .tox .tox-statusbar__wordcount {
    color: var(--dm-text);
}

html[data-app-theme="dark"] .tox .tox-tbtn svg {
    fill: var(--dm-text);
}

html[data-app-theme="dark"] .tox .tox-tbtn:hover,
html[data-app-theme="dark"] .tox .tox-mbtn:hover:not(:disabled) {
    background: var(--dm-surface-4);
}

/* ================================================================
   Sidebar — final pass. menu.blade.php ends with a "reference UI"
   block that sets light colours with !important, so these need
   !important (and a higher specificity) too.
================================================================ */
html[data-app-theme="dark"] #layout-menu.menu-container {
    border-right: 1px solid var(--dm-border) !important;
    box-shadow: none !important;
}

/* Brand / logo header */
html[data-app-theme="dark"] #layout-menu .app-brand,
html[data-app-theme="dark"] #layout-menu .menu-sidebar-header {
    background: transparent !important;
    border-bottom: 1px solid var(--dm-border) !important;
    box-shadow: none !important;
}

html[data-app-theme="dark"] #layout-menu .sidebar-collapse-button,
html[data-app-theme="dark"] #layout-menu .menu-workspace-toggle > button {
    color: var(--dm-muted) !important;
}

html[data-app-theme="dark"] #layout-menu .sidebar-collapse-button:hover,
html[data-app-theme="dark"] #layout-menu .menu-workspace-toggle > button:hover,
html[data-app-theme="dark"] #layout-menu .menu-workspace-toggle > button[aria-expanded="true"] {
    color: var(--dm-primary-text) !important;
    background: var(--dm-surface-4) !important;
    border-color: var(--dm-border-strong) !important;
}

/* "Search menu..." */
html[data-app-theme="dark"] #layout-menu .sidebar-search-box #menu-search {
    color: var(--dm-heading) !important;
    background: var(--dm-surface-4) !important;
    border-color: var(--dm-border) !important;
}

html[data-app-theme="dark"] #layout-menu .sidebar-search-box #menu-search:hover {
    background: var(--dm-surface-4) !important;
    border-color: var(--dm-border-strong) !important;
}

html[data-app-theme="dark"] #layout-menu .sidebar-search-box #menu-search:focus {
    background: var(--dm-surface-4) !important;
    border-color: var(--dm-primary) !important;
    box-shadow: 0 0 0 3px var(--dm-primary-ring) !important;
}

html[data-app-theme="dark"] #layout-menu .sidebar-search-box #menu-search::placeholder,
html[data-app-theme="dark"] #layout-menu .sidebar-search-icon {
    color: var(--dm-muted);
}

html[data-app-theme="dark"] #layout-menu .sidebar-search-shortcut kbd {
    color: var(--dm-muted);
    background: var(--dm-surface-3);
    border-color: var(--dm-border-strong);
}

html[data-app-theme="dark"] #layout-menu .sidebar-search-clear {
    color: var(--dm-muted);
    background: transparent;
}

html[data-app-theme="dark"] #layout-menu .sidebar-search-clear:hover {
    color: var(--dm-primary-text);
    background: var(--dm-primary-soft);
}

/* Menu icons and submenu */
html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link .menu-icon,
html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link > svg,
html[data-app-theme="dark"] #layout-menu .menu-inner > .menu-item > .menu-link > i {
    color: var(--dm-muted) !important;
}

html[data-app-theme="dark"] #layout-menu .menu-sub::before {
    background: var(--dm-border-strong) !important;
}

html[data-app-theme="dark"] #layout-menu .menu-sub .menu-link {
    color: var(--dm-muted) !important;
}

/* An expanded parent (not the current page) stays quiet — purple is reserved for the active item */
html[data-app-theme="dark"] #layout-menu .menu-inner .menu-item.open:not(.active) > .menu-toggle {
    color: var(--dm-heading) !important;
    background: rgba(255, 255, 255, 0.05) !important;
    box-shadow: none !important;
}

html[data-app-theme="dark"] #layout-menu .menu-inner .menu-item.open:not(.active) > .menu-link .menu-icon,
html[data-app-theme="dark"] #layout-menu .menu-inner .menu-item.open:not(.active) > .menu-link > svg,
html[data-app-theme="dark"] #layout-menu .menu-inner .menu-item.open:not(.active) > .menu-link > i {
    color: var(--dm-primary-text) !important;
}

/* Collapsed (icon-only) sidebar: the icon tiles were light grey */
html[data-app-theme="dark"].layout-menu-collapsed:not(.taskify-menu-hover) #layout-menu.menu-collapsed .menu-inner > .menu-item > .menu-link {
    color: var(--dm-muted) !important;
}

html[data-app-theme="dark"].layout-menu-collapsed:not(.taskify-menu-hover) #layout-menu.menu-collapsed .menu-inner > .menu-item > .menu-link .menu-icon,
html[data-app-theme="dark"].layout-menu-collapsed:not(.taskify-menu-hover) #layout-menu.menu-collapsed .menu-inner > .menu-item > .menu-link > svg,
html[data-app-theme="dark"].layout-menu-collapsed:not(.taskify-menu-hover) #layout-menu.menu-collapsed .menu-inner > .menu-item > .menu-link > i {
    color: var(--dm-muted) !important;
    background: var(--dm-surface-4) !important;
}

/* ---------- Inactive tabs (core.css gives them a light grey fill) ---------- */
html[data-app-theme="dark"] .nav-tabs .nav-item .nav-link:not(.active) {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--dm-muted);
}

html[data-app-theme="dark"] .nav-tabs .nav-item .nav-link:not(.active):hover {
    background-color: rgba(255, 255, 255, 0.07);
    color: var(--dm-heading);
}

/* ---------- Floating chat & timer buttons ---------- */
/* Chat: the icon is a blue disc on a baked-in light checkerboard. A border (instead of
   padding) lets border-radius clip the image to a circle and frames it in a dark ring. */
html[data-app-theme="dark"] .chat-img {
    padding: 0;
    background-color: var(--dm-surface-3);
    border: 10px solid var(--dm-surface-3);
    box-shadow: 0 0 0 1px var(--dm-border-strong), 0 6px 18px rgba(0, 0, 0, 0.5);
}

/* Timer: the PNG/GIF has an opaque white background — invert the lightness but keep the
   hues (orange hand). drop-shadow comes after invert so the shadow stays dark. */
html[data-app-theme="dark"] .timer-img {
    filter: invert(0.88) hue-rotate(180deg) drop-shadow(0 4px 10px rgba(0, 0, 0, 0.5));
    box-shadow: none;
}

/* visual effects toggle: feather = Light, sparkles = Full */
.fx-toggle .fx-icon-full { display: none; }
.fx-toggle.is-full .fx-icon-full { display: block; }
.fx-toggle.is-full .fx-icon-light { display: none; }
.fx-toggle.is-full { color: #8b5cf6; }
