/**
 * Frontend CSS for ACF Advanced Filters
 *
 * BEM methodology for modular styles.
 */

/* Main wrapper */
.acf-filters-wrapper {
    display: block;
    width: 100%;
    margin: 0 0 2rem 0;
    padding: 1.5rem;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Layout variants */
.acf-filters-wrapper[data-layout="horizontal"] .acf-filters-form {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-end;
    gap: 1rem;
}

.acf-filters-wrapper[data-layout="vertical"] .acf-filters-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.acf-filters-wrapper[data-layout="sidebar"] {
    position: sticky;
    top: 20px;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
}

/* Form */
.acf-filters-form {
    width: 100%;
}

/* Filter fields */
.acf-filter-field {
    display: flex;
    flex-direction: column;
    margin-bottom: 1rem;
    flex: 1 1 auto;
    min-width: 200px;
}

.acf-filter-field__label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    font-size: 0.875rem;
    color: #333;
}

.acf-filter-field input[type="text"],
.acf-filter-field input[type="search"],
.acf-filter-field input[type="number"],
.acf-filter-field input[type="date"],
.acf-filter-field select,
.acf-filter-field textarea {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9375rem;
    font-family: inherit;
    background: #fff;
    transition: border-color 0.3s ease;
}

.acf-filter-field input:focus,
.acf-filter-field select:focus,
.acf-filter-field textarea:focus {
    outline: none;
    border-color: #0073aa;
    box-shadow: 0 0 0 2px rgba(0, 115, 170, 0.1);
}

.acf-filter-field input[type="checkbox"],
.acf-filter-field input[type="radio"] {
    width: auto;
    margin-right: 0.5rem;
}

/* Checkbox and radio groups */
.acf-filter-field__options {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.acf-filter-field__options--horizontal {
    flex-direction: row;
    flex-wrap: wrap;
}

.acf-filter-field__option {
    display: flex;
    align-items: center;
}

.acf-filter-field__option-label {
    margin-left: 0.5rem;
    cursor: pointer;
}

/* Buttons */
.acf-filter-button,
.acf-filter-reset {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 4px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    text-decoration: none;
    display: inline-block;
}

.acf-filter-button {
    background: #0073aa;
    color: #fff;
}

.acf-filter-button:hover {
    background: #005a87;
    color: #fff;
}

.acf-filter-reset {
    background: #f0f0f0;
    color: #333;
}

.acf-filter-reset:hover {
    background: #e0e0e0;
    color: #333;
}

.acf-filters-wrapper[data-layout="horizontal"] .acf-filters-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

/* Results count */
.acf-results-count {
    margin: 1rem 0 0 0;
    padding: 0.75rem;
    background: #f8f9fa;
    border-radius: 4px;
    font-size: 0.875rem;
    color: #666;
    text-align: center;
}

/* Loading state */
.acf-filters-wrapper.acf-filters-loading {
    position: relative;
    opacity: 0.7;
    pointer-events: none;
}

.acf-filter-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
}

.acf-filter-spinner {
    display: inline-block;
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #0073aa;
    border-radius: 50%;
    animation: acf-spin 1s linear infinite;
}

@keyframes acf-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Error message */
.acf-filter-error {
    padding: 0.75rem 1rem;
    margin-bottom: 1rem;
    background: #fee;
    border: 1px solid #fcc;
    border-radius: 4px;
    color: #c33;
    font-size: 0.875rem;
}

/* Responsive */
@media (max-width: 768px) {
    .acf-filters-wrapper[data-layout="horizontal"] .acf-filters-form {
        flex-direction: column;
    }

    .acf-filter-field {
        min-width: 100%;
    }

    .acf-filters-wrapper[data-layout="horizontal"] .acf-filters-actions {
        flex-direction: column;
        width: 100%;
    }

    .acf-filter-button,
    .acf-filter-reset {
        width: 100%;
    }
}

/* Skeleton loader */
.acf-filter-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: acf-skeleton-loading 1.5s ease-in-out infinite;
    border-radius: 4px;
    height: 40px;
    margin-bottom: 0.5rem;
}

@keyframes acf-skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* Elementor compatibility */
.elementor-widget-acf-advanced-filters .acf-filters-wrapper {
    margin: 0;
}

.elementor-widget-acf-advanced-filters.acf-filtering {
    opacity: 0.7;
    pointer-events: none;
}

