/* Hanna Hierarchical AJAX Filter - Frontend */
.hhaf-filter-widget {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 1.25rem;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}

.hhaf-filter-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1rem;
    gap: 0.75rem;
}

.hhaf-filter-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    color: #111827;
}

.hhaf-clear-btn {
    background: transparent;
    border: 1px solid #d1d5db;
    color: #374151;
    font-size: 0.8rem;
    padding: 0.35rem 0.7rem;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.hhaf-clear-btn:hover {
    background: #f3f4f6;
    border-color: #9ca3af;
}

.hhaf-filter-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.hhaf-field-group {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.hhaf-field-label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #374151;
    text-transform: uppercase;
    letter-spacing: 0.025em;
}

.hhaf-select {
    appearance: none;
    -webkit-appearance: none;
    background: #ffffff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%236b7280' viewBox='0 0 16 16'%3E%3Cpath d='M1.646 4.646a.5.5 0 0 1 .708 0L8 10.293l5.646-5.647a.5.5 0 0 1 .708.708l-6 6a.5.5 0 0 1-.708 0l-6-6a.5.5 0 0 1 0-.708z'/%3E%3C/svg%3E") no-repeat right 0.75rem center;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    padding: 0.55rem 2.25rem 0.55rem 0.75rem;
    font-size: 0.95rem;
    color: #111827;
    cursor: pointer;
    width: 100%;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.hhaf-select:hover,
.hhaf-select:focus {
    border-color: #2563eb;
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.hhaf-select:disabled {
    background-color: #f3f4f6;
    color: #9ca3af;
    cursor: not-allowed;
}

.hhaf-options-list {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    max-height: 220px;
    overflow-y: auto;
    padding-right: 4px;
}

.hhaf-options-list::-webkit-scrollbar {
    width: 6px;
}

.hhaf-options-list::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

.hhaf-option {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.45rem 0.3rem;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.15s ease;
    font-size: 0.92rem;
    color: #374151;
}

.hhaf-option:hover {
    background: #f3f4f6;
}

.hhaf-option input[type="checkbox"] {
    width: 1rem;
    height: 1rem;
    accent-color: #2563eb;
    cursor: pointer;
    flex-shrink: 0;
}

.hhaf-option-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    cursor: pointer;
}

.hhaf-option-count {
    background: #e5e7eb;
    color: #4b5563;
    font-size: 0.75rem;
    padding: 0.15rem 0.45rem;
    border-radius: 9999px;
    flex-shrink: 0;
}

.hhaf-status {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: #6b7280;
    min-height: 1.2em;
}

.hhaf-loading .hhaf-status::before {
    content: "";
    display: inline-block;
    width: 0.9rem;
    height: 0.9rem;
    margin-right: 0.4rem;
    border: 2px solid #e5e7eb;
    border-top-color: #2563eb;
    border-radius: 50%;
    animation: hhaf-spin 0.8s linear infinite;
    vertical-align: middle;
}

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

.hhaf-results-loading {
    opacity: 0.55;
    pointer-events: none;
    transition: opacity 0.2s ease;
}

.hhaf-level-group[data-hhaf-parent="0"] {
    order: 1;
}

.hhaf-dynamic-levels {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Grilla AJAX de respaldo para mantener las columnas de Elementor/WooCommerce. */
.elementor-widget-wc-archive-products .products,
.hhaf-results-fallback .products {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    list-style: none;
    padding: 0;
    margin: 0;
}

@media (max-width: 768px) {
    .elementor-widget-wc-archive-products .products,
    .hhaf-results-fallback .products {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .elementor-widget-wc-archive-products .products,
    .hhaf-results-fallback .products {
        grid-template-columns: 1fr;
    }
}

.hhaf-result-count {
    margin-top: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.hhaf-view-results {
    display: inline-block;
    margin-top: 0.5rem;
    padding: 0.45rem 0.9rem;
    background: #2563eb;
    color: #fff;
    border: none;
    border-radius: 0.375rem;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s ease;
}

.hhaf-view-results:hover {
    background: #1d4ed8;
}

@media (max-width: 768px) {
    .hhaf-filter-widget {
        padding: 1rem;
    }

    .hhaf-filter-header {
        flex-wrap: wrap;
    }
}
