/* ==========================================================================
   TEMAS — Vidya Text
   Temas disponíveis: light (padrão), dark (escuro), sepia, contraste (alto
   contraste) e auto (segue a preferência do sistema operacional/navegador).

   Índice:
     1. Variáveis de tema
        1.1 Light (padrão)
        1.2 Dark (escuro)
        1.3 Sépia
        1.4 Contraste (alto contraste)
        1.5 Automático (media queries)
     2. Aplicação geral das variáveis
     3. Ajustes finos por tema
        3.1 Escuro
        3.2 Sépia
        3.3 Alto Contraste
     4. Correção geral de cores de texto dos botões Bootstrap
   ========================================================================== */


/* ==========================================================================
   1. VARIÁVEIS DE TEMA
   ========================================================================== */

/* ---------- 1.1 Light (padrão) ---------- */
:root,
html[data-theme="light"] {
    --tema-bg: #ffffff;
    --tema-bg-secundario: #f8f9fa;   /* usado por .bg-light / navbar */
    --tema-texto: #212529;
    --tema-borda: #dee2e6;
    --tema-card-bg: #ffffff;
    --tema-input-bg: #ffffff;
    --tema-input-texto: #212529;
    --tema-tabela-hover: #f1f3f5;
    --tema-link: #0d6efd;
    --tema-foco: #0d6efd;
    --tema-foco-sombra: rgba(13, 110, 253, .25);
}

/* ---------- 1.2 Dark (escuro) ---------- */
html[data-theme="dark"] {
    --tema-bg: #121212;
    --tema-bg-secundario: #1e1e1e;
    --tema-texto: #e9ecef;
    --tema-borda: #3a3f44;
    --tema-card-bg: #1a1a1a;
    --tema-input-bg: #1e1e1e;
    --tema-input-texto: #e9ecef;
    --tema-tabela-hover: #262626;
    --tema-link: #6ea8fe;
    --tema-foco: #6ea8fe;
    --tema-foco-sombra: rgba(110, 168, 254, .35);
}

/* ---------- 1.3 Sépia ---------- */
html[data-theme="sepia"] {
    --tema-bg: #f4ecd8;
    --tema-bg-secundario: #ece0c5;
    --tema-texto: #4b3621;
    --tema-borda: #d9c9a3;
    --tema-card-bg: #f8f1de;
    --tema-input-bg: #fbf5e6;
    --tema-input-texto: #4b3621;
    --tema-tabela-hover: #ecdfc0;
    --tema-link: #8a5a2b;
    --tema-foco: #8a5a2b;
    --tema-foco-sombra: rgba(138, 90, 43, .3);
}

/* ---------- 1.4 Contraste (alto contraste) ---------- */
html[data-theme="contraste"] {
    --tema-bg: #000000;
    --tema-bg-secundario: #000000;
    --tema-texto: #ffffff;
    --tema-borda: #ffffff;
    --tema-card-bg: #000000;
    --tema-input-bg: #000000;
    --tema-input-texto: #ffffff;
    --tema-tabela-hover: #1a1a1a;
    --tema-link: #ffff00;
    --tema-foco: #ffff00;
    --tema-foco-sombra: rgba(255, 255, 0, .45);
}

/* ---------- 1.5 Automático ----------
   Tema "Automático": segue a preferência do sistema operacional/navegador. */
@media (prefers-color-scheme: light) {
    html[data-theme="auto"] {
        --tema-bg: #ffffff;
        --tema-bg-secundario: #f8f9fa;
        --tema-texto: #212529;
        --tema-borda: #dee2e6;
        --tema-card-bg: #ffffff;
        --tema-input-bg: #ffffff;
        --tema-input-texto: #212529;
        --tema-tabela-hover: #f1f3f5;
        --tema-link: #0d6efd;
        --tema-foco: #0d6efd;
        --tema-foco-sombra: rgba(13, 110, 253, .25);
    }
}
@media (prefers-color-scheme: dark) {
    html[data-theme="auto"] {
        --tema-bg: #121212;
        --tema-bg-secundario: #1e1e1e;
        --tema-texto: #e9ecef;
        --tema-borda: #3a3f44;
        --tema-card-bg: #1a1a1a;
        --tema-input-bg: #1e1e1e;
        --tema-input-texto: #e9ecef;
        --tema-tabela-hover: #262626;
        --tema-link: #6ea8fe;
        --tema-foco: #6ea8fe;
        --tema-foco-sombra: rgba(110, 168, 254, .35);
    }
    html[data-theme="auto"] #navBar .navbar-brand span:last-child {
        color: #8bb9ff !important;
    }
}


/* ==========================================================================
   2. APLICAÇÃO GERAL DAS VARIÁVEIS
   ========================================================================== */

html[data-theme] body {
    background-color: var(--tema-bg);
    color: var(--tema-texto);
}

html[data-theme] a {
    color: var(--tema-link);
}

html[data-theme] #navBar,
html[data-theme] .bg-light {
    background-color: var(--tema-bg-secundario) !important;
    color: var(--tema-texto) !important;
}

html[data-theme] .card,
html[data-theme] .card-body {
    background-color: var(--tema-card-bg);
    color: var(--tema-texto);
    border-color: var(--tema-borda);
}

/* Textareas/inputs — preserva .bg-transparent (ex.: #caixaAnalise) */
html[data-theme] .form-control {
    color: var(--tema-input-texto);
    border-color: var(--tema-borda);
}
html[data-theme] .form-control:not(.bg-transparent) {
    background-color: var(--tema-input-bg);
}
html[data-theme] .form-control:focus {
    background-color: var(--tema-input-bg);
    color: var(--tema-input-texto);
    border-color: var(--tema-foco);
    box-shadow: 0 0 0 0.2rem var(--tema-foco-sombra);
}
html[data-theme] .form-control::placeholder {
    color: var(--tema-texto);
    opacity: .6;
}

html[data-theme] .table {
    --bs-table-bg: var(--tema-card-bg);
    color: var(--tema-texto);
    border-color: var(--tema-borda);
}
html[data-theme] .table-bordered,
html[data-theme] .table-bordered > :not(caption) > * > * {
    border-color: var(--tema-borda);
}
html[data-theme] .table-hover > tbody > tr:hover > * {
    background-color: var(--tema-tabela-hover);
    color: var(--tema-texto);
}

html[data-theme] .modal-content {
    background-color: var(--tema-card-bg);
    color: var(--tema-texto);
    border-color: var(--tema-borda);
}

html[data-theme] .accordion-button,
html[data-theme] .accordion-button:not(.collapsed) {
    background-color: var(--tema-bg-secundario);
    color: var(--tema-texto);
    box-shadow: none;
}

html[data-theme] .accordion-item,
html[data-theme] .accordion-body {
    background-color: var(--tema-card-bg);
    color: var(--tema-texto);
    border-color: var(--tema-borda);
}

/* Foco visível consistente em qualquer tema (acessibilidade) */
html[data-theme] a:focus-visible,
html[data-theme] button:focus-visible,
html[data-theme] .dropdown-item:focus-visible {
    outline: 2px solid var(--tema-foco);
    outline-offset: 2px;
}

/* Dropdown do seletor de tema herdando as variáveis */
html[data-theme] .dropdown-menu {
    background-color: var(--tema-card-bg);
    color: var(--tema-texto);
    border-color: var(--tema-borda);
}
html[data-theme] .dropdown-item {
    color: var(--tema-texto);
}
html[data-theme] .dropdown-item:hover,
html[data-theme] .dropdown-item:focus {
    background-color: var(--tema-tabela-hover);
    color: var(--tema-texto);
}
html[data-theme] .dropdown-item.active {
    background-color: var(--tema-foco);
    color: var(--tema-bg);
}


/* ==========================================================================
   3. AJUSTES FINOS POR TEMA
   ========================================================================== */

/* ---------- 3.1 Escuro ---------- */
html[data-theme="dark"] #navBar .navbar-brand span:last-child {
    color: #8bb9ff !important;
}

/* ---------- 3.2 Sépia ----------
   Substitui as cores saturadas padrão do Bootstrap (azul, verde, ciano)
   por tons terrosos harmonizados com a paleta sépia (#f4ecd8 / #8a5a2b). */

html[data-theme="sepia"] .btn-primary {
    background-color: #6f4e37 !important;  /* marrom café */
    border-color: #5a3e2b !important;
    color: #f8f1de !important;
}
html[data-theme="sepia"] .btn-primary:hover,
html[data-theme="sepia"] .btn-primary:focus {
    background-color: #5a3e2b !important;
    border-color: #4b3621 !important;
    color: #f8f1de !important;
}

html[data-theme="sepia"] .btn-success {
    background-color: #6b7a3f !important;  /* verde-oliva */
    border-color: #56622f !important;
    color: #f8f1de !important;
}
html[data-theme="sepia"] .btn-success:hover,
html[data-theme="sepia"] .btn-success:focus {
    background-color: #56622f !important;
    border-color: #465025 !important;
    color: #f8f1de !important;
}

html[data-theme="sepia"] .btn-info {
    background-color: #c9a66b !important;  /* dourado/areia */
    border-color: #b08f52 !important;
    color: #4b3621 !important;
}
html[data-theme="sepia"] .btn-info:hover,
html[data-theme="sepia"] .btn-info:focus {
    background-color: #b08f52 !important;
    border-color: #96773e !important;
    color: #4b3621 !important;
}

/* ---------- 3.3 Alto Contraste ----------
   Remove gradientes/sombras suaves e força o par preto/branco
   com amarelo como única cor de destaque, seguindo a convenção
   de temas de alto contraste (semelhante ao "High Contrast Black"). */
html[data-theme="contraste"] * {
    box-shadow: none !important;
    text-shadow: none !important;
}

html[data-theme="contraste"] .card,
html[data-theme="contraste"] .form-control,
html[data-theme="contraste"] .modal-content,
html[data-theme="contraste"] .dropdown-menu,
html[data-theme="contraste"] .table-bordered,
html[data-theme="contraste"] .table-bordered > :not(caption) > * > * {
    border-width: 2px !important;
}

html[data-theme="contraste"] #navBar .navbar-brand span {
    color: #ffffff !important;
}

html[data-theme="contraste"] .modal-header-pro::after {
    background: #ffffff !important;
}

html[data-theme="contraste"] .text-success,
html[data-theme="contraste"] .text-primary,
html[data-theme="contraste"] .text-info,
html[data-theme="contraste"] #headCaixaAnalise i {
    color: #ffff00 !important;
}

html[data-theme="contraste"] .btn-primary {
    background-color: #000000 !important;
    border: 2px solid #ffffff !important;
    color: #ffffff !important;
}
html[data-theme="contraste"] .btn-primary:hover,
html[data-theme="contraste"] .btn-primary:focus {
    background-color: #ffffff !important;
    color: #000000 !important;
}

html[data-theme="contraste"] .btn-info,
html[data-theme="contraste"] #ajudaGeral {
    background-color: #000000 !important;
    border: 2px solid #ffff00 !important;
    color: #ffff00 !important;
}
html[data-theme="contraste"] .btn-info:hover,
html[data-theme="contraste"] #ajudaGeral:hover {
    background-color: #ffff00 !important;
    color: #000000 !important;
}

html[data-theme="contraste"] .btn-success {
    background-color: #000000 !important;
    border: 2px solid #ffffff !important;
    color: #ffffff !important;
}
html[data-theme="contraste"] .btn-success:hover,
html[data-theme="contraste"] .btn-success:focus {
    background-color: #ffffff !important;
    color: #000000 !important;
}

html[data-theme="contraste"] .btn-outline-secondary {
    background-color: #000000 !important;
    border: 2px solid #ffffff !important;
    color: #ffffff !important;
}
html[data-theme="contraste"] .btn-outline-secondary:hover,
html[data-theme="contraste"] .btn-outline-secondary.show {
    background-color: #ffffff !important;
    color: #000000 !important;
}

html[data-theme="contraste"] *:focus-visible {
    outline: 3px solid #ffff00 !important;
    outline-offset: 2px !important;
}


/* ==========================================================================
   4. CORREÇÃO GERAL DE CORES DE TEXTO DOS BOTÕES BOOTSTRAP
   (aplica-se independentemente do tema, cobre o padrão do Bootstrap)
   ========================================================================== */

.btn-primary,
.btn-success {
    color: #fff !important;
}

.btn-info {
    color: #000 !important;
}