/* ==========================================================================
   Dark mode overrides — all rules scoped under [data-bs-theme="dark"]
   ========================================================================== */

/* --- erp_style.css overrides --- */

[data-bs-theme="dark"] body {
    color: #dee2e6;
}

[data-bs-theme="dark"] a {
    color: #6ea8fe;
}

[data-bs-theme="dark"] a:hover {
    color: #9ec5fe;
}

/* Preserve Bootstrap button text colors in dark mode */
[data-bs-theme="dark"] a.btn {
    color: var(--bs-btn-color);
}

[data-bs-theme="dark"] a.btn:hover {
    color: var(--bs-btn-hover-color);
}

/* Sidebar */
[data-bs-theme="dark"] .sidebar {
    box-shadow: inset -1px 0 0 rgba(255, 255, 255, .1);
}

[data-bs-theme="dark"] .sidebar .nav-link {
    color: #dee2e6;
}

[data-bs-theme="dark"] .sidebar .nav-link.active {
    color: #6ea8fe;
}

[data-bs-theme="dark"] .sidebar .nav-link:hover {
    color: #6ea8fe;
    background-color: rgba(255, 255, 255, .05);
}

/* Links and text */
[data-bs-theme="dark"] .normal-link {
    color: #6ea8fe;
}

[data-bs-theme="dark"] .small_text {
    color: #adb5bd;
}

[data-bs-theme="dark"] .error-text {
    color: #ea868f;
}

[data-bs-theme="dark"] .draft {
    color: #adb5bd;
}

[data-bs-theme="dark"] .draft a {
    color: #adb5bd;
}

/* Loader */
[data-bs-theme="dark"] .loader {
    border-color: #343a40;
    border-top-color: #6ea8fe;
}

/* Custom file borders */
[data-bs-theme="dark"] .custom-file-border {
    color: #dee2e6;
    background-color: #2b3035;
    border-color: #495057;
}

[data-bs-theme="dark"] .custom-file-ext-border {
    color: #dee2e6;
    background-color: #343a40;
    border-color: #495057;
}

/* --- dms_style.css overrides --- */

/* Breadcrumb */
[data-bs-theme="dark"] .murupolku {
    color: #6ea8fe;
}

[data-bs-theme="dark"] .murupolku ol {
    background-color: #2b3035;
}

/* jQuery UI states */
[data-bs-theme="dark"] .ui-state-default,
[data-bs-theme="dark"] .ui-widget-content .ui-state-default,
[data-bs-theme="dark"] .ui-widget-header .ui-state-default {
    border-color: #495057;
    background: #2b3035;
    color: #adb5bd;
}

[data-bs-theme="dark"] .ui-state-default a,
[data-bs-theme="dark"] .ui-state-default a:link,
[data-bs-theme="dark"] .ui-state-default a:visited {
    color: #dee2e6;
}

[data-bs-theme="dark"] .ui-state-active,
[data-bs-theme="dark"] .ui-widget-content .ui-state-active,
[data-bs-theme="dark"] .ui-widget-header .ui-state-active {
    border-color: #495057;
    background: #0d6efd;
    color: #ffffff;
}

/* Comments */
[data-bs-theme="dark"] .kommentti1 {
    border-color: #495057;
    background-color: #2b3035;
}

[data-bs-theme="dark"] .kommentti2 {
    border-color: #495057;
    background-color: #212529;
}

[data-bs-theme="dark"] .ryhman_kommentit {
    border-color: #495057;
}

/* Detail text colors */
[data-bs-theme="dark"] .recent_comment .details3 {
    color: #adb5bd;
}

[data-bs-theme="dark"] .recent_details {
    color: #adb5bd;
}

[data-bs-theme="dark"] .detail_name {
    color: #dee2e6;
}

[data-bs-theme="dark"] .tyoryhma {
    color: #adb5bd;
}

/* DMS list group item active */
[data-bs-theme="dark"] .list-group-item.active {
    background-color: #2b3035;
    border-color: #495057;
    color: #dee2e6;
}

[data-bs-theme="dark"] .list-group-item.active a[data-bs-target="#collapseMetadata"] {
    color: #dee2e6 !important;
}

/* Error red */
[data-bs-theme="dark"] .punainen {
    color: #ea868f;
}

[data-bs-theme="dark"] .has-error {
    color: #ea868f;
}

[data-bs-theme="dark"] #cal-slide-content a.event-item {
    color: #dee2e6;
}

/* --- list.css overrides --- */

[data-bs-theme="dark"] .list-icon .white {
    background-color: #2b3035;
}

[data-bs-theme="dark"] .list-details .document {
    border-bottom-color: #495057;
}

[data-bs-theme="dark"] .list-details {
    border-bottom-color: #495057;
}

[data-bs-theme="dark"] .list-details .details {
    color: #adb5bd;
}

[data-bs-theme="dark"] .details3 {
    color: #adb5bd;
}

/* --- Event state classes (calendar_calendar.html) --- */

[data-bs-theme="dark"] .event-state-ready {
    background-color: #1a6985;
    color: #dee2e6;
}

[data-bs-theme="dark"] .event-state-draft {
    background-color: #853a3a;
    color: #dee2e6;
}

[data-bs-theme="dark"] .event-state-reservation {
    background-color: #4a7a30;
    color: #dee2e6;
}

/* --- Third-party component overrides --- */

/* Choices.js */
[data-bs-theme="dark"] .choices__inner {
    background-color: #2b3035;
    border-color: #495057;
    color: #dee2e6;
}

[data-bs-theme="dark"] .choices__list--dropdown {
    background-color: #2b3035;
    border-color: #495057;
    color: #dee2e6;
}

[data-bs-theme="dark"] .choices__list--dropdown .choices__item--selectable.is-highlighted {
    background-color: #343a40;
}

[data-bs-theme="dark"] .choices__input {
    background-color: #2b3035;
    color: #dee2e6;
}

/* Tempus Dominus */
[data-bs-theme="dark"] .tempus-dominus-widget {
    background-color: #2b3035;
    border-color: #495057;
    color: #dee2e6;
}

[data-bs-theme="dark"] .tempus-dominus-widget .date-container-days .day:hover,
[data-bs-theme="dark"] .tempus-dominus-widget .date-container-months .month:hover,
[data-bs-theme="dark"] .tempus-dominus-widget .date-container-years .year:hover,
[data-bs-theme="dark"] .tempus-dominus-widget .date-container-decades .decade:hover,
[data-bs-theme="dark"] .tempus-dominus-widget .time-container .time-container-clock div:hover,
[data-bs-theme="dark"] .tempus-dominus-widget .time-container .time-container-counter div:hover {
    background-color: #343a40;
}

/* Bootstrap Fileinput */
[data-bs-theme="dark"] .file-preview {
    background-color: #2b3035;
    border-color: #495057;
}

[data-bs-theme="dark"] .file-drop-zone {
    background-color: #212529;
    border-color: #495057;
    color: #adb5bd;
}

/* Multi-select */
[data-bs-theme="dark"] .ms-container .ms-selectable,
[data-bs-theme="dark"] .ms-container .ms-selection {
    background-color: #2b3035;
    color: #dee2e6;
}

[data-bs-theme="dark"] .ms-container .ms-list {
    border-color: #495057;
    background-color: #2b3035;
}

[data-bs-theme="dark"] .ms-container .ms-selectable li.ms-elem-selectable,
[data-bs-theme="dark"] .ms-container .ms-selection li.ms-elem-selection {
    color: #dee2e6;
}

[data-bs-theme="dark"] .ms-container .ms-hover {
    background-color: #343a40;
    color: #dee2e6;
}

/* CKEditor 5 */
[data-bs-theme="dark"] .ck-editor__editable {
    background-color: #2b3035 !important;
    color: #dee2e6 !important;
}

[data-bs-theme="dark"] .ck.ck-toolbar {
    background-color: #343a40 !important;
    border-color: #495057 !important;
}

[data-bs-theme="dark"] .ck.ck-editor__main > .ck-editor__editable {
    border-color: #495057 !important;
}

[data-bs-theme="dark"] .ck.ck-button:not(.ck-disabled):hover,
[data-bs-theme="dark"] .ck.ck-button.ck-on {
    background-color: #495057 !important;
}

[data-bs-theme="dark"] .ck.ck-toolbar .ck.ck-toolbar__separator {
    background-color: #495057 !important;
}

[data-bs-theme="dark"] .ck.ck-list__item .ck-button:hover:not(.ck-disabled) {
    background-color: #343a40 !important;
}

[data-bs-theme="dark"] .ck.ck-dropdown__panel {
    background-color: #2b3035 !important;
    border-color: #495057 !important;
}

[data-bs-theme="dark"] .ck.ck-icon,
[data-bs-theme="dark"] .ck.ck-button {
    color: #dee2e6 !important;
}

/* Tagify */
[data-bs-theme="dark"] .tagify {
    --tags-border-color: #495057;
    --tags-bg: #2b3035;
    --tags-hover-border-color: #6ea8fe;
    --tag-bg: #343a40;
    --tag-hover: #495057;
    --tag-text-color: #dee2e6;
    --tag-remove-bg: rgba(234, 134, 143, .3);
    --tag-remove-btn-color: #ea868f;
    --placeholder-color: #adb5bd;
    --input-color: #dee2e6;
    border-color: #495057;
    background-color: #2b3035;
}

[data-bs-theme="dark"] .tagify__dropdown {
    background-color: #2b3035;
    border-color: #495057;
    color: #dee2e6;
}

[data-bs-theme="dark"] .tagify__dropdown__item--active {
    background-color: #343a40;
}

/* SMS stats table */
[data-bs-theme="dark"] .sms-stats-table th:last-child,
[data-bs-theme="dark"] .sms-stats-table td:last-child {
    background-color: #2b3035;
}

/* bg-light override for dark mode */
[data-bs-theme="dark"] .bg-light {
    background-color: #212529 !important;
}

/* btn-light in dark mode: invert to a dark button with light text */
[data-bs-theme="dark"] .btn-light {
    --bs-btn-color: #dee2e6;
    --bs-btn-bg: #343a40;
    --bs-btn-border-color: #495057;
    --bs-btn-hover-color: #fff;
    --bs-btn-hover-bg: #3d444b;
    --bs-btn-hover-border-color: #565e67;
    --bs-btn-active-color: #fff;
    --bs-btn-active-bg: #495057;
    --bs-btn-active-border-color: #565e67;
}

/* DataTables */
[data-bs-theme="dark"] table.dataTable tbody tr {
    background-color: #212529;
    color: #dee2e6;
}

[data-bs-theme="dark"] table.dataTable tbody tr:hover {
    background-color: #2b3035;
}

[data-bs-theme="dark"] table.dataTable.table-striped > tbody > tr:nth-of-type(odd) > * {
    box-shadow: inset 0 0 0 9999px rgba(255, 255, 255, .03);
    color: #dee2e6;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_filter input {
    background-color: #2b3035;
    border-color: #495057;
    color: #dee2e6;
}

[data-bs-theme="dark"] .dataTables_wrapper .dataTables_length select {
    background-color: #2b3035;
    border-color: #495057;
    color: #dee2e6;
}
