/*
 * Dashboard table widget chrome.
 *
 * Scope: .vb-dashboard-table is added by DataSourceTableWidget::renderWidget(),
 * so nothing here touches core admin tables.
 */

/*
 * Collapsed above-content filters: core Filament keeps the filter container
 * (with its trigger button) as a dedicated row above the toolbar even when
 * collapsed, wasting a full row of vertical space per widget.
 *
 * When collapsed, zero out the container and absolutely position the funnel
 * trigger so it overlays the toolbar row that follows, sitting to the right
 * of the search box (left of the column-manager icon). When expanded, the
 * layout is untouched: full-width filters with the trigger below them.
 *
 * The offsets are tuned to core Filament v5 toolbar padding; if a Filament
 * upgrade nudges the toolbar metrics, adjust top/right here.
 */
.vb-dashboard-table .fi-ta-filters-above-content-ctn:has(.fi-ta-filters-trigger-action-ctn):not(.fi-open) {
    height: 0;
    min-height: 0;
    padding: 0;
    margin: 0;
    border: none;
    overflow: visible;
    position: relative;
}

.vb-dashboard-table .fi-ta-filters-above-content-ctn:not(.fi-open) .fi-ta-filters-trigger-action-ctn {
    position: absolute;
    top: 0.75rem;
    right: 3.25rem;
    z-index: 2;
}

/*
 * Searchable widgets render a search field in the toolbar, which shifts the row
 * the funnel trigger overlays. A single top offset can't center it in both
 * cases: the value that centers on a search-less toolbar sits too high once the
 * search box is present, so nudge the trigger down when a search field exists.
 */
.vb-dashboard-table:has(.fi-ta-search-field) .fi-ta-filters-above-content-ctn:not(.fi-open) .fi-ta-filters-trigger-action-ctn {
    top: 1.5rem;
}

/*
 * Move the search box to the LEFT edge of the toolbar. Core right-aligns the
 * whole search/icons group, which leaves the relocated funnel trigger (above)
 * overlapping the search input's right edge. Letting the group span the row
 * and pushing everything after the search field right gives the funnel and
 * column-manager icons the right side to themselves. When a widget has no
 * search, the icons stay right-aligned (flex-end).
 */
.vb-dashboard-table .fi-ta-header-toolbar > :nth-child(2) {
    flex: 1;
    justify-content: flex-end;
}

/*
 * Core always renders the toolbar's left actions group (reorder / grouping /
 * bulk toolbar actions) even when empty; combined with the toolbar's gap it
 * pushes the search field off the left edge. Dashboard widgets have none of
 * those actions, so hide the group when it's empty - :has() keeps it visible
 * the moment anything real renders inside it.
 */
.vb-dashboard-table .fi-ta-header-toolbar > .fi-ta-actions:not(:has(*)) {
    display: none;
}

.vb-dashboard-table .fi-ta-header-toolbar .fi-ta-search-field {
    margin-inline-end: auto;
}

/*
 * Compact column repeater in the widget editor sidebar.
 *
 * Scope: .vb-compact-repeater is added via extraAttributes() on the table
 * widget's columns Repeater. Filament's dense() handles the field gaps
 * (fi-sc-dense); these rules tighten the repeater item chrome (item padding,
 * header padding, spacing between items) that dense() doesn't reach.
 */
.vb-compact-repeater .fi-fo-repeater-items {
    gap: 0.625rem;
}

.vb-compact-repeater .fi-fo-repeater-item-header {
    padding: 0.375rem 0.75rem;
}

.vb-compact-repeater .fi-fo-repeater-item-content {
    padding: 0.75rem;
}
