/* =====================================================
   Product listing layout with filter sidebar
   ===================================================== */

.product-listing-with-filter {
    display: flex;
    align-items: flex-start;
    width: 100%;
    gap: 2.5rem;
}

/* =====================================================
   Filter sidebar
   ===================================================== */

.product-filter-sidebar {
    width: 290px;
    flex-shrink: 0;
    position: sticky;
    top: 160px;
    max-height: calc(100vh - 100px);
    overflow-y: auto;
    background: var(--white);
    /* border-right: 1px solid #ebebeb; */
    padding: .5rem 2rem 2.5rem 0rem;
    scrollbar-width: thin;
}

.product-filter-sidebar::-webkit-scrollbar {
    width: 4px;
}
.product-filter-sidebar::-webkit-scrollbar-thumb {
    background: #ddd;
    border-radius: 2px;
}

/* =====================================================
   Product listing main area
   ===================================================== */

.product-listing-main {
    flex: 1;
    min-width: 0;
}

/* Sort control above product grid (right-aligned on desktop) */
.product-listing-toolbar {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-right: 1.5rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.product-listing-sort-icon {
    display: block;
    width: 1.6rem;
    height: 1.6rem;
    color: var(--black);
    flex-shrink: 0;
}

.product-listing-sort-label {
    font-size: 1.7rem;
    font-weight: 500;
    color: var(--black);
    margin: 0;
    white-space: nowrap;
}

.product-listing-sort {
    font-size: 1.3rem;
    padding: 0.55rem 2.4rem 0.55rem 0.85rem;
    min-width: 11rem;
    border: 1px solid #ccc;
    border-radius: 4px;
    background-color: var(--white);
    cursor: pointer;
}

/* =====================================================
   Filter header
   ===================================================== */

.product-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 1rem;
    row-gap: 0.75rem;
    margin-bottom: 2rem;
}

.product-filter-header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-shrink: 0;
}

.product-filter-heading {
    display: flex;
    align-items: center;
    gap: 0.65rem;
    min-width: 0;
    color: var(--black);
}

.product-filter-icon-funnel {
    display: block;
    width: 1.85rem;
    height: 1.85rem;
    flex-shrink: 0;
}

.product-filter-title {
    font-weight: 600;
    font-size: 2rem;
    color: var(--black);
    letter-spacing: -0.01em;
}

.product-filter-reset {
    background: none;
    border: none;
    font-size: 1.3rem;
    color: var(--red);
    cursor: pointer;
    padding: 0;
    text-decoration: none;
    font-weight: 500;
}

/* Mobile slide-in: backdrop injected before sidebar via JS */
.product-filter-panel-backdrop {
    display: none;
}

.product-filter-panel-close {
    display: none;
    align-items: center;
    justify-content: center;
    width: 3.6rem;
    height: 3.6rem;
    padding: 0;
    margin: 0;
    margin-left: -0.25rem;
    border: none;
    border-radius: 0.5rem;
    background: transparent;
    color: var(--black);
    font-size: 2.8rem;
    line-height: 1;
    cursor: pointer;
}

.product-filter-panel-close:hover {
    background: rgba(35, 31, 32, 0.06);
    color: var(--red);
}

.product-filter-panel-close:focus {
    outline: none;
}

.product-filter-panel-close:focus-visible {
    box-shadow: 0 0 0 3px rgba(255, 103, 106, 0.35);
}

/* =====================================================
   Accordion groups
   ===================================================== */

.product-filter-accordion {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.product-filter-group {
    /* space between sections only — no border lines */
    padding-bottom: 0.5rem;
}

.product-filter-group-toggle {
    width: 100%;
    background: none;
    border: none;
    padding: 0.8rem 0 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    font-size: 1.7rem;
    font-weight: 600;
    letter-spacing: -0.01em;
    color: var(--black);
    text-align: left;
    text-transform: none;
}

.product-filter-group-toggle:hover {
    color: var(--red);
}

.product-filter-toggle-icon {
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform 0.2s ease;
    flex-shrink: 0;
    margin-top: -2px;
    opacity: 0.5;
}

.product-filter-group.is-open .product-filter-toggle-icon {
    transform: rotate(-135deg);
    margin-top: 4px;
}

.product-filter-group-content {
    display: none;
    padding-bottom: 0.5rem;
}

.product-filter-group.is-open .product-filter-group-content {
    display: block;
}

/* =====================================================
   Taxonomy selects
   ===================================================== */

.product-filter-field {
    margin-bottom: 1.6rem;
}

.product-filter-field:last-child {
    margin-bottom: 0;
}

.product-filter-field-label {
    display: block;
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--black);
    margin-bottom: 0.65rem;
}

.product-filter-select {
    display: block;
    width: 100%;
    padding: 1rem 3.2rem 1rem 1.2rem;
    font-size: 1.45rem;
    font-family: inherit;
    color: var(--black);
    background-color: var(--white);
    border: 1px solid #d8d8d8;
    border-radius: 0.6rem;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath stroke='%23231f20' stroke-width='1.5' d='M1 1l5 5 5-5'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 1.2rem center;
}

.product-filter-select:focus {
    outline: none;
    border-color: var(--red);
}

/* Ja/Nej as pill toggles */
.product-filter-yn-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 0.65rem;
    margin-top: 0.35rem;
}

.product-filter-pill {
    position: relative;
    display: inline-flex;
    margin: 0;
    cursor: pointer;
}

.product-filter-pill input.product-filter-yn-pill {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
    clip-path: inset(50%);
}

.product-filter-pill-caption {
    display: inline-block;
    padding: 0.55rem 1.35rem;
    border: 1px solid #c8c8c8;
    border-radius: 999px;
    font-size: 1.35rem;
    font-weight: 500;
    line-height: 1.25;
    color: var(--black);
    background: var(--white);
    transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.product-filter-pill:hover .product-filter-pill-caption {
    border-color: #a8a8a8;
}

.product-filter-pill input:checked + .product-filter-pill-caption {
    background: var(--red);
    border-color: var(--red);
    color: var(--white);
}

.product-filter-pill input:focus-visible + .product-filter-pill-caption {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 103, 106, 0.35);
}

/* =====================================================
   Checkbox lists (taxonomy filters)
   ===================================================== */

.product-filter-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 22rem;
    overflow-y: auto;
    padding-right: 0.4rem;
}

.product-filter-checkbox-row {
    display: flex;
    align-items: center;
    gap: 1.2rem;
    cursor: pointer;
    font-size: 1.45rem;
    font-weight: 400;
    color: var(--black);
    line-height: 1.35;
}

/* Custom checkbox — square box, rounded corners, red when checked, white icon */
.product-filter-checkbox-row input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    display: inline-block;
    box-sizing: border-box;
    width: 2.35rem;
    height: 2.35rem;
    min-width: 2.35rem;
    min-height: 2.35rem;
    max-width: 2.35rem;
    max-height: 2.35rem;
    aspect-ratio: 1 / 1;
    padding: 0;
    margin: 0;
    cursor: pointer;
    flex: 0 0 2.35rem;

    border: 1px solid #c8c8c8;
    border-radius: 0.55rem;
    background-color: var(--white);
    background-repeat: no-repeat;
    background-position: center center;
    background-size: 0;

    vertical-align: middle;
    transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.product-filter-checkbox-row input[type="checkbox"]:hover {
    border-color: #a8a8a8;
}

.product-filter-checkbox-row input[type="checkbox"]:focus {
    outline: none;
}

.product-filter-checkbox-row input[type="checkbox"]:focus-visible {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 103, 106, 0.35);
    border-color: var(--red);
}

.product-filter-checkbox-row input[type="checkbox"]:checked {
    background-color: var(--red);
    border-color: var(--red);
    /* White checkmark; smaller than box => visible padding inside */
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 14 11' fill='none'%3E%3Cpath d='M1.5 5.5 L5 9 L12.5 1.5' stroke='%23ffffff' stroke-width='2.2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
    background-size: 52%;
}

.product-filter-checkbox-caption {
    flex: 1;
}

/* Category tree: subs nested under checked parent categories */
.product-filter-tax-tree {
    gap: 0.85rem;
}

.product-filter-tax-tree-branch {
    display: flex;
    flex-direction: column;
    gap: 0.45rem;
}

.product-filter-tax-tree-hint {
    margin: 0 0 1rem;
    font-size: 1.3rem;
    color: #888;
    font-style: italic;
    line-height: 1.35;
}

.product-filter-tax-tree:has(.product-filter-tax-cat:checked) .product-filter-tax-tree-hint {
    display: none;
}

.product-filter-tax-sub-list {
    display: none;
    flex-direction: column;
    gap: 0.45rem;
    margin: 0 0 0.35rem 1.6rem;
    padding-left: 1rem;
    border-left: 2px solid #ebebeb;
}

.product-filter-tax-tree-branch:has(.product-filter-tax-cat:checked) .product-filter-tax-sub-list {
    display: flex;
}

.product-filter-tax-sub-row {
    font-size: 1.35rem;
}

.product-filter-tax-sub-row input[type="checkbox"] {
    width: 2.1rem;
    height: 2.1rem;
    min-width: 2.1rem;
    min-height: 2.1rem;
    max-width: 2.1rem;
    max-height: 2.1rem;
    flex: 0 0 2.1rem;
}

/* Colour list: show first rows; rest behind “Visa alla” */
.product-filter-checkbox-list.product-filter-color-checkbox-list {
    max-height: none;
    overflow-y: visible;
    padding-right: 0;
}

.product-filter-color-more {
    display: none;
    flex-direction: column;
    gap: 0.5rem;
}

.product-filter-color-checkbox-list.is-expanded .product-filter-color-more {
    display: flex;
}

.product-filter-color-toggle {
    align-self: flex-start;
    margin-top: 0.5rem;
    background: none;
    border: none;
    padding: 0;
    font-size: 1.3rem;
    font-weight: 500;
    color: var(--red);
    cursor: pointer;
    text-decoration: none;
}

.product-filter-color-toggle:hover {
    text-decoration: underline;
}

.product-filter-color-toggle:focus {
    outline: none;
}

.product-filter-color-toggle:focus-visible {
    box-shadow: 0 0 0 3px rgba(255, 103, 106, 0.35);
    border-radius: 2px;
}

.product-filter-range {
    margin-bottom: 2rem;
}

.product-filter-range:last-child {
    margin-bottom: 0;
}

.product-filter-range-label {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    margin-bottom: 1rem;
}

.product-filter-range-label > span:first-child {
    font-size: 1.6rem;
    font-weight: 600;
    color: var(--black);
}

.range-values-display {
    color: #888;
    font-size: 1.4rem;
    font-weight: 400;
    font-variant-numeric: tabular-nums;
}

/* =====================================================
   Dual range slider
   ===================================================== */

.dual-range-wrapper {
    position: relative;
    height: 22px;
    margin: 2px 0 4px;
}

/* Background track */
.dual-range-wrapper::before {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    background: #e8e8e8;
    border-radius: 3px;
    pointer-events: none;
}

.dual-range-wrapper input {
    border: none;
}

/* Active fill between thumbs — positioned/sized by JS */
.range-fill {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    height: 6px;
    background: var(--red);
    border-radius: 3px;
    pointer-events: none;
}

/* Range inputs stacked on top of each other */
.range-input {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    appearance: none;
    -webkit-appearance: none;
    background: transparent;
    pointer-events: none;
    outline: none;
    margin: 0;
    padding: 0;
}

.range-input::-webkit-slider-runnable-track {
    background: transparent;
    height: 6px;
}

.range-input::-moz-range-track {
    background: transparent;
    height: 6px;
    border: none;
}

.range-input::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    /* Center 22px thumb on 6px track: -(22-6)/2 = -8px */
    margin-top: -8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--red);
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    pointer-events: all;
    position: relative;
    z-index: 3;
    transition: transform 0.1s ease, box-shadow 0.1s ease;
}

.range-input:active::-webkit-slider-thumb {
    transform: scale(1.15);
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
}

.range-input::-moz-range-thumb {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--red);
    border: none;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    cursor: pointer;
    pointer-events: all;
}

/* =====================================================
   Mobile toggle button
   ===================================================== */

.product-filter-mobile-toggle {
    display: none;
    align-items: center;
    gap: 0.8rem;
    background: var(--black);
    color: var(--white);
    border: none;
    padding: 1rem 1.6rem;
    cursor: pointer;
    font-size: 1.5rem;
    font-weight: 600;
    letter-spacing: 0.03em;
    margin-bottom: 1rem;
    border-radius: 2px;
}

.product-filter-mobile-toggle .product-filter-icon-funnel {
    width: 1.4rem;
    height: 1.4rem;
}

/* =====================================================
   Loading state
   ===================================================== */

.product-listing-main.is-loading {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

/* =====================================================
   No results message
   ===================================================== */

.product-filter-no-results {
    flex: 1 1 100%;
    box-sizing: border-box;
    padding: 2rem;
    color: #999;
    font-size: 1.6rem;
    width: 100%;
}

.box-100-products-flex-wrapper:has(.product-filter-no-results) {
    min-height: 12rem;
    align-items: center;
}

/* =====================================================
   Responsive: mobile slide-in panel from left
   ===================================================== */

@media (max-width: 768px) {
    body.product-filter-panel-open {
        overflow: hidden;
        touch-action: none;
    }

    .product-listing-with-filter {
        flex-direction: column;
        gap: 0;
        position: relative;
    }

    /* Dim page behind drawer */
    .product-filter-panel-backdrop {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 100180;
        background: rgba(35, 31, 32, 0.45);
        opacity: 0;
        visibility: hidden;
        pointer-events: none;
        transition:
            opacity 0.28s ease,
            visibility 0.28s;
    }

    .product-listing-with-filter.product-filter-panel-open > .product-filter-panel-backdrop {
        opacity: 1;
        visibility: visible;
        pointer-events: auto;
    }

    .product-filter-panel-close {
        display: inline-flex;
    }

    .product-filter-sidebar {
        display: flex;
        flex-direction: column;

        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(92vw, 38rem);

        padding: calc(2rem + env(safe-area-inset-top)) 2rem calc(2.5rem + env(safe-area-inset-bottom)) 2rem;
        padding-left: calc(2rem + env(safe-area-inset-left));

        margin: 0;
        border: none;
        border-radius: 0;

        box-shadow: 8px 0 32px rgba(0, 0, 0, 0.18);
        z-index: 100190;

        max-height: none;
        overflow-y: auto;
        overscroll-behavior: contain;
        -webkit-overflow-scrolling: touch;

        transform: translateX(-104%);
        pointer-events: none;
        visibility: visible;

        transition: transform 0.32s cubic-bezier(0.32, 0.72, 0, 1);
        will-change: transform;
    }

    .product-filter-sidebar.is-visible {
        transform: translateX(0);
        pointer-events: auto;
    }

    /* Sticky heading row inside drawer */
    .product-filter-sidebar .product-filter-header {
        position: sticky;
        top: calc(-2rem + -1 * env(safe-area-inset-top));
        margin-left: calc(-2rem + -1 * env(safe-area-inset-left));
        margin-right: -2rem;
        padding: 2rem 2rem 1.25rem calc(2rem + env(safe-area-inset-left));
        padding-top: calc(1.25rem + env(safe-area-inset-top));
        margin-bottom: 1rem;
        margin-top: calc(-2rem + -1 * env(safe-area-inset-top));
        background: var(--white);
        border-bottom: 1px solid #ebebeb;
        z-index: 2;
        flex-shrink: 0;
    }

    .product-filter-mobile-toggle {
        display: flex;
    }

    /* Ensure toggle aligns with stacked layout */
    .product-listing-main {
        width: 100%;
    }
}

@media (min-width: 769px) {
    .product-filter-panel-backdrop {
        display: none !important;
    }

    body.product-filter-panel-open {
        overflow: auto;
        touch-action: auto;
    }
}
