/* Lazy Loading Styles */

/* Base styles for lazy loading images */
.lazy-load {
    transition: opacity 0.3s ease-in-out, filter 0.3s ease-in-out;
}

/* Placeholder state - slightly blurred and dimmed */
.lazy-load:not(.loaded) {
    filter: blur(2px) brightness(0.9);
    opacity: 0.8;
}

/* Loaded state - clear and full opacity */
.lazy-load.loaded {
    filter: none;
    opacity: 1;
}

/* Loading animation for placeholder */
.lazy-load:not(.loaded)::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: shimmer 1.5s infinite;
    pointer-events: none;
    z-index: 1;
}

/* Shimmer animation */
@keyframes shimmer {
    0% {
        transform: translateX(-100%);
    }
    100% {
        transform: translateX(100%);
    }
}

/* Ensure parent container has relative positioning for shimmer effect */
.product-card .relative {
    position: relative;
    overflow: hidden;
}

/* Fade-in animation for newly loaded images */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.lazy-load.fade-in {
    animation: fadeIn 0.5s ease-in-out;
}

/* Responsive placeholder sizing */
.lazy-load[src*="placeholder-product.svg"] {
    background-color: #f3f4f6;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

/* Error state styling */
.lazy-load.error {
    background-color: #fee2e2;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23ef4444'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-2.5L13.732 4c-.77-.833-1.964-.833-2.732 0L4.082 16.5c-.77.833.192 2.5 1.732 2.5z'%3E%3C/path%3E%3C/svg%3E");
    background-size: 24px 24px;
    background-repeat: no-repeat;
    background-position: center;
}

/* Preload optimization */
.lazy-load {
    will-change: opacity, filter;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    .lazy-load {
        transition: none;
    }
    
    .lazy-load:not(.loaded)::before {
        animation: none;
    }
    
    .lazy-load.fade-in {
        animation: none;
    }
}