/* DataTable — fiel a handoff/reference/data_table.jsx */

.wf-dt-bulk-bar {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 16px;
    background: var(--wf-info-bg);
    border: 1px solid rgba(77, 163, 255, 0.33);
    border-radius: var(--wf-radius-lg) var(--wf-radius-lg) 0 0;
    border-bottom: none;
    font-size: 13px;
    color: var(--wf-text);
    margin-bottom: -1px;
}

.wf-dt-bulk-count {
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--wf-brand-accent);
}

.wf-dt-bulk-count strong {
    font-weight: 700;
}

.wf-dt-bulk-actions {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 8px;
}

.wf-dt {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-lg);
    overflow: hidden;
}

.wf-dt-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    border-bottom: 1px solid var(--wf-border);
    gap: 8px;
    flex-shrink: 0;
}

.wf-dt-toolbar-summary {
    font-size: 12px;
    color: var(--wf-text-muted);
}

.wf-dt-scroll {
    flex: 1;
    overflow: auto;
    position: relative;
}

.wf-dt-table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    table-layout: fixed;
    font-family: var(--wf-font);
}

/* thead como bloco sticky (mais robusto que sticky por célula: evita "desanexar"
   o cabeçalho ao scrollar rápido ou quando o browser faz layout incremental).
   Complementado com sticky individual nas células para browsers mais antigos
   e para z-index previsível sobre as rows do tbody. */
.wf-dt-table thead {
    position: sticky;
    top: 0;
    z-index: 3;
}

.wf-dt-th {
    position: sticky;
    top: 0;
    z-index: 3;
    background: var(--wf-bg-sunken);
    border-bottom: 1px solid var(--wf-border);
    border-right: 1px solid var(--wf-border);
    padding: 0;
    text-align: left;
    font-weight: 600;
    color: var(--wf-text);
    user-select: none;
}

.wf-dt-th:last-child { border-right: none; }

.wf-dt-th-content {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 0 12px;
    cursor: default;
    font-size: 12px;
    color: var(--wf-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.4px;
    height: 100%;
}

.wf-dt-th-content.sortable { cursor: pointer; }
.wf-dt-th-content.sortable:hover { color: var(--wf-text); }

.wf-dt-sort-indicator {
    display: inline-flex;
    opacity: 0.6;
}

.wf-dt-sort-indicator.active { opacity: 1; color: var(--wf-brand-accent); }

.wf-dt-filter-row {
    background: var(--wf-surface);
}

.wf-dt-filter-cell {
    padding: 6px 8px;
    /* Bottom border mais forte que a border padrão (evita visual "grudado" na row 1). */
    border-bottom: 2px solid var(--wf-border);
    border-right: 1px solid var(--wf-border);
    /* position: sticky + `top` dinâmico (vem inline do componente c/ altura real
       do header por densidade) faz o filter cell grudar abaixo do header ao
       scrollar. Sem o top dinâmico o filter fica num offset errado e a primeira
       row visível passa "por trás" do filter. O thead também é sticky (acima),
       dobrando a robustez em browsers que têm quirks com sticky por célula. */
    position: sticky;
    z-index: 3;
    background: var(--wf-surface);
    vertical-align: middle;
}

.wf-dt-filter-cell:last-child { border-right: none; }

.wf-dt-filter-input {
    width: 100%;
    height: 26px;
    padding: 0 8px;
    font-size: 12px;
    font-family: var(--wf-font);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-sm);
    background: var(--wf-surface);
    color: var(--wf-text);
    outline: none;
}

.wf-dt-filter-input:focus {
    border-color: var(--wf-border-focus);
    box-shadow: 0 0 0 3px rgba(77, 163, 255, 0.15);
}

.wf-dt-resize-handle {
    position: absolute;
    top: 0;
    right: -3px;
    width: 6px;
    height: 100%;
    cursor: col-resize;
    z-index: 3;
    user-select: none;
}

.wf-dt-resize-handle::after {
    content: "";
    position: absolute;
    right: 3px;
    top: 20%;
    bottom: 20%;
    width: 2px;
    border-radius: 1px;
    background: transparent;
    transition: background 100ms;
}

/* Dica de descoberta: ao passar o mouse em qualquer parte do cabeçalho, mostra a
   divisa redimensionável da borda direita; em cima da própria alça, fica em destaque. */
.wf-dt-th:hover .wf-dt-resize-handle::after { background: var(--wf-border-strong, var(--wf-border)); }
.wf-dt-resize-handle:hover::after { background: var(--wf-brand-accent); }

.wf-dt-row {
    cursor: pointer;
    transition: background 80ms ease-out;
}

.wf-dt-row:hover { background: var(--wf-hover); }
.wf-dt-row.striped { background: var(--wf-surface-alt); }
.wf-dt-row.striped:hover { background: var(--wf-hover); }
.wf-dt-row.selected { background: var(--wf-selected); }

.wf-dt-cell {
    border-bottom: 1px solid var(--wf-border);
    border-right: 1px solid transparent;
    padding: 0 12px;
    font-size: 13px;
    color: var(--wf-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    vertical-align: middle;
}

.wf-dt-cell.mono { font-family: var(--wf-font-mono); }
.wf-dt-cell.align-right { text-align: right; }
.wf-dt-cell.align-center { text-align: center; }

.wf-dt-select-col {
    width: 40px;
    text-align: center;
    padding: 0;
}

.wf-dt-checkbox {
    accent-color: var(--wf-brand-accent);
    cursor: pointer;
    width: 14px;
    height: 14px;
    margin: 0;
}

.wf-dt-empty {
    padding: 40px;
    text-align: center;
    color: var(--wf-text-subtle);
    font-size: 13px;
}

.wf-dt-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 8px 14px;
    border-top: 1px solid var(--wf-border);
    background: var(--wf-surface-alt);
    font-size: 12px;
    color: var(--wf-text-muted);
    flex-shrink: 0;
    gap: 16px;
}

.wf-dt-pager {
    display: flex;
    align-items: center;
    gap: 4px;
}

.wf-dt-page-btn {
    width: 28px;
    height: 28px;
    border: 1px solid var(--wf-border);
    background: var(--wf-surface);
    color: var(--wf-text);
    border-radius: var(--wf-radius-sm);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-family: var(--wf-font);
    font-size: 12px;
    transition: background 100ms;
}

.wf-dt-page-btn:hover:not(:disabled) { background: var(--wf-hover); }
.wf-dt-page-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.wf-dt-page-size {
    height: 28px;
    padding: 0 8px;
    border: 1px solid var(--wf-border);
    background: var(--wf-surface);
    color: var(--wf-text);
    border-radius: var(--wf-radius-sm);
    font-family: var(--wf-font);
    font-size: 12px;
    cursor: pointer;
}

.wf-dt-display-menu {
    position: absolute;
    top: calc(100% + 4px);
    right: 0;
    width: 280px;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-md);
    box-shadow: var(--wf-shadow-lg);
    z-index: 500;
    padding: 8px;
    font-family: var(--wf-font);
}

.wf-dt-display-section {
    font-size: 10px;
    color: var(--wf-text-subtle);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    font-weight: 600;
    padding: 6px 8px 4px;
}

.wf-dt-display-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 8px;
    font-size: 13px;
    color: var(--wf-text);
    cursor: pointer;
    border-radius: var(--wf-radius-sm);
    background: transparent;
    border: none;
    width: 100%;
    text-align: left;
    font-family: var(--wf-font);
}

.wf-dt-display-item:hover { background: var(--wf-hover); }
.wf-dt-display-item.active { color: var(--wf-brand-accent); }

.wf-dt-display-footer {
    border-top: 1px solid var(--wf-border);
    margin-top: 6px;
    padding-top: 6px;
}

/* Itens de coluna arrastáveis no menu "Exibir" (reorder). */
.wf-dt-display-col.arrastavel { cursor: grab; }
.wf-dt-display-col.arrastavel:active { cursor: grabbing; }
.wf-dt-display-col.arrastando { opacity: 0.45; }

/* FiltroBar — barra de filtros acima do DataTable (Select/MultiSelect/Data/Texto + chips). */
.wf-filtrobar {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 12px 14px;
    background: var(--wf-surface-alt);
    border: 1px solid var(--wf-border);
    border-bottom: none;
    border-radius: var(--wf-radius-lg) var(--wf-radius-lg) 0 0;
}

.wf-filtrobar-controles {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 12px;
}

.wf-filtrobar-ctrl {
    display: flex;
    flex-direction: column;
    gap: 3px;
    min-width: 160px;
}

.wf-filtrobar-lbl {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--wf-text-subtle);
}

.wf-filtrobar-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
}

.wf-filtrobar-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 8px 4px 10px;
    background: var(--wf-selected);
    color: var(--wf-selected-text);
    border-radius: var(--wf-radius-pill);
    font-size: 12px;
    font-family: var(--wf-font);
    line-height: 1.4;
}

.wf-filtrobar-chip-x {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: transparent;
    color: var(--wf-text-subtle);
    cursor: pointer;
    font-size: 14px;
    line-height: 1;
    padding: 0;
    width: 16px;
    height: 16px;
    border-radius: 50%;
}

.wf-filtrobar-chip-x:hover {
    color: var(--wf-text);
    background: var(--wf-hover);
}

.wf-filtrobar-limpar {
    border: none;
    background: transparent;
    color: var(--wf-brand-accent);
    font-family: var(--wf-font);
    font-size: 12px;
    cursor: pointer;
    padding: 4px 2px;
}

.wf-filtrobar-limpar:hover {
    text-decoration: underline;
}

/* FiltroData — dropdown de presets de data + período custom (usado dentro da FiltroBar). */
.wf-filtrodata {
    position: relative;
}

.wf-filtrodata-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 10px 0 12px;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-md);
    cursor: pointer;
    font-size: 13px;
    color: var(--wf-text);
    transition: all 120ms ease-out;
}

.wf-filtrodata-trigger:hover {
    border-color: var(--wf-border-strong);
}

.wf-filtrodata-trigger-lbl {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wf-filtrodata-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.wf-filtrodata-painel {
    position: absolute;
    top: 40px;
    left: 0;
    min-width: 220px;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-md);
    box-shadow: var(--wf-shadow-lg);
    z-index: 51;
    padding: 4px;
}

.wf-filtrodata-preset {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--wf-radius-sm);
    font-size: 13px;
    color: var(--wf-text);
    cursor: pointer;
}

.wf-filtrodata-preset:hover {
    background: var(--wf-hover);
}

.wf-filtrodata-divisor {
    height: 1px;
    margin: 4px 6px;
    background: var(--wf-border);
}

.wf-filtrodata-custom-abrir {
    padding: 8px 10px;
    border-radius: var(--wf-radius-sm);
    font-size: 13px;
    color: var(--wf-brand-accent);
    cursor: pointer;
}

.wf-filtrodata-custom-abrir:hover {
    background: var(--wf-hover);
}

.wf-filtrodata-custom {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 6px;
}

.wf-filtrodata-custom-lbl {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    color: var(--wf-text-subtle);
}

.wf-filtrodata-custom-lbl input[type="date"] {
    height: 32px;
    padding: 0 8px;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-sm);
    font-size: 13px;
    font-family: var(--wf-font);
    color: var(--wf-text);
}

.wf-filtrodata-aplicar {
    height: 32px;
    border: none;
    border-radius: var(--wf-radius-sm);
    background: var(--wf-brand-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.wf-filtrodata-aplicar:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* FiltroMultiSelect — dropdown com checkboxes (usado dentro da FiltroBar). */
.wf-filtromulti {
    position: relative;
}

.wf-filtromulti-trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    height: 36px;
    padding: 0 10px 0 12px;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-md);
    cursor: pointer;
    font-size: 13px;
    color: var(--wf-text);
    transition: all 120ms ease-out;
}

.wf-filtromulti-trigger:hover {
    border-color: var(--wf-border-strong);
}

.wf-filtromulti-trigger-lbl {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wf-filtromulti-overlay {
    position: fixed;
    inset: 0;
    z-index: 50;
}

.wf-filtromulti-painel {
    position: absolute;
    top: 40px;
    left: 0;
    min-width: 200px;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-md);
    box-shadow: var(--wf-shadow-lg);
    z-index: 51;
    padding: 4px;
    max-height: 260px;
    overflow-y: auto;
}

.wf-filtromulti-opcao {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: var(--wf-radius-sm);
    font-size: 13px;
    color: var(--wf-text);
    cursor: pointer;
}

.wf-filtromulti-opcao:hover {
    background: var(--wf-hover);
}
