/* =============================================
   KLIMA PRODUCT FILTER – STYLES v1.2
   Accordion / Collapsible UI
   ============================================= */

.kpf-wrapper {
    display: flex;
    gap: 30px;
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen,
        Ubuntu, Rubik, sans-serif;
}

/* ---- SIDEBAR ---- */
.kpf-sidebar {
    flex: 0 0 300px;
    min-width: 300px;
    position: sticky;
    top: 100px;
    align-self: flex-start;
    max-height: calc(100vh - 120px);
    overflow-y: auto;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 24px 20px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.kpf-sidebar::-webkit-scrollbar {
    width: 6px;
}

.kpf-sort-group {
    padding-top: 16px !important;
    padding-bottom: 20px !important;
    position: relative;
    z-index: 15;
}

.kpf-sort-group .kpf-select {
    margin-bottom: 10px !important;
}

.kpf-sidebar::-webkit-scrollbar-track {

    background: transparent;
}
.kpf-sidebar::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.kpf-filter-group {
    margin-bottom: 4px;
    padding-bottom: 0;
    border-bottom: 1px solid #f1f5f9;
}
.kpf-filter-group:last-of-type {
    border-bottom: none;
}

.kpf-filter-title {
    font-size: 14px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #1e293b;
    margin: 0;
}

/* ---- ACCORDION HEADER ---- */
.kpf-accordion-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 4px;
    cursor: pointer;
    user-select: none;
    border-radius: 8px;
    transition: background 0.15s;
}

.kpf-accordion-header:hover {
    background: #f8fafc;
}

.kpf-toggle-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 6px;
    background: #f1f5f9;
    color: #475569;
    font-size: 18px;
    font-weight: 700;
    line-height: 1;
    transition: all 0.2s;
    flex-shrink: 0;
}

.kpf-accordion-header:hover .kpf-toggle-icon {
    background: #e2e8f0;
    color: #1e293b;
}

.kpf-group-open .kpf-toggle-icon {
    background: #3b82f6;
    color: #fff;
}

/* ---- ACCORDION PANEL (hidden by default) ---- */
.kpf-accordion-panel {
    display: none;
    padding: 0 4px 16px;
}

/* ---- CATEGORY ROW (checkbox + toggle side by side) ---- */
.kpf-cat-row {
    display: flex;
    align-items: center;
    gap: 0;
}

.kpf-cat-row .kpf-cat-label {
    flex: 1;
    min-width: 0;
}

/* Sub-category toggle button */
.kpf-sub-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 26px;
    height: 26px;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    background: #f8fafc;
    cursor: pointer;
    flex-shrink: 0;
    padding: 0;
    margin-left: 4px;
    transition: all 0.2s;
}

.kpf-sub-toggle:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.kpf-sub-open .kpf-sub-toggle {
    background: #3b82f6;
    border-color: #3b82f6;
}

.kpf-sub-toggle-icon {
    font-size: 14px;
    font-weight: 700;
    color: #64748b;
    line-height: 1;
}

.kpf-sub-open .kpf-sub-toggle-icon {
    color: #fff;
}

/* ---- COLLAPSIBLE SUB-CATEGORIES (hidden by default) ---- */
.kpf-subcategory-list.kpf-collapsible {
    display: none;
    list-style: none;
    margin: 6px 0 8px 0;
    padding: 8px 0 4px 16px;
    border-left: 2px solid #3b82f6;
    animation: kpf-fade-in 0.2s ease;
}

@keyframes kpf-fade-in {
    from { opacity: 0; transform: translateY(-4px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* ---- CATEGORY & ATTRIBUTE LISTS ---- */
.kpf-category-list,
.kpf-attribute-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.kpf-attribute-list {
    max-height: 280px;
    overflow-y: auto;
    padding-right: 4px;
}

.kpf-attribute-list::-webkit-scrollbar {
    width: 4px;
}
.kpf-attribute-list::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 2px;
}

.kpf-parent-cat {
    margin-bottom: 2px;
}

.kpf-cat-label,
.kpf-attr-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 7px 8px;
    border-radius: 6px;
    transition: background 0.15s;
    font-size: 14px;
}
.kpf-cat-label:hover,
.kpf-attr-label:hover {
    background: #f1f5f9;
}

.kpf-parent-label .kpf-cat-name {
    font-weight: 600;
    color: #1e293b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.kpf-child-label .kpf-cat-name,
.kpf-attr-label .kpf-cat-name {
    font-weight: 400;
    color: #475569;
}

.kpf-cat-count {
    margin-left: auto;
    font-size: 11px;
    color: #94a3b8;
    font-weight: 500;
    white-space: nowrap;
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 10px;
}

.kpf-checkbox {
    width: 16px;
    height: 16px;
    accent-color: #3b82f6;
    cursor: pointer;
    flex-shrink: 0;
}

/* ---- SEARCH ---- */
.kpf-search-input {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.kpf-search-input:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

/* ---- PRICE RANGE ---- */
.kpf-price-range {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.kpf-price-inputs {
    display: flex;
    align-items: center;
    gap: 8px;
}

.kpf-price-inputs input[type="number"] {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    text-align: center;
    box-sizing: border-box;
}
.kpf-price-inputs input[type="number"]:focus {
    outline: none;
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.kpf-price-separator {
    color: #94a3b8;
    font-size: 16px;
}

/* Dual Range Slider */
.kpf-slider-container {
    position: relative;
    height: 30px;
}

.kpf-range-slider {
    position: absolute;
    width: 100%;
    height: 6px;
    background: transparent;
    pointer-events: none;
    appearance: none;
    -webkit-appearance: none;
    top: 10px;
}

.kpf-range-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    height: 20px;
    width: 20px;
    border-radius: 50%;
    background: #3b82f6;
    border: 3px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    pointer-events: all;
    cursor: grab;
}

.kpf-range-slider::-moz-range-thumb {
    height: 16px;
    width: 16px;
    border-radius: 50%;
    background: #3b82f6;
    border: 3px solid #ffffff;
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
    pointer-events: all;
    cursor: grab;
}

/* ---- SELECT ---- */
.kpf-select {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    box-sizing: border-box;
}
.kpf-select:focus {
    outline: none;
    border-color: #3b82f6;
}

/* ---- BUTTONS ---- */
.kpf-filter-actions {
    display: flex;
    flex-direction: column;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
}

.kpf-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.kpf-btn-filter {
    background: #26457A;
    color: #ffffff;
}
.kpf-btn-filter:hover {
    background: #283346;
}

.kpf-btn-reset {
    background: #000000;
    color: #475569;
}
.kpf-btn-reset:hover /* ---- SORT FIX – force no overlap ---- */
.kpf-sort-group {
    padding: 20px 4px !important;
    overflow: visible !important;
    clear: both !important;
    position: relative !important;
    z-index: 15 !important;
}

.kpf-sort-group .kpf-filter-title {
    display: block !important;
    margin-bottom: 14px !important;
    position: relative !important;
    z-index: 1 !important;
}

.kpf-sort-group .kpf-select {
    display: block !important;
    position: relative !important;
    z-index: 2 !important;
    width: 100% !important;
    margin: 0 !important;
}

.kpf-filter-actions {
    margin-top: 20px !important;
    padding-top: 16px !important;
    clear: both !important;
    position: relative !important;
    z-index: 1 !important;
}{
    background: #e2e8f0;
    color: #1e293b;
}

/* ---- RESULTS AREA ---- */
.kpf-results {
    flex: 1;
    min-width: 0;
}

.kpf-results-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    min-height: 40px;
}

.kpf-result-count {
    font-size: 15px;
    font-weight: 600;
    color: #334155;
}

/* Loading */
.kpf-loader {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #64748b;
    font-size: 14px;
}

.kpf-spinner {
    width: 20px;
    height: 20px;
    border: 3px solid #e2e8f0;
    border-top-color: #3b82f6;
    border-radius: 50%;
    animation: kpf-spin 0.7s linear infinite;
}

@keyframes kpf-spin {
    to { transform: rotate(360deg); }
}

.kpf-product-grid.kpf-loading {
    opacity: 0.4;
    pointer-events: none;
    transition: opacity 0.15s;
}

/* Product Grid */
.kpf-product-grid .products {
    display: grid !important;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    list-style: none;
    padding: 0;
    margin: 0;
}

.kpf-product-grid .products li.product {
    margin: 0 !important;
    padding: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    transition: box-shadow 0.2s, transform 0.2s;
}
.kpf-product-grid .products li.product:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    transform: translateY(-2px);
}

/* Pagination */
.kpf-pagination {
    display: flex;
    justify-content: center;
    gap: 4px;
    margin-top: 30px;
    flex-wrap: wrap;
}

.kpf-pagination a,
.kpf-pagination span {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.2s;
}

.kpf-pagination a {
    color: #475569;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
}
.kpf-pagination a:hover {
    background: #3b82f6;
    color: #fff;
    border-color: #3b82f6;
}

.kpf-pagination span.current {
    background: #3b82f6;
    color: #fff;
    border: 1px solid #3b82f6;
}

/* No results */
.kpf-no-results,
.kpf-error {
    text-align: center;
    padding: 60px 20px;
    color: #64748b;
    font-size: 16px;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 992px) {
    .kpf-wrapper {
        flex-direction: column;
    }

    .kpf-sidebar {
        flex: none;
        width: 100%;
        min-width: 100%;
        position: static;
        max-height: none;
    }

    .kpf-product-grid .products {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

@media (max-width: 576px) {
    .kpf-product-grid .products {
        grid-template-columns: 1fr !important;
    }

    .kpf-sidebar {
        padding: 16px;
    }

    .kpf-wrapper {
        padding: 10px;
    }
}


/* ---- SORT FIX – force no overlap ---- */
.kpf-sort-group {
    padding: 20px 4px !important;
    overflow: visible !important;
    clear: both !important;
    position: relative !important;
    z-index: 15 !important;
}

.kpf-sort-group .kpf-filter-title {
    display: block !important;
    margin-bottom: 14px !important;
    position: relative !important;
    z-index: 1 !important;
}

.kpf-sort-group .kpf-select {
    display: block !important;
    position: relative !important;
    z-index: 2 !important;
    width: 100% !important;
    margin: 0 !important;
}

.kpf-filter-actions {
    margin-top: 20px !important;
    padding-top: 16px !important;
    clear: both !important;
    position: relative !important;
    z-index: 1 !important;
}
/* ---- SHOP PAGE INTEGRATION ---- */

/* Hide Agricola's default shop controls when our filter is active */
.agricola_shop_mode_buttons {
    display: none !important;
}

/* Make sure our wrapper takes full width inside Agricola's content area */
.kpf-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
}

/* Hide the default WooCommerce loop we wrapped */
.kpf-hidden-default-loop {
    display: none !important;
    height: 0 !important;
    overflow: hidden !important;
}

/* Ensure our filter sits above any theme z-index */
#kpf-wrapper {
    position: relative;
    z-index: 10;
}
