/* 
  Skeleton Loading States
  This file contains all styles related to skeleton loaders across the application.
  Styles are organized by page and device type to avoid conflicts.
*/

/* ==========================================================================
   GLOBAL SKELETON ANIMATIONS & BASE STYLES
   ========================================================================== */

/* Shimmer animation for all skeletons */
@keyframes shimmer {
    0% {
        background-position: -800px 0;
    }
    100% {
        background-position: 800px 0;
    }
}

/* Base skeleton style */
.skeleton-base {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 800px 100%;
    animation: shimmer 1.5s linear infinite;
    border-radius: 4px;
}

/* ==========================================================================
   RESULTS PAGE SKELETON STYLES
   ========================================================================== */

/* Results Page - Grid Container (matches rns-flex-grid exactly) */
.rns-results-container .loading-skeleton {
    display: grid;
    column-gap: var(--rns-grid-column-gap-mobile, 1rem);
    row-gap: var(--rns-grid-row-gap-mobile, 1.5rem);
    width: 100%;
    grid-template-columns: repeat(1, 1fr);
}

/* Results Page - Responsive Grid (matches rns-flex-grid breakpoints exactly) */
@media (min-width: 576px) { 
    .rns-results-container .loading-skeleton { 
        grid-template-columns: repeat(2, 1fr); 
    } 
}
@media (min-width: 768px) { 
    .rns-results-container .loading-skeleton { 
        grid-template-columns: repeat(3, 1fr); 
        column-gap: var(--rns-grid-column-gap, 1rem);
        row-gap: var(--rns-grid-row-gap, 2rem);
    } 
}

/* ==========================================================================
   VIEW-MODE AWARE SKELETON GRID LOGIC (PARENT-BASED SELECTORS)
   ========================================================================== */

/* TILE VIEW - Full width grid (matches .rns-flex-grid.view-tiles) */
.rns-results-container .tiles.view-tiles .loading-skeleton {
    grid-template-columns: repeat(1, 1fr);
}
@media (min-width: 576px) { 
    .rns-results-container .tiles.view-tiles .loading-skeleton { 
        grid-template-columns: repeat(2, 1fr); 
    } 
}
@media (min-width: 768px) { 
    .rns-results-container .tiles.view-tiles .loading-skeleton { 
        grid-template-columns: repeat(3, 1fr); 
    } 
}
@media (min-width: 992px) { 
    .rns-results-container .tiles.view-tiles .loading-skeleton { 
        grid-template-columns: repeat(4, 1fr); 
    } 
}
@media (min-width: 1200px) { 
    .rns-results-container .tiles.view-tiles .loading-skeleton { 
        grid-template-columns: repeat(5, 1fr); 
    } 
}

/* SPLIT VIEW - Limited width grid (matches .rns-flex-grid.view-split) */
.rns-results-container .tiles.view-split .loading-skeleton {
    grid-template-columns: repeat(1, 1fr);
}
@media (min-width: 576px) { 
    .rns-results-container .tiles.view-split .loading-skeleton { 
        grid-template-columns: repeat(2, 1fr); 
    } 
}
@media (min-width: 768px) { 
    .rns-results-container .tiles.view-split .loading-skeleton { 
        grid-template-columns: repeat(2, 1fr); 
    } 
}
@media (min-width: 992px) { 
    .rns-results-container .tiles.view-split .loading-skeleton { 
        grid-template-columns: repeat(2, 1fr); 
    } 
}
@media (min-width: 1400px) { 
    .rns-results-container .tiles.view-split .loading-skeleton { 
        grid-template-columns: repeat(3, 1fr); 
    } 
}

/* MAP VIEW - Hidden skeleton (matches .rns-flex-grid.view-map) */
.rns-results-container .tiles.view-map .loading-skeleton {
    display: none;
}

/* ==========================================================================
   FALLBACK FOR LEGACY/UNKNOWN VIEW MODES
   ========================================================================== */

/* Default behavior for skeleton without parent view class - use tile view logic */
.rns-results-container .loading-skeleton {
    grid-template-columns: repeat(1, 1fr);
}
@media (min-width: 576px) { 
    .rns-results-container .loading-skeleton { 
        grid-template-columns: repeat(2, 1fr); 
    } 
}
@media (min-width: 768px) { 
    .rns-results-container .loading-skeleton { 
        grid-template-columns: repeat(3, 1fr); 
    } 
}
@media (min-width: 992px) { 
    .rns-results-container .loading-skeleton { 
        grid-template-columns: repeat(4, 1fr); 
    } 
}
@media (min-width: 1200px) { 
    .rns-results-container .loading-skeleton { 
        grid-template-columns: repeat(5, 1fr); 
    } 
}

/* Results Page - Individual Skeleton Tile (matches property-tile structure) */
.rns-results-container .skeleton-tile {
    background-color: #fff;
    border: 1px solid #e4e7ec;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0px 1px 3px 0px rgba(16, 24, 40, 0.1), 0px 1px 2px 0px rgba(16, 24, 40, 0.06);
    display: flex;
    flex-direction: column;
    min-height: 450px;
    position: relative;
    min-width: 0;
    width: 100%;
}

/* Results Page - Skeleton Image Container (matches img-slider-wrap) */
.rns-results-container .skeleton-tile .skeleton-image-container {
    position: relative;
    height: 300px;
    width: 100%;
    flex: 0 0 auto;
    background: #f8f9fa;
    overflow: hidden;
}

/* Results Page - Skeleton Image */
.rns-results-container .skeleton-tile .skeleton-image {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 2s ease-in-out infinite;
    border-radius: 0;
}

/* Results Page - Skeleton Content (matches results-tile-content) */
.rns-results-container .skeleton-tile .skeleton-content {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    flex: 1;
}

/* Results Page - Skeleton Title (matches results-tile-title) */
.rns-results-container .skeleton-tile .skeleton-title {
    height: 24px;
    width: 80%;
    margin-bottom: 8px;
    border-radius: 4px;
}

/* Results Page - Skeleton Details (matches results-tile-details) */
.rns-results-container .skeleton-tile .skeleton-details {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.rns-results-container .skeleton-tile .skeleton-detail-item {
    height: 16px;
    width: 70%;
    border-radius: 3px;
}

.rns-results-container .skeleton-tile .skeleton-detail-item:nth-child(2) {
    width: 60%;
}

.rns-results-container .skeleton-tile .skeleton-detail-item:nth-child(3) {
    width: 65%;
}

/* Results Page - Skeleton Footer (matches results-tile-footer) */
.rns-results-container .skeleton-tile .skeleton-footer {
    margin-top: auto;
    padding-top: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.rns-results-container .skeleton-tile .skeleton-price {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rns-results-container .skeleton-tile .skeleton-price-main {
    height: 20px;
    width: 100px;
    border-radius: 4px;
}

.rns-results-container .skeleton-tile .skeleton-price-sub {
    height: 14px;
    width: 80px;
    border-radius: 3px;
}

.rns-results-container .skeleton-tile .skeleton-arrow {
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

/* Results Page - Price Skeleton (for tiles with pricing) */
.rns-results-container .pricing-skeleton {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.rns-results-container .skeleton-line {
    height: 20px;
    width: 120px;
    border-radius: 4px;
}

.rns-results-container .skeleton-line-small {
    height: 14px;
    width: 80px;
    border-radius: 3px;
}

/* Results Page - Map Skeleton */
.rns-results-container .map-skeleton {
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: skeleton-shimmer 2s ease-in-out infinite;
    border-radius: 8px;
}

/* Results Page - Loading State for Individual Tiles */
.rns-results-container .loading-price {
    position: relative;
    overflow: hidden;
}

.rns-results-container .loading-price::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.1) 50%, transparent 100%);
    animation: shimmer 1.5s linear infinite;
    z-index: 1;
    pointer-events: none;
}

.rns-results-container .loading-price .price-section {
    opacity: 0.5;
}

/* Results Page - Apply shimmer to all skeleton elements */
.rns-results-container .skeleton-image,
.rns-results-container .skeleton-title,
.rns-results-container .skeleton-detail-item,
.rns-results-container .skeleton-price-main,
.rns-results-container .skeleton-price-sub,
.rns-results-container .skeleton-arrow,
.rns-results-container .map-skeleton,
.rns-results-container .skeleton-line,
.rns-results-container .skeleton-line-small {
    background: #f6f7f8;
    background-image: linear-gradient(to right, #f6f7f8 0%, #edeef1 20%, #f6f7f8 40%, #f6f7f8 100%);
    background-repeat: no-repeat;
    background-size: 800px 100%;
    animation: shimmer 1.5s linear infinite;
}

/* Results Page - Subtle skeleton shimmer animation */
@keyframes skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* ==========================================================================
   PROPERTY PAGE SKELETON STYLES
   ========================================================================== */

/* Property Page - Image Container Base */
.property-page .property-image-container {
    position: relative;
    width: 100%;
    height: 100%;
    display: block;
}

/* Property Page - Skeleton Overlay */
.property-page .property-skeleton-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--skeleton-bg, #f0f0f0);
    border-radius: 8px;
    z-index: 2;
    opacity: 1;
    transition: opacity 0.3s ease-out;
    pointer-events: none;
}

/* Property Page - Hide skeleton when image loads */
.property-page .property-skeleton-overlay[v-show="false"] {
    opacity: 0;
    pointer-events: none;
    z-index: 1;
}

/* Property Page - Skeleton Image Animation */
.property-page .property-skeleton-overlay .skeleton-image {
    width: 100%;
    height: 100%;
    background: linear-gradient(
        90deg,
        var(--skeleton-bg, #f0f0f0) 25%,
        var(--skeleton-shimmer, #e0e0e0) 50%,
        var(--skeleton-bg, #f0f0f0) 75%
    );
    background-size: 200% 100%;
    animation: property-skeleton-shimmer 1.5s infinite;
    border-radius: 8px;
    display: block;
}

/* Property Page - Skeleton Shimmer Animation */
@keyframes property-skeleton-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Property Page - Desktop Gallery Styles */
@media (min-width: 1000px) {
    /* Desktop Main Image Container */
    .property-page .main-image-container .property-image-container {
        height: 500px;
        border-radius: 12px;
        overflow: hidden;
        width: 100%;
    }

    /* Desktop Thumbnail Container */
    .property-page .thumbnail-item .property-image-container {
        height: 100%;
        border-radius: 8px;
        overflow: hidden;
        width: 100%;
    }

    /* Desktop Modal Image Container */
    .property-page .modal-image-container {
        height: 250px;
        border-radius: 8px;
        overflow: hidden;
        position: relative;
    }

    /* Hide mobile slider on desktop */
    .property-page .rns-slider-container.mobile-only {
        display: none !important;
    }

    /* Show desktop gallery on desktop */
    .property-page .image-gallery-section {
        display: grid !important;
        grid-template-columns: 2fr 1fr !important;
        gap: 1rem !important;
    }
}

/* Property Page - Modal Styles */
.property-page .modal-skeleton {
    background: var(--skeleton-bg, #f8f9fa);
    opacity: 0.8;
}

.property-page .modal-skeleton .skeleton-image {
    animation-duration: 1.3s;
}

/* Property Page - Modal Grid Layout */
.property-page .property-details-modal .image-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 16px;
    padding: 16px;
}

.property-page .property-details-modal .image-grid-item {
    aspect-ratio: 4/3;
}

/* Property Page - Modal Loading State */
.property-page .modal-loading-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 400px;
    color: #666;
}

.property-page .modal-loading-state .rns-spinner {
    margin-bottom: 16px;
}

.property-page .modal-loading-state p {
    margin: 0;
    font-size: 16px;
    color: #888;
}

/* Property Page - Staggered Animations */
.property-page .thumbnail-skeleton {
    animation-delay: 0.2s;
}

.property-page .thumbnail-skeleton:nth-child(2) {
    animation-delay: 0.4s;
}

.property-page .thumbnail-skeleton:nth-child(3) {
    animation-delay: 0.6s;
}

.property-page .image-grid-item:nth-child(1) .modal-skeleton {
    animation-delay: 0.1s;
}

.property-page .image-grid-item:nth-child(2) .modal-skeleton {
    animation-delay: 0.25s;
}

.property-page .image-grid-item:nth-child(3) .modal-skeleton {
    animation-delay: 0.4s;
}

.property-page .image-grid-item:nth-child(4) .modal-skeleton {
    animation-delay: 0.55s;
}

.property-page .image-grid-item:nth-child(5) .modal-skeleton {
    animation-delay: 0.7s;
}

.property-page .image-grid-item:nth-child(6) .modal-skeleton {
    animation-delay: 0.85s;
}

/* Property Page - Image Preloading States */
.property-page .modal-preload {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
}

.property-page .modal-preload[src] {
    opacity: 1;
}

.property-page .modal-image:not(.modal-preload) {
    opacity: 1;
    transition: opacity 0.2s ease-in-out;
}

/* ==========================================================================
   MOBILE STYLES (Consolidated at 999px)
   ========================================================================== */

@media (max-width: 999px) {
    /* Results Page - Mobile Tile Adjustments */
    .rns-results-container .skeleton-tile {
        min-height: 400px;
    }

    .rns-results-container .skeleton-tile .skeleton-image-container {
        height: 200px;
    }

    /* Property Page - Mobile Slider Container */
    .property-page .rns-slider-container.mobile-only .property-image-container {
        height: 275px;
        border-radius: 8px;
        overflow: hidden;
    }

    /* Property Page - Hide desktop gallery on mobile */
    .property-page .image-gallery-section {
        display: none !important;
    }

    /* Property Page - Show mobile slider on mobile */
    .property-page .rns-slider-container.mobile-only {
        display: block;
    }

    /* Property Page - Mobile Modal Image Container */
    .property-page .modal-image-container {
        height: 200px;
        border-radius: 8px;
        overflow: hidden;
        position: relative;
    }

    /* Property Page - Mobile Skeleton Animation */
    .property-page .property-skeleton-overlay .skeleton-image {
        animation-duration: 1.2s;
    }

    /* Property Page - Mobile Modal Grid */
    .property-page .property-details-modal .image-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 12px;
        padding: 12px;
    }
}

/* ==========================================================================
   REMOVED GENERIC STYLES
   ========================================================================== */

/* Removed: Generic skeleton styles that were causing conflicts */
/* Removed: Non-specific media queries */
/* Removed: Generic image skeleton styles */
/* Removed: Old price filtering styles */
/* Removed: Generic lazy loading styles */
/* Removed: Non-page-specific optimizations */
