/**
 * plp-filter-widget.css
 * Theme override for the roomvo-plp filter widget.
 *
 * Two visual variants are derived from the rendered markup:
 *   - "image" rows (li.plp-item that contains <img>): pill-shaped, custom
 *     close mark when the checkbox is checked. Used for pa_product-family,
 *     pa_color, pa_shade, pa_color-family.
 *   - "checkbox" rows (li.plp-item with no <img>): square brand-style
 *     checkbox + label. Used for pa_brand and any other text-only taxonomy.
 */

/* -----------------------------------------------
   Widget shell
   ----------------------------------------------- */
.kt-inside-inner-col>p {
    margin: 0 !important;
}
.widget_block .kt-row-column-wrap {
    padding-top: 0 !important;
}
.widget_block .kb-row-layout-wrap {
    border: none;
    border-right: 1px solid var(--rv-border);
    padding-right: 20px;
    border-radius: 0;
}
.plp-filter-widget {
    font-family: var(--rv-filter-option-font);
    color: var(--rv-text);
    background: var(--rv-surface);
    border: 0;
    border-radius: 0;
    box-shadow: none;
    padding: 0;
    max-width: 320px;
}

.plp-filter-widget * {
    box-sizing: border-box;
}

/* Hide the breadcrumb badge bar — selection state is shown inline as pills. */
.plp-filter-widget .plp-active-filters {
    display: none;
}

/* -----------------------------------------------
   Group / section
   ----------------------------------------------- */
.plp-filter-widget .plp-attribute-group {
    padding: 19px 0;
    border-bottom: 1px solid var(--rv-border);
}

.plp-filter-widget .plp-attribute-group:last-child {
    border-bottom: 0;
}

.plp-filter-widget .plp-attribute-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    margin: 0 0 20px 0;
    padding: 0;
    cursor: pointer;
    user-select: none;
    color: var(--rv-text);
    font-family: var(--rv-filter-title-font);
    font-size: var(--rv-filter-title-size);
    font-weight: var(--rv-filter-title-weight);
    line-height: 17px;
    text-transform: uppercase;
    min-height: 24px;
}

.plp-filter-widget .plp-group-chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    margin-left: 8px;
    transition: transform .18s ease;
}

.plp-filter-widget .plp-group-chevron svg {
    display: block;
}

.plp-filter-widget .plp-attribute-label[aria-expanded="false"] .plp-group-chevron {
    transform: rotate(180deg);
}

/* -----------------------------------------------
   Term list
   ----------------------------------------------- */
.plp-filter-widget .plp-term-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.plp-filter-widget .plp-item {
    list-style: none;
    margin: 0;
    padding: 0;
}

.plp-filter-widget .plp-item-label {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    margin: 0;
    cursor: pointer;
    font-size: var(--rv-filter-option-size);
    color: var(--rv-text);
}

.plp-filter-widget .plp-name {
    flex: 1;
    line-height: 1.2;
    color: var(--rv-text);
    font-size: var(--rv-filter-option-size);
    font-weight: var(--rv-filter-option-weight);
    display: flex;
    align-items: center;
}

/* Row reads [name] … [(count)] [checkbox]. The markup order is checkbox, name,
   count — reordering visually rather than in PHP keeps the checkbox first in
   the DOM, so the label still reads as "checkbox: name" to screen readers and
   the tab order is unchanged. .plp-name takes the free space (flex: 1), which
   pushes the other two to the right edge. The checkbox goes last so that the
   variable width of the count — "(2)" vs "(12)" vs "(128)" — can no longer
   shift it: the checkbox is always flush with the right edge and lines up
   across every row. */
.plp-filter-widget .plp-item-label .plp-name {
    order: 1;
}

.plp-filter-widget .plp-item-label .plp-count {
    order: 2;
    flex-shrink: 0;
}

.plp-filter-widget .plp-item-label .plp-filter-checkbox {
    order: 3;
}

/* -----------------------------------------------
   Variant A — items WITH a thumbnail (image-bearing taxonomies)
   Pill row with round thumb, native checkbox hidden.
   ----------------------------------------------- */
.plp-filter-widget .plp-item:has(img) {
    padding: 8px;
    border-radius: 12px;
    transition: background-color .15s ease;
}

.plp-filter-widget .plp-item:has(img):hover {
    background-color: #f6f6f6;
}

/* Framed swatch, same look as the product page colour swatches (.rv-swatch in
   single-product.css): a 42px rounded square with a 1px frame and a 4px gap
   around the thumbnail. The frame lives on the <img> itself — the filter
   markup has no wrapper around it — so padding, not a parent, makes the gap. */
.plp-filter-widget .plp-item:has(img) > img {
    box-sizing: border-box;
    width: 42px;
    height: 42px;
    padding: 4px;
    border: 1px solid var(--rv-border);
    border-radius: var(--rv-swatch-radius);
    object-fit: cover;
    flex-shrink: 0;
    display: block;
    margin: 0 10px 0 0;
    transition: border-color .15s ease;
}

/* Selected term: the same neutral frame the active product-page swatch uses. */
.plp-filter-widget .plp-item:has(img):has(.plp-filter-checkbox:checked) > img {
    border-color: var(--rv-swatch-active-border);
}

/* The whole row reorders to: [thumb] [label] — image is outside the label. */
.plp-filter-widget .plp-item:has(img) .plp-item-label {
    gap: 10px;
    padding: 4px 0;
}

/* Hide native checkbox in image rows — selection is shown via pill background + ×. */
.plp-filter-widget .plp-item:has(img) .plp-filter-checkbox {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Selected state: light pill + × glyph after the name. */
.plp-filter-widget .plp-item:has(img):has(.plp-filter-checkbox:checked) {
    background-color: #efefef;
}

.plp-filter-widget .plp-item:has(img):has(.plp-filter-checkbox:checked) .plp-name::after {
    content: '';
    display: block;
    background-image: url('data:image/svg+xml,<svg width="12" height="12" viewBox="0 0 12 12" fill="none" xmlns="http://www.w3.org/2000/svg"><path d="M0.75 0.75L5.75 5.75M10.75 10.75L5.75 5.75M5.75 5.75L10.75 0.75M5.75 5.75L0.75 10.75" stroke="black" stroke-width="1.5" stroke-linecap="round"/></svg>');
    width: 16px;
    height: 16px;
    margin-left: 8px;
    background-repeat: no-repeat;
    background-position: center;
}

/* -----------------------------------------------
   Variant B — items WITHOUT a thumbnail (Brand etc.)
   Square brand-style checkbox.
   ----------------------------------------------- */
.plp-filter-widget .plp-item:not(:has(img)) .plp-item-label {
    gap: 9px;
    padding: 4px 0;
}

.plp-filter-widget .plp-item:not(:has(img)) .plp-filter-checkbox {
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    width: 18px;
    height: 18px;
    margin: 0;
    border: 1px solid var(--rv-filter-checkbox-border);
    border-radius: 2px;
    background: var(--rv-filter-checkbox-bg);
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: background-color .12s ease, border-color .12s ease;
}

.plp-filter-widget .plp-item:not(:has(img)) .plp-filter-checkbox:checked {
    background: var(--rv-btn-primary);
    border-color: var(--rv-btn-primary);
}

.plp-filter-widget .plp-item:not(:has(img)) .plp-filter-checkbox:checked::after {
    content: '';
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid var(--rv-filter-checkbox-check);
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.plp-filter-widget .plp-item:not(:has(img)) .plp-filter-checkbox:focus-visible {
    outline: 2px solid var(--rv-filter-checkbox-focus);
    outline-offset: 2px;
}

/* -----------------------------------------------
   Show all / Show less per group
   ----------------------------------------------- */
.plp-filter-widget .plp-item.plp-item--collapsed {
    display: none;
}

/* Centred across the group and typed like a filter option, not like a link —
   it reads as one more row of the list rather than a separate control. */
.plp-filter-widget .plp-show-all-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    margin: 10px 0 0;
    padding: 4px 0;
    background: transparent;
    border: 0;
    color: var(--rv-text);
    font-family: var(--rv-filter-option-font);
    font-size: var(--rv-filter-option-size);
    font-weight: var(--rv-filter-option-weight);
    line-height: 1.2;
    text-decoration: none;
    cursor: pointer;
}

.plp-filter-widget .plp-show-all-btn:hover,
.plp-filter-widget .plp-show-all-btn:focus {
    color: var(--rv-text);
    opacity: .7;
}

.plp-filter-widget .plp-show-all-btn__chevron {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: transform .18s ease;
}

.plp-filter-widget .plp-show-all-btn__chevron svg {
    display: block;
}

/* Expanded ("Show less") — the arrow points back up. */
.plp-filter-widget .plp-show-all-btn[aria-expanded="true"] .plp-show-all-btn__chevron {
    transform: rotate(180deg);
}

/* -----------------------------------------------
   Empty state + reset
   ----------------------------------------------- */
.plp-filter-widget .plp-no-terms {
    margin: 0;
    padding: 4px 0;
    font-size: 13px;
    color: #888;
    font-style: italic;
}

.plp-filter-widget .plp-reset-btn {
    width: 100%;
    margin-top: 16px;
    padding: 10px 14px;
    border: 1px solid #d0d0d0;
    background: var(--rv-filter-reset-bg);
    border-radius: var(--rv-btn-radius);
    font-family: var(--rv-filter-reset-font);
    font-size: var(--rv-filter-reset-size);
    font-weight: var(--rv-filter-reset-weight);
    color: var(--rv-filter-reset-text);
    cursor: pointer;
    transition: background-color .12s ease;
}

.plp-filter-widget .plp-reset-btn:hover {
    background: #f5f5f5;
}

/* -----------------------------------------------
   Image-row layout fix: native order is <img>, then <label>.
   The img is a sibling of the label — keep it on the left of the row.
   ----------------------------------------------- */
.plp-filter-widget .plp-item:has(img) {
    display: flex;
    align-items: center;
    gap: 0;
}

/* -----------------------------------------------
   Mobile panel: hide filter widget by default,
   show as fixed full-screen panel when body.plp-filter-open
   ----------------------------------------------- */
.plp-filter-widget__header {
    display: none;
}

@media (max-width: 1024px) {
    .widget_block:has(> .kb-row-layout-wrap .plp-filter-widget),
    .widget_block:has(.plp-filter-widget) {
        display: none;
    }

    body.plp-filter-open {
        overflow: hidden;
    }

    body.plp-filter-open .widget_block:has(.plp-filter-widget) {
        display: block;
        position: fixed;
        inset: 0;
        z-index: 9999;
        background: var(--rv-surface);
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 0;
        animation: plp-filter-slide-in .3s ease both;
    }

    body.plp-filter-open .widget_block:has(.plp-filter-widget) .kb-row-layout-wrap {
        border: 0;
        padding: 0;
    }

    body.plp-filter-open .plp-filter-widget {
        max-width: none;
        padding: 0;
    }

    body.plp-filter-open .plp-filter-widget__header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 20px;
        position: sticky;
        top: 0;
        background: var(--rv-surface);
        z-index: 1;
        border-bottom: 1px solid var(--rv-border);
    }

    .plp-filter-widget__title {
        font-family: var(--rv-filter-title-font);
        font-size: 18px;
        font-weight: var(--rv-filter-title-weight);
        line-height: 22px;
        color: var(--rv-text);
    }

    .plp-filter-widget__close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        padding: 0;
        border: 0;
        background: transparent;
        cursor: pointer;
    }

    .plp-filter-widget__close svg {
        display: block;
    }

    .plp-filter-widget__pills {
        display: flex !important;
        flex-wrap: wrap;
        gap: 8px;
        margin-bottom: 0;
        padding: 20px;
        /*border-bottom: 1px solid rgba(225, 225, 225, 1);*/
    }
    .plp-filter-widget .plp-attribute-group {
        padding: 20px;
        border-bottom: 1px solid var(--rv-border);
    }
    .plp-filter-widget .plp-toolbar__pill, .plp-filter-widget .plp-toolbar__reset {
        display: inline-flex;
        align-items: center;
    }
    .plp-filter-widget .plp-reset-btn{
        margin-top: 0
    }
    .plp-filter-widget__reset-wrap {
        padding: 20px;
        border-top: 1px solid var(--rv-border);
    }
}

@keyframes plp-filter-slide-in {
    from { transform: translateX(-100%); }
    to   { transform: translateX(0); }
}

.plp-item-disabled span {
    color: #B4B4B4;
    cursor: not-allowed;
}
