/* Tylösand product filters */

.tylo-pf {
    --pf-bg: #f6f6f4;
    --pf-line: #e4e4df;
    --pf-text: #1f1f1f;
    --pf-muted: #8a8a8a;
    --pf-accent: var(--tylo-theme-color, #DD5700);
    display: grid;
    grid-template-columns: 260px minmax(0, 1fr);
    gap: 32px;
    align-items: start;
    color: var(--pf-text);
}

.tylo-pf.is-loading .tylo-pf__main {
    opacity: .5;
    pointer-events: none;
    transition: opacity .15s;
}

/* ---------- Sidebar ---------- */

.tylo-pf__sidebar {
    position: sticky;
    top: 100px;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    padding-right: 4px;
}

.tylo-pf__sidebar-head,
.tylo-pf__sidebar-foot {
    display: none;
}

.tylo-pf__form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin: 0;
}

.tylo-pf__group {
    background: var(--pf-bg);
    border: 0;
    border-radius: 14px;
    padding: 14px 16px;
    margin: 0;
    min-width: 0;
}

.tylo-pf__group legend,
.tylo-pf__group summary {
    font-size: 14px;
    font-weight: 700;
    padding: 0;
    margin-bottom: 10px;
    float: left;
    width: 100%;
}

.tylo-pf__group legend + * {
    clear: both;
}

.tylo-pf__group summary {
    float: none;
    margin: 0;
    cursor: pointer;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 6px;
}

.tylo-pf__group summary::-webkit-details-marker {
    display: none;
}

.tylo-pf__group summary::after {
    content: "";
    margin-left: auto;
    width: 8px;
    height: 8px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    transition: transform .2s;
}

.tylo-pf__group[open] summary {
    margin-bottom: 10px;
}

.tylo-pf__group[open] summary::after {
    transform: rotate(-135deg);
}

.tylo-pf__group summary small {
    font-weight: 400;
    color: var(--pf-muted);
}

.tylo-pf__group--search {
    padding: 0;
    background: transparent;
}

.tylo-pf .tylo-pf__search input[type="search"] {
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    height: 46px;
    border: 1px solid #d8d8d8;
    border-radius: 999px;
    padding: 0 18px 0 42px;
    font-size: 15px;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='18' height='18' viewBox='0 0 24 24' fill='none' stroke='%238a8a8a' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E") no-repeat 16px center;
}

.tylo-pf .tylo-pf__search input[type="search"]:focus {
    outline: none;
    border-color: var(--pf-text);
}

/* pills (Alla / Fabriksnytt / Återbrukat) – stacked, equal width */
.tylo-pf__pills {
    display: grid;
    grid-template-columns: 1fr;
    gap: 6px;
}

.tylo-pf__pill input,
.tylo-pf__check input[type="radio"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.tylo-pf__pill span {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 6px;
    padding: 9px 16px;
    border-radius: 999px;
    background: #fff;
    border: 1px solid var(--pf-line);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
}

.tylo-pf__pill small {
    color: var(--pf-muted);
    font-size: 12px;
    font-weight: 500;
}

.tylo-pf__pill input:checked + span {
    background: var(--pf-text);
    border-color: var(--pf-text);
    color: #fff;
}

.tylo-pf__pill input:checked + span small {
    color: #bbb;
}

.tylo-pf__pill input:focus-visible + span {
    outline: 2px solid var(--pf-accent);
    outline-offset: 2px;
}

.tylo-pf__pill.is-empty span {
    opacity: .45;
}

/* checkboxes */
.tylo-pf__check {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 5px 0;
    font-size: 14px;
    cursor: pointer;
    line-height: 1.3;
}

.tylo-pf__check input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    flex: 0 0 18px;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1.5px solid #b8b8b8;
    border-radius: 5px;
    background: #fff;
    display: grid;
    place-content: center;
    cursor: pointer;
}

.tylo-pf__check input[type="checkbox"]::after {
    content: "";
    width: 10px;
    height: 6px;
    border-left: 2px solid #fff;
    border-bottom: 2px solid #fff;
    transform: rotate(-45deg) translate(1px, -1px);
    opacity: 0;
}

.tylo-pf__check input[type="checkbox"]:checked {
    background: var(--pf-text);
    border-color: var(--pf-text);
}

.tylo-pf__check input[type="checkbox"]:checked::after {
    opacity: 1;
}

.tylo-pf__check input:focus-visible {
    outline: 2px solid var(--pf-accent);
    outline-offset: 2px;
}

.tylo-pf__check small {
    margin-left: auto;
    color: var(--pf-muted);
    font-size: 12px;
}

.tylo-pf__terms {
    list-style: none;
    margin: 0;
    padding: 0;
}

.tylo-pf__terms .tylo-pf__terms {
    padding-left: 26px;
}

.tylo-pf__badge {
    background: var(--pf-text);
    color: #fff;
    font-size: 11px;
    border-radius: 999px;
    padding: 1px 7px;
}

/* range */
.tylo-pf__slider {
    position: relative;
    height: 24px;
    margin: 4px 6px 10px;
}

.tylo-pf__slider::before,
.tylo-pf__slider::after {
    content: "";
    position: absolute;
    top: 50%;
    height: 4px;
    margin-top: -2px;
    border-radius: 4px;
}

.tylo-pf__slider::before {
    left: 0;
    right: 0;
    background: #dcdcd6;
}

.tylo-pf__range .tylo-pf__slider::after {
    left: var(--lo, 0%);
    right: calc(100% - var(--hi, 100%));
    background: var(--pf-text);
}

.tylo-pf__slider input[type="range"] {
    position: absolute;
    inset: 0;
    width: 100%;
    margin: 0;
    background: none;
    pointer-events: none;
    -webkit-appearance: none;
    appearance: none;
    z-index: 1;
}

.tylo-pf__slider input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    pointer-events: auto;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--pf-text);
    cursor: grab;
}

.tylo-pf__slider input[type="range"]::-moz-range-thumb {
    pointer-events: auto;
    width: 16px;
    height: 16px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid var(--pf-text);
    cursor: grab;
}

.tylo-pf__slider input[type="range"]::-webkit-slider-runnable-track { background: none; }
.tylo-pf__slider input[type="range"]::-moz-range-track { background: none; }

.tylo-pf__range-inputs {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 8px;
}

.tylo-pf__range-inputs label {
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 11px;
    color: var(--pf-muted);
}

.tylo-pf__range-inputs input {
    width: 100%;
    height: 36px;
    border: 1px solid #d8d8d8;
    border-radius: 8px;
    padding: 0 8px;
    font-size: 14px;
    background: #fff;
    -moz-appearance: textfield;
}

.tylo-pf__range-inputs input::-webkit-outer-spin-button,
.tylo-pf__range-inputs input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

/* ---------- Toolbar & chips ---------- */

.tylo-pf__toolbar {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.tylo-pf__count {
    font-size: 15px;
    color: #555;
    margin-right: auto;
}

.tylo-pf__open {
    display: none;
}

.tylo-pf__sort select {
    height: 40px;
    border: 1px solid #d8d8d8;
    border-radius: 999px;
    padding: 0 36px 0 16px;
    font-size: 14px;
    background-color: #fff;
}

.tylo-pf__chips {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    margin-bottom: 16px;
}

.tylo-pf__chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: var(--pf-text);
    color: #fff !important;
    border-radius: 999px;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    text-decoration: none !important;
}

.tylo-pf__chip:hover {
    background: var(--pf-accent);
}

.tylo-pf__clear {
    font-size: 13px;
    color: var(--pf-text) !important;
    text-decoration: underline;
    margin-left: 4px;
}

/* ---------- Product grid ---------- */

.tylo-pf ul.products {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 20px;
    margin: 0 !important;
    padding: 0;
}

.tylo-pf ul.products::before,
.tylo-pf ul.products::after {
    display: none !important;
}

.tylo-pf ul.products li.product {
    min-width: 0;
    width: auto !important;
    margin: 0 !important;
    float: none !important;
    clear: none !important;
}

.tylo-pf .woocommerce-pagination {
    margin-top: 24px;
}

.tylo-pf__more {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    margin: 32px 0 8px;
    font-size: 13px;
    color: var(--pf-muted);
}

.tylo-pf__more-btn,
.tylo-pf__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 48px;
    padding: 0 28px;
    border-radius: 999px;
    background: var(--pf-text);
    color: #fff !important;
    font-weight: 700;
    font-size: 15px;
    border: 0;
    text-decoration: none !important;
    cursor: pointer;
}

.tylo-pf__more-btn:hover,
.tylo-pf__btn:hover {
    background: var(--pf-accent);
}

.tylo-pf__more-btn.is-busy {
    opacity: .6;
    pointer-events: none;
}

/* with JS the numbered pagination is replaced by "Visa fler" */
.tylo-pf .woocommerce-pagination:has(~ .tylo-pf__more),
.tylo-pf:has(.tylo-pf__more) .woocommerce-pagination {
    display: none;
}

.tylo-pf__empty {
    background: var(--pf-bg);
    border-radius: 14px;
    padding: 40px 24px;
    text-align: center;
}

.tylo-pf__empty h3 {
    margin: 0 0 6px;
}

.tylo-pf__empty p {
    color: #666;
    margin: 0 0 18px;
}

/* ---------- Mobile: drawer ---------- */

@media (max-width: 900px) {
    .tylo-pf {
        grid-template-columns: minmax(0, 1fr);
        gap: 0;
    }

    .tylo-pf__open {
        display: inline-flex;
        align-items: center;
        gap: 6px;
        height: 40px;
        padding: 0 16px;
        border-radius: 999px;
        border: 1px solid var(--pf-text);
        background: #fff;
        color: var(--pf-text);
        font-weight: 700;
        font-size: 14px;
        cursor: pointer;
    }

    .tylo-pf__count {
        order: 3;
        width: 100%;
        margin: 0;
    }

    .tylo-pf__toolbar {
        flex-wrap: wrap;
    }

    .tylo-pf__sort {
        margin-left: auto;
    }

    .tylo-pf__sidebar {
        position: fixed;
        inset: 0 0 0 auto;
        width: min(420px, 100vw);
        max-height: none;
        z-index: 99999;
        background: #fff;
        padding: 0;
        transform: translateX(100%);
        transition: transform .25s ease;
        display: flex;
        flex-direction: column;
        box-shadow: -10px 0 30px rgba(0, 0, 0, .15);
    }

    .tylo-pf.is-open .tylo-pf__sidebar {
        transform: none;
    }

    .tylo-pf__sidebar-head {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid #eee;
        font-size: 18px;
    }

    .tylo-pf__close {
        border: 0;
        background: #f2f2f2;
        width: 36px;
        height: 36px;
        border-radius: 50%;
        font-size: 22px;
        line-height: 1;
        padding: 0;
        color: var(--pf-text);
        cursor: pointer;
    }

    .tylo-pf__form {
        flex: 1 1 auto;
        overflow-y: auto;
        padding: 16px 20px;
    }

    .tylo-pf__sidebar-foot {
        display: block;
        padding: 12px 20px 20px;
        border-top: 1px solid #eee;
    }

    .tylo-pf__btn--block {
        width: 100%;
    }

    .tylo-pf.is-open::before {
        content: "";
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, .35);
        z-index: 99998;
    }

    html.tylo-pf-lock,
    html.tylo-pf-lock body {
        overflow: hidden;
    }

    .tylo-pf ul.products {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 12px;
    }
}

/* Theme/Elementor kit input styles win over plain class selectors – pin ours with the form id */
#tylo-pf-form .tylo-pf__slider input[type="range"] {
    border: 0;
    border-radius: 0;
    padding: 0;
    height: 24px;
    box-shadow: none;
    outline: none;
    background: none;
}

#tylo-pf-form .tylo-pf__range-inputs input[type="number"] {
    height: 38px;
    border: 1px solid #d8d8d8;
    border-radius: 10px;
    padding: 0 12px;
    font-size: 14px;
    background: #fff;
    box-shadow: none;
}

#tylo-pf-form .tylo-pf__range-inputs input[type="number"]:focus {
    outline: none;
    border-color: var(--pf-text);
}

#tylo-pf-form .tylo-pf__check input[type="checkbox"] {
    border: 1.5px solid #b8b8b8;
    border-radius: 5px;
    padding: 0;
}

#tylo-pf-form .tylo-pf__check input[type="checkbox"]:checked {
    border-color: var(--pf-text);
}

#tylo-pf-form .tylo-pf__search input[type="search"] {
    border: 1px solid #d8d8d8;
    border-radius: 999px;
    padding: 0 18px 0 42px;
}

/* category navigation on leaf category pages */
.tylo-pf__catnav {
    list-style: none;
    margin: 0;
    padding: 0;
}

#tylo-pf-form .tylo-pf__catnav a {
    font-weight: 400;
    display: flex;
    justify-content: space-between;
    gap: 10px;
    padding: 6px 0;
    font-size: 14px;
    color: var(--pf-text);
    text-decoration: none;
}

.tylo-pf__catnav a:hover span { text-decoration: underline; }
.tylo-pf__catnav small { color: var(--pf-muted); font-size: 12px; }
#tylo-pf-form .tylo-pf__catnav .is-current a { font-weight: 700; }
#tylo-pf-form .tylo-pf__catnav .tylo-pf__catnav-up a { color: var(--pf-muted); font-size: 13px; }
