:root {
    --admin-bg: #f1f1ee;
    --admin-surface: #f8f8f5;
    --admin-surface-strong: #fcfcfa;
    --admin-border: #e4e3de;
    --admin-text-soft: #5f6470;
}

body[data-layout-mode="dark"] {
    --admin-bg: #1f232b;
    --admin-surface: #2a2f39;
    --admin-surface-strong: #323847;
    --admin-border: #40485a;
    --admin-text-soft: #d3dbea;
    color: #e7edf7 !important;
}

html,
body,
#layout-wrapper {
    background-color: var(--admin-bg) !important;
}

.page-content,
.main-content,
.container-fluid {
    background-color: var(--admin-bg) !important;
}

.card,
.table,
.dropdown-menu,
.modal-content {
    background-color: var(--admin-surface);
}

.card {
    border: 1px solid var(--admin-border);
    box-shadow: 0 3px 12px rgba(18, 28, 45, 0.05);
}

.table {
    background-color: var(--admin-surface-strong);
}

.form-control,
.form-select {
    background-color: var(--admin-surface-strong);
    border-color: var(--admin-border);
}

body[data-layout-mode="dark"] .card,
body[data-layout-mode="dark"] .table,
body[data-layout-mode="dark"] .dropdown-menu,
body[data-layout-mode="dark"] .modal-content {
    color: #e7edf7 !important;
}

body[data-layout-mode="dark"] .table {
    --bs-table-bg: var(--admin-surface-strong);
    --bs-table-color: #e7edf7;
    --bs-table-striped-color: #e7edf7;
    --bs-table-hover-color: #ffffff;
}

body[data-layout-mode="dark"] .table > :not(caption) > * > * {
    color: #e7edf7 !important;
    border-bottom-color: var(--admin-border) !important;
}

body[data-layout-mode="dark"] .card-title,
body[data-layout-mode="dark"] .form-label,
body[data-layout-mode="dark"] .text-muted {
    color: #d3dbea !important;
}

body[data-layout-mode="dark"] .form-control,
body[data-layout-mode="dark"] .form-select {
    color: #eef3ff !important;
    background-color: var(--admin-surface-strong) !important;
    border-color: var(--admin-border) !important;
}

body[data-layout-mode="dark"] .form-control::placeholder {
    color: #b8c2d8 !important;
}

body[data-layout-mode="dark"] a {
    color: #98bbff;
}

body[data-layout-mode="dark"] a:hover {
    color: #bed3ff;
}

.page-content .container-fluid {
    padding-top: 10px;
}

.footer {
    background: transparent !important;
    border-top: 1px solid var(--admin-border) !important;
    box-shadow: none !important;
}

.footer .container-fluid {
    background: transparent !important;
}

.footer .text-sm-end {
    color: var(--admin-text-soft);
}

.card-title,
.text-muted,
.form-label {
    color: var(--admin-text-soft);
}

.table > :not(caption) > * > * {
    border-bottom-color: var(--admin-border);
}

/* DataTables (jquery.dataTables.min.css) uses .display + .sorting_1 with light #fafafa on sorted column — breaks dark theme */
body[data-layout-mode="dark"] table.dataTable tbody tr {
    background-color: transparent !important;
}
body[data-layout-mode="dark"] table.dataTable tbody td {
    background-color: var(--admin-surface-strong) !important;
    color: #e7edf7 !important;
}
body[data-layout-mode="dark"] table.dataTable.display tbody tr.odd > td,
body[data-layout-mode="dark"] table.dataTable.stripe tbody tr.odd > td {
    background-color: var(--admin-surface) !important;
}
body[data-layout-mode="dark"] table.dataTable.display tbody tr.even > td,
body[data-layout-mode="dark"] table.dataTable.stripe tbody tr.even > td {
    background-color: rgba(255, 255, 255, 0.04) !important;
}
body[data-layout-mode="dark"] table.dataTable.display tbody tr.odd > .sorting_1,
body[data-layout-mode="dark"] table.dataTable.display tbody tr.odd > .sorting_2,
body[data-layout-mode="dark"] table.dataTable.display tbody tr.odd > .sorting_3,
body[data-layout-mode="dark"] table.dataTable.order-column.stripe tbody tr.odd > .sorting_1 {
    background-color: var(--admin-surface) !important;
    color: #e7edf7 !important;
}
body[data-layout-mode="dark"] table.dataTable.display tbody tr.even > .sorting_1,
body[data-layout-mode="dark"] table.dataTable.display tbody tr.even > .sorting_2,
body[data-layout-mode="dark"] table.dataTable.display tbody tr.even > .sorting_3,
body[data-layout-mode="dark"] table.dataTable.order-column.stripe tbody tr.even > .sorting_1 {
    background-color: rgba(255, 255, 255, 0.04) !important;
    color: #e7edf7 !important;
}
body[data-layout-mode="dark"] table.dataTable.display tbody tr:hover > td,
body[data-layout-mode="dark"] table.dataTable.hover tbody tr:hover > td {
    background-color: rgba(255, 255, 255, 0.08) !important;
}
body[data-layout-mode="dark"] .table-hover > tbody > tr:nth-of-type(2n) {
    background-color: transparent !important;
}
body[data-layout-mode="dark"] .dataTables_wrapper .dataTables_length,
body[data-layout-mode="dark"] .dataTables_wrapper .dataTables_filter,
body[data-layout-mode="dark"] .dataTables_wrapper .dataTables_info,
body[data-layout-mode="dark"] .dataTables_wrapper .dataTables_paginate {
    color: var(--admin-text-soft) !important;
}
