/* =========================================
   CATEGORY FILTERS – responsive + user-friendly (v3)
   - Mobil: bottom-sheet + belső scroll + sticky actions
   - Desktop: sticky sidebar + belső scroll + sticky actions
   - Apply/Clear mindig elérhető
   - Gyorsabb nyitás/zárás (transform + opacity)
   ========================================= */

.cf {
    --cf-accent: var(--cat-accent, var(--nk-accent, #f59e0b));
    --cf-border: rgba(15, 23, 42, .10);
    --cf-border-2: rgba(148, 163, 184, .26);
    --cf-bg: rgba(255, 255, 255, .92);
    --cf-bg-2: rgba(248, 250, 252, .92);
    --cf-text: rgba(15, 23, 42, .92);
    --cf-muted: rgba(100, 116, 139, 1);

    --cf-radius: 14px;
    --cf-radius-sm: 12px;

    --cf-speed: 140ms;
    --cf-ease: cubic-bezier(.22, .61, .36, 1);

    border-radius: var(--cf-radius);
}

/* =========================
     Mobil felső sor
     ========================= */
.cf-inline {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;

    padding: 8px 10px;
    border-radius: var(--cf-radius);
    border: 1px solid var(--cf-border);
    background: var(--cf-bg);
}

.cf-open {
    display: inline-flex;
    align-items: center;
    gap: 8px;

    padding: 7px 10px;
    border-radius: var(--cf-radius-sm);
    border: 1px solid rgba(148, 163, 184, .30);
    background: var(--cf-bg-2);

    font-size: 11px;
    font-weight: 800;
    color: var(--cf-text);
    cursor: pointer;
}

/* Badge: color-mix nélkül (stabil fallback) */
.cf-badge {
    min-width: 18px;
    height: 18px;
    padding: 0 6px;
    border-radius: 999px;

    display: inline-flex;
    align-items: center;
    justify-content: center;

    font-size: 11px;
    font-weight: 800;

    background: rgba(245, 158, 11, .16);
    border: 1px solid rgba(245, 158, 11, .30);
    color: rgba(15, 23, 42, .86);
}

.cf-inlineRight {
    display: flex;
    align-items: center;
    gap: 8px;
}

.cf-count {
    font-size: 11px;
    font-weight: 750;
    color: rgba(15, 23, 42, .72);
    white-space: nowrap;
}

.cf-reset {
    font-size: 11px;
    font-weight: 750;
    color: rgba(15, 23, 42, .76);
    text-decoration: none;

    padding: 7px 9px;
    border-radius: var(--cf-radius-sm);
    border: 1px solid rgba(148, 163, 184, .22);
    background: rgba(255, 255, 255, .70);
}

/* =========================
     Drawer – mobil overlay
     - gyors animáció (nem display toggling-hoz kötve)
     ========================= */
.cf-drawer {
    position: fixed;
    inset: 0;
    z-index: 2000;

    /* alap: láthatatlan, de animálható */
    opacity: 0;
    visibility: hidden;
    pointer-events: none;

    transition: opacity var(--cf-speed) var(--cf-ease), visibility 0s linear var(--cf-speed);
}

.cf-drawer.is-open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;

    transition: opacity var(--cf-speed) var(--cf-ease);
}

.cf-backdrop {
    position: absolute;
    inset: 0;
    border: 0;

    background: rgba(2, 6, 23, .38);

    /* blur szép, de drága: enyhítjük */
    backdrop-filter: blur(3px);
    -webkit-backdrop-filter: blur(3px);
}

/* PANEL: max-height + flex layout + animált felcsúszás */
.cf-panel {
    position: absolute;
    left: 50%;
    transform: translateX(-50%) translateY(12px);

    bottom: max(10px, env(safe-area-inset-bottom));
    width: min(480px, calc(100% - 16px));

    border-radius: 16px;
    border: 1px solid var(--cf-border);
    background: rgba(255, 255, 255, .96);
    overflow: hidden;

    box-shadow: 0 18px 46px rgba(15, 23, 42, .18);

    max-height: calc(100dvh - 16px - env(safe-area-inset-bottom));
    display: flex;
    flex-direction: column;
    min-height: 0;

    opacity: 0;
    transition: transform var(--cf-speed) var(--cf-ease), opacity var(--cf-speed) var(--cf-ease);
}

.cf-drawer.is-open .cf-panel {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.cf-head {
    display: flex;
    align-items: center;
    justify-content: space-between;

    padding: 10px 10px;
    border-bottom: 1px solid rgba(15, 23, 42, .07);
    flex: 0 0 auto;
}

.cf-title {
    font-size: 12px;
    font-weight: 800;
    letter-spacing: -0.02em;
    color: var(--cf-text);
}

.cf-x {
    width: 34px;
    height: 34px;
    border-radius: var(--cf-radius-sm);
    border: 1px solid rgba(148, 163, 184, .30);
    background: var(--cf-bg-2);

    cursor: pointer;
    font-size: 18px;
    line-height: 1;
}

/* =========================
     Form – BELÜL scrollozzon, a gombok sticky alul
     ========================= */
.cf-form {
    padding: 10px;
    display: flex;
    flex-direction: column;
    gap: 12px;

    /* kulcs: itt scroll */
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    min-height: 0;
}

/* kis “lélegzet” */
.cf-form::after {
    content: "";
    display: block;
    height: 4px;
}

.cf-block {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.cf-blockTitle {
    font-size: 11px;
    font-weight: 800;
    color: rgba(15, 23, 42, .72);
}

.cf-facet {
    border: 1px solid var(--cf-border-2);
    border-radius: 14px;
    background: rgba(255, 255, 255, .9);
    overflow: hidden;
}

.cf-facetSum {
    list-style: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 10px 11px;
    font-size: 12px;
    font-weight: 850;
    color: rgba(15, 23, 42, .86);
    border-bottom: 1px solid transparent;
}

.cf-facetSum::-webkit-details-marker {
    display: none;
}

.cf-facetSum::after {
    content: "▾";
    font-size: 11px;
    color: rgba(100, 116, 139, 1);
    margin-left: auto;
    transition: transform .15s ease;
}

.cf-facet:not([open]) .cf-facetSum::after {
    transform: rotate(-90deg);
}

.cf-facet[open] .cf-facetSum {
    border-bottom-color: rgba(148, 163, 184, .22);
}

.cf-facetMeta {
    font-size: 11px;
    font-weight: 780;
    color: rgba(100, 116, 139, 1);
    white-space: nowrap;
}

.cf-facetBody {
    padding: 10px;
    display: grid;
    gap: 8px;
}

.cf-search {
    width: 100%;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, .32);
    background: rgba(248, 250, 252, .95);
    font-size: 12px;
    font-weight: 600;
    color: rgba(15, 23, 42, .88);
    padding: 0 11px;
}

.cf-search:focus-visible {
    outline: none;
    border-color: rgba(245, 158, 11, .55);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, .14);
}

.cf-priceOut {
    font-size: 12.5px;
    font-weight: 800;
    color: rgba(15, 23, 42, .82);
}

.cf-priceSep {
    opacity: .60;
    margin: 0 4px;
}

.cf-priceUnit {
    margin-left: 6px;
    opacity: .65;
}

/* =========================
     Dual range – kisebb
     ========================= */
.cf-range {
    position: relative;
    height: 34px;
    --a: 0%;
    --b: 100%;
}

.cf-rangeTrack {
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);

    height: 6px;
    border-radius: 999px;

    background: linear-gradient(to right,
            rgba(148, 163, 184, .22) 0%,
            rgba(148, 163, 184, .22) var(--a),
            rgba(245, 158, 11, .55) var(--a),
            rgba(245, 158, 11, .55) var(--b),
            rgba(148, 163, 184, .22) var(--b),
            rgba(148, 163, 184, .22) 100%);
}

.cf-rangeInput {
    position: absolute;
    inset: 0;
    width: 100%;
    background: transparent;
    margin: 0;
    -webkit-appearance: none;
    appearance: none;
}

.cf-rangeInput:focus {
    outline: none;
}

.cf-rangeInput::-webkit-slider-runnable-track {
    height: 6px;
    background: transparent;
}

.cf-rangeInput::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;

    width: 16px;
    height: 16px;
    border-radius: 999px;

    background: rgba(255, 255, 255, .98);
    border: 1px solid rgba(15, 23, 42, .18);
    box-shadow: 0 6px 14px rgba(15, 23, 42, .16);

    margin-top: -5px;
}

.cf-rangeInput::-moz-range-track {
    height: 6px;
    background: transparent;
}

.cf-rangeInput::-moz-range-thumb {
    width: 16px;
    height: 16px;
    border-radius: 999px;

    background: rgba(255, 255, 255, .98);
    border: 1px solid rgba(15, 23, 42, .18);
    box-shadow: 0 6px 14px rgba(15, 23, 42, .16);
}

/* =========================
     Kategória lista – kompakt
     (a teljes panel scrollozik, de a doboz marad rendben)
     ========================= */
.cf-catBox {
    border-radius: 14px;
    border: 1px solid var(--cf-border-2);
    background: var(--cf-bg-2);
    padding: 6px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
}

.cf-catBox--cat {
    max-height: min(34vh, 280px);
}

.cf-catBox--brand {
    max-height: min(38vh, 320px);
}

.cf-cat {
    --cf-level: 0;

    display: flex;
    align-items: center;
    gap: 10px;

    padding: 8px 9px;
    border-radius: var(--cf-radius-sm);
    cursor: pointer;
    user-select: none;

    padding-left: calc(9px + (var(--cf-level) * 12px));
}

.cf-cat--lvl-0 { --cf-level: 0; }
.cf-cat--lvl-1 { --cf-level: 1; }
.cf-cat--lvl-2 { --cf-level: 2; }
.cf-cat--lvl-3 { --cf-level: 3; }
.cf-cat--lvl-4 { --cf-level: 4; }
.cf-cat--lvl-5 { --cf-level: 5; }
.cf-cat--lvl-6 { --cf-level: 6; }
.cf-cat--lvl-7 { --cf-level: 7; }
.cf-cat--lvl-8 { --cf-level: 8; }

.cf-cat.is-hidden {
    display: none;
}

.cf-cat:hover {
    background: rgba(255, 255, 255, .72);
}

.cf-cat input {
    width: 15px;
    height: 15px;
    accent-color: var(--cf-accent);
}

.cf-catTxt {
    font-size: 12.5px;
    font-weight: 750;
    color: rgba(15, 23, 42, .82);
}

.cf-empty {
    padding: 10px;
    font-weight: 750;
    color: var(--cf-muted);
}

.cf-empty--search {
    padding: 8px 2px 2px;
    font-size: 11px;
}

/* =========================
     Actions – STICKY alul (mindig látszik)
     Feltétel: .cf-actions a .cf-form belsejében van (nálad így van)
     ========================= */
.cf-actions {
    margin-top: 2px;
    display: grid;
    grid-template-columns: 1fr;
    gap: 9px;

    position: sticky;
    bottom: 0;

    padding: 10px 0 0;
    background: linear-gradient(to top,
            rgba(255, 255, 255, .98) 0%,
            rgba(255, 255, 255, .92) 55%,
            rgba(255, 255, 255, 0) 100%);

    border-top: 1px solid rgba(15, 23, 42, .07);
    /* kis “ragadós” érzet */
    box-shadow: 0 -14px 22px rgba(15, 23, 42, .06);
}

.cf-apply {
    width: 100%;
    min-height: 42px;
    border-radius: 13px;
    font-weight: 800;

    background: var(--cf-accent) !important;
    border: 1px solid rgba(15, 23, 42, .10) !important;
    color: #fff !important;
}

.cf-clear {
    width: 100%;
    min-height: 40px;
    border-radius: 13px;
    font-weight: 750;

    background: rgba(255, 255, 255, .94) !important;
    border: 1px solid rgba(148, 163, 184, .30) !important;
    color: rgba(15, 23, 42, .82) !important;
}

/* Scroll lock (JS kapcsolja) */
html.cf-lock,
body.cf-lock {
    overflow: hidden;
}

/* =========================
     Desktop: panel kint oldalsávban (sticky + belső scroll)
     ========================= */
@media (min-width: 1024px) {
    .cf-inline {
        display: none;
    }

    .cf-x {
        display: none;
    }

    .cf-drawer {
        position: static;
        inset: auto;
        z-index: auto;

        opacity: 1 !important;
        visibility: visible !important;
        pointer-events: auto !important;

        transition: none !important;
    }

    .cf-backdrop {
        display: none !important;
    }

    .cf-panel {
        position: sticky;
        top: calc(var(--header-h, 92px) + 14px);

        transform: none;
        left: auto;
        bottom: auto;
        opacity: 1;

        width: 100%;
        border-radius: 16px;
        box-shadow: 0 16px 42px rgba(15, 23, 42, .10);

        max-height: calc(100dvh - (var(--header-h, 92px) + 28px));
        transition: none !important;
    }

    .cf-form {
        overflow: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* =========================
     Reduced motion / mobil teljesítmény
     ========================= */
@media (prefers-reduced-motion: reduce) {

    .cf-drawer,
    .cf-panel {
        transition: none !important;
    }
}

@media (hover:none) and (pointer:coarse) {

    /* mobilon a blur még mindig drága lehet */
    .cf-backdrop {
        backdrop-filter: none;
        -webkit-backdrop-filter: none;
    }
}
