/*
 * Tabelas dos componentes Livewire (Gratuidade, Dirigentes e Empregados,
 * Integridade e Demonstração de Resultados).
 *
 * Escopo: apenas tabelas dentro de um componente Livewire ([wire:id]), para não
 * alterar as demais telas do portal. Deve ser carregado DEPOIS do CSS da página,
 * porque as folhas antigas definem regras globais de `table` com !important.
 */

[wire\:id] {
    --tb-laranja: #d96f19;
    --tb-laranja-escuro: #b85a0f;
    --tb-laranja-suave: #fff4ea;
    --tb-linha: #ececec;
    --tb-zebra: #fafafa;
    --tb-grupo: #e9e9e9;
    --tb-subgrupo: #f2f2f2;
    --tb-subtitulo: #ddd;
}

/* Contêiner: rolagem horizontal em telas estreitas */
[wire\:id] .tb-resultados,
[wire\:id] .table-responsive,
[wire\:id] .col-12.mt-5 {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* Base da tabela */
[wire\:id] table {
    width: 100%;
    margin-top: 0 !important;
    padding: 0 !important;
    border: 1px solid var(--tb-laranja) !important;
    border-collapse: separate !important;
    border-spacing: 0 !important;
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    font-variant-numeric: tabular-nums;
    box-shadow: 0 1px 3px rgba(0, 0, 0, .08);
}

/* Cabeçalho */
[wire\:id] table thead th,
[wire\:id] table thead td {
    padding: 12px 14px !important;
    background-color: var(--tb-laranja) !important;
    color: #fff !important;
    font-weight: 700;
    line-height: 1.25;
    vertical-align: middle;
    border: 0 !important;
    box-shadow: none !important;
    letter-spacing: .2px;
}

/* Segunda linha de cabeçalho (sub-títulos): cinza claro, sem sombra preta */
[wire\:id] table thead tr:nth-child(n + 2) th,
[wire\:id] table thead tr:nth-child(n + 2) td {
    background-color: var(--tb-subtitulo) !important;
    color: #333 !important;
    border-top: 1px solid rgba(0, 0, 0, .12) !important;
    box-shadow: none !important;
    font-size: 12px !important;
}

/* Células do corpo */
[wire\:id] table tbody td {
    padding: 10px 14px !important;
    border: 0 !important;
    border-bottom: 1px solid var(--tb-linha) !important;
    vertical-align: middle;
    line-height: 1.35;
    color: #222;
    transition: background-color .15s ease;
}

[wire\:id] table tbody tr:last-child td {
    border-bottom: 0 !important;
}

/* Quebra de linha: nunca no meio da palavra (só se a palavra não couber) */
[wire\:id] table td,
[wire\:id] table th {
    word-break: normal !important;
    overflow-wrap: break-word !important;
}

/* Listras: apenas nas linhas comuns, sem mexer nas linhas de grupo */
[wire\:id] table tbody tr:not(.tema):not(.linha):not(.programa):not(.total):nth-child(even) td:not(.programas) {
    background-color: var(--tb-zebra);
}

/* Destaque ao passar o mouse */
[wire\:id] table tbody tr:not(.tema):not(.linha):not(.programa):not(.total):hover td:not(.programas) {
    background-color: var(--tb-laranja-suave) !important;
    color: #000 !important;
}

/* Linhas de grupo */
[wire\:id] table tbody td.programas,
[wire\:id] table tbody tr.programa td,
[wire\:id] table tbody tr.tema td {
    background-color: var(--tb-grupo) !important;
    font-weight: 700;
    border-left: 0 !important;
}

[wire\:id] table tbody tr.tema td:first-child,
[wire\:id] table tbody tr.programa td:first-child,
[wire\:id] table tbody td.programas:first-child {
    box-shadow: inset 4px 0 0 var(--tb-laranja);
}

[wire\:id] table tbody tr.linha td {
    background-color: var(--tb-subgrupo) !important;
    font-weight: 600;
}

/* Linha de total */
[wire\:id] table tbody tr.total td {
    border-top: 2px solid var(--tb-laranja) !important;
}

/* Tabelas de totais (rodapé das tabelas por modalidade) */
[wire\:id] table.table-total {
    margin-top: 8px !important;
}

/* Números alinhados à direita onde o portal já os centraliza/alinha */
[wire\:id] table tbody td.text-right {
    text-align: right !important;
}

/* Links dentro da tabela */
[wire\:id] table tbody td a {
    color: var(--tb-laranja-escuro);
    text-decoration: underline;
    text-underline-offset: 2px;
}

[wire\:id] table tbody td a:hover,
[wire\:id] table tbody td a:focus {
    color: #7a3a06;
}

/* Linhas clicáveis do Plano Estratégico (abrem o modal) */
[wire\:id] table tbody tr.modal-open td:last-child {
    color: var(--tb-laranja);
    font-weight: 700;
    text-align: center;
}

/* Telas estreitas */
@media (max-width: 767px) {
    [wire\:id] table thead th,
    [wire\:id] table thead td,
    [wire\:id] table tbody td {
        padding: 8px 10px !important;
        font-size: 12px !important;
    }
}
