/* Ajustes visuais sobre o Bootstrap. Cores da marca como variáveis para facilitar troca de tema. */
:root {
    --app-primaria: #1f5f8b;
    --app-primaria-clara: #e8f1f8;
}

[data-bs-theme="light"] {
    --bs-primary: var(--app-primaria);
    --bs-primary-rgb: 31, 95, 139;
    --bs-link-color: var(--app-primaria);
    --bs-link-color-rgb: 31, 95, 139;
    --bs-body-bg: #f6f8fa;
}

[data-bs-theme="dark"] {
    --app-primaria-clara: #1b2a36;
    --bs-primary: #6ea8d8;
    --bs-primary-rgb: 110, 168, 216;
}

.btn-primary {
    --bs-btn-bg: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: #174a6c;
    --bs-btn-hover-border-color: #174a6c;
}

[data-bs-theme="dark"] .btn-primary {
    --bs-btn-color: #0b1620;
    --bs-btn-hover-bg: #8fbde3;
    --bs-btn-hover-border-color: #8fbde3;
}

.btn-outline-primary {
    --bs-btn-color: var(--bs-primary);
    --bs-btn-border-color: var(--bs-primary);
    --bs-btn-hover-bg: var(--bs-primary);
    --bs-btn-hover-border-color: var(--bs-primary);
    --bs-btn-active-bg: var(--bs-primary);
    --bs-btn-active-border-color: var(--bs-primary);
}

.app-navbar {
    background-color: var(--bs-body-bg);
}

[data-bs-theme="light"] .app-navbar,
[data-bs-theme="light"] .card {
    background-color: #fff;
}

.card-header {
    font-weight: 600;
}

.indicador {
    border-left: 4px solid var(--bs-primary);
}

.indicador .valor {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}

/* Tabelas viram cartões em telas pequenas */
@media (max-width: 767.98px) {
    .tabela-responsiva thead {
        display: none;
    }

    .tabela-responsiva tr {
        display: block;
        border: 1px solid var(--bs-border-color);
        border-radius: .5rem;
        margin-bottom: .75rem;
        padding: .5rem .75rem;
        background: var(--bs-body-bg);
    }

    .tabela-responsiva td {
        display: flex;
        justify-content: space-between;
        gap: 1rem;
        border: 0;
        padding: .25rem 0;
    }

    .tabela-responsiva td[data-rotulo]::before {
        content: attr(data-rotulo);
        font-weight: 600;
        color: var(--bs-secondary-color);
    }
    .tabela-responsiva .selos-perfil {
        justify-content: flex-end;
    }
}

/* ---------- Perfis de acesso ---------- */
.grupo-funcionalidades {
    background: var(--bs-tertiary-bg) !important;
    color: var(--bs-secondary-color) !important;
    font-size: .75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .04em;
}

.coluna-nivel {
    width: 16rem;
}

@media (max-width: 575.98px) {
    .coluna-nivel {
        width: 45%;
    }
}

.texto-preservado {
    white-space: pre-line;
}

/* ---------- Menu lateral (área logada) ---------- */
:root {
    --app-menu-largura: 260px;
    --app-menu-fundo: #ffffff;
}

[data-bs-theme="dark"] {
    --app-menu-fundo: #1a1d21;
}

.app-marca {
    padding: 1rem 1.25rem;
}

.app-menu-grupo {
    padding: 1rem 1.25rem .25rem;
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .06em;
    text-transform: uppercase;
    color: var(--bs-secondary-color);
}

.app-menu-link {
    color: var(--bs-body-color);
    padding: .45rem 1.25rem;
    border-left: 3px solid transparent;
}

.app-menu-link:hover {
    background: var(--bs-tertiary-bg);
    color: var(--bs-body-color);
}

.app-menu-link.active {
    background: var(--bs-primary-bg-subtle);
    border-left-color: var(--bs-primary);
    color: var(--bs-primary-text-emphasis);
    font-weight: 600;
}

.app-menu-link .bi {
    width: 1.25rem;
    display: inline-block;
}

.app-menu-usuario {
    padding: .75rem 1.25rem 1rem;
}

.app-topo {
    background: var(--app-menu-fundo);
    z-index: 1020;
}

/* O offcanvas-lg do Bootstrap deixa o fundo transparente no desktop: o menu precisa do próprio fundo. */
.app-sidebar.offcanvas-lg {
    background-color: var(--app-menu-fundo) !important;
}

@media (max-width: 991.98px) {
    .app-sidebar {
        --bs-offcanvas-width: var(--app-menu-largura);
    }
}

@media (min-width: 992px) {
    .app-sidebar {
        position: fixed;
        top: 0;
        bottom: 0;
        left: 0;
        width: var(--app-menu-largura);
        z-index: 1030;
    }

    .com-menu .app-conteudo {
        margin-left: var(--app-menu-largura);
    }
}

@media print {
    .app-sidebar, .app-topo {
        display: none !important;
    }

    .com-menu .app-conteudo {
        margin-left: 0 !important;
    }
}

/* ---------- Gráficos: tokens da visualização (paleta validada da aplicação irmã) ---------- */
[data-bs-theme="light"] .viz {
    --viz-serie-1: #2a78d6;
    --viz-serie-2: #eb6834;
    --viz-serie-3: #1baf7a;
    --viz-texto: #52514e;
    --viz-texto-fraco: #898781;
    --viz-grade: #e1e0d9;
    --viz-superficie: #ffffff;
}

[data-bs-theme="dark"] .viz {
    --viz-serie-1: #3987e5;
    --viz-serie-2: #d95926;
    --viz-serie-3: #199e70;
    --viz-texto: #c3c2b7;
    --viz-texto-fraco: #898781;
    --viz-grade: #2c2c2a;
    --viz-superficie: #212529;
}

.viz-grafico {
    position: relative;
    height: 260px;
}

.viz-grafico.alto {
    height: 300px;
}

.indicador-gestao .valor {
    font-size: clamp(1.2rem, 5vw, 1.75rem);
    white-space: nowrap;
    font-weight: 600;
    line-height: 1.1;
}

.viz table {
    font-variant-numeric: tabular-nums;
}

/* Barra de um valor sobre o máximo (indicadores): trilho na cor da grade, uma série, ponta arredondada de 4px. */
.barra {
    display: block;
    height: 10px;
    min-width: 3rem;
    border-radius: 4px;
    background: var(--viz-grade, #e1e0d9);
    overflow: hidden;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.barra > span {
    display: block;
    height: 100%;
    max-width: 100%;
    border-radius: 0 4px 4px 0;
    background: var(--viz-serie-1, #2a78d6);
}

/* Faltou / deu certo / sobrou: partes de um todo numa barra fina, 2px de superfície entre elas. */
.segmentos {
    display: flex;
    gap: 2px;
    height: 10px;
    min-width: 4rem;
    border-radius: 4px;
    overflow: hidden;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.segmentos > span, .amostra {
    display: inline-block;
    min-width: 4px;
}

.amostra {
    width: .75rem;
    height: .75rem;
    border-radius: 2px;
    vertical-align: -1px;
}

.faltou { background: var(--bs-danger); }
.na-medida { background: var(--bs-success); }
.sobrou { background: var(--bs-warning); }

/* Diferença sobre o previsto: menos para a esquerda (azul), mais para a direita (laranja), o meio neutro. */
.divergente {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 2px;
    height: 10px;
    min-width: 5rem;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.divergente > span {
    display: flex;
    background: var(--viz-grade, #e1e0d9);
}

.divergente .menos { justify-content: flex-end; border-radius: 4px 0 0 4px; }
.divergente .mais { border-radius: 0 4px 4px 0; }
.divergente .menos > span { background: var(--viz-serie-1, #2a78d6); border-radius: 4px 0 0 4px; }
.divergente .mais > span { background: var(--viz-serie-2, #eb6834); border-radius: 0 4px 4px 0; }

/* Números em coluna (saldos, contagens): dígitos da mesma largura. */
.tabular { font-variant-numeric: tabular-nums; }

/* ---- Suporte ------------------------------------------------------------------------------------------------ */

/* Fluxo de situação: três marcos ligados por uma linha; o atual em destaque, os já passados preenchidos. */
.fluxo-suporte { list-style: none; margin: 0; padding: 0; display: grid; grid-template-columns: repeat(3, 1fr); }
.fluxo-suporte li { position: relative; display: flex; flex-direction: column; align-items: center; text-align: center; gap: .15rem; }
.fluxo-suporte li:not(:first-child)::before {
    content: ""; position: absolute; top: 1.1rem; right: 50%; width: 100%; height: 2px; background: var(--bs-border-color); z-index: 0;
}
.fluxo-suporte li.feita:not(:first-child)::before, .fluxo-suporte li.atual:not(:first-child)::before { background: var(--bs-primary); }
.fluxo-suporte .marco {
    position: relative; z-index: 1; width: 2.2rem; height: 2.2rem; border-radius: 50%; display: grid; place-items: center;
    border: 2px solid var(--bs-border-color); background: var(--bs-body-bg); color: var(--bs-secondary-color);
}
.fluxo-suporte li.feita .marco { border-color: var(--bs-primary); color: var(--bs-primary); }
.fluxo-suporte li.atual .marco { border-color: var(--bs-primary); background: var(--bs-primary); color: #fff; }
.fluxo-suporte .rotulo { font-size: .85rem; font-weight: 600; }
.fluxo-suporte li:not(.atual):not(.feita) .rotulo { color: var(--bs-secondary-color); font-weight: 400; }
.fluxo-suporte .quando { font-size: .75rem; color: var(--bs-secondary-color); min-height: 1.1em; }

/* Resumo do item: rótulos pequenos em caixa alta sobre o valor, lado a lado (quebra no celular). */
.resumo-suporte { display: flex; flex-wrap: wrap; gap: .75rem 1.75rem; align-items: flex-start; }
.resumo-suporte > div { display: flex; flex-direction: column; gap: .2rem; }
.resumo-suporte .rotulo, .bloco-suporte span { font-size: .7rem; letter-spacing: .06em; text-transform: uppercase; color: var(--bs-secondary-color); }

/* Blocos de ocorrências do erro automático */
.bloco-suporte { display: flex; align-items: center; gap: .75rem; padding: .75rem 1rem; border: 1px solid var(--bs-border-color);
    border-radius: var(--bs-border-radius); background: var(--bs-body-bg); height: 100%; }
.bloco-suporte > i { font-size: 1.4rem; }
.bloco-suporte strong { display: block; font-variant-numeric: tabular-nums; }

/* Stack trace: bloco de código escuro nos dois temas, com rolagem própria (a página não rola de lado). */
.stack-trace { background: #1e2227; color: #e6e9ed; font-size: .78rem; line-height: 1.45; padding: 1rem; border-radius: var(--bs-border-radius);
    max-height: 26rem; overflow: auto; white-space: pre; tab-size: 4; margin-bottom: .25rem; }

/* Anexos: miniatura do print e prévia de texto */
.anexo-suporte { border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius); overflow: hidden; background: var(--bs-body-bg); }
.anexo-miniatura { display: block; background: var(--bs-tertiary-bg); border-bottom: 1px solid var(--bs-border-color); }
.anexo-miniatura img { display: block; width: 100%; height: 9rem; object-fit: cover; object-position: top left; }
.previa-texto { max-height: 16rem; overflow: auto; white-space: pre-wrap; font-size: .78rem; background: var(--bs-tertiary-bg); padding: .5rem; border-radius: var(--bs-border-radius); }
.zona-anexos { border-style: dashed !important; transition: background-color .15s; }
.zona-anexos.arrastando { background: var(--bs-primary-bg-subtle); border-color: var(--bs-primary) !important; }
.miniatura-escolhida { width: 3rem; height: 3rem; object-fit: cover; border-radius: .25rem; }

/* Comentários: os do suporte com a borda de destaque */
.comentario-suporte { border-left: 3px solid var(--bs-border-color); padding: .25rem 0 .25rem .75rem; }
.comentario-suporte.do-suporte { border-left-color: var(--bs-info); }
.texto-livre { white-space: pre-wrap; overflow-wrap: anywhere; }

/* Lista da comum congregação (static/js/comum-congregacao.js): autocadastro do voluntário e formulário da administração. */
.comum-sugestoes {
    position: absolute; left: 0; right: 0; z-index: 1060; margin: .25rem calc(var(--bs-gutter-x, 1.5rem) * .5) 0;
    max-height: 20rem; overflow-y: auto; padding: .25rem 0;
    background: var(--bs-body-bg); border: 1px solid var(--bs-border-color); border-radius: var(--bs-border-radius);
    box-shadow: var(--bs-box-shadow);
}
.comum-sugestoes [role="option"] { padding: .5rem .75rem; min-height: 44px; cursor: pointer; }
.comum-sugestoes [role="option"]:hover,
.comum-sugestoes [role="option"].ativa { background: var(--bs-primary-bg-subtle); }
