/*
 * portal-tables.css — Padrão único das tabelas do Portal da Transparência.
 *
 * Fonte de verdade para o visual, cores e responsividade das tabelas. Carregado
 * uma vez no layout do site. Todo o CSS fica escopado na classe .portal-datatable
 * (aplicada no wrapper da tabela) para NÃO vazar para tabelas que precisem ser
 * diferentes — quem não tem a classe, não é afetado.
 *
 * Como usar numa tela (padrão client-side, busca instantânea):
 *   <div class="card-body portal-datatable">
 *     <table class="table dataTable js-horizontal-scroll table-striped table-white
 *                   table-borderless table-sm text-secondary-50 text-center
 *                   text-nowrap portal-table"
 *            data-dt-order='[[1,"desc"]]' data-dt-no-order="11"
 *            data-empty-text="Nenhum registro encontrado.">
 *       <thead class="thead-dark"> ... </thead>
 *       <tbody> ... </tbody>
 *       <tfoot> ...linha de totais (12 <td>, sem colspan)... </tfoot>
 *     </table>
 *   </div>
 * O init genérico do DataTables (layout) cuida de busca/ordenação/paginação e lê
 * data-dt-order / data-dt-page-length / data-dt-no-order.
 */

.portal-datatable {
  font-size: 12.5px;
}

/* Célula com truncamento por reticências (usar title="" para tooltip). */
.portal-cell {
  max-width: 160px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.portal-cell-wide {
  max-width: 220px;
}

.portal-cell-object {
  max-width: 280px;
}

.portal-table {
  margin-bottom: 0;
}

.portal-table th,
.portal-table td {
  vertical-align: middle;
  padding: 0.45rem 0.55rem;
  line-height: 1.2;
}

.portal-table td {
  font-size: 12px;
}

.portal-table .btn {
  padding: 0.12rem 0.4rem;
}

/* ---- Controles do DataTables (2.x) no padrão do portal ---- */
.portal-datatable .dt-length,
.portal-datatable .dt-search,
.portal-datatable .dt-info {
  color: #6c757d;
  font-weight: 400;
  margin-bottom: 0.75rem;
}

.portal-datatable .dt-length select {
  width: 72px;
  min-width: 72px;
  margin: 0 0.35rem;
  padding: 0.2rem 1.6rem 0.2rem 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
}

.portal-datatable .dt-search input {
  width: 230px;
  max-width: 100%;
  margin-left: 0.5rem;
  padding: 0.2rem 0.5rem;
  border: 1px solid #ced4da;
  border-radius: 0.25rem;
}

div.dt-container div.dt-paging .dt-paging-button {
  border-radius: 0.25rem;
  margin: 0 2px;
  padding: 0.3rem 0.6rem;
}

/* Página ativa: fundo escuro do portal com número BRANCO legível. Seletor com
   especificidade alta o bastante para vencer o CSS padrão do DataTables. */
div.dt-container div.dt-paging .dt-paging-button.current,
div.dt-container div.dt-paging .dt-paging-button.current:hover,
div.dt-container div.dt-paging .dt-paging-button.current:active,
div.dt-container div.dt-paging .dt-paging-button.current:focus {
  background: #343a40 !important;
  border-color: #343a40 !important;
  color: #ffffff !important;
}

/* ---- Linha de totais (tfoot) ----
   Com scrollX o DataTables replica a tfoot no rodapé de rolagem, alinhada às
   colunas. NÃO usar colspan (colspan quebra o scrollX): usar 12 <td>, com o
   rótulo na 1ª coluna transbordando sobre as células vazias vizinhas. */
.portal-table tfoot td,
div.dt-container tfoot td {
  background-color: #f8f9fa;
  border-top: 2px solid #343a40;
  color: #343a40;
  white-space: nowrap;
}

.portal-totals-label {
  overflow: visible !important;
  position: relative;
  z-index: 1;
}

/* ---- Botão de ordenação server-side (fallback), quando usado ---- */
.portal-sort-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  background: transparent;
  border: 0;
  color: inherit;
  font-weight: inherit;
  padding: 0;
  width: 100%;
  cursor: pointer;
}

.portal-sort-button:focus {
  outline: none;
}

/* ---- Responsividade ---- */
@media (max-width: 991px) {
  .portal-datatable .dt-search,
  .portal-datatable .dt-search label {
    width: 100%;
  }

  .portal-datatable .dt-search input {
    width: 100%;
    margin-left: 0;
    margin-top: 0.35rem;
  }
}
