/* ==============================================
   ENHANCED SEARCH AUTOCOMPLETE
   ============================================== */

.search-suggestions {
    font-family: 'Vazir', sans-serif;
    border: 1px solid #e0e0e0;
    border-top: none;
    border-radius: 0 0 8px 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    background: white;
    z-index: 1000;
    max-height: 300px;
    overflow-y: auto;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    display: none;
}

.suggestion-item {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s ease;
}

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

.suggestion-item:hover,
.suggestion-item.active {
    background-color: #f8f9fa !important;
}

.suggestion-item i {
    color: #00A693;
    width: 16px;
    text-align: center;
    flex-shrink: 0;
}

.suggestion-item span {
    flex: 1;
    font-size: var(--ds-text-sm);
    color: #333;
}

.suggestion-item small {
    color: #666;
    font-size: var(--ds-text-xs);
    flex-shrink: 0;
}

/* Search input enhancements */
.sheet-search-container {
    position: relative;
}

.filter-section input[name="search"] {
    position: relative;
}

/* Mobile search suggestions positioning */
@media (max-width: 768px) {
    .search-suggestions {
        position: fixed !important;
        left: 16px !important;
        right: 16px !important;
        top: auto !important;
        max-width: calc(100vw - 32px);
        border-radius: 8px;
        border: 1px solid #e0e0e0;
        margin-top: 4px;
        z-index: 99998;
    }
    
    .sheet-search-container .search-suggestions {
        position: absolute !important;
        left: 0 !important;
        right: 0 !important;
        max-width: 100%;
        margin-top: 0;
    }
}

/* Enhanced search input styling */
.enhanced-search-input {
    border-radius: 8px !important;
    border: 2px solid #e0e0e0 !important;
    transition: border-color 0.2s ease !important;
}

.enhanced-search-input:focus {
    border-color: #00A693 !important;
    box-shadow: 0 0 0 3px rgba(0, 166, 147, 0.1) !important;
}

/* Search loading indicator */
.search-loading {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: #00A693;
    font-size: var(--ds-text-sm);
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: translateY(-50%) rotate(0deg); }
    to { transform: translateY(-50%) rotate(360deg); }
}

/* ==============================================
   ENHANCED FILTER UI COMPONENTS
   ============================================== */

/* Sort Options */
.sort-options {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 12px;
}

.sort-label {
    font-size: var(--ds-text-sm);
    font-weight: 600;
    color: #333;
    white-space: nowrap;
}

.sort-select {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: var(--ds-text-sm);
    color: #333;
    background: white;
    font-family: 'Vazir', sans-serif;
    cursor: pointer;
    transition: border-color 0.2s ease;
}

.sort-select:focus {
    outline: none;
    border-color: #00A693;
    box-shadow: 0 0 0 2px rgba(0, 166, 147, 0.1);
}

/* Enhanced Quick Filter Chips */
.quick-filter-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* Desktop Quick Filter Buttons */
.quick-filter-btn {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 6px 16px;
    font-size: var(--ds-text-sm);
    font-weight: 500;
    color: #666;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Vazir', sans-serif;
    position: relative;
    overflow: hidden;
}

.quick-filter-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s ease;
}

.quick-filter-btn:hover::before {
    left: 100%;
}

.quick-filter-btn:hover {
    background: #f0f0f0;
    border-color: #00A693;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 166, 147, 0.15);
}

.quick-filter-btn.active {
    background: #00A693;
    color: white;
    border-color: #00A693;
    box-shadow: 0 2px 8px rgba(0, 166, 147, 0.3);
}

.quick-filter-btn.active:hover {
    background: #008f7d;
    transform: translateY(-1px);
}

/* Navbar Quick Filter Buttons */
.navbar-quick-filter-btn {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 1px solid #dee2e6;
    border-radius: 8px;
    padding: 6px 12px;
    font-size: var(--ds-text-xs);
    font-weight: 600;
    color: #495057;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: 'Vazir', sans-serif;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    position: relative;
    overflow: hidden;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    /* WCAG 2.5.8: 44 minimum tap target even if the desktop strip ever
       surfaces on mobile (e.g. stale SW shell without utilities.css). */
    min-height: 44px;
}

.navbar-quick-filter-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.6), transparent);
    transition: left 0.6s ease;
}

.navbar-quick-filter-btn:hover::before {
    left: 100%;
}

.navbar-quick-filter-btn:hover {
    background: linear-gradient(135deg, #e9ecef 0%, #dee2e6 100%);
    border-color: #00A693;
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 166, 147, 0.15);
    color: #00A693;
}

.navbar-quick-filter-btn.active {
    background: linear-gradient(135deg, #00A693 0%, #008f7d 100%);
    color: white;
    border-color: #00A693;
    box-shadow: 0 8px 25px rgba(0, 166, 147, 0.3);
    transform: translateY(-1px);
}

.navbar-quick-filter-btn.active:hover {
    background: linear-gradient(135deg, #008f7d 0%, #007a6b 100%);
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(0, 166, 147, 0.4);
}

.navbar-quick-filter-btn i {
    font-size: var(--ds-text-xs);
    transition: transform 0.2s ease;
}

.navbar-quick-filter-btn:hover i {
    transform: scale(1.1);
}

.navbar-quick-filter-btn.active i {
    color: white;
}

.quick-filter-chips::-webkit-scrollbar {
    display: none;
}

.quick-chip {
    background: #f5f5f5;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 8px 16px;
    font-size: var(--ds-text-sm);
    font-weight: 500;
    color: #666;
    white-space: nowrap;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: 'Vazir', sans-serif;
    position: relative;
    overflow: hidden;
}

.quick-chip::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    transition: left 0.5s ease;
}

.quick-chip:hover::before {
    left: 100%;
}

.quick-chip:hover {
    background: #f0f0f0;
    border-color: #00A693;
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 166, 147, 0.15);
}

.quick-chip.active {
    background: #00A693;
    color: white;
    border-color: #00A693;
    box-shadow: 0 2px 8px rgba(0, 166, 147, 0.3);
}

.quick-chip.active:hover {
    background: #008f7d;
    transform: translateY(-1px);
}

/* Filter Group Enhancements */
.filter-group {
    background: white;
    border: 1px solid #f0f0f0;
    border-radius: 8px;
    padding: 16px;
    transition: all 0.2s ease;
}

.filter-group:hover {
    border-color: #e0e0e0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

.filter-label {
    font-size: var(--ds-text-sm);
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-label::before {
    content: '';
    width: 3px;
    height: 16px;
    background: #00A693;
    border-radius: 2px;
}

/* Enhanced Price Range Inputs */
.price-range-inputs {
    display: flex;
    align-items: center;
    gap: 12px;
}

.price-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    font-size: var(--ds-text-sm);
    text-align: center;
    font-family: 'Vazir', sans-serif;
    transition: all 0.2s ease;
}

.price-input:focus {
    outline: none;
    border-color: #00A693;
    box-shadow: 0 0 0 2px rgba(0, 166, 147, 0.1);
    transform: scale(1.02);
}

.price-input::placeholder {
    color: #999;
    font-size: var(--ds-text-sm);
}

/* Range Separator */
.range-separator {
    font-size: var(--ds-text-sm);
    color: #666;
    font-weight: 500;
    padding: 0 4px;
}

/* Loading States */
.filter-loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.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 #00A693;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Mobile Responsive Enhancements */
@media (max-width: 768px) {
    .sort-options {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }
    
    .sort-label {
        font-size: var(--ds-text-sm);
    }
    
    .sort-select {
        font-size: var(--ds-text-sm);
        padding: 10px 12px;
    }
    
    .quick-chip {
        font-size: var(--ds-text-sm);
        padding: 6px 12px;
    }
    
    .filter-group {
        padding: 12px;
    }
    
    .price-input {
        font-size: var(--ds-text-sm);
        padding: 8px 10px;
    }
}

/* ==============================================
   LAZY LOADING AND PERFORMANCE OPTIMIZATIONS
   ============================================== */

/* Lazy loading background images */
.lazy-bg {
    background-color: #f5f5f5;
    background-image: linear-gradient(45deg, #f0f0f0 25%, transparent 25%), 
                      linear-gradient(-45deg, #f0f0f0 25%, transparent 25%), 
                      linear-gradient(45deg, transparent 75%, #f0f0f0 75%), 
                      linear-gradient(-45deg, transparent 75%, #f0f0f0 75%);
    background-size: 20px 20px;
    background-position: 0 0, 0 10px, 10px -10px, -10px 0px;
    animation: loading-shimmer 1.5s ease-in-out infinite;
    transition: all 0.3s ease;
}

.lazy-bg.lazy-loaded {
    background-image: var(--loaded-bg) !important;
    animation: fade-in 0.3s ease-in-out;
}

.lazy-bg.lazy-error {
    background-color: #f8f9fa;
    background-image: none;
}

@keyframes loading-shimmer {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

@keyframes fade-in {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Performance optimizations */
.mobile-property-card {
    will-change: transform;
    transform: translateZ(0); /* Enable hardware acceleration */
}

.mobile-property-card:hover {
    will-change: transform, box-shadow;
}

/* Skeleton loading for property cards */
/* 3D Tour Label */
.mobile-card-3d-tour {
    position: absolute;
    bottom: 8px;
    left: 8px;
    background: linear-gradient(135deg, #FF6B35, #E85A2B);
    color: white;
    padding: 4px 8px;
    border-radius: 12px;
    font-size: var(--ds-text-xs);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 4px;
    box-shadow: 0 2px 8px rgba(255, 107, 53, 0.3);
    z-index: 2;
}

.mobile-card-3d-tour i {
    font-size: var(--ds-text-xs);
}

.property-skeleton {
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 16px;
    animation: pulse 1.5s ease-in-out infinite;
}

.skeleton-image {
    height: 200px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}

.skeleton-content {
    padding: 16px;
}

.skeleton-line {
    height: 16px;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
    border-radius: 4px;
    margin-bottom: 8px;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.medium {
    width: 80%;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

@keyframes shimmer {
    0% { background-position: -200% 0; }
    100% { background-position: 200% 0; }
}

/* Optimized scrolling */
.property-cards-container {
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .lazy-bg,
    .mobile-property-card,
    .quick-chip,
    .suggestion-item {
        animation: none !important;
        transition: none !important;
    }
    
    .mobile-property-card:hover {
        transform: none !important;
    }
}
