/* ==========================================================================
   Encanto — Product filters
   ========================================================================== */

:root {
    --ef-border: #e5e5e5;
    --ef-border-strong: #111;
    --ef-bg-dim: #f5f5f5;
    --ef-text: #111;
    --ef-text-muted: #777;
    --ef-radius: 2px;
}

/* Reset form element quirks inside filter scope */
.encanto-filters,
.encanto-filters * {
    box-sizing: border-box;
}

.encanto-filters {
    display: flex;
    flex-direction: row;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px 20px;
}

.encanto-filters__facet {
    border: 0;
    padding: 0;
    margin: 0;
}

.encanto-filters__legend {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    margin-bottom: 6px;
    color: var(--ef-text);
}

/* ---- Chips (size) ---- */
.encanto-filters__chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}
.encanto-filters__chip {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 32px;
    padding: 0 10px;
    border: 1px solid var(--ef-border);
    border-radius: var(--ef-radius);
    font-size: 14px;
    cursor: pointer;
    user-select: none;
    background: #fff;
    transition: border-color .15s, background .15s, color .15s;
}
.encanto-filters__chip input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.encanto-filters__chip:hover { border-color: var(--ef-border-strong); }
.encanto-filters__chip:has(input:checked) {
    background: var(--ef-border-strong);
    color: #fff;
    border-color: var(--ef-border-strong);
}
.encanto-filters__chip.is-dimmed { opacity: 0.4; }

/* ---- Swatches (color) ---- */
.encanto-filters__swatches {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
}
.encanto-filters__swatch {
    position: relative;
    width: 36px;
    height: 36px;
    padding: 4px;
    border: 2px solid transparent;
    border-radius: 50%;
    cursor: pointer;
    transition: border-color .15s;
}
.encanto-filters__swatch input {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}
.encanto-filters__swatch-dot {
    display: block;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: 1px solid var(--ef-border);
}
.encanto-filters__swatch:has(input:checked) { border-color: var(--ef-border-strong); }
.encanto-filters__swatch.is-dimmed { opacity: 0.4; }

/* ---- Price range ---- */
.encanto-filters__facet[data-facet="price"] {
    min-width: 200px;
    max-width: 260px;
}
.encanto-filters__range {
    position: relative;
    height: 30px;
}
.encanto-filters__range input[type="range"] {
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    -webkit-appearance: none;
    appearance: none;
    background: transparent;
    pointer-events: none;
    top: 8px;
    margin: 0;
}
.encanto-filters__range input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--ef-border-strong);
    cursor: pointer;
    pointer-events: auto;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--ef-border-strong);
}
.encanto-filters__range input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--ef-border-strong);
    cursor: pointer;
    pointer-events: auto;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px var(--ef-border-strong);
}
.encanto-filters__range::before {
    content: "";
    position: absolute;
    top: 16px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--ef-border);
    border-radius: 2px;
}
.encanto-filters__range-values {
    font-size: 12px;
    color: var(--ef-text-muted);
    margin-top: 2px;
}

/* ---- Toggles (in_stock / on_sale) ---- */
.encanto-filters__toggle {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}
.encanto-filters__toggle input {
    width: 18px;
    height: 18px;
    accent-color: var(--ef-border-strong);
}

/* ---- Submit (hidden when JS is enabled) ---- */
.encanto-filters__submit {
    background: var(--ef-border-strong);
    color: #fff;
    border: 0;
    padding: 12px 20px;
    font-size: 14px;
    cursor: pointer;
    border-radius: var(--ef-radius);
}
html.js-enabled .encanto-filters__submit { display: none; }

/* ==========================================================================
   Topbar (count + sort)
   ========================================================================== */
.encanto-filters__topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
    border-bottom: 1px solid var(--ef-border);
    margin-bottom: 16px;
}
.encanto-filters__count { font-size: 14px; color: var(--ef-text-muted); }
.encanto-filters__sort select {
    border: 1px solid var(--ef-border);
    padding: 8px 12px;
    font-size: 14px;
    background: #fff;
    border-radius: var(--ef-radius);
    cursor: pointer;
}

/* ==========================================================================
   Active chips
   ========================================================================== */
.encanto-filters__active {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 16px;
}
.encanto-filters__active-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border: 1px solid var(--ef-border);
    border-radius: 999px;
    background: var(--ef-bg-dim);
    font-size: 13px;
    cursor: pointer;
    color: var(--ef-text);
}
.encanto-filters__active-chip:hover { border-color: var(--ef-border-strong); }
.encanto-filters__active-chip-x {
    font-size: 16px;
    line-height: 1;
    color: var(--ef-text-muted);
}
.encanto-filters__reset-all {
    border: 0;
    background: transparent;
    font-size: 13px;
    text-decoration: underline;
    color: var(--ef-text-muted);
    cursor: pointer;
    padding: 6px 10px;
}

/* ==========================================================================
   Empty + loading states
   ========================================================================== */
.encanto-filters__empty {
    padding: 60px 20px;
    text-align: center;
    color: var(--ef-text-muted);
}
.encanto-filters__empty .button { margin-top: 16px; }

.cat-product__list.is-loading {
    opacity: 0.5;
    pointer-events: none;
    position: relative;
}
.cat-product__list.is-loading::after {
    content: "";
    position: absolute;
    top: 40px;
    left: 50%;
    width: 32px;
    height: 32px;
    margin-left: -16px;
    border: 3px solid var(--ef-border);
    border-top-color: var(--ef-border-strong);
    border-radius: 50%;
    animation: ef-spin 0.8s linear infinite;
}
@keyframes ef-spin { to { transform: rotate(360deg); } }

/* ==========================================================================
   Mobile drawer (< 1050px)
   ========================================================================== */
.encanto-filters__mobile-trigger { display: none; }
.encanto-filters__overlay { display: none; }
.encanto-filters__drawer { display: none; }

@media (max-width: 1049px) {
    .cat-product__sidebar { display: none; }

    .encanto-filters__mobile-trigger {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        padding: 8px 14px;
        border: 1px solid var(--ef-border-strong);
        background: #fff;
        color: var(--ef-text);
        font-size: 14px;
        cursor: pointer;
        border-radius: var(--ef-radius);
    }

    .encanto-filters__topbar {
        flex-wrap: wrap;
        gap: 10px;
    }

    .encanto-filters__overlay {
        display: block;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.4);
        z-index: 998;
    }
    .encanto-filters__overlay[hidden] { display: none; }

    .encanto-filters__drawer {
        display: flex;
        flex-direction: column;
        position: fixed;
        top: 0;
        right: 0;
        width: 360px;
        max-width: 90vw;
        height: 100vh;
        background: #fff;
        z-index: 999;
        transform: translateX(100%);
        transition: transform 0.3s ease;
    }
    .encanto-filters__drawer[hidden] { display: none; }
    .encanto-filters__drawer.is-open { transform: translateX(0); }

    .encanto-filters__drawer-head {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 16px;
        border-bottom: 1px solid var(--ef-border);
        font-weight: 700;
    }
    .encanto-filters__drawer-close {
        border: 0;
        background: transparent;
        font-size: 24px;
        cursor: pointer;
        padding: 0 6px;
    }
    .encanto-filters__drawer-body {
        flex: 1;
        overflow-y: auto;
        padding: 16px;
    }
    .encanto-filters__drawer-foot {
        display: flex;
        gap: 8px;
        padding: 16px;
        border-top: 1px solid var(--ef-border);
    }
    .encanto-filters__drawer-reset {
        flex: 1;
        background: #fff;
        border: 1px solid var(--ef-border-strong);
        color: var(--ef-text);
        padding: 12px;
        font-size: 14px;
        cursor: pointer;
    }
    .encanto-filters__drawer-apply {
        flex: 2;
        background: var(--ef-border-strong);
        color: #fff;
        border: 0;
        padding: 12px;
        font-size: 14px;
        cursor: pointer;
    }

    body.encanto-filters-open { overflow: hidden; }
}
