/* ─────────────────────────────────────────────────────────────────────────────
 * crm-filter-bar.css — the house filter bar (crm-filter-bar.js), standalone.
 * Every rule is scoped under .crm-fbar so it never fights crm-ui.css where
 * that file is loaded, and it carries the full look where it is not (the
 * super-admin layout). Colours follow whichever theme variable the layout
 * defines: --crm-primary (app) or --sa-primary (super-admin).
 * ───────────────────────────────────────────────────────────────────────── */
.crm-fbar { margin: 0 0 .25rem; }
.crm-fbar-head { display: flex; justify-content: flex-end; padding: 10px 14px 0; }

.crm-fbar .crm-icon-btn {
    position: relative;
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0;
    border: 1.5px solid var(--crm-border, var(--sa-border, #e2e8f0));
    border-radius: 8px;
    background: var(--crm-card-bg, var(--sa-card, #fff));
    color: var(--crm-primary, var(--sa-primary, #530383));
    cursor: pointer; font-size: .95rem; line-height: 1;
    transition: all .14s;
}
.crm-fbar .crm-icon-btn:hover,
.crm-fbar .crm-icon-btn.active {
    border-color: var(--crm-primary, var(--sa-primary, #530383));
    background: var(--crm-primary-soft, var(--sa-primary-soft, rgba(83, 3, 131, .07)));
}
.crm-fbar .crm-icon-btn--primary,
.crm-fbar .crm-icon-btn--primary:hover {
    background: var(--crm-primary, var(--sa-primary, #530383));
    border-color: var(--crm-primary, var(--sa-primary, #530383));
    color: #fff;
}

.crm-fbar-count {
    position: absolute; top: -6px; right: -6px;
    min-width: 17px; height: 17px; padding: 0 4px;
    border-radius: 9px;
    background: var(--crm-primary, var(--sa-primary, #530383)); color: #fff;
    font-size: 10px; line-height: 17px; font-weight: 600;
    display: none;
}
.crm-fbar-count.on { display: block; }

/* collapsed by default; the funnel opens it */
.crm-fbar .crm-filter-wrap {
    display: flex; flex-direction: row; flex-wrap: wrap; align-items: center;
    gap: 8px;
    max-height: 0; overflow: hidden;
    padding: 0 14px; margin: 0;
    background: var(--crm-filter-bg, var(--sa-hover, #f9fafb));
    border-bottom: 1px solid transparent;
    transition: max-height .2s ease, padding .2s ease;
}
.crm-fbar .crm-filter-wrap.open {
    max-height: 320px;
    padding: 10px 14px;
    border-bottom-color: var(--crm-border, var(--sa-border, #e8eaef));
    overflow: visible;
}

.crm-fbar .crm-filter-ctrl {
    width: auto !important;
    min-width: 130px; max-width: 210px;
    height: 32px;
    font-size: .8rem; padding: .15rem .5rem;
    border: 1px solid var(--crm-border, var(--sa-border, #e2e8f0));
    border-radius: 8px;
    background: var(--crm-card-bg, var(--sa-card, #fff));
    color: inherit;
}
/* The column name IS the label of a text box. The super-admin layout blanks
   every input::placeholder globally (opacity 0 !important) — without this
   override six boxes sat there nameless. */
.crm-fbar .crm-filter-ctrl::placeholder {
    opacity: 1 !important;
    color: #9ca3af !important;
}

/* A <select> has to LOOK like one. The `background` shorthand above is a
   shorthand: it resets background-image, which is where Bootstrap keeps the
   .form-select chevron — and the padding override takes away the room it sits
   in. The result was a dropdown rendered as a flat box, so a bar full of real
   dropdowns still read as "13 identical search boxes" (owner, 07/09/2026).
   One neutral grey serves both themes. Guarded by
   tests/Feature/CodeQuality/FilterBarDropdownVocabularyTest. */
.crm-fbar select.crm-filter-ctrl,
.crm-filter-wrap select.crm-filter-ctrl[data-crm-generated] {
    -webkit-appearance: none;
    appearance: none;
    padding-right: 1.6rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%239ca3af' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right .5rem center;
    background-size: 11px 8px;
    cursor: pointer;
}
.crm-fbar .crm-filter-ctrl:focus {
    outline: 0;
    border-color: var(--crm-primary, var(--sa-primary, #530383));
    box-shadow: 0 0 0 2px rgba(83, 3, 131, .1);
}
.crm-fbar .crm-filter-wrap .crm-icon-btn { width: 32px; height: 32px; }

.crm-fbar .crm-filter-sep {
    width: 1px; height: 22px;
    background: var(--crm-border, var(--sa-border, #e2e8f0));
    margin: 0 .25rem;
}

/* plain (non-DataTable) tables: a filtered-out row simply leaves */
tr.crm-row-filtered { display: none !important; }

/* A page bar that received generated controls: pages size their bar for ONE
   row of pills (max-height ~60px) — with a control per column it must wrap.
   ONLY while the bar is open. A third selector here used to read
   `:not(.d-none):not(.collapsed)`, which matches a CLOSED .crm-filter-wrap —
   it has neither class — so `max-height:none` won the cascade over the base
   `max-height:0` and the funnel stopped collapsing the bar. Measured stuck
   open at 133px on /super-admin/saas-accounts and /super-admin/demo-sessions
   (27/08/2026). Every .crm-filter-wrap in CRM5 is height-driven via .open —
   none carries d-none in markup and all 66 toggles call toggleClass('open') —
   so the display-driven arm had no legitimate target at all.
   Guarded by tests/Feature/CodeQuality/FilterBarCollapseRulesTest. */
.crm-filter-wrap--merged.open,
.crm-filter-wrap--merged.show {
    max-height: none !important;
    overflow: visible !important;
    flex-wrap: wrap !important;
    row-gap: 8px;
}

/* Generated controls MERGED into a page's own bar (no .crm-fbar ancestor):
   same size and shape as the page's hand-built pills and selects. */
.crm-filter-wrap .crm-filter-ctrl[data-crm-generated] {
    width: auto !important;
    min-width: 130px; max-width: 210px;
    height: 32px;
    font-size: .8rem; padding: .15rem .5rem;
    border-radius: 8px;
}
.crm-filter-ctrl[data-crm-generated]::placeholder { opacity: 1 !important; color: #9ca3af !important; }
.crm-filter-wrap .crm-fbar-clear {
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0;
    border: 1.5px solid var(--crm-border, var(--sa-border, #e2e8f0));
    border-radius: 8px; background: transparent;
    color: var(--crm-primary, var(--sa-primary, #530383)); cursor: pointer;
}

/* narrow screens: controls take the full row width so the bar never scrolls sideways */
@media (max-width: 575.98px) {
    .crm-fbar .crm-filter-ctrl { min-width: 0; max-width: none; flex: 1 1 calc(50% - 8px); }
}

/* ── "Showing a slice" bar (CrmDrill.note) — a dash_* drill from the sign-in
   "Work assigned to you" alert or a dashboard tile. Painted above the filter
   row so a narrowed list is never mistaken for a list that lost rows. ───── */
.crm-drill-note {
    display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
    min-height: 34px; padding: 6px 12px; margin: 0 0 8px;
    font-size: .78rem; color: #4b5563;
    background: var(--crm-primary-soft, #f6f3fb);
    border: 1px solid var(--crm-border, #e6ddf3); border-radius: 8px;
}
.crm-drill-note .crm-drill-lead { font-weight: 600; color: var(--crm-primary, #530383); }
.crm-drill-note .crm-drill-chip {
    display: inline-block; padding: 2px 9px; border-radius: 999px;
    background: #fff; border: 1px solid var(--crm-border, #e6ddf3);
    font-weight: 600; color: #374151; white-space: nowrap; max-width: 100%;
    overflow: hidden; text-overflow: ellipsis;
}
.crm-drill-note .crm-drill-clear {
    margin-left: auto; font-weight: 600; text-decoration: none;
    color: var(--crm-primary, #530383);
}
.crm-drill-note .crm-drill-clear:hover { text-decoration: underline; }
