/* Tabelas do app (classes thead_*/tbody_* definidas em App/views/functions_template.php).
   Substituem o fundo rosa/cor do parceiro por um visual neutro, nos dois temas.
   O seletor "html .classe" tem mais especificidade que as regras inline com !important do functions_template. */

/* ---------- TEMA CLARO (padrao quando nao ha tema-escuro) ---------- */
html .thead_simple_default,
html .thead_simple_default_warning,
html .thead_doble_default,
html .thead_doble_default_left {
    background-color: #f1f5f9 !important;
    color: #334155 !important;
    font-weight: 600;
    letter-spacing: 0.02em;
    border-bottom: 2px solid #3b82f6 !important;
    padding: 0.6rem 0.75rem !important;
}

html .thead_simple_default_warning {
    border-bottom-color: #f59e0b !important;
}

html .tbody_simple_default,
html .tbody_simple_default_left,
html .tbody_simple_default_warning,
html .tbody_doble_default,
html .tbody_doble_default_secondary,
html .tbody_simple_dados_default,
html .tbody_doble_dados_default {
    background-color: #ffffff !important;
    color: #1e293b !important;
    border-bottom: 1px solid #e2e8f0 !important;
    padding: 0.5rem 0.75rem !important;
}

html .tbody_simple_default_left,
html .tbody_doble_default {
    font-weight: 600;
}

html .tbody_doble_default_secondary {
    background-color: #f8fafc !important;
    color: #475569 !important;
}

html .tbody_simple_default_warning {
    background-color: #fffbeb !important;
    border-left: 3px solid #f59e0b !important;
}

html tr:hover > .tbody_simple_default,
html tr:hover > .tbody_simple_default_left,
html tr:hover > .tbody_doble_default {
    background-color: #f8fafc !important;
}

/* ---------- TEMA ESCURO ---------- */
html.tema-escuro .thead_simple_default,
html.tema-escuro .thead_simple_default_warning,
html.tema-escuro .thead_doble_default,
html.tema-escuro .thead_doble_default_left {
    background-color: var(--ds-surface) !important;
    color: var(--ds-text-3) !important;
    border-bottom: 1px solid var(--ds-border-strong) !important;
}

html.tema-escuro .thead_simple_default_warning {
    border-bottom-color: var(--ds-warning) !important;
}

html.tema-escuro .tbody_simple_default,
html.tema-escuro .tbody_simple_default_left,
html.tema-escuro .tbody_simple_default_warning,
html.tema-escuro .tbody_doble_default,
html.tema-escuro .tbody_doble_default_secondary,
html.tema-escuro .tbody_simple_dados_default,
html.tema-escuro .tbody_doble_dados_default {
    background-color: var(--ds-surface) !important;
    color: var(--ds-text) !important;
    border-bottom: 1px solid var(--ds-border) !important;
}

html.tema-escuro .tbody_doble_default_secondary {
    background-color: var(--ds-surface-2) !important;
    color: var(--ds-text-2) !important;
}

html.tema-escuro .tbody_simple_default_warning {
    background-color: rgba(210, 153, 34, 0.08) !important;
    border-left: 3px solid var(--ds-warning) !important;
}

html.tema-escuro tr:hover > .tbody_simple_default,
html.tema-escuro tr:hover > .tbody_simple_default_left,
html.tema-escuro tr:hover > .tbody_doble_default {
    background-color: var(--ds-surface-2) !important;
}

/* ---------- AJUSTES NO TEMA ESCURO: bordas e primeira coluna ---------- */

/* sem bordas brancas/pretas: todas as linhas e colunas na cor de borda do tema */
html.tema-escuro table,
html.tema-escuro table th,
html.tema-escuro table td {
    border-color: var(--ds-border) !important;
}

/* bordas inline definidas nas views (border-left/right/top/bottom em preto ou branco) */
html.tema-escuro table td[style*="border"],
html.tema-escuro table th[style*="border"] {
    border-color: var(--ds-border) !important;
}

/* celulas com fundo branco fixo na view (background-color:white) viram a cor do tema */
html.tema-escuro table td[style*="background-color:white"],
html.tema-escuro table td[style*="background-color: white"] {
    background-color: var(--ds-surface) !important;
    color: var(--ds-text) !important;
}

/* primeira coluna (nomes/visoes): mais legivel */
html.tema-escuro .thead_doble_default_left,
html.tema-escuro .thead_simple_default_left,
html.tema-escuro th[scope="row"] {
    color: var(--ds-text) !important;
    font-weight: 600 !important;
    font-size: 1.05em;
    letter-spacing: 0.01em;
}

/* a mesma coluna no tema claro, para manter a hierarquia */
html .thead_doble_default_left,
html .thead_simple_default_left,
html th[scope="row"] {
    color: #0f172a !important;
    font-weight: 600 !important;
}

/* ---------- TABELAS EM ARVORE (drilldown / desempenho): linhas e apresentacao ---------- */
/* tabelas geradas pelo JS com id table_* / tableout_* */
table[id^="table_"],
table[id^="tableout_"] {
    border: 0 !important;
    border-collapse: separate !important;
    border-spacing: 0;
    width: 100%;
}

table[id^="table_"] thead th,
table[id^="tableout_"] thead th {
    padding: 0.6rem 0.75rem !important;
    position: sticky;
    top: 0;
    z-index: 2;
    border-top: 0 !important;
}

table[id^="table_"] tbody td,
table[id^="tableout_"] tbody td {
    padding: 0.55rem 0.75rem !important;
    font-variant-numeric: tabular-nums;
    border-top: 0 !important;
    vertical-align: middle;
}

/* linha do estabelecimento: nome em destaque */
table[id^="table_"] tr.linha > td:first-child,
table[id^="table_"] tr.linha > th:first-child {
    font-weight: 600;
}

/* linhas de detalhe (filhos): um nivel abaixo, mais discretas */
table[id^="table_"] tr.linha_out > td:first-child,
table[id^="tableout_"] tr[class*="linha_out"] > td:first-child {
    padding-left: 2.25rem !important;
    font-weight: 400;
    opacity: 0.92;
}

/* setinha da arvore */
table[id^="table_"] .expander,
table[id^="table_"] .indenter {
    opacity: 0.85;
}

/* ---- tema claro ---- */
html table[id^="table_"] tbody td,
html table[id^="tableout_"] tbody td {
    border-bottom: 1px solid #e8edf3 !important;
}

html table[id^="table_"] tbody tr:hover > td,
html table[id^="tableout_"] tbody tr:hover > td {
    background-color: #f5f8fc !important;
}

/* ---- tema escuro ---- */
html.tema-escuro table[id^="table_"] tbody td,
html.tema-escuro table[id^="tableout_"] tbody td {
    border-bottom: 1px solid var(--ds-border) !important;
    background-color: transparent;
}

html.tema-escuro table[id^="table_"] tbody tr:hover > td,
html.tema-escuro table[id^="tableout_"] tbody tr:hover > td {
    background-color: var(--ds-hover) !important;
}

html.tema-escuro table[id^="table_"] tr.linha > td:first-child {
    color: var(--ds-text) !important;
}

/* linha "vigente" da tabela de vinculos no tema claro: texto escuro sobre o verde-claro */
html:not(.tema-escuro) tr.table-success > td,
html:not(.tema-escuro) tr.table-success > th {
    color: #0f172a !important;
}
