/* 
 * CSS para Sistema de Filtros
 * Portal Agregador Brasil
 */

/* ==============================================
   FILTROS GERAIS
   ============================================== */
.filter-form {
    background: white;
    border-radius: 1rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    border: 1px solid #e9ecef;
}

.filter-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 1rem 1rem 0 0;
}

.filter-header h6 {
    margin: 0;
    font-weight: 700;
    color: #212529;
}

.filter-body {
    padding: 1.5rem;
}

.filter-section {
    margin-bottom: 2rem;
}

.filter-section:last-child {
    margin-bottom: 0;
}

.filter-section-title {
    font-size: 0.9rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #e9ecef;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ==============================================
   INPUTS CUSTOMIZADOS
   ============================================== */
.custom-range-input {
    position: relative;
    margin: 1rem 0;
}

.range-labels {
    display: flex;
    justify-content: space-between;
    margin-top: 0.5rem;
    font-size: 0.875rem;
    color: #6c757d;
}

.price-range-container {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.price-input {
    flex: 1;
    min-width: 0;
}

.price-separator {
    color: #6c757d;
    font-weight: 500;
}

/* Inputs de preço melhorados */
.price-input-group {
    display: flex;
    align-items: center;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 0.5rem;
    padding: 0.5rem;
}

.price-input-group .currency {
    color: #6c757d;
    font-weight: 500;
    margin-right: 0.5rem;
    font-size: 0.875rem;
}

.price-input-group input {
    border: none;
    background: transparent;
    outline: none;
    width: 100%;
    font-weight: 500;
}

.price-input-group:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb), 0.25);
}

/* ==============================================
   CHECKBOXES E RADIOS CUSTOMIZADOS
   ============================================== */
.custom-checkbox,
.custom-radio {
    display: block;
    position: relative;
    padding-left: 2rem;
    margin-bottom: 0.75rem;
    cursor: pointer;
    font-size: 0.9rem;
    line-height: 1.5;
    color: #495057;
}

.custom-checkbox input,
.custom-radio input {
    position: absolute;
    opacity: 0;
    cursor: pointer;
}

.checkbox-mark,
.radio-mark {
    position: absolute;
    top: 0.125rem;
    left: 0;
    height: 1.25rem;
    width: 1.25rem;
    background-color: #f8f9fa;
    border: 2px solid #dee2e6;
    border-radius: 0.25rem;
    transition: all 0.3s ease;
}

.radio-mark {
    border-radius: 50%;
}

.custom-checkbox:hover input ~ .checkbox-mark,
.custom-radio:hover input ~ .radio-mark {
    border-color: var(--primary);
}

.custom-checkbox input:checked ~ .checkbox-mark,
.custom-radio input:checked ~ .radio-mark {
    background-color: var(--primary);
    border-color: var(--primary);
}

.checkbox-mark:after,
.radio-mark:after {
    content: "";
    position: absolute;
    display: none;
}

.custom-checkbox input:checked ~ .checkbox-mark:after {
    display: block;
    left: 0.25rem;
    top: 0.125rem;
    width: 0.375rem;
    height: 0.625rem;
    border: solid white;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.custom-radio input:checked ~ .radio-mark:after {
    display: block;
    top: 0.25rem;
    left: 0.25rem;
    width: 0.5rem;
    height: 0.5rem;
    border-radius: 50%;
    background: white;
}

/* ==============================================
   TAGS DE FILTROS ATIVOS
   ============================================== */
.active-filters {
    margin-bottom: 1.5rem;
}

.active-filters-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
}

.filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.filter-tag {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--primary);
    color: white;
    padding: 0.375rem 0.75rem;
    border-radius: 1.5rem;
    font-size: 0.875rem;
    font-weight: 500;
    text-decoration: none;
    transition: all 0.3s ease;
}

.filter-tag:hover {
    background: var(--primary-dark);
    color: white;
    text-decoration: none;
}

.filter-tag .remove-filter {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    width: 1rem;
    height: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.filter-tag .remove-filter:hover {
    background-color: rgba(255, 255, 255, 0.2);
}

/* ==============================================
   BOTÕES DE AÇÃO
   ============================================== */
.filter-actions {
    display: flex;
    gap: 0.75rem;
    padding-top: 1.5rem;
    border-top: 1px solid #e9ecef;
}

.filter-actions .btn {
    flex: 1;
    font-weight: 600;
}

.btn-apply-filters {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
}

.btn-apply-filters:hover {
    background: var(--primary-dark);
    border-color: var(--primary-dark);
}

.btn-clear-filters {
    background: transparent;
    border-color: #dee2e6;
    color: #6c757d;
}

.btn-clear-filters:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
}

/* ==============================================
   FILTROS AVANÇADOS (MODAL/DROPDOWN)
   ============================================== */
.advanced-filters {
    display: none;
    margin-top: 1rem;
    padding: 1rem;
    background: #f8f9fa;
    border-radius: 0.5rem;
    border: 1px solid #e9ecef;
}

.advanced-filters.show {
    display: block;
    animation: slideDown 0.3s ease;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.advanced-filters-toggle {
    background: none;
    border: none;
    color: var(--primary);
    font-size: 0.875rem;
    font-weight: 600;
    padding: 0.5rem 0;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    width: 100%;
    justify-content: center;
}

.advanced-filters-toggle:hover {
    color: var(--primary-dark);
}

.advanced-filters-toggle i {
    transition: transform 0.3s ease;
}

.advanced-filters-toggle.active i {
    transform: rotate(180deg);
}

/* ==============================================
   FILTROS DE LOCALIZAÇÃO
   ============================================== */
.location-filters {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
}

.location-search {
    position: relative;
    grid-column: 1 / -1;
}

.location-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #dee2e6;
    border-top: none;
    border-radius: 0 0 0.5rem 0.5rem;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    z-index: 1000;
    max-height: 200px;
    overflow-y: auto;
    display: none;
}

.location-suggestions.show {
    display: block;
}

.location-suggestion {
    padding: 0.75rem;
    cursor: pointer;
    border-bottom: 1px solid #f8f9fa;
    transition: background-color 0.3s ease;
}

.location-suggestion:hover {
    background-color: #f8f9fa;
}

.location-suggestion:last-child {
    border-bottom: none;
}

/* ==============================================
   SLIDER PERSONALIZADO PARA PREÇOS
   ============================================== */
.price-slider-container {
    margin: 1.5rem 0;
}

.price-slider {
    position: relative;
    height: 6px;
    background: #e9ecef;
    border-radius: 3px;
    margin: 1rem 0;
}

.price-slider-track {
    position: absolute;
    height: 100%;
    background: var(--primary);
    border-radius: 3px;
}

.price-slider-thumb {
    position: absolute;
    width: 20px;
    height: 20px;
    background: var(--primary);
    border: 3px solid white;
    border-radius: 50%;
    cursor: grab;
    top: -7px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    transition: transform 0.2s ease;
}

.price-slider-thumb:hover {
    transform: scale(1.2);
}

.price-slider-thumb:active {
    cursor: grabbing;
    transform: scale(1.3);
}

.price-values {
    display: flex;
    justify-content: space-between;
    margin-top: 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
}

.price-values .min-price {
    color: var(--success);
}

.price-values .max-price {
    color: var(--danger);
}

/* ==============================================
   FILTROS QUICK (TAGS RÁPIDAS)
   ============================================== */
.quick-filters {
    margin-bottom: 1.5rem;
}

.quick-filters-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #495057;
    margin-bottom: 0.75rem;
}

.quick-filter-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.quick-filter-tag {
    padding: 0.375rem 0.75rem;
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 1.5rem;
    font-size: 0.875rem;
    color: #495057;
    text-decoration: none;
    transition: all 0.3s ease;
    cursor: pointer;
}

.quick-filter-tag:hover,
.quick-filter-tag.active {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    text-decoration: none;
}

/* ==============================================
   FILTROS MOBILE
   ============================================== */
.mobile-filters {
    display: none;
}

.mobile-filter-button {
    width: 100%;
    background: var(--primary);
    border: none;
    color: white;
    padding: 1rem;
    border-radius: 0.75rem;
    font-weight: 600;
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.filter-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1040;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.filter-overlay.show {
    opacity: 1;
    visibility: visible;
}

.filter-modal {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-radius: 1rem 1rem 0 0;
    max-height: 80vh;
    overflow-y: auto;
    z-index: 1050;
    transform: translateY(100%);
    transition: transform 0.3s ease;
}

.filter-modal.show {
    transform: translateY(0);
}

.filter-modal-header {
    padding: 1.5rem;
    border-bottom: 1px solid #e9ecef;
    background: #f8f9fa;
    border-radius: 1rem 1rem 0 0;
    position: sticky;
    top: 0;
    z-index: 10;
}

.filter-modal-title {
    margin: 0;
    font-weight: 700;
}

.filter-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    padding: 0;
    width: 2rem;
    height: 2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #6c757d;
}

.filter-modal-body {
    padding: 1.5rem;
}

.filter-modal-footer {
    padding: 1.5rem;
    border-top: 1px solid #e9ecef;
    background: #f8f9fa;
    position: sticky;
    bottom: 0;
}

/* ==============================================
   RESPONSIVIDADE
   ============================================== */
@media (max-width: 991px) {
    .desktop-filters {
        display: none;
    }
    
    .mobile-filters {
        display: block;
    }
    
    .filter-actions {
        flex-direction: column;
    }
    
    .location-filters {
        grid-template-columns: 1fr;
    }
    
    .quick-filter-tags {
        justify-content: center;
    }
    
    .filter-tags {
        justify-content: center;
    }
}

@media (max-width: 576px) {
    .price-range-container {
        flex-direction: column;
        gap: 0.5rem;
        align-items: stretch;
    }
    
    .price-separator {
        text-align: center;
        padding: 0.5rem 0;
    }
    
    .quick-filter-tag {
        padding: 0.5rem 1rem;
        font-size: 0.8rem;
    }
}

/* ==============================================
   ANIMAÇÕES
   ============================================== */
.filter-form {
    animation: fadeInUp 0.5s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.filter-tag {
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

/* ==============================================
   ESTADOS ESPECIAIS
   ============================================== */
.filter-loading {
    pointer-events: none;
    opacity: 0.6;
}

.filter-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.no-results-message {
    text-align: center;
    padding: 2rem;
    color: #6c757d;
    font-style: italic;
}

.filter-results-count {
    background: var(--primary);
    color: white;
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    font-weight: 600;
    margin-bottom: 1rem;
    text-align: center;
}

/* ==============================================
   ACESSIBILIDADE
   ============================================== */
.filter-form:focus-within {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.custom-checkbox:focus-within .checkbox-mark,
.custom-radio:focus-within .radio-mark {
    box-shadow: 0 0 0 0.2rem rgba(var(--primary-rgb), 0.25);
}

.quick-filter-tag:focus {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

@media (prefers-reduced-motion: reduce) {
    .filter-form,
    .filter-tag,
    .advanced-filters,
    .filter-modal {
        animation: none;
        transition: none;
    }
}