/* ==========================================================================
   faceted-search.css — shared token/facet search box

   Progressive enhancement of any ``<input data-facets='[…]'>`` (see
   static/js/faceted-search.js). Structured filters render as removable pills
   INSIDE the box; free text stays in the trailing input. Flat design system —
   no bevels, no gradients (see design-system feedback): hairline borders,
   brand-green focus ring, neutral pills.
   ========================================================================== */

/* The enhanced group drops the fixed 360px / 36px sizing of the plain
   .search-input-group so pills can wrap the box to auto height. */
.search-input-group.is-faceted {
    display: flex;
    align-items: stretch;
    gap: 8px;
    width: 520px; /* wider than the 360px plain box, per request */
    max-width: 100%;
    height: auto;
    border: none;
    box-shadow: none;
    overflow: visible;
}

/* The box itself: carries the border + background the group used to own. */
.faceted-search {
    position: relative;
    flex: 1 1 auto;
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 6px;
    min-height: 36px;
    padding: 3px 8px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-base);
    background: var(--bg-page);
    box-shadow: 0 1px 0.5px 0.05px rgba(29, 41, 61, 0.02);
    transition:
        border-color var(--transition-fast),
        box-shadow var(--transition-fast);
    color: var(--fg-heading);
}

.faceted-search:focus-within {
    border-color: var(--color-primary);
    box-shadow: var(--shadow-focus);
}

/* A committed filter, e.g. "Device: sensor-3". Soft brand-green tint so the
   active filters read clearly against the near-white box. */
.faceted-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    max-width: 220px;
    padding: 2px 4px 2px 8px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--facet-pill-border);
    background: var(--banner-soft-end);
    font-size: var(--fs-sm);
    line-height: 1.4;
    white-space: nowrap;
}

.faceted-pill__key {
    color: var(--color-brand-green-deep);
    font-weight: 600;
}

.faceted-pill__val {
    color: var(--banner-tenant-border);
    overflow: hidden;
    text-overflow: ellipsis;
}

.faceted-pill__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--facet-pill-remove-fg);
    font-size: var(--fs-xs);
    line-height: 1;
    cursor: pointer;
    transition:
        color var(--transition-fast),
        background-color var(--transition-fast);
}

.faceted-pill__remove:hover {
    color: var(--banner-tenant-border);
    background: var(--pos-terrain-border);
}

.faceted-pill__remove:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 1px;
}

/* The trailing free-text / typing input. Borderless — the box draws the
   border. Grows to fill the remaining row width. */
.faceted-search__input {
    flex: 1 1 80px;
    min-width: 80px;
    border: none;
    background: transparent;
    padding: 3px 2px;
    font-size: var(--fs-base);
    color: var(--color-gray-900);
    outline: none;
}

.faceted-search__input::placeholder {
    color: var(--color-gray-600);
}

/* Autocomplete popover: hairline border + card-soft shadow (menu popover, not
   page chrome — the almost-invisible lift keeps it legible over the table). */
.faceted-search__dropdown {
    position: absolute;
    top: calc(100% + 4px);
    left: 0;
    z-index: 40;
    min-width: 220px;
    max-width: 320px;
    max-height: 260px;
    overflow-y: auto;
    padding: 4px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-base);
    background: var(--bg-card);
    box-shadow: 0 4px 12px rgba(29, 41, 61, 0.08);
}

.faceted-search__dropdown[hidden] {
    display: none;
}

.faceted-search__option {
    display: flex;
    align-items: baseline;
    gap: 8px;
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--fs-base);
    color: var(--color-gray-900);
    cursor: pointer;
}

.faceted-search__option:hover,
.faceted-search__option.is-active {
    background: color-mix(in srgb, var(--color-brand-green) 8%, transparent);
}

.faceted-search__option-key {
    color: var(--fg-4);
    font-size: var(--fs-sm);
    font-weight: 500;
}

.faceted-search__option-hint {
    margin-left: auto;
    color: var(--fg-5);
    font-size: var(--fs-xs);
}

/* Section heading inside the dropdown (e.g. "Filters", "Status values"). */
.faceted-search__group-label {
    padding: 6px 8px 2px;
    color: var(--fg-5);
    font-size: var(--fs-xs);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}
