/* ===================================================
   List Filter – Generic Dropdown (same style as catfilter)
   Mobile-first, accessible, touch-friendly
   =================================================== */

.listfilter {
    position: relative;
    width: 100%;
}

/* ---- Trigger Button ---- */
.listfilter__trigger {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 10px 14px;
    background: var(--color-bg-white, #fff);
    border: 1.5px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 8px);
    font-size: 14px;
    color: var(--color-text, #222);
    cursor: pointer;
    transition: border-color .15s, box-shadow .15s;
    text-align: left;
    -webkit-tap-highlight-color: transparent;
}
.listfilter__trigger:hover {
    border-color: var(--color-primary, #4f46e5);
}
.listfilter__trigger:focus-visible {
    outline: 2px solid var(--color-border-focus, #4f46e5);
    outline-offset: 2px;
}
.listfilter__trigger[aria-expanded="true"] {
    border-color: var(--color-primary, #4f46e5);
    box-shadow: 0 0 0 3px rgba(79,70,229,.12);
}
.listfilter__trigger[aria-expanded="true"] .listfilter__chevron {
    transform: rotate(180deg);
}

.listfilter__icon {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    opacity: .55;
}
.listfilter__icon svg {
    width: 16px;
    height: 16px;
}
.listfilter__label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.listfilter__label--placeholder {
    color: var(--color-text-muted, #999);
}
.listfilter__chevron {
    flex-shrink: 0;
    opacity: .5;
    transition: transform .2s ease;
}

/* ---- Panel ---- */
.listfilter__panel {
    display: none;
    position: absolute;
    z-index: 120;
    top: calc(100% + 4px);
    left: 0;
    right: 0;
    min-width: 240px;
    max-height: 340px;
    overflow-y: auto;
    background: var(--color-bg-white, #fff);
    border: 1.5px solid var(--color-border, #ddd);
    border-radius: var(--radius-md, 8px);
    box-shadow: 0 8px 32px rgba(0,0,0,.12), 0 2px 8px rgba(0,0,0,.06);
    padding: 6px 0;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}
.listfilter--open .listfilter__panel {
    display: block;
    animation: listfilterSlideIn .15s ease;
}

@keyframes listfilterSlideIn {
    from { opacity: 0; transform: translateY(-6px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- Search inside panel ---- */
.listfilter__search {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 4px 8px 6px;
    padding: 8px 10px;
    background: var(--color-bg-subtle, #f7f7f8);
    border: 1px solid var(--color-border-light, #eee);
    border-radius: var(--radius-sm, 6px);
}
.listfilter__search svg {
    flex-shrink: 0;
    opacity: .4;
}
.listfilter__search-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 13px;
    color: var(--color-text, #222);
    outline: none;
    min-width: 0;
}
.listfilter__search-input::placeholder {
    color: var(--color-text-muted, #aaa);
}

/* ---- Items ---- */
.listfilter__item {
    display: flex;
    align-items: center;
    gap: 8px;
    width: 100%;
    padding: 9px 14px;
    border: none;
    background: none;
    font-size: 13.5px;
    color: var(--color-text, #222);
    cursor: pointer;
    text-align: left;
    transition: background .1s;
    -webkit-tap-highlight-color: transparent;
}
.listfilter__item:hover,
.listfilter__item:focus-visible {
    background: var(--color-bg-hover, #f0f0f5);
}
.listfilter__item--active {
    background: var(--color-primary-light, #eef2ff) !important;
    color: var(--color-primary, #4f46e5);
    font-weight: 600;
}
.listfilter__item--all {
    border-bottom: 1px solid var(--color-border-light, #eee);
    margin-bottom: 2px;
    font-weight: 500;
}
.listfilter__item--hidden {
    display: none !important;
}

/* Item parts */
.listfilter__item-dot {
    flex-shrink: 0;
    width: 10px;
    height: 10px;
    border-radius: 50%;
}
.listfilter__item-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    object-fit: contain;
    border-radius: 3px;
}
.listfilter__item-name {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.listfilter__item-count {
    flex-shrink: 0;
    font-size: 11px;
    font-weight: 600;
    color: var(--color-text-muted, #999);
    background: var(--color-bg-subtle, #f3f3f6);
    padding: 1px 7px;
    border-radius: var(--radius-full, 999px);
    min-width: 22px;
    text-align: center;
}
.listfilter__item--active .listfilter__item-count {
    background: rgba(79,70,229,.12);
    color: var(--color-primary, #4f46e5);
}

/* ---- Backdrop (mobile) ---- */
.listfilter__backdrop {
    display: none;
}

/* ===================================================
   Mobile: bottom sheet style
   =================================================== */
@media (max-width: 768px) {
    .listfilter__panel {
        position: fixed;
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        min-width: 100%;
        max-height: 60vh;
        border-radius: 16px 16px 0 0;
        border: none;
        box-shadow: 0 -4px 40px rgba(0,0,0,.18);
        padding-top: 0;
        z-index: 1010;
    }
    .listfilter--open .listfilter__panel {
        animation: listfilterSlideUp .2s ease;
    }
    @keyframes listfilterSlideUp {
        from { opacity: 0; transform: translateY(40px); }
        to   { opacity: 1; transform: translateY(0); }
    }

    /* Drag handle */
    .listfilter__panel::before {
        content: '';
        display: block;
        width: 36px;
        height: 4px;
        background: var(--color-border, #ccc);
        border-radius: 4px;
        margin: 10px auto 6px;
    }

    .listfilter__search {
        position: sticky;
        top: 0;
        z-index: 2;
        margin: 0 0 4px;
        border-radius: 0;
        border-left: none;
        border-right: none;
        background: var(--color-bg-white, #fff);
        padding: 12px 14px;
    }

    .listfilter__item {
        padding: 12px 16px;
        font-size: 15px;
    }
    .listfilter__item-count {
        font-size: 12px;
        padding: 2px 8px;
    }
    .listfilter__item-icon {
        width: 24px;
        height: 24px;
    }

    /* Backdrop */
    .listfilter__backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 1009;
    }
    .listfilter--open .listfilter__backdrop {
        display: block;
    }
}
