/**
 * Stili per ACF CPT Filter
 */

.acf-cpt-filter-wrapper {
    margin: 0 auto;
    padding: 20px;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    position: relative;
    max-width: 750px;
}

/* Link reset sempre visibile */
.acf-cpt-filter-reset-link-wrapper {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
}

.acf-cpt-filter-reset-link {
    color: #718096;
    text-decoration: none;
    font-size: 0.9em;
    font-weight: 600;
    border-radius: 4px;
    transition: all 0.2s ease;
    display: inline-block;
}

.acf-cpt-filter-reset-link:hover {
    color: #2d3748;
    background: #f7fafc;
    text-decoration: none;
}

.acf-cpt-filter-reset-link:focus {
    outline: 2px solid #cbd5e0;
    outline-offset: 2px;
}

.acf-cpt-filter-form {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.acf-cpt-filter-field {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.acf-cpt-filter-field label {
    font-weight: 600;
    color: #2d3748;
    font-size: 0.95em;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.acf-cpt-filter-field label i {
    color: #9333ea;
}

.acf-cpt-filter-input,
.acf-cpt-filter-select {
    padding: 0.75rem;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 1em;
    transition: all 0.2s ease;
    background: #ffffff;
}

.acf-cpt-filter-input:focus,
.acf-cpt-filter-select:focus {
    outline: none;
    border-color: #9333ea;
    box-shadow: 0 0 0 3px rgba(147, 51, 234, 0.1);
}

.acf-cpt-filter-input::placeholder {
    color: #a0aec0;
}

.acf-cpt-filter-select {
    min-height: 42px;
}

.acf-cpt-filter-select[multiple] {
    min-height: 100px;
    padding: 0.5rem;
}

/* Toggle principale (livello 1) */
.acf-cpt-filter-main-toggle-wrapper {
    margin-bottom: 0;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
}

.acf-cpt-filter-main-toggle {
    padding: 0.5rem;
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    flex-shrink: 0;
    margin-top: 2.0rem; /* Allinea con l'input */
    min-width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.acf-cpt-filter-main-toggle:hover {
    background: #edf2f7;
    border-color: #cbd5e0;
}

.acf-cpt-filter-main-toggle:focus {
    outline: none;
}

.acf-cpt-filter-main-toggle:focus-visible {
    outline: 2px solid #cbd5e0;
    outline-offset: 2px;
}

/* Rimuovi qualsiasi sfondo quando il toggle è aperto ma non in hover */
.acf-cpt-filter-main-toggle[aria-expanded="true"] {
    background: #f7fafc;
}

.acf-cpt-filter-main-toggle[aria-expanded="true"]:hover {
    background: #edf2f7;
}

.acf-cpt-filter-main-toggle-icon {
    color: #718096;
    font-size: 0.9em;
    transition: transform 0.3s ease;
}

/* Campo ricerca principale */
.acf-cpt-filter-search {
    margin-bottom: 0;
    flex: 1;
}

.acf-cpt-filter-search input {
    font-size: 1.1em;
    padding: 1rem;
}

/* Pulsante Cerca: solo su mobile (desktop usa ricerca automatica) */
.acf-cpt-filter-apply {
    display: none;
}

/* Wrapper sezioni (livello 2) */
.acf-cpt-filter-sections-wrapper {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

/* Sezioni */
.acf-cpt-filter-section {
    padding: 0;
    background: #ffffff;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
}

/* Sezioni collassabili */
.acf-cpt-filter-collapsible {
    padding: 0;
    overflow: hidden;
    margin-bottom: 0.75rem;
}

.acf-cpt-filter-section-toggle {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    background: transparent;
    border: none;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s ease;
    border-radius: 6px;
}

.acf-cpt-filter-section-toggle:hover {
    background: #f7fafc;
}

.acf-cpt-filter-section-toggle:focus {
    outline: none;
}

.acf-cpt-filter-section-toggle:focus-visible {
    outline: 2px solid #cbd5e0;
    outline-offset: 2px;
}

/* Rimuovi qualsiasi sfondo quando il toggle è aperto ma non in hover */
.acf-cpt-filter-section-toggle[aria-expanded="true"] {
    background: transparent;
}

.acf-cpt-filter-section-toggle[aria-expanded="true"]:hover {
    background: #f7fafc;
}

.acf-cpt-filter-section-title {
    margin: 0;
    font-size: 1em;
    font-weight: 600;
    color: #2d3748;
    flex: 1;
}

.acf-cpt-filter-toggle-icon {
    color: #718096;
    font-size: 0.85em;
    transition: transform 0.3s ease;
    margin-left: 1rem;
    flex-shrink: 0;
}

.acf-cpt-filter-section-content {
    padding: 1rem 1.5rem;
    padding-top: 0.75rem;
    background: #ffffff;
}

/* Range inputs */
.acf-cpt-filter-range {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.acf-cpt-filter-range-input {
    flex: 1;
    min-width: 120px;
}

.acf-cpt-filter-range-separator {
    color: #718096;
    font-weight: 600;
}

.acf-cpt-filter-range-info {
    width: 100%;
    font-size: 0.85em;
    color: #718096;
    margin-top: 0.25rem;
}

/* Date range */
.acf-cpt-filter-date-range {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.acf-cpt-filter-date-input {
    flex: 1;
    min-width: 150px;
}

/* Checkbox */
.acf-cpt-filter-checkbox-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 4px;
    transition: background 0.2s ease;
}

.acf-cpt-filter-checkbox-label:hover {
    background: #f7fafc;
}

.acf-cpt-filter-checkbox {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

/* Azioni */
.acf-cpt-filter-actions {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid #e2e8f0;
}

.acf-cpt-filter-reset {
    padding: 0.75rem 1.5rem;
    background: #718096;
    color: #ffffff;
    border: none;
    border-radius: 6px;
    font-size: 1em;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.acf-cpt-filter-reset:hover {
    background: #4a5568;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.acf-cpt-filter-reset:active {
    transform: translateY(0);
}

/* Loading */
.acf-cpt-filter-loading {
    text-align: center;
    padding: 1rem;
    color: #9333ea;
    font-weight: 600;
}

.acf-cpt-filter-loading i {
    margin-right: 0.5rem;
    font-size: 1.2em;
}

/* Risultati */
.acf-cpt-filter-results {
    margin-top: 1rem;
    padding: 0.75rem 1rem;
    background: #edf2f7;
    border-radius: 6px;
    font-size: 0.95em;
    color: #2d3748;
    text-align: center;
}

.acf-cpt-filter-results-count {
    font-weight: 700;
    color: #9333ea;
}

/* Errori */
.acf-cpt-filter-error {
    padding: 1rem;
    background: #fed7d7;
    color: #c53030;
    border-radius: 6px;
    border-left: 4px solid #c53030;
}

/* Responsive */
@media (max-width: 768px) {
    .acf-cpt-filter-wrapper {
        padding: 15px;
        margin-bottom:15px;
    }
    
    .acf-cpt-filter-section {
        padding: 1rem;
    }
    
    .acf-cpt-filter-range,
    .acf-cpt-filter-date-range {
        flex-direction: column;
        align-items: stretch;
    }
    
    .acf-cpt-filter-range-separator {
        display: none;
    }
    
    /* Su mobile mostra il pulsante Cerca (ricerca solo al tap); input + bottone sulla stessa riga */
    .acf-cpt-filter-search {
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        gap: 0.5rem;
    }
    
    .acf-cpt-filter-search label {
        width: 100%;
    }
    
    .acf-cpt-filter-search .acf-cpt-filter-input {
        flex: 1;
        min-width: 0;
    }
    
    .acf-cpt-filter-apply {
        display: inline-flex;
        align-items: center;
        gap: 0.5rem;
        padding: 0.75rem 1rem;
        background: #9333ea;
        color: #fff;
        border: none;
        border-radius: 6px;
        font-size: 1em;
        font-weight: 600;
        cursor: pointer;
        flex-shrink: 0;
    }
    
    .acf-cpt-filter-apply:hover {
        background: #7e22ce;
    }
}
