/* Filter panel and chips — BEM classes from LPC_Filter_Renderer. */

/* ---- Toggle button ---- */
.lpc-filters-toggle {
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    font-weight: 500;
    color: #333;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.lpc-filters-toggle:hover {
    border-color: #bbb;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.lpc-filters-toggle i {
    font-size: 12px;
    color: #666;
}

/* ---- Chips ---- */
.lpc-chips-container {
    position: relative;
    z-index: 1;
    clear: both; /* .filter-top-section (preceding sibling) is float:left;
                    width:100% (main.css) - without this, this container
                    doesn't get pushed below it and visually overlaps
                    whatever sits at that vertical position (the fixed map
                    sidebar on listing-with-map-classic), instead of
                    rendering underneath the filter row as intended. */
}

.lpc-chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    padding: 12px 0 4px;
}

.lpc-chips__item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 8px 5px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    font-size: 13px;
    line-height: 1.4;
    white-space: nowrap;
    max-width: 280px;
}

.lpc-chips__label {
    color: #374151;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lpc-chips__remove {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #d1d5db;
    color: #6b7280;
    text-decoration: none;
    font-size: 13px;
    line-height: 1;
    transition: background 0.15s, color 0.15s;
}

.lpc-chips__remove:hover {
    background: #ef4444;
    color: #fff;
}

.lpc-chips__reset {
    font-size: 13px;
    color: #9ca3af;
    text-decoration: none;
    padding: 4px 0;
    margin-left: 4px;
    transition: color 0.15s;
}

.lpc-chips__reset:hover {
    color: #374151;
    text-decoration: underline;
}

/* ---- Filter panel ---- */
.lpc-filters {
    display: none;
    flex-direction: column;
    gap: 0;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    margin-top: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
    overflow: hidden;
}

.lpc-filters.is-open {
    display: flex;
}

/* ---- Header ---- */
.lpc-filters__header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    border-bottom: 1px solid #f3f4f6;
}

.lpc-filters__title {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #111827;
    flex: 1;
}

.lpc-filters__reset {
    color: #9ca3af;
    font-size: 13px;
    text-decoration: none;
    transition: color 0.15s;
}

.lpc-filters__reset:hover {
    color: #374151;
    text-decoration: underline;
}

.lpc-filters__close {
    display: none;
    background: none;
    border: none;
    font-size: 14px;
    cursor: pointer;
    color: #9ca3af;
    padding: 4px 8px;
    transition: color 0.15s;
}

.lpc-filters__close:hover {
    color: #374151;
}

/* ---- Filter body (scrollable area between header and footer) ---- */
.lpc-filters__body {
    display: grid;
    gap: 0;
    padding: 0;
    overflow-y: auto;
}

/* ---- Filter groups ---- */
.lpc-filters__group {
    border: none;
    border-bottom: 1px solid #f3f4f6;
    padding: 14px 20px;
    margin: 0;
}

.lpc-filters__group:last-of-type {
    border-bottom: none;
}

.lpc-filters__legend {
    display: block;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: #6b7280;
    margin-bottom: 8px;
}

/* Checkbox / radio options */
.lpc-filters__option {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 5px 0;
    cursor: pointer;
    font-size: 14px;
    color: #374151;
    transition: color 0.15s;
}

.lpc-filters__option:hover {
    color: #111827;
}

.lpc-filters__option input[type="checkbox"],
.lpc-filters__option input[type="radio"] {
    margin: 0;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    accent-color: #2563eb;
}

.lpc-filters__option-label {
    flex: 1;
    line-height: 1.4;
}

.lpc-filters__count {
    font-size: 12px;
    color: #9ca3af;
    min-width: 20px;
    text-align: right;
}

/* Field controls (select / text / number) share one filled, high-contrast
 * look so they read as tappable inputs rather than faint outlines on white.
 * min-height keeps a comfortable touch target on mobile. */
.lpc-filters__select,
.lpc-filters__text,
.lpc-filters__number {
    width: 100%;
    min-height: 44px;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    background: #f9fafb;
    color: #374151;
    transition: border-color 0.15s, box-shadow 0.15s, background 0.15s;
}

.lpc-filters__select {
    appearance: auto;
}

.lpc-filters__select:focus,
.lpc-filters__text:focus,
.lpc-filters__number:focus {
    outline: none;
    background: #fff;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.12);
}

/* Price range group: two number fields ("От" / "До") side by side */
.lpc-filters__range {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

.lpc-filters__range-field {
    flex: 1;
    min-width: 0;
    display: block;
}

.lpc-filters__range-label {
    display: block;
    font-size: 12px;
    color: #6b7280;
    margin-bottom: 4px;
}

/* ---- Footer ---- */
.lpc-filters__footer {
    padding: 12px 20px;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
}

.lpc-filters__submit {
    width: 100%;
    padding: 10px 20px;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.15s, box-shadow 0.15s;
}

.lpc-filters__submit:hover {
    background: #1d4ed8;
    box-shadow: 0 2px 4px rgba(37, 99, 235, 0.25);
}

.lpc-filters__submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* ---- Mobile: filter bar layout ---- */
@media (max-width: 768px) {
    .filter-top-section.classic-top-filters {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }

    .filter-top-section.classic-top-filters .lp-title {
        width: 100%;
    }

    .filter-top-section.classic-top-filters .lp-title h3 {
        font-size: 14px;
        white-space: normal;
        word-break: break-word;
    }

    /*
     * Mobile toolbar layout: sort dropdown on the first full-width row,
     * the map toggle and filters button sharing a second row as two
     * equal-width, visually matched outlined buttons. Without this the
     * three controls inherit the desktop flex-wrap plus the map wrapper's
     * float:right and scatter across uneven rows.
     */
    .lp-classic-top-filters {
        width: 100%;
        display: flex;
        flex-wrap: wrap;
        align-items: stretch;
        gap: 8px;
    }

    /* Row 1: sort dropdown spans the full width. */
    .lp-classic-top-filters > .search-filters:first-child {
        flex: 1 1 100%;
        min-width: 0;
    }

    .lp-classic-top-filters > .search-filters:first-child ul,
    .lp-classic-top-filters > .search-filters:first-child li.lp-tooltip-outer {
        width: 100%;
        margin: 0;
    }

    /* Sort trigger styled as a full-width select control. */
    .lp-classic-top-filters .classic-sortingby-select-option {
        display: flex;
        align-items: center;
        gap: 6px;
        width: 100%;
        min-height: 44px;
        margin: 0;
        padding: 8px 12px;
        font-size: 13px;
        white-space: nowrap;
        background: #fff;
        border: 1.5px solid #ddd;
        border-radius: 6px;
        max-width: none;
    }

    .lp-classic-top-filters .classic-sortingby-select-option span {
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    /* Caret pinned to the right edge. */
    .lp-classic-top-filters .classic-sortingby-select-option .fa-caret-down {
        margin-left: auto;
    }

    /* Row 2: map toggle + filters button, equal width. */
    .lp-classic-top-filters .listing-view-layout,
    .lp-classic-top-filters > .search-filters:last-child {
        flex: 1 1 0;
        min-width: 0;
        margin: 0;
    }

    /* Neutralise the desktop floats that push the map toggle away. */
    .lp-classic-top-filters .listing-view-layout,
    .lp-classic-top-filters .listing-view-layout ul,
    .lp-classic-top-filters .listing-view-layout li,
    .lp-classic-top-filters .listing-view-layout a {
        float: none;
    }

    .lp-classic-top-filters .listing-view-layout ul,
    .lp-classic-top-filters .listing-view-layout li.classic-mobile-map {
        display: block;
        width: 100%;
        margin: 0;
    }

    /* Map toggle and filters button share one outlined look.
     * The map selector is deliberately specific to beat the theme's
     * base `.listing-view-layout ul li a` rule. */
    .lp-classic-top-filters .listing-view-layout ul li a.open-map-view,
    .lp-classic-top-filters .lpc-filters-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        width: 100%;
        min-height: 44px;
        margin: 0;
        padding: 8px 12px;
        font-size: 13px;
        color: #333;
        background: #fff;
        border: 1.5px solid #ddd;
        border-radius: 6px;
        box-shadow: none;
    }

    /* The classic map toggle carries a base `width: auto !important`
     * (responsive.css) meant for its inline-pill layout. Override it so the
     * Map button fills its half of the second row like the Filters button. */
    .search-row-classic .lp-classic-top-filters .listing-view-layout > ul li.classic-mobile-map a.open-map-view {
        width: 100% !important;
    }

    .lpc-chips-container {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .lpc-chips {
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        padding-bottom: 8px;
    }

    .lpc-chips__item {
        flex-shrink: 0;
    }

    .lpc-chips__reset {
        flex-shrink: 0;
    }

    /* Full-screen overlay */
    .lpc-filters.is-open {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        z-index: 9999;
        margin-top: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
    }

    /* Lock the archive page behind the open overlay so touch scrolling stays
     * inside the panel instead of chaining to the page (funnel-filter.js
     * toggles the body class in step with the panel's is-open state). */
    body.lpc-filters-open {
        overflow: hidden;
    }

    .lpc-filters__close {
        display: block;
    }

    .lpc-filters__body {
        flex: 1;
        min-height: 0;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;
        /* Pack groups to the top; without this the grid stretches its rows to
         * fill the full-screen body, scattering each field in dead space and
         * detaching it from its label. */
        align-content: start;
    }

    /* Roomier touch targets for checkbox/radio rows inside the overlay. */
    .lpc-filters__option {
        padding: 9px 0;
        font-size: 15px;
    }

    /* Sticky action bar reads as a fixed footer and hints at scrollable
     * content above it. */
    .lpc-filters__footer {
        position: sticky;
        bottom: 0;
        box-shadow: 0 -4px 12px rgba(0, 0, 0, 0.08);
    }

    .lpc-filters__submit {
        min-height: 48px;
        font-size: 15px;
    }
}

/* ---- Desktop: inline panel ---- */
@media (min-width: 769px) {
    .lpc-filters__body {
        max-height: 50vh;
    }

    .lpc-filters__group {
        padding: 12px 20px;
    }

    .lpc-filters__footer {
        text-align: right;
    }

    .lpc-filters__submit {
        width: auto;
        padding: 8px 28px;
    }
}

/* ---- Desktop: 2-column layout for compact filters ---- */
@media (min-width: 992px) {
    .lpc-filters__body {
        grid-template-columns: 1fr 1fr;
    }

    .lpc-filters__group {
        border-bottom: none;
        border-right: 1px solid #f3f4f6;
    }

    .lpc-filters__group:nth-child(even) {
        border-right: none;
    }

    /* Top row border */
    .lpc-filters__group:nth-child(n+3) {
        border-top: 1px solid #f3f4f6;
    }
}
