:root {
    --nb-pnfs-bg: #ffffff;
    --nb-pnfs-soft: #f7f8fa;
    --nb-pnfs-border: #e7eaf0;
    --nb-pnfs-text: #151922;
    --nb-pnfs-muted: #697386;
    --nb-pnfs-accent: #111827;
    --nb-pnfs-radius: 18px;
    --nb-pnfs-shadow: 0 16px 44px rgba(16, 24, 40, .08);
}

.nb-pnfs-shell {
    display: inline-flex;
    align-items: center;
}

.nb-pnfs-shop-grid {
    display: grid;
    grid-template-columns: minmax(250px, 310px) minmax(0, 1fr);
    gap: 34px;
    align-items: start;
    margin-top: 30px;
}

.nb-pnfs-shop-grid > .woocommerce-content-inner {
    min-width: 0;
    width: 100%;
}

.nb-pnfs-sidebar {
    background: var(--nb-pnfs-bg);
    border: 1px solid var(--nb-pnfs-border);
    border-radius: var(--nb-pnfs-radius);
    box-shadow: var(--nb-pnfs-shadow);
    color: var(--nb-pnfs-text);
    overflow: hidden;
}

@media (min-width: 992px) {
    .nb-pnfs-sidebar {
        position: sticky;
        top: 115px;
    }
}

.nb-pnfs-sidebar-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 14px;
    padding: 20px 20px 16px;
    border-bottom: 1px solid var(--nb-pnfs-border);
    background: linear-gradient(180deg, #ffffff, #fafbfc);
}

.nb-pnfs-sidebar-head h3 {
    margin: 0;
    font-size: 20px;
    line-height: 1.2;
    font-weight: 800;
    color: var(--nb-pnfs-text);
}

.nb-pnfs-close {
    display: none;
    width: 38px;
    height: 38px;
    border: 1px solid var(--nb-pnfs-border);
    border-radius: 999px;
    background: #fff;
    color: var(--nb-pnfs-text);
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
}

.nb-pnfs-sidebar-body {
    padding: 8px 20px 20px;
}

.nb-pnfs-clear-all {
    display: block;
    margin: 14px 20px 2px;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f1f4f8;
    color: var(--nb-pnfs-text);
    font-size: 13px;
    font-weight: 700;
    text-align: center;
    text-decoration: none;
}

.nb-pnfs-clear-all:hover {
    color: var(--nb-pnfs-text);
    background: #e9edf3;
}

.nb-pnfs-block {
    border-bottom: 1px solid var(--nb-pnfs-border);
    padding: 12px 0;
}

.nb-pnfs-block:last-child {
    border-bottom: 0;
    padding-bottom: 0;
}

.nb-pnfs-block-title {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    padding: 9px 0;
    border: 0;
    background: transparent;
    color: var(--nb-pnfs-text);
    font-size: 15px;
    font-weight: 800;
    text-align: left;
    cursor: pointer;
}

.nb-pnfs-block-title em {
    min-width: 22px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: var(--nb-pnfs-accent);
    color: #fff;
    font-size: 11px;
    font-style: normal;
    margin-left: auto;
}

.nb-pnfs-chevron {
    width: 9px;
    height: 9px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg) translateY(-2px);
    transition: transform .2s ease;
    opacity: .65;
}

.nb-pnfs-block.is-collapsed .nb-pnfs-chevron {
    transform: rotate(-45deg);
}

.nb-pnfs-block.is-collapsed .nb-pnfs-block-content {
    display: none;
}

.nb-pnfs-category-list {
    list-style: none;
    margin: 2px 0 0;
    padding: 0;
}

.nb-pnfs-category-list li {
    margin: 0;
}

.nb-pnfs-category-list a {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 9px 10px;
    border-radius: 12px;
    color: var(--nb-pnfs-text);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.25;
}

.nb-pnfs-category-list a:hover,
.nb-pnfs-category-list a.is-active {
    background: var(--nb-pnfs-soft);
    color: var(--nb-pnfs-text);
}

.nb-pnfs-category-list small,
.nb-pnfs-choice small {
    min-width: 24px;
    height: 22px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    background: #eef1f5;
    color: var(--nb-pnfs-muted);
    font-size: 11px;
    font-weight: 700;
}

.nb-pnfs-options {
    display: grid;
    gap: 7px;
    padding-top: 2px;
}

.nb-pnfs-choice {
    display: flex;
    align-items: center;
    gap: 10px;
    min-height: 40px;
    padding: 8px 10px;
    border: 1px solid transparent;
    border-radius: 12px;
    color: var(--nb-pnfs-text);
    text-decoration: none;
    font-size: 14px;
    line-height: 1.2;
    transition: background .15s ease, border-color .15s ease, transform .15s ease;
}

.nb-pnfs-choice:hover {
    background: var(--nb-pnfs-soft);
    color: var(--nb-pnfs-text);
}

.nb-pnfs-choice.is-active {
    background: #111827;
    border-color: #111827;
    color: #fff;
}

.nb-pnfs-choice.is-active small {
    background: rgba(255,255,255,.18);
    color: #fff;
}

.nb-pnfs-choice-label {
    flex: 1;
}

.nb-pnfs-box {
    width: 18px;
    height: 18px;
    border: 2px solid #c7ced8;
    border-radius: 5px;
    background: #fff;
    flex: 0 0 auto;
}

.nb-pnfs-display-radio .nb-pnfs-box {
    border-radius: 999px;
}

.nb-pnfs-choice.is-active .nb-pnfs-box {
    border-color: #fff;
    background: #fff;
    box-shadow: inset 0 0 0 4px #111827;
}

.nb-pnfs-display-buttons .nb-pnfs-options,
.nb-pnfs-display-swatches .nb-pnfs-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.nb-pnfs-display-buttons .nb-pnfs-choice {
    min-height: 34px;
    padding: 7px 12px;
    border: 1px solid var(--nb-pnfs-border);
    background: #fff;
}

.nb-pnfs-display-buttons .nb-pnfs-box,
.nb-pnfs-display-buttons .nb-pnfs-choice small {
    display: none;
}

.nb-pnfs-swatch {
    width: 24px;
    height: 24px;
    border-radius: 999px;
    border: 1px solid rgba(0,0,0,.15);
    box-shadow: inset 0 0 0 2px rgba(255,255,255,.8);
    flex: 0 0 auto;
}

.nb-pnfs-display-swatches .nb-pnfs-choice {
    padding: 7px 10px;
    border: 1px solid var(--nb-pnfs-border);
    background: #fff;
}

.nb-pnfs-display-swatches .nb-pnfs-choice.is-active {
    background: #111827;
    border-color: #111827;
}

.nb-pnfs-select {
    width: 100%;
    height: 42px;
    border: 1px solid var(--nb-pnfs-border);
    border-radius: 12px;
    background: #fff;
    color: var(--nb-pnfs-text);
    padding: 0 12px;
}

.nb-pnfs-price-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

.nb-pnfs-price-row label span {
    display: block;
    margin-bottom: 5px;
    font-size: 12px;
    font-weight: 700;
    color: var(--nb-pnfs-muted);
}

.nb-pnfs-price-row input {
    width: 100%;
    height: 42px;
    border: 1px solid var(--nb-pnfs-border);
    border-radius: 12px;
    padding: 0 10px;
}

.nb-pnfs-apply-price {
    width: 100%;
    margin-top: 10px;
    height: 42px;
    border: 0;
    border-radius: 12px;
    background: var(--nb-pnfs-accent);
    color: #fff;
    font-weight: 800;
    cursor: pointer;
}

.nb-pnfs-mobile-toggle {
    display: none;
    align-items: center;
    gap: 9px;
    min-height: 42px;
    padding: 0 16px;
    border: 1px solid var(--nb-pnfs-border);
    border-radius: 999px;
    background: #111827;
    color: #fff;
    font-weight: 800;
    cursor: pointer;
    position: relative;
}

.nb-pnfs-mobile-toggle-icon,
.nb-pnfs-mobile-toggle-icon::before,
.nb-pnfs-mobile-toggle-icon::after {
    display: block;
    width: 16px;
    height: 2px;
    border-radius: 4px;
    background: currentColor;
    content: "";
}

.nb-pnfs-mobile-toggle-icon {
    position: relative;
}

.nb-pnfs-mobile-toggle-icon::before {
    position: absolute;
    top: -5px;
}

.nb-pnfs-mobile-toggle-icon::after {
    position: absolute;
    top: 5px;
}

.nb-pnfs-active-dot {
    position: absolute;
    right: 7px;
    top: 6px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    background: #ff4d4d;
}

.nb-pnfs-backdrop {
    display: none;
}

@media (max-width: 991px) {
    .nb-pnfs-shop-grid {
        display: block;
        margin-top: 20px;
    }

    .nb-pnfs-mobile-toggle {
        display: inline-flex;
    }

    .nb-pnfs-close {
        display: inline-flex;
        align-items: center;
        justify-content: center;
    }

    .nb-pnfs-sidebar {
        position: fixed;
        z-index: 999999;
        left: 0;
        top: 0;
        bottom: 0;
        width: min(88vw, 390px);
        border-radius: 0 22px 22px 0;
        transform: translateX(-105%);
        transition: transform .25s ease;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }

    body.nb-pnfs-open .nb-pnfs-sidebar {
        transform: translateX(0);
    }

    .nb-pnfs-backdrop {
        position: fixed;
        inset: 0;
        z-index: 999998;
        background: rgba(15, 23, 42, .48);
        backdrop-filter: blur(3px);
    }

    body.nb-pnfs-open .nb-pnfs-backdrop {
        display: block;
    }

    body.nb-pnfs-open {
        overflow: hidden;
    }
}

/* v1.3 - Accordion chiusi e ricerca interna */
.nb-pnfs-block-title {
    position: relative;
    border-radius: 12px;
}

.nb-pnfs-block-title:hover {
    background: rgba(17, 24, 39, .035);
    padding-left: 10px;
    padding-right: 10px;
}

.nb-pnfs-block-content {
    padding: 4px 0 10px;
}

.nb-pnfs-search {
    display: block;
    margin: 0 0 10px;
}

.nb-pnfs-search input {
    width: 100%;
    height: 40px;
    border: 1px solid var(--nb-pnfs-border);
    border-radius: 12px;
    background: #fff;
    color: var(--nb-pnfs-text);
    font-size: 13px;
    padding: 0 12px;
    outline: none;
    box-shadow: none;
}

.nb-pnfs-search input:focus {
    border-color: #111827;
    box-shadow: 0 0 0 3px rgba(17, 24, 39, .08);
}

.nb-pnfs-options,
.nb-pnfs-category-list {
    max-height: 320px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: #c7ced8 transparent;
    padding-right: 3px;
}

.nb-pnfs-display-buttons .nb-pnfs-options,
.nb-pnfs-display-swatches .nb-pnfs-options {
    max-height: 260px;
}

.nb-pnfs-display-swatches .nb-pnfs-choice {
    max-width: 100%;
}

.nb-pnfs-choice.is-hidden-by-search,
.nb-pnfs-category-list li.is-hidden-by-search {
    display: none !important;
}

.nb-pnfs-no-results {
    margin: 8px 0 0;
    padding: 10px 12px;
    border-radius: 12px;
    background: #f7f8fa;
    color: var(--nb-pnfs-muted);
    font-size: 13px;
    font-weight: 700;
}

.nb-pnfs-no-results[hidden] {
    display: none !important;
}

.nb-pnfs-block.is-collapsed {
    padding-bottom: 8px;
}

.nb-pnfs-block.is-collapsed .nb-pnfs-block-title {
    margin-bottom: 0;
}

@media (max-width: 991px) {
    .nb-pnfs-sidebar-body {
        padding-bottom: 34px;
    }

    .nb-pnfs-options,
    .nb-pnfs-category-list {
        max-height: none;
        overflow-y: visible;
    }
}

/* v1.4 - UX senza scroll interni + mobile ottimizzato */
.nb-pnfs-options,
.nb-pnfs-category-list,
.nb-pnfs-display-buttons .nb-pnfs-options,
.nb-pnfs-display-swatches .nb-pnfs-options {
    max-height: none !important;
    overflow: visible !important;
    scrollbar-width: auto;
    padding-right: 0;
}

.nb-pnfs-choice.is-hidden-over-limit,
.nb-pnfs-category-list li.is-hidden-over-limit {
    display: none !important;
}

.nb-pnfs-show-more {
    width: 100%;
    min-height: 38px;
    margin-top: 10px;
    border: 1px solid var(--nb-pnfs-border);
    border-radius: 12px;
    background: #f7f8fa;
    color: var(--nb-pnfs-text);
    font-size: 13px;
    font-weight: 800;
    cursor: pointer;
    transition: background .16s ease, border-color .16s ease, transform .16s ease;
}

.nb-pnfs-show-more:hover {
    background: #eef2f7;
    border-color: #d8dee8;
}

.nb-pnfs-show-more:active {
    transform: scale(.99);
}

.nb-pnfs-show-more[hidden] {
    display: none !important;
}

.nb-pnfs-sidebar {
    overflow: visible;
}

.nb-pnfs-sidebar-body {
    overflow: visible;
}

.nb-pnfs-shop-grid {
    grid-template-columns: minmax(240px, 292px) minmax(0, 1fr);
    gap: 30px;
}

.nb-pnfs-block-title {
    min-height: 44px;
}

.nb-pnfs-choice,
.nb-pnfs-category-list a {
    word-break: normal;
    overflow-wrap: anywhere;
}

@media (min-width: 992px) {
    .nb-pnfs-sidebar {
        position: sticky;
        top: 105px;
        align-self: start;
    }
}

@media (max-width: 991px) {
    .nb-pnfs-shell {
        display: flex;
        width: 100%;
        margin: 6px 0 12px;
    }

    .woocommerce-toolbar-top-right .nb-pnfs-shell,
    .woocommerce-toolbar-top .nb-pnfs-shell {
        flex: 1 1 100%;
    }

    .nb-pnfs-mobile-toggle {
        width: 100%;
        justify-content: center;
        min-height: 48px;
        border-radius: 14px;
        box-shadow: 0 10px 26px rgba(17, 24, 39, .12);
    }

    .nb-pnfs-sidebar {
        left: 10px;
        right: 10px;
        top: auto;
        bottom: 0;
        width: auto;
        max-height: min(86dvh, 720px);
        border-radius: 24px 24px 0 0;
        transform: translateY(105%);
        display: flex;
        flex-direction: column;
        overflow: hidden !important;
        box-shadow: 0 -18px 60px rgba(15, 23, 42, .22);
    }

    body.nb-pnfs-open .nb-pnfs-sidebar {
        transform: translateY(0);
    }

    .nb-pnfs-sidebar-head {
        flex: 0 0 auto;
        padding: 18px 18px 14px;
        position: relative;
    }

    .nb-pnfs-sidebar-head::before {
        content: "";
        position: absolute;
        top: 7px;
        left: 50%;
        width: 42px;
        height: 4px;
        border-radius: 999px;
        background: #d6dbe4;
        transform: translateX(-50%);
    }

    .nb-pnfs-sidebar-head h3 {
        font-size: 18px;
        padding-top: 8px;
    }

    .nb-pnfs-close {
        width: 42px;
        height: 42px;
        font-size: 25px;
    }

    .nb-pnfs-clear-all {
        flex: 0 0 auto;
        margin: 12px 18px 0;
    }

    .nb-pnfs-sidebar-body {
        flex: 1 1 auto;
        min-height: 0;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        padding: 8px 18px calc(22px + env(safe-area-inset-bottom));
    }

    .nb-pnfs-block {
        padding: 10px 0;
    }

    .nb-pnfs-block-title {
        min-height: 48px;
        font-size: 15px;
    }

    .nb-pnfs-choice,
    .nb-pnfs-category-list a {
        min-height: 44px;
        padding: 10px 11px;
        font-size: 14px;
    }

    .nb-pnfs-search input,
    .nb-pnfs-select,
    .nb-pnfs-price-row input,
    .nb-pnfs-apply-price {
        min-height: 46px;
    }

    .nb-pnfs-backdrop {
        background: rgba(15, 23, 42, .52);
        backdrop-filter: blur(2px);
    }

    body.nb-pnfs-open {
        overflow: hidden;
        touch-action: none;
    }

    body.nb-pnfs-open .nb-pnfs-sidebar,
    body.nb-pnfs-open .nb-pnfs-sidebar * {
        touch-action: pan-y;
    }
}

@media (max-width: 575px) {
    .nb-pnfs-sidebar {
        left: 0;
        right: 0;
        max-height: 88dvh;
        border-radius: 22px 22px 0 0;
    }

    .nb-pnfs-sidebar-body {
        padding-left: 15px;
        padding-right: 15px;
    }
}
