/* Performance Optimizations CSS */

/* Slick Carousel Performance */
.slick-slider {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

.slick-track {
    will-change: transform;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
}

.slick-slide {
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Smooth scrolling optimizations */
* {
    -webkit-overflow-scrolling: touch;
}

/* Reduce paint and layout thrashing */
.slick-slider img,
.slick-slider video {
    will-change: auto;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Optimize animations */
.slick-slider .slick-slide {
    transition: transform 0.3s ease;
    -webkit-transition: -webkit-transform 0.3s ease;
}

/* Prevent layout shifts */
.slick-slider {
    min-height: 200px; /* Adjust based on your content */
}

/* Touch action optimizations */
.slick-slider {
    touch-action: pan-y pinch-zoom;
    -ms-touch-action: pan-y pinch-zoom;
}

/* Reduce repaints on hover */
.slick-slider:hover {
    will-change: auto;
}

/* Optimize for mobile */
@media (max-width: 768px) {
    .slick-slider {
        -webkit-transform: translate3d(0, 0, 0);
        transform: translate3d(0, 0, 0);
    }
}

/* Video performance optimizations */
video {
    will-change: auto;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Image loading optimizations */
img {
    image-rendering: -webkit-optimize-contrast;
    image-rendering: optimize-contrast;
}

/* Lazy loading placeholder */
img[data-src] {
    background: #f8f9fa;
    min-height: 100px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .slick-slider,
    .slick-slide {
        transition: none !important;
        animation: none !important;
    }
}

/* GPU acceleration for common elements */
.header-ads,
.ads-banner,
.video-banner-container {
    will-change: auto;
    transform: translateZ(0);
    -webkit-transform: translateZ(0);
}

/* Optimize font rendering */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeSpeed;
}

/* Contain layout and paint */
.slick-slider {
    contain: layout style paint;
}

/* Optimize for high DPI displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    img {
        image-rendering: -webkit-optimize-contrast;
        image-rendering: crisp-edges;
    }
}
/* =
================================
   ADVANCED PERFORMANCE OPTIMIZATIONS
   ================================= */

/* Hardware-accelerated animations */
.fade-in {
    opacity: 0;
    transform: translateY(20px);
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1), 
                transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: opacity, transform;
}

.fade-in.visible {
    opacity: 1;
    transform: translateY(0);
}

/* Slide animations */
.slide-in-left {
    opacity: 0;
    transform: translateX(-30px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    will-change: opacity, transform;
}

.slide-in-left.visible {
    opacity: 1;
    transform: translateX(0);
}

.slide-in-right {
    opacity: 0;
    transform: translateX(30px);
    transition: opacity 0.4s ease, transform 0.4s ease;
    will-change: opacity, transform;
}

.slide-in-right.visible {
    opacity: 1;
    transform: translateX(0);
}

/* Scale animations */
.scale-in {
    opacity: 0;
    transform: scale(0.9);
    transition: opacity 0.3s ease, transform 0.3s ease;
    will-change: opacity, transform;
}

.scale-in.visible {
    opacity: 1;
    transform: scale(1);
}

/* Optimized hover effects */
.property-card {
    transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1), 
                box-shadow 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    will-change: transform, box-shadow;
    backface-visibility: hidden;
    transform: translateZ(0);
}

.property-card:hover {
    transform: translateY(-4px) translateZ(0);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

/* Button hover effects */
.btn-primary {
    transition: background-color 0.2s ease, transform 0.1s ease;
    will-change: background-color, transform;
}

.btn-primary:hover {
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

/* Loading states */
.loading {
    opacity: 0.6;
    pointer-events: none;
    position: relative;
}

.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 #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Spinner variations */
.spinner {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.spinner-sm {
    width: 16px;
    height: 16px;
    border-width: 1px;
}

.spinner-lg {
    width: 32px;
    height: 32px;
    border-width: 3px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Pulse loading */
.pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Enhanced image optimization */
img.loaded {
    opacity: 1;
}

img.loading {
    opacity: 0.5;
}

img.error {
    opacity: 0.5;
    filter: grayscale(100%);
    background: #f8f9fa url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="%23dee2e6"><path d="M21 19V5c0-1.1-.9-2-2-2H5c-1.1 0-2 .9-2 2v14c0 1.1.9 2 2 2h14c1.1 0 2-.9 2-2zM8.5 13.5l2.5 3.01L14.5 12l4.5 6H5l3.5-4.5z"/></svg>') center/50px no-repeat;
}

/* Responsive images */
.img-responsive {
    width: 100%;
    height: auto;
    object-fit: cover;
}

/* Image aspect ratios */
.aspect-ratio-16-9 {
    aspect-ratio: 16/9;
    object-fit: cover;
}

.aspect-ratio-4-3 {
    aspect-ratio: 4/3;
    object-fit: cover;
}

.aspect-ratio-1-1 {
    aspect-ratio: 1/1;
    object-fit: cover;
}

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200px 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: 4px;
}

.skeleton-text {
    height: 1em;
    margin-bottom: 0.5em;
}

.skeleton-text:last-child {
    margin-bottom: 0;
    width: 60%;
}

.skeleton-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
}

.skeleton-card {
    padding: 1rem;
    border: 1px solid #e9ecef;
    border-radius: 8px;
}

@keyframes skeleton-loading {
    0% { background-position: -200px 0; }
    100% { background-position: calc(200px + 100%) 0; }
}

/* Performance utilities */
.gpu-accelerated {
    transform: translateZ(0);
    backface-visibility: hidden;
    perspective: 1000px;
}

.contain-layout {
    contain: layout;
}

.contain-paint {
    contain: paint;
}

.contain-size {
    contain: size;
}

.will-change-transform {
    will-change: transform;
}

.will-change-opacity {
    will-change: opacity;
}

.will-change-scroll {
    will-change: scroll-position;
}

.animation-complete {
    will-change: auto;
}

/* Scroll performance */
html {
    scroll-behavior: smooth;
}

.scroll-snap-x {
    scroll-snap-type: x mandatory;
    overflow-x: auto;
}

.scroll-snap-y {
    scroll-snap-type: y mandatory;
    overflow-y: auto;
}

.scroll-snap-start {
    scroll-snap-align: start;
}

.scroll-snap-center {
    scroll-snap-align: center;
}

.hide-scrollbar {
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.hide-scrollbar::-webkit-scrollbar {
    display: none;
}

/* Mobile optimizations */
.tap-target {
    min-height: 44px;
    min-width: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.no-select {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}

.touch-scroll {
    -webkit-overflow-scrolling: touch;
    overflow-scrolling: touch;
}

/* Toast notifications */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: #fff;
    padding: 12px 20px;
    border-radius: 4px;
    transform: translateY(100px);
    opacity: 0;
    transition: transform 0.3s ease, opacity 0.3s ease;
    z-index: 9999;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

/* Search results */
#search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 4px 4px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.search-result-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-bottom: 1px solid #eee;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.search-result-item:hover {
    background-color: #f8f9fa;
}

.search-result-item img {
    width: 60px;
    height: 45px;
    object-fit: cover;
    border-radius: 4px;
    margin-right: 10px;
}

.result-content h4 {
    margin: 0 0 4px 0;
    font-size: 14px;
    font-weight: 600;
}

.result-content p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

.result-content .price {
    color: #007bff;
    font-weight: 600;
}

/* Enhanced accessibility and reduced motion */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
        scroll-behavior: auto !important;
    }
    
    .fade-in, .slide-in-left, .slide-in-right, .scale-in {
        opacity: 1;
        transform: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .skeleton {
        background: #000;
    }
    
    .loading::after {
        border-color: #000;
        border-top-color: #fff;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .skeleton {
        background: linear-gradient(90deg, #2d3748 25%, #4a5568 50%, #2d3748 75%);
    }
    
    img.error {
        filter: grayscale(100%) brightness(0.8);
    }
    
    .toast {
        background: #4a5568;
        color: #f7fafc;
    }
    
    #search-results {
        background: #2d3748;
        border-color: #4a5568;
        color: #f7fafc;
    }
    
    .search-result-item:hover {
        background-color: #4a5568;
    }
}

/* Print optimizations */
@media print {
    .no-print {
        display: none !important;
    }
    
    .loading, .skeleton {
        opacity: 1 !important;
        animation: none !important;
    }
    
    img[data-src] {
        opacity: 1 !important;
    }
}