/* Keep the square brand mark at the same readable size in both themes. */
#sidebar .sidebar-header .logo .panel-logo,
body.theme-dark #sidebar .sidebar-header .logo .panel-logo {
    display: block;
    width: 96px !important;
    height: auto !important;
    aspect-ratio: 1 / 1;
    max-width: 100%;
    object-fit: contain;
}

/* Contrast overrides for the legacy theme's dark text utilities and striped rows. */
.dashboard-cards {
    --bs-gutter-x: 1.5rem;
    row-gap: 1.5rem;
}

.dashboard-cards > [class*="col-"] > .card {
    height: 100%;
    margin-bottom: 0;
}

body.theme-dark {
    --panel-text: #e2e8f0;
    --panel-muted: #b3bfd0;
    --panel-link: #a9baff;
    color: var(--panel-text);
}

body.theme-dark h1,
body.theme-dark h2,
body.theme-dark h3,
body.theme-dark h4,
body.theme-dark h5,
body.theme-dark h6,
body.theme-dark label,
body.theme-dark legend,
body.theme-dark .card-title,
body.theme-dark .form-check-label {
    color: #f1f5f9;
}

body.theme-dark .text-muted,
body.theme-dark .text-secondary,
body.theme-dark .text-gray-500,
body.theme-dark .text-gray-600,
body.theme-dark .text-gray-700,
body.theme-dark .text-gray-800,
body.theme-dark .text-gray-900,
body.theme-dark .form-text,
body.theme-dark .breadcrumb-item.active,
body.theme-dark .breadcrumb-item + .breadcrumb-item::before,
body.theme-dark .auth-subtitle {
    color: var(--panel-muted) !important;
}

body.theme-dark .text-dark,
body.theme-dark .text-black,
body.theme-dark .text-body {
    color: var(--panel-text) !important;
}

body.theme-dark a:not(.btn):not(.badge):not(.sidebar-link):not(.dropdown-item):not(.page-link),
body.theme-dark .text-primary {
    color: var(--panel-link) !important;
}

body.theme-dark .text-success { color: #79dba3 !important; }
body.theme-dark .text-danger,
body.theme-dark .invalid-feedback { color: #ffadb4 !important; }
body.theme-dark .text-warning { color: #f5d57d !important; }

body.theme-dark .sidebar-wrapper .menu .sidebar-link,
body.theme-dark .dropdown-item {
    color: #d3dceb;
}

body.theme-dark .sidebar-wrapper .menu .sidebar-item.active > .sidebar-link,
body.theme-dark .dropdown-item.active,
body.theme-dark .dropdown-item:active {
    color: #fff;
}

body.theme-dark .table,
body.theme-dark .dataTable-table {
    --bs-table-striped-color: #e2e8f0;
    --bs-table-active-color: #f1f5f9;
    --bs-table-hover-color: #fff;
    --bs-table-striped-bg: rgba(255, 255, 255, .035);
    --bs-table-active-bg: rgba(255, 255, 255, .08);
    color: var(--panel-text);
}

body.theme-dark .table thead th,
body.theme-dark .dataTable-table thead th {
    color: #f1f5f9;
}

body.theme-dark .form-control,
body.theme-dark .form-select,
body.theme-dark .dataTable-input,
body.theme-dark .dataTable-selector,
body.theme-dark .input-group-text {
    background-color: #232337;
    border-color: #62647d;
    color: var(--panel-text);
}

body.theme-dark .form-control::placeholder,
body.theme-dark .dataTable-input::placeholder {
    color: #aab6c9;
    opacity: 1;
}

body.theme-dark .form-control:disabled,
body.theme-dark .form-control[readonly] {
    background-color: #303044;
    color: #bbc5d4;
}

body.theme-dark .btn-light-primary {
    background-color: #303c66;
    color: #e1e8ff;
}

body.theme-dark .btn-outline-primary {
    border-color: #a9baff;
    color: #c3cfff;
}

body.theme-dark .btn-light-primary:hover,
body.theme-dark .btn-outline-primary:hover {
    background-color: #435ebe;
    color: #fff;
}

body.theme-dark .dataTable-info,
body.theme-dark .dataTable-dropdown,
body.theme-dark .dataTable-pagination a {
    color: var(--panel-text);
}

body.theme-dark .choices__inner,
body.theme-dark .choices__list--dropdown,
body.theme-dark .choices__list[aria-expanded],
body.theme-dark .choices__input,
body.theme-dark .datepicker,
body.theme-dark .page-link {
    background-color: #232337;
    border-color: #62647d;
    color: var(--panel-text);
}

body.theme-dark .choices__list--dropdown .choices__item--selectable.is-highlighted,
body.theme-dark .choices__list[aria-expanded] .choices__item--selectable.is-highlighted,
body.theme-dark .datepicker table tr td.day:hover,
body.theme-dark .datepicker table tr th:hover,
body.theme-dark .page-link:hover {
    background-color: #384468;
    color: #fff;
}

body.theme-dark .page-item.active .page-link {
    background-color: #435ebe;
    color: #fff;
}

body.theme-dark .ck {
    --ck-color-base-background: #232337;
    --ck-color-base-foreground: #303044;
    --ck-color-base-border: #62647d;
    --ck-color-text: #e2e8f0;
    --ck-color-toolbar-background: #232337;
    --ck-color-toolbar-border: #62647d;
    --ck-color-button-default-hover-background: #384468;
    --ck-color-button-default-active-background: #384468;
    --ck-color-button-on-background: #384468;
    --ck-color-button-on-color: #dbe4ff;
}

/* The document canvas keeps its published colors while editor controls follow the theme. */
body.theme-dark .ck-editor__editable {
    background-color: #fff;
    color: #212529;
}
