/**
 * Nocelli Filters - Frontend CSS
 */

:root {
    --npf-primary: #b8860b;
    --npf-text: #333;
    --npf-light: #666;
    --npf-border: #e5e5e5;
    --npf-swatch: 28px;
}

.npf-wrapper { font-size: 14px; line-height: 1.5; }
.npf-wrapper * { box-sizing: border-box; }

/* Paginazione NPF */
.npf-pagination {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
    margin: 30px 0;
    text-align: center;
    clear: both;
}

/* Nascondi paginazione WooCommerce standard */
.woocommerce-pagination { 
    display: none !important; 
}

/* Classe per nascondere paginazione Alukas quando NPF è attivo */
.pls-pagination.npf-hidden {
    display: none !important;
}

/* Active tags */
.npf-active-tags {
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 15px;
    padding: 10px;
    background: #f9f9f9;
    border-radius: 4px;
}
.npf-active-tags.has-tags { display: flex; }
.npf-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: var(--npf-primary);
    color: #fff;
    border-radius: 3px;
    font-size: 12px;
}
.npf-tag-remove { cursor: pointer; opacity: 0.8; }
.npf-tag-remove:hover { opacity: 1; }
.npf-tag-clear { background: #666; cursor: pointer; }

/* Blocks */
.npf-block { margin-bottom: 20px; }

/* Header */
.npf-header {
    cursor: pointer;
    padding: 12px 0;
    border-bottom: 1px solid var(--npf-border);
}
.npf-header h4 {
    margin: 0;
    font-size: 13px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.npf-header h4 i { font-size: 11px; color: #999; transition: transform 0.3s; }
.npf-header.open h4 i { transform: rotate(180deg); }

/* Body */
.npf-body { padding: 15px 0; }

/* Search */
.npf-search {
    position: relative;
    margin-bottom: 12px;
}
.npf-search input {
    width: 100%;
    padding: 8px 12px 8px 32px;
    border: 1px solid var(--npf-border);
    border-radius: 4px;
    font-size: 13px;
}
.npf-search input:focus { outline: none; border-color: var(--npf-primary); }
.npf-search i { position: absolute; left: 10px; top: 50%; transform: translateY(-50%); color: #999; font-size: 12px; }

/* Lists */
.npf-list {
    list-style: none;
    margin: 0;
    padding: 0;
    max-height: 300px;
    overflow-y: auto;
}
.npf-list::-webkit-scrollbar { width: 5px; }
.npf-list::-webkit-scrollbar-thumb { background: #ccc; border-radius: 3px; }

.npf-item { margin-bottom: 4px; }
.npf-item.hidden { display: none; }

/* Item row con expand button */
.npf-item-row {
    display: flex;
    align-items: center;
}
.npf-item-row > label { flex: 1; }

/* Expand button per sottocategorie */
.npf-expand {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    color: #999;
    transition: all 0.2s;
    border-radius: 4px;
    margin-left: 5px;
}
.npf-expand:hover { background: #f0f0f0; color: var(--npf-primary); }
.npf-expand i { transition: transform 0.2s; font-size: 10px; }
.npf-expand.open i { transform: rotate(180deg); }

/* DISABLED STATE */
.npf-item.disabled { opacity: 0.4; pointer-events: none; }
.npf-item.disabled label { color: #aaa; cursor: not-allowed; }
.npf-item.disabled .npf-check { background: #f0f0f0; border-color: #ddd; }
.npf-item.disabled .npf-swatch { opacity: 0.3; }

/* Sublists */
.npf-sublist {
    margin: 6px 0 6px 20px !important;
    padding-left: 12px !important;
    border-left: 2px solid #eee;
    max-height: none;
    overflow: visible;
    list-style: none;
}

/* Labels */
.npf-item > label,
.npf-item-row > label {
    display: flex;
    align-items: center;
    cursor: pointer;
    padding: 5px 0;
    transition: color 0.2s;
}
.npf-item > label:hover,
.npf-item-row > label:hover { color: var(--npf-primary); }

/* Hidden checkbox */
.npf-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

/* Custom checkbox */
.npf-check {
    width: 18px;
    height: 18px;
    border: 2px solid #ccc;
    border-radius: 3px;
    margin-right: 10px;
    flex-shrink: 0;
    position: relative;
    transition: all 0.2s;
    background: #fff;
}
.npf-item > label:hover .npf-check,
.npf-item-row > label:hover .npf-check { border-color: var(--npf-primary); }
.npf-item input:checked + .npf-check {
    background: var(--npf-primary);
    border-color: var(--npf-primary);
}
.npf-item input:checked + .npf-check::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 10px;
    color: #fff;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.npf-text { flex: 1; font-size: 13px; }
.npf-count { color: var(--npf-light); font-size: 12px; margin-left: 4px; }

/* Swatches */
.npf-swatch-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    max-height: none;
    overflow: visible;
}
.npf-swatch-item { margin: 0 !important; }
.npf-swatch-label { display: block; cursor: pointer; padding: 2px; }
.npf-swatch {
    display: block;
    width: var(--npf-swatch);
    height: var(--npf-swatch);
    border: 2px solid #ddd;
    border-radius: 50%;
    transition: all 0.2s;
}
.npf-swatches[data-style="square"] .npf-swatch { border-radius: 0; }
.npf-swatches[data-style="rounded"] .npf-swatch { border-radius: 4px; }
.npf-swatch:hover { transform: scale(1.1); border-color: #999; }
.npf-swatch.selected {
    border-color: var(--npf-primary);
    box-shadow: 0 0 0 2px var(--npf-primary);
}
.npf-swatch.selected::after {
    content: '\f00c';
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    font-size: 10px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-shadow: 0 0 2px rgba(0,0,0,0.5);
}
.npf-swatch-item.disabled .npf-swatch { opacity: 0.3; cursor: not-allowed; }

/* Price */
.npf-price-wrap { padding: 10px 5px 20px; }
.npf-price-display {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
    padding-top: 10px;
    border-top: 1px solid #f0f0f0;
    font-size: 13px;
}

/* Ion Range Slider */
.irs--round .irs-bar { background: var(--npf-primary); }
.irs--round .irs-handle { border: 4px solid var(--npf-primary); background: #fff; }
.irs--round .irs-handle:hover { background: var(--npf-primary); }
.irs--round .irs-from, .irs--round .irs-to, .irs--round .irs-single {
    background: var(--npf-primary);
    font-size: 11px;
}
.irs--round .irs-from::before, .irs--round .irs-to::before, .irs--round .irs-single::before {
    border-top-color: var(--npf-primary);
}
.irs--round .irs-line { background: #e5e5e5; height: 6px; }
.irs--round .irs-bar { height: 6px; }

/* Reset */
.npf-reset-block { margin-top: 10px; }
.npf-reset {
    width: 100%;
    padding: 12px;
    background: #333;
    color: #fff;
    border: none;
    border-radius: 4px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.3s;
}
.npf-reset:hover { background: var(--npf-primary); }
.npf-reset i { margin-right: 6px; }

/* NPF Custom Pagination */
.npf-pagination {
    display: block !important;
    margin: 30px 0;
    text-align: center;
}
.npf-pagination ul.page-numbers {
    display: inline-flex;
    list-style: none;
    margin: 0;
    padding: 0;
    gap: 5px;
}
.npf-pagination .page-numbers li { margin: 0; }
.npf-pagination .page-numbers a,
.npf-pagination .page-numbers span {
    display: inline-block;
    padding: 8px 14px;
    border: 1px solid #ddd;
    background: #fff;
    color: #333;
    text-decoration: none;
    border-radius: 4px;
    font-size: 14px;
    transition: all 0.2s;
    cursor: pointer;
}
.npf-pagination .page-numbers a:hover {
    background: var(--npf-primary);
    border-color: var(--npf-primary);
    color: #fff;
}
.npf-pagination .page-numbers .current {
    background: var(--npf-primary);
    border-color: var(--npf-primary);
    color: #fff;
}
.npf-pagination .page-numbers .dots {
    border: none;
    background: transparent;
    cursor: default;
}

/* Loading */
.npf-wrapper.loading { pointer-events: none; opacity: 0.6; }
.npf-loading-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(255,255,255,0.8);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}
.npf-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e5e5e5;
    border-top-color: var(--npf-primary);
    border-radius: 50%;
    animation: npf-spin 0.8s linear infinite;
}
@keyframes npf-spin { to { transform: rotate(360deg); } }

.woocommerce .products.loading { opacity: 0.5; pointer-events: none; }

@media print { .npf-wrapper { display: none; } }

.npf-item input:focus + .npf-check { outline: 2px solid var(--npf-primary); outline-offset: 2px; }
@media (prefers-reduced-motion: reduce) {
    .npf-spinner { animation: none; }
    * { transition: none !important; }
}
