/* ===================================================================
   SISFO Budiman - Velzon Dark Mode Custom Overrides & Text Fixes
   =================================================================== */

/* 1. Global Dark Mode Variables & Colors */
[data-bs-theme="dark"],
[data-layout-mode="dark"],
html[data-bs-theme="dark"],
html[data-layout-mode="dark"] {
    --vz-body-color: #adb5bd;
    --vz-body-bg: #1a1d21;
    --vz-card-bg: #212529;
    --vz-card-cap-bg: #212529;
    --vz-border-color: #2b3035;
    --vz-heading-color: #e9ecef;
    --vz-light: #262a2f;
    --vz-dark: #e9ecef;
    --bs-body-color: #adb5bd;
    --bs-body-bg: #1a1d21;
}

/* 2. Text Utilities Fix (Crucial: Overrides black/dark text on dark background) */
[data-bs-theme="dark"] .text-dark,
[data-layout-mode="dark"] .text-dark,
html[data-bs-theme="dark"] .text-dark,
html[data-layout-mode="dark"] .text-dark {
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .text-black,
[data-layout-mode="dark"] .text-black,
html[data-bs-theme="dark"] .text-black,
html[data-layout-mode="dark"] .text-black {
    color: #ffffff !important;
}

[data-bs-theme="dark"] .text-muted,
[data-layout-mode="dark"] .text-muted,
html[data-bs-theme="dark"] .text-muted,
html[data-layout-mode="dark"] .text-muted {
    color: #9297a7 !important;
}

[data-bs-theme="dark"] .text-secondary,
[data-layout-mode="dark"] .text-secondary,
html[data-bs-theme="dark"] .text-secondary,
html[data-layout-mode="dark"] .text-secondary {
    color: #a4abb6 !important;
}

/* 3. Headings, Titles, Breadcrumbs & Card Headers */
[data-bs-theme="dark"] h1, [data-bs-theme="dark"] .h1,
[data-bs-theme="dark"] h2, [data-bs-theme="dark"] .h2,
[data-bs-theme="dark"] h3, [data-bs-theme="dark"] .h3,
[data-bs-theme="dark"] h4, [data-bs-theme="dark"] .h4,
[data-bs-theme="dark"] h5, [data-bs-theme="dark"] .h5,
[data-bs-theme="dark"] h6, [data-bs-theme="dark"] .h6,
[data-layout-mode="dark"] h1, [data-layout-mode="dark"] .h1,
[data-layout-mode="dark"] h2, [data-layout-mode="dark"] .h2,
[data-layout-mode="dark"] h3, [data-layout-mode="dark"] .h3,
[data-layout-mode="dark"] h4, [data-layout-mode="dark"] .h4,
[data-layout-mode="dark"] h5, [data-layout-mode="dark"] .h5,
[data-layout-mode="dark"] h6, [data-layout-mode="dark"] .h6 {
    color: #e9ecef;
}

[data-bs-theme="dark"] .card-title,
[data-layout-mode="dark"] .card-title {
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .card,
[data-layout-mode="dark"] .card {
    background-color: #212529 !important;
    border-color: #2b3035 !important;
}

[data-bs-theme="dark"] .card-header,
[data-layout-mode="dark"] .card-header {
    background-color: #212529 !important;
    border-bottom-color: #2b3035 !important;
}

[data-bs-theme="dark"] .card-footer,
[data-layout-mode="dark"] .card-footer {
    background-color: #212529 !important;
    border-top-color: #2b3035 !important;
}

[data-bs-theme="dark"] .breadcrumb-item.active,
[data-layout-mode="dark"] .breadcrumb-item.active {
    color: #ced4da;
}

[data-bs-theme="dark"] .breadcrumb-item a,
[data-layout-mode="dark"] .breadcrumb-item a {
    color: #878a99;
}

/* 4. Table Styles & Overrides */
[data-bs-theme="dark"] .table,
[data-layout-mode="dark"] .table {
    --vz-table-color: #adb5bd;
    --vz-table-bg: transparent;
    --vz-table-border-color: #2b3035;
    --vz-table-striped-bg: rgba(255, 255, 255, 0.025);
    --vz-table-striped-color: #ced4da;
    --vz-table-hover-bg: rgba(255, 255, 255, 0.04);
    --vz-table-hover-color: #ffffff;
    color: #adb5bd;
    border-color: #2b3035;
}

[data-bs-theme="dark"] .table > :not(caption) > * > *,
[data-layout-mode="dark"] .table > :not(caption) > * > * {
    border-bottom-color: #2b3035;
    color: #ced4da;
}

[data-bs-theme="dark"] table strong,
[data-bs-theme="dark"] table b,
[data-layout-mode="dark"] table strong,
[data-layout-mode="dark"] table b {
    color: #e9ecef;
}

[data-bs-theme="dark"] .table thead th,
[data-layout-mode="dark"] .table thead th {
    color: #e9ecef !important;
    background-color: #262a2f !important;
    border-color: #32383e !important;
    font-weight: 600;
}

[data-bs-theme="dark"] .table-light,
[data-bs-theme="dark"] thead.table-light,
[data-bs-theme="dark"] thead.table-light th,
[data-layout-mode="dark"] .table-light,
[data-layout-mode="dark"] thead.table-light,
[data-layout-mode="dark"] thead.table-light th {
    background-color: #262a2f !important;
    color: #e9ecef !important;
    border-color: #32383e !important;
}

[data-bs-theme="dark"] .table tfoot,
[data-bs-theme="dark"] .table tfoot th,
[data-bs-theme="dark"] .table tfoot td,
[data-layout-mode="dark"] .table tfoot,
[data-layout-mode="dark"] .table tfoot th,
[data-layout-mode="dark"] .table tfoot td {
    background-color: #262a2f !important;
    color: #e9ecef !important;
    border-color: #32383e !important;
}

[data-bs-theme="dark"] .table-hover > tbody > tr:hover > *,
[data-layout-mode="dark"] .table-hover > tbody > tr:hover > * {
    color: #ffffff !important;
    background-color: rgba(255, 255, 255, 0.05) !important;
}

[data-bs-theme="dark"] .table-striped > tbody > tr:nth-of-type(odd) > *,
[data-layout-mode="dark"] .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255, 255, 255, 0.02) !important;
    color: #ced4da !important;
}

/* 5. DataTables Dark Mode Controls */
[data-bs-theme="dark"] .dataTables_wrapper,
[data-layout-mode="dark"] .dataTables_wrapper {
    color: #adb5bd;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length label,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter label,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_info,
[data-layout-mode="dark"] .dataTables_wrapper .dataTables_length,
[data-layout-mode="dark"] .dataTables_wrapper .dataTables_length label,
[data-layout-mode="dark"] .dataTables_wrapper .dataTables_filter,
[data-layout-mode="dark"] .dataTables_wrapper .dataTables_filter label,
[data-layout-mode="dark"] .dataTables_wrapper .dataTables_info {
    color: #ced4da !important;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter input,
[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length select,
[data-layout-mode="dark"] .dataTables_wrapper .dataTables_filter input,
[data-layout-mode="dark"] .dataTables_wrapper .dataTables_length select {
    background-color: #212529 !important;
    color: #e9ecef !important;
    border-color: #32383e !important;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button,
[data-layout-mode="dark"] .dataTables_wrapper .dataTables_paginate .paginate_button {
    color: #adb5bd !important;
}

[data-bs-theme="dark"] .dataTables_wrapper .pagination .page-item .page-link,
[data-layout-mode="dark"] .dataTables_wrapper .pagination .page-item .page-link {
    background-color: #212529 !important;
    border-color: #32383e !important;
    color: #adb5bd !important;
}

[data-bs-theme="dark"] .dataTables_wrapper .pagination .page-item.active .page-link,
[data-layout-mode="dark"] .dataTables_wrapper .pagination .page-item.active .page-link {
    background-color: #405189 !important;
    border-color: #405189 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .dataTables_wrapper .pagination .page-item.disabled .page-link,
[data-layout-mode="dark"] .dataTables_wrapper .pagination .page-item.disabled .page-link {
    background-color: #1a1d21 !important;
    border-color: #2a2f34 !important;
    color: #495057 !important;
}

/* 6. Form Controls, Labels & Placeholders */
[data-bs-theme="dark"] .form-label,
[data-bs-theme="dark"] label,
[data-layout-mode="dark"] .form-label,
[data-layout-mode="dark"] label {
    color: #ced4da !important;
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select,
[data-bs-theme="dark"] .form-control-solid,
[data-layout-mode="dark"] .form-control,
[data-layout-mode="dark"] .form-select,
[data-layout-mode="dark"] .form-control-solid {
    background-color: #212529 !important;
    border-color: #32383e !important;
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus,
[data-layout-mode="dark"] .form-control:focus,
[data-layout-mode="dark"] .form-select:focus {
    background-color: #212529 !important;
    border-color: #405189 !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(64, 81, 137, 0.25) !important;
}

[data-bs-theme="dark"] .form-control::placeholder,
[data-bs-theme="dark"] input::placeholder,
[data-bs-theme="dark"] textarea::placeholder,
[data-layout-mode="dark"] .form-control::placeholder,
[data-layout-mode="dark"] input::placeholder,
[data-layout-mode="dark"] textarea::placeholder {
    color: #6c757d !important;
}

[data-bs-theme="dark"] .form-check-label,
[data-layout-mode="dark"] .form-check-label {
    color: #ced4da !important;
}

/* 7. Modals & Dialogs */
[data-bs-theme="dark"] .modal-content,
[data-layout-mode="dark"] .modal-content {
    background-color: #212529 !important;
    border-color: #32383e !important;
    color: #ced4da !important;
}

[data-bs-theme="dark"] .modal-header,
[data-layout-mode="dark"] .modal-header {
    border-bottom-color: #32383e !important;
}

[data-bs-theme="dark"] .modal-header.bg-light,
[data-layout-mode="dark"] .modal-header.bg-light {
    background-color: #262a2f !important;
}

[data-bs-theme="dark"] .modal-header .modal-title,
[data-layout-mode="dark"] .modal-header .modal-title {
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .modal-footer,
[data-layout-mode="dark"] .modal-footer {
    border-top-color: #32383e !important;
}

[data-bs-theme="dark"] .btn-close,
[data-layout-mode="dark"] .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

/* 8. Dropdown & Velzon Action Menu (x-action-menu) */
[data-bs-theme="dark"] .dropdown-menu,
[data-layout-mode="dark"] .dropdown-menu {
    background-color: #212529 !important;
    border-color: #32383e !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5) !important;
}

[data-bs-theme="dark"] .dropdown-item,
[data-layout-mode="dark"] .dropdown-item {
    color: #ced4da !important;
}

[data-bs-theme="dark"] .dropdown-item:hover,
[data-bs-theme="dark"] .dropdown-item:focus,
[data-layout-mode="dark"] .dropdown-item:hover,
[data-layout-mode="dark"] .dropdown-item:focus {
    background-color: #2c3238 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .dropdown-item i,
[data-layout-mode="dark"] .dropdown-item i {
    color: #878a99;
}

[data-bs-theme="dark"] .dropdown-item:hover i,
[data-layout-mode="dark"] .dropdown-item:hover i {
    color: #ffffff;
}

[data-bs-theme="dark"] .dropdown-item.text-danger,
[data-layout-mode="dark"] .dropdown-item.text-danger {
    color: #f06548 !important;
}

[data-bs-theme="dark"] .dropdown-item.text-danger i,
[data-layout-mode="dark"] .dropdown-item.text-danger i {
    color: #f06548 !important;
}

[data-bs-theme="dark"] .dropdown-divider,
[data-layout-mode="dark"] .dropdown-divider {
    border-top-color: #32383e !important;
}

/* 9. Select2 Bootstrap 5 Theme Dark Mode Overrides */
[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection,
[data-layout-mode="dark"] .select2-container--bootstrap-5 .select2-selection {
    background-color: #212529 !important;
    border-color: #32383e !important;
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered,
[data-layout-mode="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__rendered {
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder,
[data-layout-mode="dark"] .select2-container--bootstrap-5 .select2-selection--single .select2-selection__placeholder {
    color: #6c757d !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown,
[data-layout-mode="dark"] .select2-container--bootstrap-5 .select2-dropdown {
    background-color: #212529 !important;
    border-color: #32383e !important;
    color: #ced4da !important;
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.5) !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field,
[data-layout-mode="dark"] .select2-container--bootstrap-5 .select2-dropdown .select2-search .select2-search__field {
    background-color: #1a1d21 !important;
    border-color: #32383e !important;
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option,
[data-layout-mode="dark"] .select2-container--bootstrap-5 .select2-results__option {
    color: #ced4da !important;
    background-color: transparent !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted,
[data-layout-mode="dark"] .select2-container--bootstrap-5 .select2-results__option--highlighted {
    background-color: #405189 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .select2-container--bootstrap-5 .select2-results__option--selected,
[data-layout-mode="dark"] .select2-container--bootstrap-5 .select2-results__option--selected {
    background-color: #2a2f34 !important;
    color: #e9ecef !important;
}

/* 10. Badges, Background Utilities & Stat Cards */
[data-bs-theme="dark"] .bg-light,
[data-layout-mode="dark"] .bg-light {
    background-color: #262a2f !important;
    color: #ced4da !important;
}

[data-bs-theme="dark"] .badge.bg-light,
[data-layout-mode="dark"] .badge.bg-light {
    background-color: #262a2f !important;
    color: #e9ecef !important;
    border-color: #373c43 !important;
}

[data-bs-theme="dark"] .badge-soft-secondary,
[data-bs-theme="dark"] .bg-secondary-subtle,
[data-layout-mode="dark"] .badge-soft-secondary,
[data-layout-mode="dark"] .bg-secondary-subtle {
    background-color: rgba(142, 150, 163, 0.18) !important;
    color: #ced4da !important;
}

[data-bs-theme="dark"] .border,
[data-layout-mode="dark"] .border {
    border-color: #2b3035 !important;
}

[data-bs-theme="dark"] .border-bottom-dashed,
[data-layout-mode="dark"] .border-bottom-dashed {
    border-bottom-color: #2b3035 !important;
}

[data-bs-theme="dark"] .stat-card,
[data-layout-mode="dark"] .stat-card {
    background: #212529 !important;
    border-color: #2d3238 !important;
    box-shadow: 0 0.125rem 0.25rem rgba(0,0,0,0.2) !important;
}

[data-bs-theme="dark"] .stat-card h3,
[data-bs-theme="dark"] .stat-card .fw-bold,
[data-layout-mode="dark"] .stat-card h3,
[data-layout-mode="dark"] .stat-card .fw-bold {
    color: #e9ecef !important;
}

/* Light mode Personil Tipe Badges */
.tipe-badge-sopir {
    background-color: #e0e7ff !important;
    color: #312e81 !important;
    border: 1px solid #c7d2fe;
    font-weight: 600;
}

.tipe-badge-kondektur {
    background-color: #ccfbf1 !important;
    color: #0f766e !important;
    border: 1px solid #99f6e4;
    font-weight: 600;
}

/* DataTables Global Action Buttons (Excel & Cetak PDF) */
.dt-buttons .btn-danger,
button.dt-button.btn-danger {
    background: #dc3545 !important;
    background-color: #dc3545 !important;
    border-color: #dc3545 !important;
    color: #ffffff !important;
    font-weight: 500;
    border-radius: 4px;
    box-shadow: none !important;
}
.dt-buttons .btn-danger:hover,
button.dt-button.btn-danger:hover {
    background: #bb2d3b !important;
    background-color: #bb2d3b !important;
    border-color: #b02a37 !important;
    color: #ffffff !important;
}
.dt-buttons .btn-success,
button.dt-button.btn-success {
    background: #198754 !important;
    background-color: #198754 !important;
    border-color: #198754 !important;
    color: #ffffff !important;
    font-weight: 500;
    border-radius: 4px;
    box-shadow: none !important;
}
.dt-buttons .btn-success:hover,
button.dt-button.btn-success:hover {
    background: #157347 !important;
    background-color: #157347 !important;
    border-color: #146c43 !important;
    color: #ffffff !important;
}

[data-bs-theme="dark"] .tipe-badge-sopir,
[data-layout-mode="dark"] .tipe-badge-sopir {
    background-color: rgba(99, 102, 241, 0.2) !important;
    color: #a5b4fc !important;
}

[data-bs-theme="dark"] .tipe-badge-kondektur,
[data-layout-mode="dark"] .tipe-badge-kondektur {
    background-color: rgba(20, 184, 166, 0.2) !important;
    color: #5eead4 !important;
}

[data-bs-theme="dark"] .btn-outline-secondary,
[data-layout-mode="dark"] .btn-outline-secondary {
    border-color: #3b4248;
    color: #ced4da;
}

[data-bs-theme="dark"] .btn-outline-secondary:hover,
[data-layout-mode="dark"] .btn-outline-secondary:hover {
    background-color: #2c3238;
    color: #ffffff;
}

/* 11. Nav Tabs & Nav Pills */
[data-bs-theme="dark"] .nav-tabs .nav-link,
[data-layout-mode="dark"] .nav-tabs .nav-link {
    color: #adb5bd;
}

[data-bs-theme="dark"] .nav-tabs .nav-link.active,
[data-layout-mode="dark"] .nav-tabs .nav-link.active {
    color: #687fe5 !important;
    background-color: #212529;
    border-color: #2b3035 #2b3035 #212529;
}

[data-bs-theme="dark"] .nav-pills .nav-link,
[data-layout-mode="dark"] .nav-pills .nav-link {
    color: #adb5bd;
}

[data-bs-theme="dark"] .nav-pills .nav-link.active,
[data-layout-mode="dark"] .nav-pills .nav-link.active {
    color: #ffffff;
    background-color: #405189;
}

/* 12. Topbar & Search Elements */
[data-bs-theme="dark"] .topbar-user .user-name-text,
[data-layout-mode="dark"] .topbar-user .user-name-text {
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .topbar-user .user-name-sub-text,
[data-layout-mode="dark"] .topbar-user .user-name-sub-text {
    color: #878a99 !important;
}

[data-bs-theme="dark"] .app-search .form-control,
[data-layout-mode="dark"] .app-search .form-control {
    background-color: #212529 !important;
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .search-box .form-control,
[data-layout-mode="dark"] .search-box .form-control {
    background-color: #212529 !important;
    color: #e9ecef !important;
    border-color: #32383e !important;
}

[data-bs-theme="dark"] .search-box .search-icon,
[data-layout-mode="dark"] .search-box .search-icon {
    color: #878a99 !important;
}

/* 13. SweetAlert2 in Dark Mode */
[data-bs-theme="dark"] .swal2-popup,
[data-layout-mode="dark"] .swal2-popup {
    background-color: #212529 !important;
    color: #ced4da !important;
    border: 1px solid #32383e !important;
}

[data-bs-theme="dark"] .swal2-title,
[data-layout-mode="dark"] .swal2-title {
    color: #e9ecef !important;
}

[data-bs-theme="dark"] .swal2-html-container,
[data-layout-mode="dark"] .swal2-html-container {
    color: #adb5bd !important;
}
