/* ==========================================================================
   Modo escuro — Portal da Transparência
   Ativado pela classe .theme-dark no <html> (assets/dist/js/tema.js; aplicada
   já no <head> dos layouts públicos para não piscar branco).

   - Independente do "Alto Contraste": o Alto Contraste aplica style inline e
     continua vencendo tudo aqui (evitar !important — só onde o vendor já usa).
   - Tokens com prefixo --esc-*: o DataTables 2 já usa --dt-* (--dt-row-stripe,
     --dt-row-hover...), não reaproveitar esse prefixo.
   ========================================================================== */

html.theme-dark {
    color-scheme: dark;
    --esc-bg: #0e1330;
    --esc-surface: #161d3f;
    --esc-surface-2: #1e2750;
    --esc-border: #2b3564;
    --esc-text: #e3e6f0;
    --esc-muted: #9aa2c0;
    --esc-link: #ff8a5c;
    /* DataTables 2: listras/hover claros sobre fundo escuro */
    --dt-row-stripe: 255, 255, 255;
    --dt-row-hover: 255, 255, 255;
    --dt-row-selected: 242, 84, 45;
    --dt-html-background: #161d3f;
}

/* ---------- Base ---------- */
html.theme-dark body,
html.theme-dark .page-wrapper,
html.theme-dark .preloader {
    background-color: var(--esc-bg);
    color: var(--esc-text);
}

html.theme-dark h1, html.theme-dark h2, html.theme-dark h3,
html.theme-dark h4, html.theme-dark h5, html.theme-dark h6,
html.theme-dark .card-title,
html.theme-dark .text-themecolor,
html.theme-dark label {
    color: var(--esc-text);
}

html.theme-dark a {
    color: var(--esc-link);
}

    html.theme-dark a:hover {
        color: #fff;
    }

html.theme-dark hr {
    border-color: var(--esc-border);
}

html.theme-dark .text-muted {
    color: var(--esc-muted) !important;
}

html.theme-dark .text-dark {
    color: var(--esc-text) !important;
}

html.theme-dark .bg-white,
html.theme-dark .bg-light {
    background-color: var(--esc-surface) !important;
}

html.theme-dark .border,
html.theme-dark .border-top,
html.theme-dark .border-bottom,
html.theme-dark .border-left,
html.theme-dark .border-right {
    border-color: var(--esc-border) !important;
}

/* textos com color:#000 inline (ex.: títulos da tela de entidades) */
html.theme-dark [style*="color:#000"],
html.theme-dark [style*="color: #000"] {
    color: var(--esc-text) !important;
}

/* ---------- Superfícies ---------- */
html.theme-dark .card,
html.theme-dark .footer,
html.theme-dark .footerGrafico,
html.theme-dark .page-titles,
html.theme-dark .modal-content,
html.theme-dark .dropdown-menu,
html.theme-dark .list-group-item,
html.theme-dark .right-sidebar,
html.theme-dark .horizontal-nav .left-sidebar,
html.theme-dark .linha0 {
    background-color: var(--esc-surface);
    color: var(--esc-text);
    border-color: var(--esc-border);
}

html.theme-dark .page-titles {
    box-shadow: none;
}

html.theme-dark .breadcrumb {
    background-color: transparent;
}

html.theme-dark body[class*="skin-"] .page-titles .breadcrumb .breadcrumb-item.active {
    color: var(--esc-text);
}

html.theme-dark .card-header,
html.theme-dark .card-footer {
    background-color: rgba(255, 255, 255, .03);
}

html.theme-dark .modal-footer,
html.theme-dark .footer {
    border-top-color: var(--esc-border);
}

html.theme-dark .modal-header {
    background: #0b1027;
}

html.theme-dark .dropdown-item {
    color: var(--esc-text);
}

    html.theme-dark .dropdown-item:hover,
    html.theme-dark .dropdown-item:focus {
        background-color: var(--esc-surface-2);
        color: #fff;
    }

/* ---------- Cards de menu (Home / submenus) ---------- */
html.theme-dark .menu-card .icon-wrap,
html.theme-dark .menu-card.menu-card-back .icon-wrap {
    background: var(--esc-surface-2);
    box-shadow: none;
}

html.theme-dark .menu-card:hover .icon-wrap {
    background: #28325f;
}

html.theme-dark .menu-card .card-label,
html.theme-dark .menu-card.menu-card-back .card-label {
    color: var(--esc-text);
}

html.theme-dark .menu-card:hover {
    box-shadow: 0 .75rem 1.5rem rgba(0, 0, 0, .45), 0 0 0 1px rgba(255, 255, 255, .08) !important;
}

html.theme-dark .mapa-site {
    background: #0b1027;
}

/* ---------- Menu lateral: um tom abaixo do navy do topo ---------- */
html.theme-dark #menu-lateral,
html.theme-dark #menu-lateral .scroll-sidebar,
html.theme-dark #menu-lateral .sidebar-nav,
html.theme-dark .mini-sidebar #menu-lateral .sidebar-nav #sidebarnav > li > ul {
    background: #11173a;
}

/* recolhido: fundo só na coluna de 70px (ver abase-marca.css) */
html.theme-dark .mini-sidebar #menu-lateral .scroll-sidebar,
html.theme-dark .mini-sidebar #menu-lateral .sidebar-nav {
    background: transparent;
}

html.theme-dark .horizontal-nav .sidebar-nav #sidebarnav > li:hover > a,
html.theme-dark .horizontal-nav .sidebar-nav #sidebarnav > li > ul {
    background: var(--esc-surface-2);
}

html.theme-dark .sidebar-nav ul li a {
    color: var(--esc-text);
}

/* ---------- Tabelas ---------- */
html.theme-dark .table,
html.theme-dark table.dataTable {
    color: var(--esc-text);
}

    html.theme-dark .table td,
    html.theme-dark .table th,
    html.theme-dark .table thead th,
    html.theme-dark .table-bordered,
    html.theme-dark .table-bordered td,
    html.theme-dark .table-bordered th,
    html.theme-dark table.dataTable > thead > tr > th,
    html.theme-dark table.dataTable > thead > tr > td {
        border-color: var(--esc-border);
    }

html.theme-dark .table-striped tbody tr:nth-of-type(odd) {
    background-color: rgba(255, 255, 255, .03);
}

html.theme-dark .table-hover tbody tr:hover {
    color: var(--esc-text);
    background-color: rgba(255, 255, 255, .06);
}

html.theme-dark .table .thead-light th {
    color: var(--esc-text);
    background-color: var(--esc-surface-2);
    border-color: var(--esc-border);
}

html.theme-dark .dt-empty-state {
    color: var(--esc-muted);
}

/* ---------- Formulários ---------- */
html.theme-dark .form-control,
html.theme-dark .custom-select,
html.theme-dark .input-group-text,
html.theme-dark .dt-length select,
html.theme-dark .dt-search input,
html.theme-dark .dataTables_filter input,
html.theme-dark .dataTables_length select {
    background-color: var(--esc-surface-2);
    color: var(--esc-text);
    border-color: var(--esc-border);
}

    html.theme-dark .form-control:focus {
        background-color: var(--esc-surface-2);
        color: var(--esc-text);
        border-color: var(--abase-orange, #f2542d);
    }

    html.theme-dark .form-control::placeholder {
        color: var(--esc-muted);
    }

    html.theme-dark .form-control:disabled,
    html.theme-dark .form-control[readonly] {
        background-color: #141a38;
        color: var(--esc-muted);
    }

html.theme-dark .btn-secondary,
html.theme-dark .btn-light,
html.theme-dark .btn-default,
html.theme-dark .abase .card .btn-secondary {
    background-color: var(--esc-surface-2);
    border-color: var(--esc-border);
    color: var(--esc-text);
}

    html.theme-dark .btn-secondary:hover,
    html.theme-dark .btn-light:hover,
    html.theme-dark .btn-default:hover {
        background-color: #28325f;
        color: #fff;
    }

html.theme-dark .nav-tabs {
    border-bottom-color: var(--esc-border);
}

    html.theme-dark .nav-tabs .nav-link.active,
    html.theme-dark .nav-tabs .nav-item.show .nav-link {
        background-color: var(--esc-surface);
        color: var(--esc-text);
        border-color: var(--esc-border) var(--esc-border) var(--esc-surface);
    }

html.theme-dark body .page-link {
    background-color: var(--esc-surface);
    border-color: var(--esc-border);
    color: var(--esc-text);
}

html.theme-dark body .page-item.disabled .page-link {
    background-color: var(--esc-surface);
    color: var(--esc-muted);
}

/* Select2 */
html.theme-dark .select2-container--default .select2-selection--single,
html.theme-dark .select2-container--default .select2-selection--multiple,
html.theme-dark .select2-dropdown,
html.theme-dark .select2-container--default .select2-search--dropdown .select2-search__field {
    background-color: var(--esc-surface-2);
    border-color: var(--esc-border);
    color: var(--esc-text);
}

html.theme-dark .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: var(--esc-text);
}

html.theme-dark .select2-container--default .select2-results__option[aria-selected=true],
html.theme-dark .select2-container--default .select2-results__option--selected {
    background-color: #28325f;
}

/* bootstrap-select */
html.theme-dark .bootstrap-select .dropdown-toggle .filter-option-inner-inner {
    color: var(--esc-text);
}

html.theme-dark body .bootstrap-select .dropdown-menu li a:hover,
html.theme-dark body .bootstrap-select .dropdown-menu li a:focus {
    background: var(--esc-surface-2);
}

/* ---------- FullCalendar (calendário de licitações) ---------- */
html.theme-dark .fc-unthemed th,
html.theme-dark .fc-unthemed td,
html.theme-dark .fc-unthemed thead,
html.theme-dark .fc-unthemed tbody,
html.theme-dark .fc-unthemed .fc-divider,
html.theme-dark .fc-unthemed .fc-row,
html.theme-dark .fc-unthemed .fc-content,
html.theme-dark .fc-unthemed .fc-popover,
html.theme-dark .fc-unthemed .fc-list-view,
html.theme-dark .fc-unthemed .fc-list-heading td {
    border-color: var(--esc-border);
}

html.theme-dark .fc-unthemed .fc-popover,
html.theme-dark .fc-unthemed .fc-list-heading td,
html.theme-dark .fc-unthemed .fc-divider {
    background: var(--esc-surface-2);
}

html.theme-dark .fc-unthemed td.fc-today {
    background: rgba(242, 84, 45, .12);
}

html.theme-dark .fc-unthemed .fc-list-item:hover td {
    background-color: rgba(255, 255, 255, .06);
}

/* ---------- Botão do tema no topo ---------- */
#tema_escuro .nav-link {
    cursor: pointer;
}

/* ---------- Painel de Serviços: itens de acessibilidade (o vendor fixa #212529 no span) ---------- */
html.theme-dark .right-sidebar .chatonline li a span {
    color: var(--esc-text);
}

    html.theme-dark .right-sidebar .chatonline li a:hover span,
    html.theme-dark .right-sidebar .chatonline li a:focus-visible span {
        color: var(--abase-orange, #f2542d);
    }

/* ---------- Breadcrumb: itens com link e separador ---------- */
html.theme-dark .page-titles .breadcrumb .breadcrumb-item a,
html.theme-dark .page-titles .breadcrumb .breadcrumb-item + .breadcrumb-item::before {
    color: var(--esc-muted);
}

    html.theme-dark .page-titles .breadcrumb .breadcrumb-item a:hover {
        color: var(--esc-text);
    }
