.category-filters{
    display: flex;
    align-items: center;
    border-top: 2px solid #fff;
}

.category-filters .category-groups.flex{
    margin-top: 0;
    flex-grow: 1;
    background-color: transparent;
}

.category-filters .category-groups.flex .menu-group {
    flex: 1;
    min-width: 0; /* undo woo_general's 25% so the Reset Filters segment fits */
    padding: 0;
    border: none;
    color: var(--brand-white);
}

.category-filters .category-groups.flex .menu-group--item img {
    transition: transform 0.3s ease;
    transform: scale(1);
    will-change: transform;
}

.category-filters .category-groups.flex .menu-group .horizontal-list{
    display: none;
}

.filter-panels{
    display: flex;
    margin-bottom: 40px;
}

.filter-panel-spacer{
    width: 20%;
    flex-shrink: 0;
}

.filter-panel-slot{
    flex: 1;
    overflow: hidden;
}

/* Slide + fade the panel open (woo.js toggles .is-open on the list). max-height
   drives the slide-down and opacity eases it in over the full duration so it
   settles smoothly. The list stays display:flex the whole time — no measuring,
   no display swap, no glitch. */
.filter-panels .horizontal-list.flex{
    display: flex;
    justify-content: center;
    align-items: center;
    color: var(--brand-white);
    overflow: hidden;
    max-height: 0;
    padding: 0 10px;   /* no vertical padding while collapsed */
    opacity: 0;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.3s ease;
}

.filter-panels .horizontal-list.flex[style*="background-color: rgb(248, 190, 20)"] .product-category img {
    filter: brightness(0) saturate(100%) invert(22%) sepia(28%) saturate(1218%) hue-rotate(174deg) brightness(91%) contrast(91%) !important;
}

.filter-panels .horizontal-list.flex[style*="background-color: rgb(248, 190, 20)"] .product-category p {
    color: #184183;
}

.filter-panels .horizontal-list.flex.is-open{
    max-height: 400px;
    padding: 5px;
    opacity: 1;
}

.filter-panels .horizontal-list .product-category{
    text-align: center;
    padding: 10px 15px;
    align-self: auto;
}

.filter-panels .horizontal-list .gf-category-filter{
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    color: var(--brand-white);
    text-decoration: none;
    position: static;
    padding-top: 0;
}

.filter-panels .horizontal-list .gf-category-filter img{
    width: 25px;
    height: 25px;
    object-fit: contain;
    filter: brightness(0) invert(1) !important;
    margin: 0;
    transition: transform 0.3s ease;
    transform: scale(1);
    will-change: transform;
}

.filter-panels .horizontal-list .gf-category-filter p{
    color: var(--brand-white);
    padding-top: 0;
    margin: 0;
    font-size: 12px;
}

.category-filters .category-groups.flex .menu-group.waterproofing,
.category-filters .category-groups.flex .menu-group.impregnacja,
.category-filters .category-groups.flex .menu-group.imprägnieren,
.category-filters .category-groups.flex .menu-group.imprägnierung{
    background-color: #512f7d;
}

.category-filters .category-groups.flex .menu-group.cleaning,
.category-filters .category-groups.flex .menu-group.czyszczenie,
.category-filters .category-groups.flex .menu-group.schoonmaak,
.category-filters .category-groups.flex .menu-group.reinigung{
    background-color: var(--nikwax-green);
}

.category-filters .category-groups.flex .menu-group.deodorising,
.category-filters .category-groups.flex .menu-group.deodorizing,
.category-filters .category-groups.flex .menu-group.deodoriserende,
.category-filters .category-groups.flex .menu-group.desodorierung{
    background-color: #0078ba;
}

.category-filters .category-groups.flex .menu-group.uv-protection,
.category-filters .category-groups.flex .menu-group.ochrona-przed-uv,
.category-filters .category-groups.flex .menu-group.uv-schutz{
    background-color: #f8be14;
    color: var(--nikwax-blue);
}

.category-filters .category-groups.flex .menu-group--item{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 5px 0px;
    cursor: pointer;
}

.category-filters .category-groups.flex .menu-group--item img{
    width: 38px;
    height: 38px;
    object-fit: contain;
    flex-shrink: 0;
}

.category-filters .category-groups.flex .menu-group h3{
    font-size: 1.1rem;
    font-weight: 500;
}

.category-filters .category-filter-buttons{
    background-color: var(--nikwax-blue);
    width: 20%;
    align-self: stretch;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--brand-white);
    font-size: 1.1rem;
    font-weight: 500;
}

.category-filters .category-filter-buttons p {
    margin-left: 0;
    margin-right: 0;
}


.category-filters .category-groups.flex .menu-group:hover .menu-group--item img, .filter-panels .horizontal-list .product-category:hover .gf-category-filter img {
    transform: scale(1.07) !important;
}

/* "Reset Filters" icon (inline SVG) — sized to match the category images */
.category-filters .gf-reset-filter svg{
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}

/* Mobile-only reset button in the "Filter Products" header
   (.woocommerce prefix beats woo_general's `.category-filter-buttons button`) */
.category-filters .filter-reset-mobile,
.woocommerce .category-filters .filter-reset-mobile{
    display: none;
}

/* Shop page: global "Reset Filters" segment at the end of the bar */
.category-filters .category-groups.flex .menu-group.reset-filters{
    background-color: var(--nikwax-blue);
    border-left: 1px solid rgba(255, 255, 255, 0.25);
    transition: background-color 0.2s ease;
}

.category-filters .category-groups.flex .menu-group.reset-filters:hover{
    background-color: #16306b;
}

.category-filters .menu-group--reset{
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 100%;
    padding: 5px 0;
    color: var(--brand-white);
    text-decoration: none;
}

.category-filters .menu-group--reset svg{
    width: 30px;
    height: 30px;
    flex-shrink: 0;
}

.category-filters .menu-group--reset h3{
    margin: 0;
    color: var(--brand-white);
}

/* ============================================================
   Product category pages only
   Segmented full-width filter bar: a green "Filter Products"
   cell followed by one equal-width blue cell per sub-category,
   each with its icon inline beside the label.
   (woo.js skips building the dropdown panels when .tax-product_cat)
   ============================================================ */

/* Full-height equal segments across the whole bar */
.tax-product_cat .category-filters{
    align-items: stretch;
    margin-bottom: 50px;
}

/* Flatten the wrappers so "Filter Products" and each child category
   become sibling flex segments of .category-filters */
.tax-product_cat .category-filters .category-groups.flex,
.tax-product_cat .category-filters .category-groups.flex .menu-group,
.tax-product_cat .category-filters .category-groups.flex .menu-group .horizontal-list{
    display: contents;
}

/* The parent category heading isn't shown in this layout
   (override the base .category-groups.flex .menu-group--item display:flex) */
.tax-product_cat .category-filters .category-groups.flex .menu-group--item{
    display: none !important;
}

/* "Filter Products" segment — green */
.tax-product_cat .category-filters .category-filter-buttons{
    flex: 1 1 0;
    min-width: 0;
    width: auto;
    background-color: var(--nikwax-green);
    justify-content: center;
    text-align: center;
    padding: 20px 0;
}

.tax-product_cat .category-filters .category-filter-buttons p{
    margin: 0;
}

/* Each category segment — equal width, divider on the left.
   padding:0 !important defeats woo_general's `.product-category{padding:1rem}`
   (loaded later, equal specificity) which otherwise leaves a gap around each cell. */
.tax-product_cat .category-filters .product-category{
    flex: 1 1 0;
    min-width: 0;
    display: flex;
    align-items: stretch;
    padding: 0 !important;
    border-left: 1px solid rgba(255, 255, 255, 0.25);
}

.tax-product_cat .category-filters .product-category .gf-category-filter{
    flex: 1;
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 12px;
    background-color: var(--nikwax-blue);
    color: var(--brand-white);
    text-decoration: none;
    /* Cancel the shop-dropdown aspect-ratio square */
    position: static;
    padding: 11px 10px;
    transition: background-color 0.2s ease;
}

.tax-product_cat .category-filters .product-category .gf-category-filter:hover,
.tax-product_cat .category-filters .product-category .gf-category-filter.active{
    background-color: #16306b;
}

.tax-product_cat .category-filters .product-category .gf-category-filter img{
    width: auto;
    height: 40px;
    object-fit: contain;
    filter: brightness(0) invert(1) !important;
    margin: 0;
}

.tax-product_cat .category-filters .product-category .gf-reset-filter svg{
    width: 36px;
    height: 36px;
}

.tax-product_cat .category-filters .product-category .gf-category-filter p{
    margin: 0;
    padding: 0;
    color: var(--brand-white);
    font-size: 1.1rem;
    font-weight: 600;
    white-space: nowrap;
}

@media screen and (max-width: 1300px) {
    .filter-panels .horizontal-list .product-category{
        padding: 10px 7px;
    }
}

@media screen and (max-width: 1200px) {
    .filter-panels .horizontal-list.flex{
        flex-wrap: wrap;
    }
    
    .filter-panels .horizontal-list .product-category{
        padding: 5px;
    }
}

/* ============================================================
   Mobile / tablet (<= 1024px)
   The filter bar collapses into a vertical accordion:
   • "Filter Products" is a full-width header that toggles the list
   • each parent category is a full-width coloured row (icon + label
     + arrow) that toggles its own sub-categories
   (woo.js moves the sub-lists back inline and handles the toggles)
   ============================================================ */
@media screen and (max-width: 1024px) {

    /* Stack vertically — undo the flex row and the segmented bar */
    .category-filters{
        display: block;
        margin-bottom: clamp(20px, 5vw, 40px);
    }

    .tax-product_cat .category-filters{
        align-items: initial;
    }

    /* Category pages: undo the display:contents flattening so the group stacks.
       (Show/hide of the list and sub-lists is handled by the rules below.) */
    .tax-product_cat .category-filters .category-groups.flex .menu-group{
        display: block;
    }

    /* ---- "Filter Products" header / toggle ---- */
    .category-filters .category-filter-buttons{
        width: 100%;
        justify-content: center;
        align-items: center;
        gap: 14px;
        cursor: pointer;
    }
    .tax-product_cat .category-filters .category-filter-buttons{
        background-color: var(--nikwax-blue);
        flex: none;
    }
    .category-filters .category-filter-buttons,
    .tax-product_cat .category-filters .category-filter-buttons{
        padding: 0 0 0 20px;
    }
    .category-filters .category-filter-buttons p,
    .tax-product_cat .category-filters .category-filter-buttons p{
        margin: 18px 0 18px auto;
    }

    /* Reset segment pinned to the right of the header, full height.
       .woocommerce prefix beats woo_general's `.category-filter-buttons button`
       (min-width/margin/padding). */
    .category-filters .filter-reset-mobile,
    .woocommerce .category-filters .filter-reset-mobile{
        min-width: 0;
        margin: 0 0 0 auto;
        border-radius: 0;
        display: flex;
        align-items: center;
        gap: 8px;
        order: 2;
        align-self: stretch;
        flex-shrink: 0;
        padding: 0 18px;
        background-color: #16306b;
        border: none;
        border-left: 1px solid rgba(255, 255, 255, 0.25);
        color: var(--brand-white);
        font-family: inherit;
        font-size: 0.95rem;
        font-weight: 600;
        white-space: nowrap;
        cursor: pointer;
    }
    /* beats woo_general's `.woocommerce .category-filter-buttons span` (green) */
    .woocommerce .category-filters .filter-reset-mobile span{
        color: inherit;
    }
    .category-filters .filter-reset-mobile svg{
        width: 20px;
        height: 20px;
        flex-shrink: 0;
    }
    .category-filters .category-filter-buttons::after{
        content: "";
        width: 0;
        height: 0;
        border-left: 9px solid transparent;
        border-right: 9px solid transparent;
        border-top: 11px solid var(--golden-yellow); /* points down when closed */
        transition: transform 0.2s ease;
        order: 1;
    }
    .category-filters.is-open .category-filter-buttons::after{
        transform: rotate(180deg); /* points up when open */
    }

    /* ---- Category list: hidden until "Filter Products" is tapped ---- */
    .category-filters .category-groups.flex,
    .tax-product_cat .category-filters .category-groups.flex{
        display: none;
    }
    .category-filters.is-open .category-groups.flex,
    .tax-product_cat .category-filters.is-open .category-groups.flex{
        display: block;
    }
    .category-filters .category-groups.flex .menu-group{
        width: 100%;
    }

    /* ---- Parent category row: icon + label centred as a group,
       arrow pinned to the right edge (absolute so it doesn't shift the
       centred pair) ---- */
    .category-filters .category-groups.flex .menu-group--item,
    .tax-product_cat .category-filters .category-groups.flex .menu-group--item{
        display: flex !important;
        align-items: center;
        justify-content: center;
        gap: 16px;
        padding: 16px 55px;
        position: relative;
        cursor: pointer;
    }
    .category-filters .category-groups.flex .menu-group--item img{
        width: 40px;
        height: 40px;
        filter: brightness(0) invert(1);
        flex-shrink: 0;
    }
    .category-filters .category-groups.flex .menu-group h3{
        margin: 0;
        font-size: 1.1rem;
        text-align: center;
    }
    /* right-pointing arrow, rotates down when the group is open */
    .category-filters .category-groups.flex .menu-group--item::after{
        content: "";
        position: absolute;
        right: 20px;
        top: 50%;
        transform: translateY(-50%);
        width: 0;
        height: 0;
        border-top: 8px solid transparent;
        border-bottom: 8px solid transparent;
        border-left: 12px solid var(--golden-yellow);
        transition: transform 0.2s ease;
    }
    .category-filters .category-groups.flex .menu-group.is-open .menu-group--item::after{
        transform: translateY(-50%) rotate(90deg);
    }

    /* Reset lives in the header on mobile, not in the dropdown list */
    .category-filters .category-groups.flex .menu-group.reset-filters,
    .tax-product_cat .category-filters .category-groups.flex .menu-group .horizontal-list .reset-filter-item{
        display: none;
    }

    /* UV Protection (yellow bg) → dark label + arrow for contrast */
    .category-filters .category-groups.flex .menu-group.uv-protection h3{
        color: var(--nikwax-blue);
    }
    .category-filters .category-groups.flex .menu-group.uv-protection .menu-group--item img{
        filter: none;
    }
    .category-filters .category-groups.flex .menu-group.uv-protection .menu-group--item::after{
        border-left-color: var(--nikwax-blue);
    }

    /* ---- Sub-categories (hidden until the parent row is tapped) ----
       The .tax-product_cat variants carry the extra specificity needed to
       override the desktop `display:contents` on category pages. */
    .category-filters .category-groups.flex .menu-group .horizontal-list,
    .tax-product_cat .category-filters .category-groups.flex .menu-group .horizontal-list{
        display: none;
        padding: 20px;
        background: rgba(0, 0, 0, 0.18);
    }
    .category-filters .category-groups.flex .menu-group.is-open .horizontal-list,
    .tax-product_cat .category-filters .category-groups.flex .menu-group.is-open .horizontal-list{
        display: flex;
        flex-wrap: wrap;
    }

    .category-filters .category-groups.flex .menu-group .horizontal-list .product-category,
    .tax-product_cat .category-filters .category-groups.flex .menu-group .horizontal-list .product-category{
        flex: 1 1 140px;
        min-width: 140px;
        width: auto;
        padding: 0 !important;
        border: none;
    }
    .category-filters .category-groups.flex .menu-group .horizontal-list .gf-category-filter{
        flex-direction: row;
        justify-content: center;
        align-items: center;
        gap: 12px;
        padding: 10px 0;
        position: static;
        background: transparent;
        color: var(--brand-white);
    }
    .category-filters .category-groups.flex .menu-group .horizontal-list .gf-category-filter img{
        width: 26px;
        height: 26px;
        filter: brightness(0) invert(1) !important;
        margin: 0;
    }
    .category-filters .category-groups.flex .menu-group .horizontal-list .gf-category-filter p{
        margin: 0;
        padding: 0;
        color: var(--brand-white);
        font-size: 1rem;
        white-space: normal;
    }

    @media screen and (max-width: 359px) {
        .woocommerce .category-filters .filter-reset-mobile span{
            display: none;
        }
    }

    /* The desktop shop dropdown panels aren't used on mobile */
    .filter-panels{
        display: none !important;
    }
}