/* ================================================================
   MODO ESCURO (DARK MODE) — TODOS os overrides body[class*="-dark"]
   consolidados aqui. Antes estavam espalhados em ~6 pontos diferentes
   do site.css original; qualquer ajuste de tema escuro deve entrar
   neste arquivo daqui em diante.
   ================================================================ */

/* --- Cards de menu / grupo / filhos --- */
body[class*="-dark"] .menu-grupo-card,
body[class*="-dark"] .menu-grupo-filhos,
body[class*="-dark"] .menu-card {
    background-color: #2b3035 !important;
    border-color: #3e444a !important;
}

body[class*="-dark"] .menu-grupo-nome,
body[class*="-dark"] .menu-card .card-title,
body[class*="-dark"] .menu-filho-item {
    color: #e2e8f0 !important;
}

/* Garante que o botão de sair continue vermelho mesmo no tema escuro */
body[class*="-dark"] .menu-card-sair .menu-grupo-nome,
body[class*="-dark"] .menu-card-sair i {
    color: #e57373 !important;
}

body[class*="-dark"] .menu-filho-item {
    border-bottom-color: #3e444a !important;
}

body[class*="-dark"] .menu-filho-item:hover {
    background-color: #3e444a !important;
    color: #61b0ff !important;
}

/* --- Selectpicker, Notify e SweetAlert --- */

/* Selectpicker: Cor da fonte selecionada no modo escuro */
body[class*="-dark"] .bootstrap-select .dropdown-toggle .filter-option-inner-inner,
body[class*="-dark"] .bootstrap-select > .dropdown-toggle {
    color: #ffffff !important;
}

/* Selectpicker: Cor do hover nas opções no modo escuro */
body[class*="-dark"] .bootstrap-select .dropdown-menu .dropdown-item:hover,
body[class*="-dark"] .bootstrap-select .dropdown-menu .dropdown-item:focus,
body[class*="-dark"] .bootstrap-select .dropdown-menu .dropdown-item.active,
body[class*="-dark"] .bootstrap-select .dropdown-menu .dropdown-item:active {
    background-color: #3e444a !important;
    color: #ffffff !important;
}

/* Selectpicker: Mensagem "Nenhum resultado" no modo escuro */
body[class*="-dark"] .bootstrap-select .dropdown-menu .no-results {
    background-color: #3e444a !important;
    color: #ffffff !important;
}

/* Input File: Estilo para o botão "Escolher arquivo" no modo escuro */
body[class*="-dark"] input[type="file"]::file-selector-button,
body[class*="-dark"] input[type="file"]::-webkit-file-upload-button {
    background-color: #3e444a !important;
    color: #ffffff !important;
    border: 1px solid #4a5057 !important;
    transition: background-color 0.2s ease-in-out;
}

body[class*="-dark"] input[type="file"]:hover::file-selector-button,
body[class*="-dark"] input[type="file"]:hover::-webkit-file-upload-button {
    background-color: #4a5057 !important;
}

/* Inputs de Data/Hora: Popup e ícone do calendário com tema escuro nativo */
body[class*="-dark"] input[type="date"],
body[class*="-dark"] input[type="time"],
body[class*="-dark"] input[type="datetime-local"] {
    color-scheme: dark;
}

/* Bootstrap Notify: Melhorar o contraste para notificações em modo escuro */
body[class*="-dark"] [data-notify="container"] {
    color: #ffffff !important;
}

body[class*="-dark"] [data-notify="container"].alert-info {
    background-color: #113642 !important;
    border-color: #0f2c36 !important;
}

body[class*="-dark"] [data-notify="container"].alert-success {
    background-color: #144626 !important;
    border-color: #11381e !important;
}

body[class*="-dark"] [data-notify="container"].alert-warning {
    background-color: #5c410b !important;
    border-color: #4b3509 !important;
}

body[class*="-dark"] [data-notify="container"].alert-danger {
    background-color: #5a151b !important;
    border-color: #481116 !important;
}

/* Alertas "soltos" (Bootstrap .alert-*, fora do notify) — ex.: erro de login
   ("Usuário não encontrado"), 2FA, recuperação de senha. Sem isso, o texto
   herda a cor padrão do Bootstrap (escura) e fica ilegível no tema escuro. */
body[class*="-dark"] .alert-info {
    background-color: #113642 !important;
    border-color: #0f2c36 !important;
    color: #ffffff !important;
}

body[class*="-dark"] .alert-success {
    background-color: #144626 !important;
    border-color: #11381e !important;
    color: #ffffff !important;
}

body[class*="-dark"] .alert-warning {
    background-color: #5c410b !important;
    border-color: #4b3509 !important;
    color: #ffffff !important;
}

body[class*="-dark"] .alert-danger {
    background-color: #5a151b !important;
    border-color: #481116 !important;
    color: #ffffff !important;
}

/* SweetAlert2: Ajustes de tema escuro */
body[class*="-dark"] .swal2-popup {
    background: #2b3035 !important;
    color: #e2e8f0 !important;
}

body[class*="-dark"] .swal2-title,
body[class*="-dark"] .swal2-content,
body[class*="-dark"] .swal2-html-container {
    color: #e2e8f0 !important;
}

body[class*="-dark"] .swal2-icon.swal2-warning {
    border-color: #ffca28 !important;
    color: #ffca28 !important;
}

body[class*="-dark"] .swal2-icon.swal2-info {
    border-color: #29b6f6 !important;
    color: #29b6f6 !important;
}

body[class*="-dark"] .swal2-icon.swal2-success {
    border-color: #66bb6a !important;
    color: #66bb6a !important;
}

body[class*="-dark"] .swal2-icon.swal2-success [class^="swal2-success-line"] {
    background-color: #66bb6a !important;
}

body[class*="-dark"] .swal2-icon.swal2-success .swal2-success-ring {
    border-color: rgba(102, 187, 106, 0.3) !important;
}

body[class*="-dark"] .swal2-icon.swal2-error {
    border-color: #ef5350 !important;
    color: #ef5350 !important;
}

body[class*="-dark"] .swal2-icon.swal2-error [class^="swal2-x-mark-line"] {
    background-color: #ef5350 !important;
}

/* Correção do Autofill dos navegadores no modo escuro */
body[class*="-dark"] input:-webkit-autofill,
body[class*="-dark"] input:-webkit-autofill:hover,
body[class*="-dark"] input:-webkit-autofill:focus,
body[class*="-dark"] input:-webkit-autofill:active,
body[class*="-dark"] input.form-control:-webkit-autofill,
body[class*="-dark"] input.form-control:-webkit-autofill:hover,
body[class*="-dark"] input.form-control:-webkit-autofill:focus,
body[class*="-dark"] input.form-control:-webkit-autofill:active {
    -webkit-text-fill-color: #ffffff !important;
    color: #ffffff !important;
    caret-color: #ffffff !important;
    color-scheme: dark !important;
    transition: background-color 5000s ease-in-out 0s !important;
}

body[class*="-dark"] input:-webkit-autofill::first-line,
body[class*="-dark"] input.form-control:-webkit-autofill::first-line {
    -webkit-text-fill-color: #ffffff !important;
    color: #ffffff !important;
}

/* Folha de pagamento: Fundo do bloco de exibição do período (bg-light) no modo escuro */
body[class*="-dark"] .bg-light {
    background-color: #3e444a !important;
    color: #ffffff !important;
}

/* Asterisco de campo obrigatório no modo escuro */
body[class*="-dark"] .label-danger-form {
    color: #ef5350 !important;
}

/* Custom loading: Ajuste do fundo e texto no modo escuro */
body[class*="-dark"] .element-loading-content {
    background-color: #2b3035 !important;
    color: #e2e8f0 !important;
}

/* --- Nav Pills Custom --- */
body[class*="-dark"] .nav-pills-custom {
    background: #2b3035;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.2);
}
body[class*="-dark"] .nav-pills-custom .nav-link {
    color: #cbd5e1;
}
body[class*="-dark"] .nav-pills-custom .nav-link:hover {
    background: rgba(25, 118, 210, 0.2);
    color: #64b5f6;
}
body[class*="-dark"] .nav-pills-custom .nav-link.active {
    background: #1976d2 !important;
    color: #fff !important;
}

/* --- Menu Card Dinâmico (favoritos/recentes) --- */
body[class*="-dark"] .menu-card-item {
    background: #2b3035 !important;
    border: 1.5px solid rgba(255, 255, 255, 0.1) !important;
    color: #e2e8f0 !important;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3) !important;
}

/* Tratamento de hover para o Dark Mode */
body[class*="-dark"] .menu-card-item:hover {
    border-color: #4a5057 !important;
    box-shadow: 0 10px 24px rgba(0, 0, 0, 0.4) !important;
}

/* --- Impersonação / z-index de modais ---
   A barra fixa #barra-impersonacao usa z-index:99999 e cobria modais/alertas/o
   Painel de Serviços (.right-sidebar) em várias telas. Garante que todos eles
   fiquem acima dela.
   (Mantido aqui por estar historicamente junto aos ajustes de dark mode;
   não depende de tema, é sempre aplicado.) */
.right-sidebar { z-index: 100010 !important; }
.modal-backdrop { z-index: 100040 !important; }
.modal { z-index: 100050 !important; }
.swal2-container { z-index: 100060 !important; }

/* --- Dashboard --- */
body[class*="-dark"] #lbl-recibos-desk {
    color: #ffffff !important;
}

/* --- Notas de versão: modal e drawer de histórico ---
   O conteúdo (nota.conteudoHtml) vem de um editor rich-text e costuma trazer
   cor inline (ex: style="color:#000"), por isso o override do texto precisa
   de !important mesmo dentro do container escuro. */
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll {
    background: var(--tema-surface) !important;
    border-color: var(--tema-border) !important;
    color: var(--tema-text) !important;
}

body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll p,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll span,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll div,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll li,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll strong,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll b,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll em,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll i,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll td,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll th,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll h1,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll h2,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll h3,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll h4,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll h5,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll h6,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll blockquote,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll small,
body[class*="-dark"] #modal-notas-versao .ndv-conteudo-scroll label {
    color: var(--tema-text) !important;
}

body[class*="-dark"] #modal-notas-versao .ndv-emoji-label {
    color: var(--tema-text-muted) !important;
}

body[class*="-dark"] .ndv-historico {
    background: var(--tema-surface) !important;
    box-shadow: -10px 0 30px rgba(0, 0, 0, .5) !important;
}

body[class*="-dark"] .ndv-historico__header,
body[class*="-dark"] .ndv-historico__search {
    border-color: var(--tema-border) !important;
}

body[class*="-dark"] .ndv-historico__subtitle,
body[class*="-dark"] .ndv-historico__loading,
body[class*="-dark"] .ndv-historico__empty,
body[class*="-dark"] .ndv-historico__itemMeta {
    color: var(--tema-text-muted) !important;
}

body[class*="-dark"] .ndv-historico__close {
    color: var(--tema-text) !important;
}

body[class*="-dark"] .ndv-historico__item {
    border-bottom-color: var(--tema-border) !important;
}

body[class*="-dark"] .ndv-historico__itemTitle {
    color: var(--tema-text) !important;
}

body[class*="-dark"] .ndv-nao-lido {
    background: rgba(92, 198, 216, 0.15) !important;
}

body[class*="-dark"] .ndv-lido {
    background: transparent !important;
}

/* --- Barra de progresso (pré-cadastro no Autenticador e demais .progress) --- */
body[class*="-dark"] .progress {
    background-color: var(--tema-surface-alt) !important;
    border: 1px solid var(--tema-border);
}
