/* Modern Property Filters Styles */

/* Filter Container */
.filter-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 30px;
    align-items: center;
}

/* Filter Button */
.filter-button {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-family: 'montserratmed', sans-serif;
    font-size: 13px;
    color: #333;
    cursor: pointer;
    transition: all 0.2s ease;
    text-transform: none;
    white-space: nowrap;
}

.filter-button:hover {
    border-color: #00527b;
    color: #00527b;
}

.filter-button.active {
    border-color: #00527b;
    color: #00527b;
    background: #f0f7fa;
}

.filter-button .arrow {
    width: 12px;
    height: 12px;
    transition: transform 0.2s ease;
}

.filter-button.active .arrow {
    transform: rotate(180deg);
}

/* Filter Wrapper - must be relative for dropdown positioning */
.filter-wrapper {
    position: relative;
    display: inline-block;
}

/* Filter Dropdown Overlay */
.filter-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    z-index: 10002 !important;
    min-width: 320px;
    max-width: 500px;
    padding: 24px;
    margin-top: 4px;
    pointer-events: auto !important;
}

.filter-dropdown.active {
    display: block !important;
    animation: fadeInDown 0.2s ease;
    pointer-events: auto !important;
}

.filter-dropdown.active * {
    visibility: visible !important;
}

.filter-dropdown.active .rooms-filter-content,
.filter-dropdown.active .rooms-range-selectors,
.filter-dropdown.active .rooms-select-wrapper,
.filter-dropdown.active .rooms-select {
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.filter-dropdown.active .property-type-item,
.filter-dropdown.active .property-type-grid {
    pointer-events: auto !important;
    z-index: 1;
}

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

.filter-dropdown-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #e0e0e0;
}

.filter-dropdown-title {
    font-family: 'montserratmed', sans-serif;
    font-size: 18px;
    color: #333;
    margin: 0;
}

.filter-dropdown-done {
    background: none;
    border: none;
    color: #00527b;
    font-family: 'montserratmed', sans-serif;
    font-size: 14px;
    cursor: pointer;
    padding: 4px 8px;
    transition: color 0.2s ease;
}

.filter-dropdown-done:hover {
    color: #003d5c;
}

/* Price Filter Styles */
.price-filter-content {
    width: 100%;
}

.price-histogram {
    width: 100%;
    height: 80px;
    margin-bottom: 20px;
    position: relative;
    display: flex;
    align-items: flex-end;
    gap: 2px;
    padding: 0 10px;
}

.histogram-bar {
    flex: 1;
    background: #e0e0e0;
    border-radius: 2px 2px 0 0;
    min-height: 4px;
    transition: background 0.2s ease;
}

.histogram-bar.active {
    background: #00527b;
}

.price-slider-container {
    position: relative;
    width: 100%;
    height: 40px;
    margin: 20px 0;
}

.price-slider-track {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 4px;
    background: #e0e0e0;
    transform: translateY(-50%);
    border-radius: 2px;
}

.price-slider-range {
    position: absolute;
    top: 50%;
    height: 4px;
    background: #00527b;
    transform: translateY(-50%);
    border-radius: 2px;
}

.price-slider-handle {
    position: absolute;
    top: 50%;
    width: 20px;
    height: 20px;
    background: #fff;
    border: 2px solid #00527b;
    border-radius: 50%;
    cursor: grab;
    transform: translate(-50%, -50%);
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
    transition: transform 0.1s ease;
}

.price-slider-handle:hover {
    transform: translate(-50%, -50%) scale(1.1);
}

.price-slider-handle:active {
    cursor: grabbing;
    transform: translate(-50%, -50%) scale(1.15);
}

.price-range-display {
    display: flex;
    justify-content: space-between;
    margin-top: 16px;
    font-family: 'montserrat', sans-serif;
    font-size: 14px;
    color: #666;
}

/* Property Type Grid */
.property-type-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 12px;
    margin-top: 16px;
}

.property-type-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fff;
    text-align: center;
    z-index: 1;
    pointer-events: auto !important;
}

.property-type-item:hover {
    border-color: #00527b;
    background: #f0f7fa;
}

.property-type-item.selected {
    border-color: #00527b;
    background: #00527b;
    color: #fff;
}

.property-type-item input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    pointer-events: none;
}

.property-type-icon {
    width: 32px;
    height: 32px;
    margin-bottom: 8px;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.property-type-item.selected .property-type-icon {
    opacity: 1;
    filter: brightness(0) invert(1);
}

.property-type-label {
    font-family: 'montserrat', sans-serif;
    font-size: 13px;
    margin-top: 4px;
}

.property-type-item.selected .property-type-label {
    color: #fff;
}

/* Rooms Filter */
.rooms-filter-content {
    width: 100%;
    display: block !important;
    visibility: visible !important;
    opacity: 1 !important;
}

.rooms-range-selectors {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    gap: 12px;
    margin-top: 16px;
    width: 100%;
    max-width: 350px;
}

.rooms-select-wrapper {
    flex: 0 1 auto;
    position: relative;
    min-width: 120px;
    max-width: 150px;
}

.rooms-select {
    width: 100%;
    min-width: 120px;
    max-width: 150px;
    height: 40px;
    padding: 10px 32px 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: 'montserrat', sans-serif;
    font-size: 14px;
    background: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: border-color 0.2s ease;
    display: block;
    box-sizing: border-box;
}

.rooms-select:hover {
    border-color: #00527b;
}

.rooms-select:focus {
    outline: none;
    border-color: #00527b;
}

.rooms-select-wrapper::after {
    content: '▼';
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    pointer-events: none;
    font-size: 10px;
    color: #666;
}

.rooms-dash {
    font-family: 'montserrat', sans-serif;
    font-size: 16px;
    color: #666;
}

/* Checkbox List Filters (Zonas, Desarrollos) */
.filter-checkbox-list {
    max-height: 300px;
    overflow-y: auto;
    margin-top: 16px;
}

.filter-checkbox-item {
    display: flex;
    align-items: center;
    padding: 10px 0;
    cursor: pointer;
    transition: background 0.2s ease;
    border-radius: 4px;
    padding-left: 8px;
    margin-left: -8px;
}

.filter-checkbox-item:hover {
    background: #f5f5f5;
}

.filter-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    margin-right: 12px;
    cursor: pointer;
    accent-color: #00527b;
}

.filter-checkbox-item label {
    font-family: 'montserrat', sans-serif;
    font-size: 14px;
    color: #333;
    cursor: pointer;
    margin: 0;
    flex: 1;
    text-transform: none;
}

/* Sort and Clear Filters */
.filter-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-left: auto;
}

.filter-sort-label {
    font-family: 'montserratmed', sans-serif;
    font-size: 13px;
    color: #333;
    white-space: nowrap;
}

.filter-sort {
    padding: 6px 32px 6px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-family: 'montserrat', sans-serif;
    font-size: 13px;
    background: #fff;
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    transition: border-color 0.2s ease;
}

.filter-sort:hover {
    border-color: #00527b;
}

.filter-clear {
    padding: 10px 20px;
    background: #00527b;
    border: none;
    border-radius: 6px;
    color: #fff;
    font-family: 'montserratmed', sans-serif;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease;
    white-space: nowrap;
}

.filter-clear:hover {
    background: #003d5c;
}

/* Mobile Filter Button */
.mobile-filter-button {
    display: none;
    width: 100%;
    padding: 12px 16px;
    background: #00527b;
    color: #fff;
    border: none;
    border-radius: 6px;
    font-family: 'montserratmed', sans-serif;
    font-size: 16px;
    cursor: pointer;
    margin-bottom: 16px;
    text-align: center;
    position: relative;
}

.mobile-filter-button::after {
    content: '▼';
    position: absolute;
    right: 16px;
    transition: transform 0.2s ease;
}

.mobile-filter-button.active::after {
    transform: rotate(180deg);
}

/* Mobile Filter Overlay */
.mobile-filter-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 10001;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

.mobile-filter-overlay.active {
    display: block;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.mobile-filter-sheet {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.3s ease;
    z-index: 10002;
    padding-bottom: 100px; /* Space for footer buttons */
}

.mobile-filter-overlay.active .mobile-filter-sheet {
    transform: translateY(0);
}

.mobile-filter-header {
    position: sticky;
    top: 0;
    background: #fff;
    padding: 20px;
    border-bottom: 1px solid #e0e0e0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 10;
    border-radius: 20px 20px 0 0;
}

.mobile-filter-header h2 {
    font-family: 'montserratmed', sans-serif;
    font-size: 20px;
    color: #333;
    margin: 0;
}

.mobile-filter-close {
    background: none;
    border: none;
    font-size: 24px;
    color: #666;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.mobile-filter-content {
    padding: 20px;
}

.mobile-filter-section {
    margin-bottom: 24px;
    border-bottom: 1px solid #e0e0e0;
    padding-bottom: 20px;
}

.mobile-filter-section:last-child {
    border-bottom: none;
}

.mobile-filter-section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0;
    cursor: pointer;
    user-select: none;
}

.mobile-filter-section-title {
    font-family: 'montserratmed', sans-serif;
    font-size: 16px;
    color: #333;
    margin: 0;
}

.mobile-filter-section-arrow {
    font-size: 12px;
    color: #666;
    transition: transform 0.2s ease;
}

.mobile-filter-section.expanded .mobile-filter-section-arrow {
    transform: rotate(180deg);
}

.mobile-filter-section-content {
    display: none;
    padding-top: 16px;
}

.mobile-filter-section.expanded .mobile-filter-section-content {
    display: block;
}

.mobile-filter-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #fff;
    padding: 16px 20px;
    border-top: 1px solid #e0e0e0;
    display: flex;
    gap: 12px;
    z-index: 10003;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

.mobile-filter-reset {
    flex: 1;
    padding: 12px;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-family: 'montserrat', sans-serif;
    font-size: 14px;
    color: #666;
    cursor: pointer;
    text-decoration: underline;
}

.mobile-filter-apply {
    flex: 2;
    padding: 12px;
    background: #00527b;
    border: none;
    border-radius: 6px;
    font-family: 'montserratmed', sans-serif;
    font-size: 16px;
    color: #fff;
    cursor: pointer;
}

.mobile-filter-apply:hover {
    background: #003d5c;
}

/* Responsive Design */
@media (max-width: 768px) {
    /* Hide desktop filters on mobile */
    .filter-container {
        display: none;
    }
    
    /* Show mobile filter button */
    .mobile-filter-button {
        display: block;
    }
    
    /* Mobile filter specific styles */
    .mobile-filter-section-content .property-type-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 8px;
    }
    
    .mobile-filter-section-content .rooms-range-selectors {
        flex-direction: column;
        gap: 12px;
    }
    
    .mobile-filter-section-content .rooms-select-wrapper {
        width: 100%;
    }
    
    .mobile-filter-section-content .filter-checkbox-list {
        max-height: 200px;
    }
    
    .price-slider-container {
        margin: 16px 0;
    }
    
    .price-histogram {
        height: 60px;
    }
}

@media (min-width: 769px) {
    /* Hide mobile filter on desktop */
    .mobile-filter-button,
    .mobile-filter-overlay {
        display: none !important;
    }
    
    /* Show desktop filters */
    .filter-container {
        display: flex;
    }
}

/* Overlay for closing dropdowns */
.filter-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 999;
    background: transparent;
    pointer-events: auto;
}

.filter-overlay.active {
    display: block;
    pointer-events: auto;
}

