/**
 * Lazy Loading Styles
 * Provides smooth transitions and loading states for images
 */

/* Base lazy image styles */
img.lazy {
    transition: opacity 0.4s ease-in-out, filter 0.4s ease-in-out;
}

/* Loading state - slight blur on placeholder */
img.lazy:not(.lazy-loaded) {
    filter: blur(2px);
    opacity: 0.8;
}

/* Loading animation */
img.lazy-loading {
    filter: blur(2px);
    opacity: 0.8;
}

/* Loaded state - sharp and full opacity */
img.lazy-loaded {
    filter: blur(0);
    opacity: 1;
    animation: fadeIn 0.4s ease-in-out;
}

@keyframes fadeIn {
    from {
        filter: blur(2px);
        opacity: 0.8;
    }
    to {
        filter: blur(0);
        opacity: 1;
    }
}

/* Error state */
img.lazy-error {
    opacity: 1;
    background: #f8f8f8;
    border: 1px solid #e0e0e0;
}

/* Loading animation */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Loading placeholder - can be used for blur-up effect */
img.lazy[data-placeholder] {
    filter: blur(10px);
    transform: scale(1.05);
    transition: filter 0.3s ease-in-out, transform 0.3s ease-in-out;
}

img.lazy-loaded {
    filter: blur(0);
    transform: scale(1);
}

/* Aspect ratio preservation */
.lazy-wrapper {
    position: relative;
    overflow: hidden;
    background: #f0f0f0;
}

.lazy-wrapper img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Common aspect ratios */
.lazy-wrapper.ratio-16-9 {
    padding-bottom: 56.25%;
}

.lazy-wrapper.ratio-4-3 {
    padding-bottom: 75%;
}

.lazy-wrapper.ratio-1-1 {
    padding-bottom: 100%;
}

/* Product image specific styles */
.product-image-lazy {
    min-height: 200px;
    background: #f8f9fa url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect width="100" height="100" fill="%23f0f0f0"/><path d="M50 30 L30 50 L40 50 L40 70 L60 70 L60 50 L70 50 Z" fill="%23ddd"/></svg>') center/60px no-repeat;
}

/* Gallery specific styles */
.gallery-lazy img.lazy {
    min-height: 150px;
    background: #f5f5f5;
}

/* Card image styles */
.card img.lazy {
    min-height: 120px;
}

/* Profile image styles */
.rounded-circle.lazy {
    background: #e9ecef;
}

/* Responsive loading */
@media (max-width: 768px) {
    /* Adjust root margin for mobile */
    img.lazy {
        transition-duration: 0.2s;
    }
}