
/* =====================================================================
   KHMER HRMS — STANDARD RESPONSIVE FILTER BAR
   UI-only patch: no form names, routes, query parameters, JavaScript,
   validation, pagination, or business logic are changed.
   Applies to normal .filter-bar forms and intentionally leaves
   .filter-form-compact / specialised toolbars alone.
   ===================================================================== */

/* ── Shared filter card proportions ───────────────────────────────── */
.filter-bar:not(.filter-form-compact) {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.filter-bar:not(.filter-form-compact) > .filter-form {
    width: 100%;
    min-width: 0;
    flex: 1 1 100%;
    box-sizing: border-box;
}

/* Keep the normal desktop/tablet filter controls visually balanced.
   Search fields get a little more room; selects share the remaining
   space instead of sizing themselves from their option text. */
@media (min-width: 768px) {
    .filter-bar:not(.filter-form-compact) > .filter-form {
        display: flex;
        align-items: stretch;
        flex-wrap: wrap;
        gap: 10px;
    }

    .filter-bar:not(.filter-form-compact) > .filter-form > select,
    .filter-bar:not(.filter-form-compact) > .filter-form > .s11-picker-field {
        flex: 1 1 180px;
        width: auto;
        min-width: 150px;
        max-width: none;
        box-sizing: border-box;
    }

    .filter-bar:not(.filter-form-compact) > .filter-form > input[type="text"] {
        flex: 1.35 1 240px;
        width: auto;
        min-width: 190px;
        max-width: none;
        box-sizing: border-box;
    }

    .filter-bar:not(.filter-form-compact) > .filter-form > .btn {
        flex: 0 0 auto;
        min-height: 38px;
        white-space: nowrap;
    }
}

/* ── Phone: one clean vertical filter stack ─────────────────────────
   Every select receives exactly the same width, including
   All Departments / All Positions / All Statuses. This deliberately
   overrides width differences caused by long option labels. */
@media (max-width: 767.98px) {
    .filter-bar:not(.filter-form-compact) {
        padding: 12px !important;
        border-radius: 14px;
        margin-bottom: 12px;
    }

    .filter-bar:not(.filter-form-compact) > .filter-form {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        align-items: stretch;
        gap: 8px;
        width: 100%;
        margin: 0;
    }

    .filter-bar:not(.filter-form-compact) > .filter-form > select,
    .filter-bar:not(.filter-form-compact) > .filter-form > input,
    .filter-bar:not(.filter-form-compact) > .filter-form > .s11-picker-field {
        width: 100% !important;
        min-width: 0 !important;
        max-width: none !important;
        flex: none !important;
        box-sizing: border-box;
    }

    .filter-bar:not(.filter-form-compact) > .filter-form > select {
        min-height: 38px;
    }

    /* Date/time picker wrappers must occupy the same full-width lane as
       the selects, while the actual visible picker remains responsive. */
    .filter-bar:not(.filter-form-compact) > .filter-form > .s11-picker-field {
        display: flex;
        min-height: 38px;
    }

    .filter-bar:not(.filter-form-compact) > .filter-form > .s11-picker-field > * {
        min-width: 0;
        max-width: none;
        box-sizing: border-box;
    }

    /* Filter + Clear Filters share one row and exactly the same width.
       This keeps the action row visually balanced at 375/390/430px. */
    .filter-bar:not(.filter-form-compact) > .filter-form > .btn {
        width: 100%;
        min-width: 0;
        min-height: 40px;
        box-sizing: border-box;
        margin: 0;
    }

    .filter-bar:not(.filter-form-compact) > .filter-form > .btn:last-child,
    .filter-bar:not(.filter-form-compact) > .filter-form > a.btn {
        min-width: 0;
    }

    /* When the final controls are a submit button followed by a Clear
       Filters link, place them into equal 1fr columns. */
    .filter-bar:not(.filter-form-compact) > .filter-form > button.btn[type="submit"]:nth-last-child(2),
    .filter-bar:not(.filter-form-compact) > .filter-form > a.btn:last-child {
        grid-column: span 1;
    }

    /* The two action controls are kept side-by-side without requiring
       any HTML wrapper, so existing form flow remains untouched. */
    .filter-bar:not(.filter-form-compact) > .filter-form {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }

    .filter-bar:not(.filter-form-compact) > .filter-form > input[type="hidden"] {
        display: none;
    }

    /* Search/date/select fields span the complete filter width. */
    .filter-bar:not(.filter-form-compact) > .filter-form > input:not([type="hidden"]),
    .filter-bar:not(.filter-form-compact) > .filter-form > select,
    .filter-bar:not(.filter-form-compact) > .filter-form > .s11-picker-field {
        grid-column: 1 / -1;
    }

    /* Action buttons occupy one equal column each. */
    .filter-bar:not(.filter-form-compact) > .filter-form > .btn {
        grid-column: span 1;
    }
}

/* ── Very narrow phones ──────────────────────────────────────────── */
@media (max-width: 374.98px) {
    .filter-bar:not(.filter-form-compact) {
        padding: 10px !important;
    }

    .filter-bar:not(.filter-form-compact) > .filter-form {
        gap: 7px;
    }

    .filter-bar:not(.filter-form-compact) > .filter-form > .btn {
        font-size: 0.82rem;
        padding-left: 8px;
        padding-right: 8px;
    }
}
