/* Chip-Filter Component
   Wiederverwendbare Filter-UI mit entfernbaren Badges + "+ Filter"-Chip.
   Ersetzt Multi-Select-Filterzeilen mit Server-Submit oder Live-Client-Filter.
   Zwei Modi: data-mode="server" (Form-Submit) und data-mode="client" (Callback).
*/

.chip-filter-bar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px 8px;
    padding: 8px 4px;
    min-height: 34px;
    position: relative;
}

.chip-filter-bar .chip-label {
    font-size: 12px;
    color: #6c757d;
    margin-right: 4px;
    white-space: nowrap;
}

.chip-filter-bar .chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--iq-dark-blue, #0F326F);
    color: #fff;
    border-radius: 999px;
    padding: 4px 6px 4px 12px;
    font-size: 12.5px;
    line-height: 1.2;
    max-width: 100%;
}

.chip-filter-bar .chip-text {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 260px;
}

.chip-filter-bar .chip-remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    background: rgba(255, 255, 255, 0.22);
    border: none;
    border-radius: 50%;
    color: #fff;
    font-size: 11px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
}

.chip-filter-bar .chip-remove:hover {
    background: rgba(255, 255, 255, 0.35);
}

.chip-filter-bar .chip-add {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    color: var(--iq-dark-blue, #0F326F);
    border: 1px dashed #A9B4C7;
    border-radius: 999px;
    padding: 3px 12px 3px 10px;
    font-size: 12.5px;
    line-height: 1.2;
    cursor: pointer;
    white-space: nowrap;
}

.chip-filter-bar .chip-add:hover {
    background: #EEF2F8;
    border-color: var(--iq-dark-blue, #0F326F);
}

.chip-filter-bar .chip-add-icon {
    font-size: 14px;
    line-height: 1;
    font-weight: 500;
}

.chip-filter-bar .chip-reset {
    background: transparent;
    color: #6c757d;
    border: none;
    font-size: 12px;
    padding: 3px 8px;
    cursor: pointer;
    margin-left: 4px;
    text-decoration: underline;
    text-underline-offset: 3px;
}

.chip-filter-bar .chip-reset:hover {
    color: var(--iq-dark-blue, #0F326F);
}

/* Popover — Auswahl der Filter-Kategorie */
.chip-filter-popover {
    position: absolute;
    top: 100%;
    left: 0;
    z-index: 1000;
    background: #fff;
    border: 1px solid #D0D6DE;
    border-radius: 4px;
    box-shadow: 0 4px 16px rgba(15, 50, 111, 0.14);
    padding: 6px;
    min-width: 220px;
    max-width: 320px;
    max-height: 320px;
    overflow-y: auto;
    margin-top: 4px;
}

.chip-filter-popover[hidden] {
    display: none;
}

.chip-filter-popover .cfp-search {
    width: 100%;
    border: 1px solid #ced4da;
    border-radius: 3px;
    padding: 5px 8px;
    font-size: 13px;
    margin-bottom: 6px;
    box-sizing: border-box;
}

.chip-filter-popover .cfp-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.chip-filter-popover .cfp-item {
    padding: 6px 10px;
    font-size: 13px;
    color: #212529;
    cursor: pointer;
    border-radius: 3px;
}

.chip-filter-popover .cfp-item:hover,
.chip-filter-popover .cfp-item.active {
    background: #EEF2F8;
    color: var(--iq-dark-blue, #0F326F);
}

.chip-filter-popover .cfp-item .cfp-secondary {
    font-size: 11px;
    color: #6c757d;
    margin-left: 6px;
}

.chip-filter-popover .cfp-empty {
    padding: 12px 10px;
    font-size: 12.5px;
    color: #6c757d;
    text-align: center;
}

.chip-filter-popover .cfp-back {
    background: transparent;
    border: none;
    color: #6c757d;
    font-size: 12px;
    padding: 4px 8px 8px;
    cursor: pointer;
    display: block;
    width: 100%;
    text-align: left;
    border-bottom: 1px solid #E9ECEF;
    margin-bottom: 6px;
}

.chip-filter-popover .cfp-back:hover {
    color: var(--iq-dark-blue, #0F326F);
}

/* Mobile-Anpassung — auf schmalen Screens Popover full-width unten */
@media (max-width: 576px) {
    .chip-filter-popover {
        position: fixed;
        top: auto;
        bottom: 0;
        left: 0;
        right: 0;
        border-radius: 12px 12px 0 0;
        max-width: 100%;
        max-height: 60vh;
    }
}
