/* Search Container con responsividad completa */
.search-container {
    padding: 1rem; /* Padding reducido en móviles */
    margin-bottom: 1rem;
    background: var(--glass-background);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(166, 215, 222, 0.2);
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.08);
}

@media (min-width: 576px) {
    .search-container {
        padding: 1.25rem;
    }
}

@media (min-width: 768px) {
    .search-container {
        padding: 1.5rem;
    }
}

/* MLS Search Section adaptable */
.mls-search-section {
    margin-bottom: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(0,0,0,0.1);
}

@media (min-width: 576px) {
    .mls-search-section {
        margin-bottom: 1.25rem;
        padding-bottom: 1.25rem;
    }
}

@media (min-width: 768px) {
    .mls-search-section {
        margin-bottom: 1.5rem;
        padding-bottom: 1.5rem;
    }
}

.mls-search-container {
    position: relative;
    display: flex;
    gap: 0.75rem;
    align-items: center;
}

.mls-search-input {
    flex: 1;
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    background: white;
    min-height: 44px; /* Altura mínima para mejor toque */
}

.mls-search-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 110, 109, 0.1);
}

.mls-search-icon {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

/* Filter Sections adaptativas */
.filter-row {
    display: flex;
    flex-direction: column; /* Columna en móviles */
    gap: 0.75rem;
    align-items: stretch;
}

@media (min-width: 576px) {
    .filter-row {
        flex-direction: row; /* Fila en tablets y superiores */
        gap: 1rem;
        align-items: flex-end;
        flex-wrap: wrap;
    }
}

.filter-group {
    width: 100%; /* Ancho completo en móviles */
    position: relative;
}

@media (min-width: 576px) {
    .filter-group {
        flex: 1;
        min-width: 180px;
    }
}

.filter-group label {
    display: block;
    font-size: 0.875rem;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-weight: 500;
}

.filter-select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    background: white;
    appearance: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-primary);
    transition: all 0.3s ease;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='%23999' viewBox='0 0 16 16'%3E%3Cpath d='M7.247 11.14L2.451 5.658C1.885 5.013 2.345 4 3.204 4h9.592a1 1 0 0 1 .753 1.659l-4.796 5.48a1 1 0 0 1-1.506 0z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: calc(100% - 1rem) center;
    background-size: 12px;
    padding-right: 2.5rem;
    min-height: 44px; /* Altura mínima para mejor toque */
}

.filter-select:hover {
    border-color: var(--primary-color);
}

.filter-select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(166, 215, 222, 0.2);
}

/* Search Buttons adaptables */
.search-buttons {
    display: flex;
    flex-direction: column; /* Columna en móviles */
    gap: 0.75rem;
    margin-top: 1.25rem;
}

@media (min-width: 576px) {
    .search-buttons {
        flex-direction: row; /* Fila en tablets y superiores */
        gap: 1rem;
        margin-top: 1.5rem;
    }
}

.search-btn,
.clear-all-filters {
    width: 100%; /* Ancho completo en móviles */
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px; /* Altura mínima para mejor toque */
}

@media (min-width: 576px) {
    .search-btn,
    .clear-all-filters {
        flex: 1;
        min-width: 120px;
    }
}

.search-btn {
    background: var(--primary-color);
    color: white;
    border: none;
}

@media (hover: hover) {
    .search-btn:hover {
        background: var(--primary-dark);
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(0, 110, 109, 0.2);
    }
}

.clear-all-filters {
    background: transparent;
    border: 1px solid var(--danger-color);
    color: var(--danger-color);
}

@media (hover: hover) {
    .clear-all-filters:hover {
        background: var(--danger-color);
        color: white;
        transform: translateY(-2px);
        box-shadow: 0 4px 12px rgba(194, 166, 99, 0.2);
    }
}

/* Advanced Filters Toggle optimizado */
.advanced-filters-toggle {
    margin-top: 1rem;
    border-top: 1px solid rgba(0,0,0,0.1);
    padding-top: 1rem;
}

.toggle-btn {
    width: 100%;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    padding: 0.75rem;
    border-radius: 4px;
    transition: all 0.3s ease;
    min-height: 44px; /* Altura mínima para mejor toque */
}

@media (hover: hover) {
    .toggle-btn:hover {
        color: var(--primary-color);
        background: rgba(166, 215, 222, 0.1);
    }
}

.advanced-filters {
    display: none;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(0,0,0,0.1);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.advanced-filters.show {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

/* Additional Filters Styling adaptativo */
.filter-section {
    background: rgba(255, 255, 255, 0.6);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
}

@media (min-width: 576px) {
    .filter-section {
        padding: 1.25rem;
        margin-bottom: 1.5rem;
    }
}

.filter-section h4 {
    font-family: 'Playfair Display', serif;
    color: var(--primary-dark);
    margin-bottom: 1rem;
    font-size: 1rem;
    border-bottom: 2px solid var(--secondary-color);
    padding-bottom: 0.5rem;
}

@media (min-width: 576px) {
    .filter-section h4 {
        font-size: 1.1rem;
        margin-bottom: 1.25rem;
    }
}

.filter-grid {
    display: grid;
    grid-template-columns: repeat(1, 1fr); /* Una columna en móviles pequeños */
    gap: 0.75rem;
}

@media (min-width: 375px) {
    .filter-grid {
        grid-template-columns: repeat(2, 1fr); /* Dos columnas en móviles más grandes */
    }
}

@media (min-width: 576px) {
    .filter-grid {
        grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); /* Columnas automáticas en tablets y superiores */
        gap: 1rem;
    }
}

.feature-checkbox {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(255, 255, 255, 0.5);
    border: 1px solid rgba(0, 0, 0, 0.05);
    min-height: 44px; /* Altura mínima para mejor toque */
}

@media (hover: hover) {
    .feature-checkbox:hover {
        background: rgba(0, 110, 109, 0.05);
        transform: translateY(-2px);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05);
    }
}

.feature-checkbox input[type="checkbox"] {
    width: 20px; /* Ligeramente más grande para mejor toque */
    height: 20px;
    border: 2px solid var(--secondary-color);
    border-radius: 4px;
    cursor: pointer;
    accent-color: var(--primary-color);
}

.feature-checkbox span {
    font-size: 0.9rem;
    color: var(--text-primary);
    font-weight: 500;
}

/* Active Filters Display optimizado */
.active-filters {
    padding: 1rem;
    margin-bottom: 1rem;
    background: var(--glass-background);
    border-radius: 12px;
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    opacity: 0;
    transform: translateY(-10px);
    transition: all 0.3s ease;
}

.active-filters.show {
    opacity: 1;
    transform: translateY(0);
}

.active-filters h6 {
    margin: 0;
    color: var(--text-secondary);
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
}

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

.filter-tag {
    background: rgba(0, 110, 109, 0.1);
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    animation: fadeInUp 0.3s ease forwards;
}

@media (hover: hover) {
    .filter-tag:hover {
        background: rgba(0, 110, 109, 0.15);
    }
}

.remove-filter {
    background: none;
    border: none;
    color: var(--danger-color);
    padding: 0;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    opacity: 0.7;
    width: 24px; /* Área de toque más grande */
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: opacity 0.3s ease, transform 0.3s ease;
}

@media (hover: hover) {
    .remove-filter:hover {
        opacity: 1;
        transform: scale(1.1);
    }
}

/* Price Range Select with Toggle optimizado */
.price-range-group {
    position: relative;
}

.price-select-container {
    display: flex;
    align-items: center;
    position: relative;
    width: 100%;
}

.filter-select.price-range {
    width: 100%;
    padding-right: 40px;
}

.price-slider-toggle {
    position: absolute;
    right: 8px;
    background: transparent;
    border: none;
    color: var(--primary-color);
    width: 36px; /* Área de toque más grande */
    height: 36px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

@media (hover: hover) {
    .price-slider-toggle:hover {
        color: var(--primary-dark);
        transform: scale(1.1);
    }
}

/* Modal de precio adaptativo */
.price-slider-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 1050;
}

.price-slider-modal.show {
    display: flex;
}

.price-slider-content {
    background: white;
    padding: 1.5rem;
    border-radius: 12px;
    width: 95%;
    max-width: 600px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
}

@media (min-width: 576px) {
    .price-slider-content {
        padding: 2rem;
        width: 90%;
    }
}

.price-slider-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.price-slider-header h3 {
    margin: 0;
    font-size: 1.25rem;
    color: var(--primary-dark);
}

.close-slider {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 0.5rem;
    transition: color 0.3s ease, transform 0.3s ease;
    width: 40px; /* Área de toque más grande */
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

@media (hover: hover) {
    .close-slider:hover {
        color: var(--primary-dark);
        transform: rotate(90deg);
    }
}

/* Price Range Inputs and Slider adaptativo */
.price-range-container {
    padding: 0 0.5rem;
}

@media (min-width: 576px) {
    .price-range-container {
        padding: 0 1rem;
    }
}

.price-range-inputs {
    display: flex;
    flex-direction: column; /* Columna en móviles pequeños */
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (min-width: 480px) {
    .price-range-inputs {
        flex-direction: row; /* Fila en móviles más grandes */
        justify-content: space-between;
    }
}

.price-input-group {
    flex: 1;
}

.price-input-group label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    display: block;
}

.price-input {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid rgba(0,0,0,0.1);
    border-radius: 8px;
    font-size: 0.9rem;
    text-align: right;
    min-height: 44px; /* Altura mínima para mejor toque */
}

.price-slider {
    margin-bottom: 2rem;
}

/* NoUiSlider Custom Styles optimizados para táctil */
.noUi-target {
    background: rgba(0, 110, 109, 0.1);
    border: none;
    box-shadow: none;
    height: 6px; /* Ligeramente más grande para mejor toque */
    border-radius: 3px;
}

.noUi-connect {
    background: var(--primary-color);
}

.noUi-handle {
    border: 2px solid var(--primary-color);
    background: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    width: 24px !important; /* Más grande para mejor toque */
    height: 24px !important;
    border-radius: 50%;
    right: -12px !important;
    top: -10px !important;
    cursor: pointer;
    transition: transform 0.2s ease;
}

@media (hover: hover) {
    .noUi-handle:hover {
        transform: scale(1.1);
    }
}

.noUi-handle::before,
.noUi-handle::after {
    display: none;
}

.noUi-tooltip {
    font-size: 0.8rem;
    padding: 0.5rem;
    border: 1px solid var(--primary-color);
    background: white;
    color: var(--primary-color);
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    font-weight: 500;
}

/* Apply Range Button adaptativo */
.apply-price-range {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    min-height: 44px; /* Altura mínima para mejor toque */
    width: 100%; /* Ancho completo en móviles */
}

@media (min-width: 576px) {
    .apply-price-range {
        width: auto; /* Ancho automático en pantallas más grandes */
    }
}

@media (hover: hover) {
    .apply-price-range:hover {
        background: var(--primary-dark);
        transform: translateY(-2px);
    }
}

/* Price Slider Actions centrado */
.price-slider-actions {
    display: flex;
    justify-content: center;
    margin-top: 1rem;
}

/* Select Options Styling optimizado */
.filter-select option {
    padding: 8px 12px;
    font-size: 0.95rem;
}

.filter-select option[value^="all-"] {
    font-weight: 600;
    background-color: #f5f5f5;
    color: #006E6D;
    padding-top: 12px;
    padding-bottom: 12px;
}

.filter-select option[value^="-"] {
    padding-left: 24px;
    color: #666;
}

.filter-select option:not([value^="-"]):not(:first-child) {
    border-top: 1px solid #eee;
    margin-top: 8px;
}

@media (hover: hover) {
    .filter-select option:hover {
        background-color: rgba(0, 110, 109, 0.1);
    }
}

/* Funcionalidades de movilidad mejoradas */
@media (max-width: 767px) {
    .search-container {
        position: relative;
        max-height: 90vh;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
    }
    
    /* Botón fijo para expandir/colapsar filtros en móvil */
    .mobile-filters-toggle {
        position: fixed;
        bottom: 1rem;
        right: 1rem;
        width: 50px;
        height: 50px;
        background: var(--primary-color);
        color: white;
        border: none;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
        z-index: 900;
        cursor: pointer;
        font-size: 1.25rem;
    }
    
    .filters-collapsed .filter-row,
    .filters-collapsed .search-buttons,
    .filters-collapsed .advanced-filters-toggle {
        display: none;
    }
    
    .filters-collapsed .mobile-expand-text {
        display: block;
        text-align: center;
        padding: 0.5rem;
        color: var(--primary-color);
        cursor: pointer;
    }
    
    .mobile-expand-text {
        display: none;
    }
}

/* Animación para filtros activos */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Optimizaciones para dispositivos extra pequeños */
@media (max-width: 320px) {
    .search-container {
        padding: 0.75rem;
    }
    
    .mls-search-input {
        padding: 0.6rem 0.75rem 0.6rem 2.25rem;
        font-size: 0.9rem;
    }
    
    .filter-group label {
        font-size: 0.8rem;
    }
    
    .filter-select {
        padding: 0.6rem 0.75rem;
        font-size: 0.9rem;
    }
    
    .search-btn,
    .clear-all-filters {
        padding: 0.6rem 1rem;
    }
    
    .feature-checkbox {
        padding: 0.6rem;
        gap: 0.5rem;
    }
    
    .feature-checkbox span {
        font-size: 0.85rem;
    }
    
    .filter-tag {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* Adaptaciones para pantallas muy grandes */
@media (min-width: 1400px) {
    .search-container {
        padding: 2rem;
    }
    
    .filter-group label {
        font-size: 1rem;
    }
    
    .filter-select,
    .mls-search-input {
        padding: 0.85rem 1.25rem;
        font-size: 1rem;
    }
    
    .search-btn,
    .clear-all-filters {
        padding: 0.85rem 2rem;
        font-size: 1rem;
    }
    
    .filter-section h4 {
        font-size: 1.25rem;
    }
    
    .feature-checkbox span {
        font-size: 1rem;
    }
}

/* Adaptaciones de accesibilidad */
@media (prefers-reduced-motion: reduce) {
    .filter-select,
    .mls-search-input,
    .search-btn,
    .clear-all-filters,
    .advanced-filters,
    .feature-checkbox,
    .filter-tag,
    .active-filters,
    .noUi-handle {
        transition: none !important;
        animation: none !important;
    }
}

/* Soporte para modo oscuro */
@media (prefers-color-scheme: dark) {
    .search-container,
    .active-filters {
        background: rgba(34, 34, 34, 0.95);
        border-color: rgba(194, 166, 99, 0.2);
    }
    
    .filter-group label,
    .active-filters h6 {
        color: #bbb;
    }
    
    .mls-search-input,
    .filter-select,
    .price-input {
        background: #333;
        border-color: #555;
        color: #eee;
    }
    
    .filter-section {
        background: rgba(34, 34, 34, 0.8);
    }
    
    .filter-section h4 {
        color: var(--secondary-color);
    }
    
    .feature-checkbox {
        background: rgba(34, 34, 34, 0.6);
        border-color: #444;
    }
    
    .feature-checkbox span {
        color: #eee;
    }
    
    .toggle-btn {
        color: #bbb;
    }
    
    .price-slider-content {
        background: #222;
    }
    
    .price-slider-header h3 {
        color: var(--secondary-color);
    }
    
    .noUi-target {
        background: rgba(194, 166, 99, 0.2);
    }
    
    .noUi-tooltip {
        background: #333;
        color: var(--secondary-color);
        border-color: var(--secondary-color);
    }
}

/* Soporte para dispositivos de contraste alto */
@media (forced-colors: active) {
    .filter-select,
    .mls-search-input,
    .search-btn,
    .clear-all-filters,
    .feature-checkbox,
    .filter-tag {
        border: 1px solid CanvasText;
    }
    
    .noUi-target {
        border: 1px solid CanvasText;
    }
    
    .noUi-handle {
        border: 2px solid CanvasText;
    }
}