/**
 * Modo escuro — estilos globais do sistema Ágil Fiscal
 * IMPORTANTE: não altera --primary-color global (sidebar usa tokens --sb-* em main.php)
 */

html.agil-theme-dark {
    color-scheme: dark;

    --agil-dark-bg: #0f1419;
    --agil-dark-surface: #1a2332;
    --agil-dark-surface-2: #243044;
    --agil-dark-surface-3: #2d3a50;
    --agil-dark-border: rgba(255, 255, 255, 0.12);
    --agil-dark-text: #e2e8f0;
    --agil-dark-text-muted: #94a3b8;
    --agil-dark-accent: #2dd4bf;
    --agil-dark-accent-soft: rgba(45, 212, 191, 0.12);

    --ui-border: rgba(255, 255, 255, 0.14);
    --ui-card-bg: #1a2332;
    --ui-shell-bg: #121820;
    --ui-shadow: 0 6px 20px rgba(0, 0, 0, 0.35), 0 2px 8px rgba(0, 0, 0, 0.25);
    --ui-shadow-sm: 0 3px 12px rgba(0, 0, 0, 0.28), 0 1px 4px rgba(0, 0, 0, 0.18);
    --ui-shadow-modal: 0 12px 40px rgba(0, 0, 0, 0.45), 0 4px 14px rgba(0, 0, 0, 0.3);
}

html.agil-theme-dark body {
    background-color: var(--agil-dark-bg) !important;
    color: var(--agil-dark-text);
}

html.agil-theme-dark .main-content {
    background-color: var(--agil-dark-bg);
    color: var(--agil-dark-text);
}

html.agil-theme-dark h1,
html.agil-theme-dark h2,
html.agil-theme-dark h3,
html.agil-theme-dark h4,
html.agil-theme-dark h5,
html.agil-theme-dark h6,
html.agil-theme-dark p,
html.agil-theme-dark span,
html.agil-theme-dark small,
html.agil-theme-dark li {
    color: inherit;
}

/* Cards Bootstrap */
html.agil-theme-dark .card {
    background-color: var(--agil-dark-surface);
    color: var(--agil-dark-text);
    border-color: var(--agil-dark-border) !important;
    box-shadow: var(--ui-shadow-sm);
}

html.agil-theme-dark .card-header {
    background: linear-gradient(135deg, rgba(5, 88, 93, 0.9), rgba(4, 74, 78, 0.85)) !important;
    color: #fff !important;
    border-bottom-color: var(--agil-dark-border) !important;
}

html.agil-theme-dark .card-body,
html.agil-theme-dark .card-footer {
    background-color: var(--agil-dark-surface);
    color: var(--agil-dark-text);
    border-color: var(--agil-dark-border);
}

/* Formulários */
html.agil-theme-dark .form-control,
html.agil-theme-dark .form-select,
html.agil-theme-dark .form-control:focus,
html.agil-theme-dark .form-select:focus {
    background-color: var(--agil-dark-surface-2);
    border-color: var(--agil-dark-border);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .form-control:focus,
html.agil-theme-dark .form-select:focus {
    box-shadow: 0 0 0 0.2rem rgba(45, 212, 191, 0.2);
    border-color: var(--agil-dark-accent);
}

html.agil-theme-dark .form-control::placeholder {
    color: var(--agil-dark-text-muted);
    opacity: 0.85;
}

html.agil-theme-dark .form-control:disabled,
html.agil-theme-dark .form-select:disabled {
    background-color: var(--agil-dark-surface-3);
    color: var(--agil-dark-text-muted);
}

html.agil-theme-dark .form-label,
html.agil-theme-dark label {
    color: var(--agil-dark-text) !important;
}

html.agil-theme-dark .form-text {
    color: var(--agil-dark-text-muted) !important;
}

html.agil-theme-dark .input-group-text {
    background-color: var(--agil-dark-surface-2);
    border-color: var(--agil-dark-border);
    color: var(--agil-dark-text);
}

/* Tabelas */
html.agil-theme-dark .table {
    color: var(--agil-dark-text);
    border-color: var(--agil-dark-border);
}

html.agil-theme-dark .table thead th,
html.agil-theme-dark .table-light th {
    background-color: var(--agil-dark-surface-2) !important;
    color: var(--agil-dark-text-muted) !important;
    border-color: var(--agil-dark-border) !important;
}

html.agil-theme-dark .table td,
html.agil-theme-dark .table th {
    border-color: var(--agil-dark-border);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(255, 255, 255, 0.03);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .table-hover > tbody > tr:hover > * {
    background-color: rgba(45, 212, 191, 0.08);
    color: var(--agil-dark-text);
}

/* Modais genéricos — cabeçalho: public/assets/css/modal-header.css */
html.agil-theme-dark .modal-footer:not(.modal-editar-usuario-footer) {
    background-color: var(--agil-dark-surface) !important;
    border-top-color: var(--agil-dark-border);
}

html.agil-theme-dark .modal-body:not(.modal-editar-usuario-body) {
    color: var(--agil-dark-text);
}

html.agil-theme-dark .btn-close {
    filter: invert(1) grayscale(100%) brightness(200%);
}

html.agil-theme-dark .modal-content > .modal-header .btn-close,
html.agil-theme-dark #modalEditarUsuario .modal-editar-usuario-header .btn-close {
    filter: none;
}

/* Modal editar usuário: estilos em app/Views/usuarios/_estilos_modal_editar_usuario.php (tokens --me-*) */

/* Dashboard principal: app/Views/home/_estilos_padrao.php (#dashboard-app) */

/* Dropdowns e listas */
html.agil-theme-dark .dropdown-menu {
    background-color: var(--agil-dark-surface);
    border-color: var(--agil-dark-border);
    box-shadow: var(--ui-shadow);
}

html.agil-theme-dark .dropdown-item {
    color: var(--agil-dark-text);
}

html.agil-theme-dark .dropdown-item:hover,
html.agil-theme-dark .dropdown-item:focus {
    background-color: var(--agil-dark-accent-soft);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .dropdown-divider {
    border-color: var(--agil-dark-border);
}

html.agil-theme-dark .list-group-item {
    background-color: var(--agil-dark-surface);
    color: var(--agil-dark-text);
    border-color: var(--agil-dark-border);
}

html.agil-theme-dark .list-group-item-action:hover {
    background-color: var(--agil-dark-surface-2);
    color: var(--agil-dark-text);
}

/* Alertas */
html.agil-theme-dark .alert-secondary,
html.agil-theme-dark .alert-light,
html.agil-theme-dark .alert-info {
    background-color: var(--agil-dark-surface-2);
    border-color: var(--agil-dark-border);
    color: var(--agil-dark-text);
}

/* Utilitários Bootstrap */
html.agil-theme-dark .text-dark {
    color: var(--agil-dark-text) !important;
}

html.agil-theme-dark .text-muted {
    color: var(--agil-dark-text-muted) !important;
}

html.agil-theme-dark .bg-light {
    background-color: var(--agil-dark-surface-2) !important;
    color: var(--agil-dark-text) !important;
}

html.agil-theme-dark .bg-white {
    background-color: var(--agil-dark-surface) !important;
    color: var(--agil-dark-text) !important;
}

html.agil-theme-dark .border,
html.agil-theme-dark .border-top,
html.agil-theme-dark .border-bottom,
html.agil-theme-dark .border-start,
html.agil-theme-dark .border-end {
    border-color: var(--agil-dark-border) !important;
}

html.agil-theme-dark .badge.bg-light.text-dark {
    background-color: var(--agil-dark-surface-2) !important;
    color: var(--agil-dark-text) !important;
    border: 1px solid var(--agil-dark-border);
}

/* Paginação */
html.agil-theme-dark .page-link {
    background-color: var(--agil-dark-surface);
    border-color: var(--agil-dark-border);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .page-item.active .page-link {
    background-color: #05585d;
    border-color: #05585d;
}

html.agil-theme-dark .page-item.disabled .page-link {
    background-color: var(--agil-dark-surface-2);
    color: var(--agil-dark-text-muted);
}

/* Nav tabs genéricos */
html.agil-theme-dark .nav-tabs {
    border-bottom-color: var(--agil-dark-border);
}

html.agil-theme-dark .nav-tabs .nav-link {
    color: var(--agil-dark-text-muted);
}

html.agil-theme-dark .nav-tabs .nav-link:hover {
    border-color: var(--agil-dark-border);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .nav-tabs .nav-link.active {
    background-color: var(--agil-dark-surface);
    border-color: var(--agil-dark-border) var(--agil-dark-border) var(--agil-dark-surface);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .nav-pills .nav-link:not(.active) {
    color: var(--agil-dark-text-muted);
}

/* UI tokens compartilhados */
html.agil-theme-dark .ui-shell,
html.agil-theme-dark .ui-card {
    background-color: var(--ui-shell-bg) !important;
    border-color: var(--ui-border) !important;
    color: var(--agil-dark-text);
}

html.agil-theme-dark .ui-page-title,
html.agil-theme-dark [class*="-page-title"]:not(.sidebar *) {
    color: var(--agil-dark-accent) !important;
}

html.agil-theme-dark .ui-subtitle,
html.agil-theme-dark .ui-data-meta,
html.agil-theme-dark [class*="-subtitle"]:not(.sidebar *) {
    color: var(--agil-dark-text-muted) !important;
}

/* Select2 */
html.agil-theme-dark .select2-container--default .select2-selection--single,
html.agil-theme-dark .select2-container--default .select2-selection--multiple {
    background-color: var(--agil-dark-surface-2);
    border-color: var(--agil-dark-border);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .select2-dropdown {
    background-color: var(--agil-dark-surface);
    border-color: var(--agil-dark-border);
}

html.agil-theme-dark .select2-container--default .select2-results__option {
    color: var(--agil-dark-text);
}

html.agil-theme-dark .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: var(--agil-dark-accent-soft);
    color: var(--agil-dark-text);
}

/* Scrollbar */
html.agil-theme-dark ::-webkit-scrollbar {
    width: 10px;
    height: 10px;
}

html.agil-theme-dark ::-webkit-scrollbar-track {
    background: var(--agil-dark-bg);
}

html.agil-theme-dark ::-webkit-scrollbar-thumb {
    background: var(--agil-dark-surface-3);
    border-radius: 5px;
}

html.agil-theme-dark ::-webkit-scrollbar-thumb:hover {
    background: #3d4f66;
}

html.agil-theme-dark footer {
    background-color: #0a0e14 !important;
    color: var(--agil-dark-text-muted);
}

html.agil-theme-dark .btn-outline-secondary {
    color: var(--agil-dark-text);
    border-color: var(--agil-dark-border);
}

html.agil-theme-dark .btn-outline-secondary:hover {
    background-color: var(--agil-dark-surface-2);
    color: var(--agil-dark-text);
    border-color: var(--agil-dark-border);
}

html.agil-theme-dark .btn-outline-primary:not(.active) {
    color: var(--agil-dark-accent);
    border-color: rgba(45, 212, 191, 0.45);
    background: transparent;
}

html.agil-theme-dark .btn-outline-primary:not(.active):hover {
    background: var(--agil-dark-accent-soft);
    color: var(--agil-dark-accent);
}

html.agil-theme-dark hr {
    border-color: var(--agil-dark-border);
    opacity: 1;
}

html.agil-theme-dark pre,
html.agil-theme-dark code {
    background-color: var(--agil-dark-surface-2);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .popover {
    background-color: var(--agil-dark-surface);
    border-color: var(--agil-dark-border);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .popover-header {
    background-color: var(--agil-dark-surface-2);
    border-bottom-color: var(--agil-dark-border);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .tooltip-inner {
    background-color: var(--agil-dark-surface-3);
}

html.agil-theme-dark .offcanvas {
    background-color: var(--agil-dark-surface);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .offcanvas-header {
    border-bottom-color: var(--agil-dark-border);
}

html.agil-theme-dark .accordion-item {
    background-color: var(--agil-dark-surface);
    border-color: var(--agil-dark-border);
}

html.agil-theme-dark .accordion-button {
    background-color: var(--agil-dark-surface-2);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .accordion-button:not(.collapsed) {
    background-color: var(--agil-dark-accent-soft);
    color: var(--agil-dark-text);
}

html.agil-theme-dark .accordion-body {
    background-color: var(--agil-dark-surface);
    color: var(--agil-dark-text);
}

/* Chart.js legendas/tooltips em canvas ficam no JS — área ao redor */
html.agil-theme-dark canvas {
    filter: none;
}
