﻿/**
 * Taxonomy Filter Enhancer - Stylesheet
 * Version: 1.0.23
 * 
 * Data Attributes:
 * - data-filter: Term slug identifier
 * - data-tax-parent: Parent term slug (for child items)
 * - data-parent-filter: Parent hierarchical level (e.g., "parent", "child-level-1", "child-level-2")
 * - data-post-count: Number of posts in this term
 * - data-taxonomy: Taxonomy name (on main wrapper)
 * 
 * CSS Classes:
 * - filter-{slug}: Current term filter class
 * - filter-{parent-slug}: Parent term filter class (added to child elements)
 * - collapsed: Added to child-level-1 when children are hidden
 * - hidden: Added to child elements when parent is collapsed
 */

:root {
    /* Colors */
    --tfe-primary-color: #e85b17;
    --tfe-primary-hover: #d04d0f;
    --tfe-secondary-color: #007cba;
    --tfe-border-color: #4A4643;
    --tfe-background-hover: #f8f9fa;
    --tfe-text-gray: #666;
    --tfe-badge-gray: #b9b9b9;
    --tfe-white: white;
    
    /* Checkbox */
    --tfe-checkbox-size: 18px;
    --tfe-checkbox-border-width: 1px;
    --tfe-checkbox-border-radius: 0px;
    
    /* Toggle indicator */
    --tfe-toggle-size: 20px;
    --tfe-toggle-font-size: 12px;
    
    /* Spacing */
    --tfe-wrapper-padding: 8px 12px;
    --tfe-wrapper-margin: 0px 0;
    --tfe-wrapper-border-radius: 6px;
    --tfe-wrapper-border-width: 1px;
    
    /* Hierarchy indentation */
    --tfe-indent-level-1: 0;
    --tfe-indent-level-2: 20px;
    --tfe-indent-level-3: 40px;
    --tfe-indent-level-4: 60px;
    
    /* Typography */
    --tfe-font-weight-parent: 700;
    --tfe-font-weight-level-1: 700;
    --tfe-font-weight-level-2: 600;
    --tfe-font-weight-level-3: 500;
    --tfe-font-weight-level-4: 400;
    
    /* Post count badge */
    --tfe-badge-font-size: 11px;
    --tfe-badge-padding: 2px 6px;
    --tfe-badge-border-radius: 10px;
    --tfe-badge-margin-left: 8px;
    
    /* Transitions */
    --tfe-transition-duration: 0.3s;
    --tfe-transition-easing: ease;
}

.tax-filter-wrapper.parent.filter-tutte {
    display: none !important;
}

.tax-filter-wrapper {
    position: relative;
    display: flex !important;
    align-items: center !important;
    width: 100% !important;
    max-width: unset !important;
    padding: var(--tfe-wrapper-padding);
    margin: var(--tfe-wrapper-margin);
    border: var(--tfe-wrapper-border-width) solid transparent;
    border-radius: var(--tfe-wrapper-border-radius);
    flex-direction: row;
    flex-wrap: wrap;
    justify-content: flex-start !important;
    align-content: center;
    transition: all var(--tfe-transition-duration) var(--tfe-transition-easing);
}

.tax-filter-wrapper button {
    width: auto !important;
    max-width: unset !important;
}

.tax-checkbox {
    display: none;
}

.tax-filter-wrapper::before {
    content: '';
    width: var(--tfe-checkbox-size);
    height: var(--tfe-checkbox-size);
    border: var(--tfe-checkbox-border-width) solid var(--tfe-border-color);
    border-radius: var(--tfe-checkbox-border-radius);
    background: var(--tfe-white);
    transition: all var(--tfe-transition-duration) var(--tfe-transition-easing);
    flex-shrink: 0;
    cursor: pointer;
}

.tax-filter-wrapper.active::before {
    background-color: var(--tfe-primary-color);
    border-color: var(--tfe-primary-color);
    background-image: url(/wp-content/uploads/2023/03/X-Explorer-White.svg);
    background-size: 90%;
    background-repeat: no-repeat;
    background-position: center center;
}

.tax-filter-wrapper:hover {
    background-color: var(--tfe-background-hover);
}

.tax-filter-wrapper:hover::before {
    border-color: var(--tfe-primary-color);
}

.tax-filter-wrapper.active:hover::before {
    background-color: var(--tfe-primary-hover);
    border-color: var(--tfe-primary-hover);
}

.tax-filter-wrapper.parent {
    font-weight: var(--tfe-font-weight-parent);
    background: var(--tfe-background-hover);
    border-left: 3px solid var(--tfe-secondary-color);
}

.child-level-1 {
    margin-left: var(--tfe-indent-level-1);
    margin-top: 0px;
    font-weight: var(--tfe-font-weight-level-1);
    text-transform: uppercase;
    cursor: pointer;
    position: relative;
}

.child-level-1 button {
    pointer-events: none;
}

.child-level-1::before {
    display: none !important;
}

.child-level-1 button::after {
    display: none !important;
}

/* Toggle indicator for collapsible categories */
.tax-filter-wrapper.child-level-1::after {
    content: '▼';
    position: absolute;
    right: 0px;
    font-size: var(--tfe-toggle-font-size);
    transition: transform var(--tfe-transition-duration) var(--tfe-transition-easing);
    pointer-events: none;
    color: var(--tfe-text-gray);
    background-color: var(--tfe-white);
    aspect-ratio: 1 / 1;
    width: var(--tfe-toggle-size);
    display: flex;
    border-radius: 100%;
    flex-direction: column;
    flex-wrap: wrap;
    align-content: center;
    justify-content: center;
    align-items: center;
}

.tax-filter-wrapper.child-level-1.collapsed::after {
    transform: rotate(-90deg);
}

/* Hidden state for collapsed children */
.tax-filter-wrapper.hidden {
    display: none !important;
    opacity: 0;
    max-height: 0;
    overflow: hidden;
}

.tax-filter-wrapper.child-level-2 {
    margin-left: var(--tfe-indent-level-2);
    font-weight: var(--tfe-font-weight-level-2);
}

.child-level-2 {
    margin-left: 10px;
}

.tax-filter-wrapper.child-level-3 {
    margin-left: var(--tfe-indent-level-3);
    font-weight: var(--tfe-font-weight-level-3);
    font-size: 0.95em;
}

.tax-filter-wrapper.child-level-4 {
    margin-left: var(--tfe-indent-level-4);
    font-weight: var(--tfe-font-weight-level-4);
    font-size: 0.9em;
    color: var(--tfe-text-gray);
}

.tax-filter-wrapper .e-filter-item::after {
    content: attr(data-post-count);
    display: inline-block;
    background: var(--tfe-badge-gray);
    color: var(--tfe-white);
    font-size: var(--tfe-badge-font-size);
    padding: var(--tfe-badge-padding);
    border-radius: var(--tfe-badge-border-radius);
    margin-left: var(--tfe-badge-margin-left);
    line-height: 1;
    font-weight: normal;
}

.tax-filter-wrapper.active .e-filter-item::after {
    background: var(--tfe-primary-color);
}

.tax-filter-wrapper.parent .e-filter-item::after {
    background: var(--tfe-secondary-color);
    font-weight: bold;
}

.post-count-badge {
    margin-left: 10px;
    font-size: 12px;
}

.post-count-badge::before {
    content: '(';
}

.post-count-badge::after {
    content: ')';
}

@media (max-width: 768px) {
    :root {
        --tfe-checkbox-size: 16px;
        --tfe-wrapper-padding: 6px 10px;
        --tfe-indent-level-2: 15px;
        --tfe-indent-level-3: 30px;
        --tfe-indent-level-4: 45px;
    }
}

@media (max-width: 480px) {
    :root {
        --tfe-indent-level-2: 10px;
        --tfe-indent-level-3: 20px;
        --tfe-indent-level-4: 30px;
    }
    
    .tax-filter-wrapper {
        font-size: 0.9em;
    }
}

/* Pulsante "Rimuovi filtri" */
.clear-filters,
.tfe-clear-filters {
    display: none; /* Nascosto di default */
    margin-top: 16px;
    padding: 10px 20px;
    background-color: var(--tfe-primary-color);
    color: var(--tfe-white);
    border: none;
    border-radius: var(--tfe-wrapper-border-radius);
    cursor: pointer;
    font-weight: 600;
    transition: all var(--tfe-transition-duration) var(--tfe-transition-easing);
}

.clear-filters:hover,
.tfe-clear-filters:hover {
    background-color: var(--tfe-primary-hover);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.clear-filters:active,
.tfe-clear-filters:active {
    transform: translateY(0);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}
