/* public/css/components/multiselect-filter.css
 *
 * The searchable multi-select in components/multiSelectFilter.js — used in the
 * Stock screen's filter panel to pick several titles, imprints or holders.
 *
 * Sits inside a .filter-group beside plain .filter-input / .filter-select
 * controls (components/enhanced-sales.css), so the toggle deliberately matches
 * their padding, border and font: a row of filters must read as one row of
 * filters even though one of them opens a panel.
 */

.multiselect-container {
    position: relative;
    display: flex;
    flex-direction: column;
}

.multiselect-toggle {
    /* Anchors the caret below; without it the caret would position against
       .multiselect-container and drift as the chip row grows. */
    position: relative;
    /* Same box as .filter-select — see the note above. */
    padding: 9px 28px 9px 12px;
    border: 1px solid var(--rule-2);
    background: var(--white);
    font-family: var(--font-body);
    font-size: 0.875rem;
    color: var(--ink-dim);
    text-align: left;
    cursor: pointer;
    transition: border-color var(--duration-fast) var(--ease-out);
}

/* The caret is drawn rather than typed so the toggle's text can be replaced
   wholesale with a count without taking the affordance with it. */
.multiselect-toggle::after {
    content: '';
    position: absolute;
    top: 50%;
    right: 12px;
    /* -2px keeps the solid half of the triangle optically centred. */
    transform: translateY(-2px);
    border: 4px solid transparent;
    border-top-color: currentColor;
}

.multiselect-toggle.has-selection {
    color: var(--ink);
    border-color: var(--ink);
}

.multiselect-toggle:hover {
    border-color: var(--ink);
}

.multiselect-toggle:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 2px;
}

.multiselect-dropdown {
    position: absolute;
    /* Below the toggle, not below the chips: the chips grow downward as things
       are picked, and an anchor that moved with them would walk the open panel
       down the page mid-selection. */
    top: 38px;
    left: 0;
    right: 0;
    z-index: 20;
    background: var(--white);
    border: 1px solid var(--rule-2);
    border-radius: var(--border-radius-sm);
    box-shadow: var(--shadow-md);
    padding: var(--space-2);
}

.multiselect-dropdown[hidden] {
    display: none;
}

.multiselect-search {
    width: 100%;
    padding: 7px 10px;
    margin-bottom: var(--space-2);
    border: 1px solid var(--rule-2);
    font-family: var(--font-body);
    font-size: 0.875rem;
    background: var(--white);
}

.multiselect-search:focus {
    outline: none;
    border-color: var(--ink);
}

.multiselect-options {
    max-height: 220px;
    overflow-y: auto;
}

.multiselect-option {
    display: flex;
    align-items: center;
    gap: var(--space-2);
    padding: var(--space-2);
    font-size: 0.875rem;
    color: var(--ink);
    cursor: pointer;
    border-radius: var(--border-radius-sm);
}

.multiselect-option:hover,
.multiselect-option:focus-visible {
    background: var(--ink-faint);
    outline: none;
}

.multiselect-option.selected {
    background: var(--gold-tint);
}

.multiselect-checkbox {
    display: flex;
    align-items: center;
    color: var(--ink-dim);
    flex-shrink: 0;
}

.multiselect-option.selected .multiselect-checkbox {
    color: var(--gold-deep);
}

.multiselect-empty {
    padding: var(--space-2);
    font-size: 0.875rem;
    font-style: italic;
    color: var(--ink-dim);
}

.multiselect-chips {
    display: flex;
    flex-wrap: wrap;
    gap: var(--space-1);
}

/* Only spaced when there is something to space — an empty chip row must not
   leave this control taller than the inputs beside it. */
.multiselect-chips:not(:empty) {
    margin-top: var(--space-2);
}

.multiselect-chip {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: 2px var(--space-2);
    border: 1px solid var(--rule-2);
    border-radius: var(--border-radius-lg);
    background: var(--white);
    font-family: var(--font-body);
    font-size: 0.75rem;
    color: var(--ink);
    cursor: pointer;
    transition: var(--transition-fast);
}

.multiselect-chip:hover {
    border-color: var(--ink);
    background: var(--ink-faint);
}

.multiselect-chip:focus-visible {
    outline: 2px solid var(--ink);
    outline-offset: 1px;
}
