/* TableFilterPanel — shared search/clear/refresh bar + collapsible "Mais filtros" panel.
   Reuses .panel-card (dashboard.css) for the outer card look. Every table-filter page should
   converge on these classes instead of a page-specific *-filters-grid. */

.table-filter-panel {
    margin-bottom: 24px;
}

.table-filter-panel-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.table-filter-panel-search {
    flex: 1 1 auto;
    min-width: 0;
}

.table-filter-panel-btn.mud-button-root {
    height: 40px;
    min-width: 120px;
    white-space: nowrap;
    flex: 0 0 auto;
}

/* ---------- Primary (always-visible) filters ----------
   Only rendered when a page passes <PrimaryFilters>. The fields share the row's free space
   evenly on desktop; the flex-basis is what pushes the whole block onto its own line once the
   buttons no longer fit beside it. Limpar/Atualizar keep their fixed width throughout. */
.table-filter-panel-primary {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1 1 420px;
    min-width: 0;
}

.table-filter-panel-primary > * {
    flex: 1 1 0;
    min-width: 0;
}

/* Wrapping is opt-in per row — pages with only search + buttons keep the original single line. */
.table-filter-panel-row-has-primary {
    flex-wrap: wrap;
}

/* Tablet: the filters take the full width above the buttons, and may break into two lines
   among themselves rather than squeezing three dense inputs into a narrow row. */
@media (max-width: 899px) {
    .table-filter-panel-primary {
        flex: 1 1 100%;
        flex-wrap: wrap;
    }

    .table-filter-panel-primary > * {
        flex: 1 1 180px;
    }
}

.table-filter-panel-expansion,
.table-filter-panel-expansion .mud-expand-panel {
    background-color: transparent;
    box-shadow: none;
}

.table-filter-panel-expansion {
    margin-top: 8px;
}

.table-filter-panel-expansion .mud-expand-panel-header {
    padding-left: 0;
    padding-right: 0;
    min-height: 40px;
}

.table-filter-panel-expansion .mud-expand-panel-content .mud-expand-panel-text {
    padding-left: 0;
    padding-right: 0;
}

.table-filter-panel-toggle {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 500;
    color: var(--tm-text-secondary, inherit);
}

.table-filter-panel-badge {
    min-width: 22px;
    height: 22px;
}

.table-filter-panel-advanced {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    padding-top: 4px;
    padding-bottom: 8px;
}

.table-filter-panel-advanced > * {
    width: 100%;
}

@media (max-width: 1279px) {
    .table-filter-panel-advanced {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 599px) {
    .table-filter-panel-row {
        flex-wrap: wrap;
    }

    .table-filter-panel-search {
        flex: 1 1 100%;
    }

    .table-filter-panel-btn.mud-button-root {
        flex: 1 1 auto;
        min-width: 0;
    }

    /* Phone: one primary filter per line — stacked, never hidden. */
    .table-filter-panel-primary {
        flex-direction: column;
        align-items: stretch;
    }

    .table-filter-panel-primary > * {
        flex: 0 0 auto;
        width: 100%;
    }

    .table-filter-panel-advanced {
        grid-template-columns: 1fr;
    }
}
