/* 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: 25%;
    bottom: 25%;
    width: 1px;
    background: transparent;
    transition: background 100ms;
}

.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;
}
