/* =====================================================================
 * webner-nucleo — TEMA GLOBAL DE DATATABLES (engine compartilhada)
 * =====================================================================
 *
 * O QUE É: estilização padrão, elegante e tokenizada para TODOS os
 * DataTables do sistema. Nasceu do protótipo da tela Tabela de Preços
 * (produto/tabelaPreco.gsp) e foi generalizada para o plugin.
 *
 * COMO LIGA (opt-in, NÃO muda nada por padrão):
 *   1) Adicione a classe `wn-dt-theme` ao <body> do layout do cliente.
 *   2) Defina as cores (tokens --wn-dt-*) no :root do site-<cliente>.css.
 * Sem a classe no body, este arquivo é inerte — bump do plugin é seguro
 * para todos os consumidores.
 *
 * COMO PERSONALIZA: cada cliente sobrescreve só os tokens de cor no seu
 * site-<cliente>.css. NÃO copie estas regras. Veja docs/tema.
 *
 * OPT-OUT pontual: adicione `wn-dt-plain` na <table> (ou num ancestral)
 * para uma tabela específica escapar do tema.
 *
 * Ordem de carga: este arquivo é incluído por ÚLTIMO no _cssPadrao.gsp,
 * depois do CSS vendor do DataTables, para vencer os defaults. Por isso
 * NÃO declaramos defaults em :root — usamos var(--token, fallback) para
 * que os tokens do cliente (carregados antes) não sejam sobrescritos.
 *
 * --------------------------------------------------------------------
 * TOKENS (defina no :root do site-<cliente>.css):
 *   --wn-dt-header-bg     fundo do cabeçalho (thead)
 *   --wn-dt-header-fg     texto do cabeçalho
 *   --wn-dt-accent        cor de destaque (fio do header, ordenação ativa,
 *                         borda de hover, paginação ativa, ícone +)
 *   --wn-dt-accent-fg     texto sobre a cor de destaque
 *   --wn-dt-row-stripe    fundo das linhas ímpares (zebra)
 *   --wn-dt-row-hover     fundo da linha em hover
 *   --wn-dt-row-hover-fg  texto da linha em hover
 *   --wn-dt-border        borda das células
 *   --wn-dt-ink           texto do corpo
 *   --wn-dt-muted         texto auxiliar (info, contadores)
 *   --wn-dt-control-bg    fundo de inputs/selects (busca, "mostrar N")
 *   --wn-dt-control-border  borda dos inputs/selects
 *   --wn-dt-focus-ring    cor do anel de foco (rgba)
 *   --wn-dt-radius        raio dos cantos
 * Os fallbacks abaixo formam um tema "slate" neutro e elegante caso o
 * cliente ative a classe mas ainda não tenha definido os tokens.
 * ===================================================================== */

/* ----------------------------- WRAPPER ------------------------------ */
/* Transparente de propósito: muitas tabelas já vivem dentro de .panel.
   Não criamos um "card" extra aqui para não emoldurar duas vezes. */
.wn-dt-theme .dataTables_wrapper {
    padding: 4px 2px 2px;
    font-family: var(--wn-dt-font, inherit);
    color: var(--wn-dt-ink, #33404f);
}

/* ------------------------ CONTROLES (topo) -------------------------- */
.wn-dt-theme .dataTables_wrapper .dataTables_length label,
.wn-dt-theme .dataTables_wrapper .dataTables_filter label {
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    color: var(--wn-dt-muted, #8a94a3);
}

.wn-dt-theme .dataTables_wrapper .dataTables_filter input,
.wn-dt-theme .dataTables_wrapper .dataTables_length select {
    height: 38px;
    padding: 6px 12px;
    margin-left: 10px;
    border: 1px solid var(--wn-dt-control-border, #dfe3ea);
    border-radius: calc(var(--wn-dt-radius, 12px) - 3px);
    background-color: var(--wn-dt-control-bg, #fff);
    color: var(--wn-dt-ink, #33404f);
    box-shadow: none;
    transition: border-color .18s ease, box-shadow .18s ease;
}
.wn-dt-theme .dataTables_wrapper .dataTables_filter input { min-width: 220px; }
.wn-dt-theme .dataTables_wrapper .dataTables_length select { min-width: 72px; }

.wn-dt-theme .dataTables_wrapper .dataTables_filter input:focus,
.wn-dt-theme .dataTables_wrapper .dataTables_length select:focus {
    border-color: var(--wn-dt-header-bg, #2f3a4a);
    box-shadow: 0 0 0 3px var(--wn-dt-focus-ring, rgba(47, 58, 74, .13));
    outline: none;
}

.wn-dt-theme .dataTables_wrapper .dataTables_info {
    font-size: 12.5px;
    color: var(--wn-dt-muted, #8a94a3);
    padding-top: 14px;
}

/* ----------------------------- TABELA ------------------------------- */
.wn-dt-theme table.dataTable {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    font-family: var(--wn-dt-font, inherit);
}

.wn-dt-theme table.dataTable thead th,
.wn-dt-theme table.dataTable thead td {
    position: relative;
    padding: 14px 14px;
    padding-right: 26px;
    border: 0 !important;
    border-bottom: 2px solid var(--wn-dt-accent, #6b7c93) !important;
    background-color: var(--wn-dt-header-bg, #2f3a4a) !important;
    background-image: none !important;
    color: var(--wn-dt-header-fg, #e6ebf2);
    font-weight: 700;
    font-size: 11px;
    letter-spacing: .08em;
    text-transform: uppercase;
    white-space: nowrap;
    vertical-align: middle;
}

.wn-dt-theme table.dataTable thead th:first-child {
    border-top-left-radius: var(--wn-dt-radius, 12px);
}
.wn-dt-theme table.dataTable thead th:last-child {
    border-top-right-radius: var(--wn-dt-radius, 12px);
}

/* Ícones de ordenação (FontAwesome 4 já é global no tema Remark).
   Removemos o background-image do vendor e desenhamos via ::after. */
.wn-dt-theme table.dataTable thead th.sorting,
.wn-dt-theme table.dataTable thead th.sorting_asc,
.wn-dt-theme table.dataTable thead th.sorting_desc {
    cursor: pointer;
}
.wn-dt-theme table.dataTable thead th.sorting::after,
.wn-dt-theme table.dataTable thead th.sorting_asc::after,
.wn-dt-theme table.dataTable thead th.sorting_desc::after {
    /* Font Awesome 6: a familia deixou de se chamar 'FontAwesome' e o peso virou
       obrigatorio (900 = Solid). Os codepoints abaixo sobreviveram a migracao. */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    right: 11px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 10px;
}
.wn-dt-theme table.dataTable thead th.sorting::after { content: '\f0dc'; opacity: .45; }
.wn-dt-theme table.dataTable thead th.sorting_asc::after { content: '\f0de'; color: var(--wn-dt-accent, #6b7c93); }
.wn-dt-theme table.dataTable thead th.sorting_desc::after { content: '\f0dd'; color: var(--wn-dt-accent, #6b7c93); }

.wn-dt-theme table.dataTable tbody td,
.wn-dt-theme table.dataTable tbody th {
    padding: 11px 14px;
    border: 0;
    border-bottom: 1px solid var(--wn-dt-border, #e7eaef);
    color: var(--wn-dt-ink, #33404f);
    font-size: 13.5px;
    vertical-align: middle;
    font-variant-numeric: tabular-nums;
    font-feature-settings: 'tnum' 1;
}

.wn-dt-theme table.dataTable.table-striped tbody tr:nth-of-type(odd) > td,
.wn-dt-theme table.dataTable.table-striped tbody tr.odd > td {
    background-color: var(--wn-dt-row-stripe, #f7f8fa);
}
.wn-dt-theme table.dataTable.table-striped tbody tr:nth-of-type(even) > td,
.wn-dt-theme table.dataTable.table-striped tbody tr.even > td {
    background-color: var(--wn-dt-control-bg, #fff);
}

.wn-dt-theme table.dataTable.table-hover tbody tr:hover > td,
.wn-dt-theme table.dataTable tbody tr:hover > td {
    background-color: var(--wn-dt-row-hover, #eef2f7);
    color: var(--wn-dt-row-hover-fg, #1f2733);
}
.wn-dt-theme table.dataTable tbody tr:hover > td:first-child {
    box-shadow: inset 3px 0 0 var(--wn-dt-accent, #6b7c93);
}

.wn-dt-theme table.dataTable tbody tr:last-child > td { border-bottom: 0; }

/* miniaturas / imagens dentro das células */
.wn-dt-theme table.dataTable tbody img {
    border-radius: calc(var(--wn-dt-radius, 12px) - 4px);
    border: 1px solid var(--wn-dt-border, #e7eaef);
    box-shadow: 0 5px 12px -7px rgba(23, 38, 54, .5);
    transition: transform .18s ease, box-shadow .18s ease;
}
.wn-dt-theme table.dataTable tbody tr:hover img {
    transform: scale(1.06);
    box-shadow: 0 9px 18px -8px rgba(23, 38, 54, .6);
}

.wn-dt-theme table.dataTable input[type="checkbox"],
.wn-dt-theme table.dataTable input[type="radio"] {
    accent-color: var(--wn-dt-header-bg, #2f3a4a);
    cursor: pointer;
}

/* rodapé */
.wn-dt-theme table.dataTable tfoot th,
.wn-dt-theme table.dataTable tfoot td {
    padding: 12px 14px;
    border-top: 2px solid var(--wn-dt-border, #e7eaef);
    color: var(--wn-dt-ink, #33404f);
    font-weight: 700;
    font-size: 12px;
}

/* --------------------------- PAGINAÇÃO ------------------------------ */
/* Cobre as duas integrações: bootstrap (.pagination > li) e vanilla
   (.paginate_button), pois o DataTables pode renderizar de ambas formas. */
.wn-dt-theme .dataTables_wrapper .dataTables_paginate { padding-top: 12px; }

.wn-dt-theme .dataTables_paginate .pagination > li > a,
.wn-dt-theme .dataTables_paginate .pagination > li > span,
.wn-dt-theme .dataTables_paginate .paginate_button {
    min-width: 36px;
    height: 36px;
    margin: 0 3px;
    padding: 0 12px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--wn-dt-control-border, #dfe3ea) !important;
    border-radius: calc(var(--wn-dt-radius, 12px) - 3px) !important;
    background: var(--wn-dt-control-bg, #fff) !important;
    color: var(--wn-dt-ink, #33404f) !important;
    font-size: 13px;
    font-weight: 600;
    transition: background .18s ease, color .18s ease, border-color .18s ease, transform .12s ease;
}

.wn-dt-theme .dataTables_paginate .pagination > li > a:hover,
.wn-dt-theme .dataTables_paginate .paginate_button:hover {
    border-color: var(--wn-dt-header-bg, #2f3a4a) !important;
    color: var(--wn-dt-header-bg, #2f3a4a) !important;
    transform: translateY(-1px);
}

.wn-dt-theme .dataTables_paginate .pagination > li.active > a,
.wn-dt-theme .dataTables_paginate .pagination > li.active > span,
.wn-dt-theme .dataTables_paginate .paginate_button.current,
.wn-dt-theme .dataTables_paginate .paginate_button.current:hover {
    border-color: var(--wn-dt-header-bg, #2f3a4a) !important;
    background: var(--wn-dt-header-bg, #2f3a4a) !important;
    color: var(--wn-dt-header-fg, #e6ebf2) !important;
    box-shadow: 0 8px 18px -10px var(--wn-dt-header-bg, #2f3a4a);
}

.wn-dt-theme .dataTables_paginate .pagination > li.disabled > a,
.wn-dt-theme .dataTables_paginate .paginate_button.disabled,
.wn-dt-theme .dataTables_paginate .paginate_button.disabled:hover {
    opacity: .45;
    transform: none;
    cursor: not-allowed;
}

/* ------------------- EXTENSÕES (Buttons / processing) --------------- */
.wn-dt-theme .dt-buttons .dt-button {
    border: 1px solid var(--wn-dt-control-border, #dfe3ea);
    border-radius: calc(var(--wn-dt-radius, 12px) - 3px);
    background: var(--wn-dt-control-bg, #fff);
    color: var(--wn-dt-header-bg, #2f3a4a);
    font-weight: 600;
    padding: 7px 14px;
    margin-right: 6px;
    transition: background .18s ease, color .18s ease;
}
.wn-dt-theme .dt-buttons .dt-button:hover {
    background: var(--wn-dt-header-bg, #2f3a4a);
    color: var(--wn-dt-header-fg, #e6ebf2);
}

.wn-dt-theme .dataTables_wrapper .dataTables_processing {
    border: 1px solid var(--wn-dt-border, #e7eaef);
    border-radius: var(--wn-dt-radius, 12px);
    box-shadow: 0 18px 40px -22px rgba(23, 38, 54, .45);
    color: var(--wn-dt-header-bg, #2f3a4a);
    font-weight: 600;
}

/* Ícone "+" das linhas responsivas (DataTables Responsive).
   Re-tematiza o verde fixo definido em custom.css. */
.wn-dt-theme table.dataTable.dtr-inline.collapsed > tbody > tr > td:first-child:before,
.wn-dt-theme table.dataTable.dtr-inline.collapsed > tbody > tr > th:first-child:before {
    background-color: var(--wn-dt-accent, #6b7c93) !important;
    border-color: var(--wn-dt-accent, #6b7c93) !important;
    box-shadow: 0 3px 8px -3px var(--wn-dt-accent, #6b7c93);
}
.wn-dt-theme table.dataTable.dtr-inline.collapsed > tbody > tr.parent > td:first-child:before {
    background-color: var(--wn-dt-header-bg, #2f3a4a) !important;
    border-color: var(--wn-dt-header-bg, #2f3a4a) !important;
}

/* --------------------------- OPT-OUT -------------------------------- */
/* Tabela (ou ancestral) com .wn-dt-plain volta ao visual neutro do tema. */
.wn-dt-theme .wn-dt-plain table.dataTable thead th,
.wn-dt-theme table.dataTable.wn-dt-plain thead th {
    background-color: transparent !important;
    color: inherit;
    border-bottom: 2px solid var(--wn-dt-border, #e7eaef) !important;
}
.wn-dt-theme .wn-dt-plain table.dataTable thead th::after,
.wn-dt-theme table.dataTable.wn-dt-plain thead th::after { content: none; }
.wn-dt-theme .wn-dt-plain table.dataTable tbody tr:hover > td:first-child,
.wn-dt-theme table.dataTable.wn-dt-plain tbody tr:hover > td:first-child {
    box-shadow: none;
}

/* ---------------------- ACESSIBILIDADE / MOTION --------------------- */
@media (prefers-reduced-motion: reduce) {
    .wn-dt-theme table.dataTable tbody img,
    .wn-dt-theme .dataTables_paginate .pagination > li > a,
    .wn-dt-theme .dataTables_paginate .paginate_button { transition: none; }
    .wn-dt-theme table.dataTable tbody tr:hover img { transform: none; }
}
