/**
 * Estilos para Lazy Loading de Imágenes
 */

/* Placeholder mientras carga */
.lazy-placeholder {
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e0e0e0 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: lazy-shimmer 1.5s ease-in-out infinite;
    min-height: 200px;
    object-fit: cover;
}

/* Animación de shimmer */
@keyframes lazy-shimmer {
    0% {
        background-position: -200% 0;
    }
    100% {
        background-position: 200% 0;
    }
}

/* Estado de carga */
.lazy-loading {
    opacity: 0.6;
    filter: blur(5px);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

/* Imagen cargada */
.lazy-loaded {
    animation: lazy-fade-in 0.4s ease-in-out;
    opacity: 1;
    filter: none;
}

/* Animación de aparición */
@keyframes lazy-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Error al cargar */
.lazy-error {
    background: #fee;
    border: 2px dashed #f88;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #c66;
    font-size: 14px;
    min-height: 200px;
}

.lazy-error::before {
    content: '⚠️';
    font-size: 48px;
    display: block;
}

/* Skeleton específico para productos */
.product-image-skeleton {
    aspect-ratio: 1 / 1;
    width: 100%;
    background: linear-gradient(
        90deg,
        #f0f0f0 0%,
        #e8e8e8 20%,
        #f0f0f0 40%,
        #f0f0f0 100%
    );
    background-size: 200% 100%;
    animation: lazy-shimmer 1.5s ease-in-out infinite;
    border-radius: 0.5rem;
}

/* Optimización para dark mode (si se implementa) */
@media (prefers-color-scheme: dark) {
    .lazy-placeholder,
    .product-image-skeleton {
        background: linear-gradient(
            90deg,
            #2a2a2a 0%,
            #333 20%,
            #2a2a2a 40%,
            #2a2a2a 100%
        );
    }
    
    .lazy-error {
        background: #3a1a1a;
        border-color: #a44;
        color: #d88;
    }
}

/* Reducir animaciones si el usuario lo prefiere */
@media (prefers-reduced-motion: reduce) {
    .lazy-placeholder,
    .product-image-skeleton {
        animation: none;
        background: #f0f0f0;
    }
    
    .lazy-loaded {
        animation: none;
    }
    
    .lazy-loading {
        filter: none;
    }
}

/* Estilos específicos para tamaños de imagen */
.lazy-thumbnail {
    min-height: 100px;
}

.lazy-small {
    min-height: 150px;
}

.lazy-medium {
    min-height: 250px;
}

.lazy-large {
    min-height: 400px;
}

/* Aspecto 1:1 para productos */
.lazy-square {
    aspect-ratio: 1 / 1;
    min-height: auto;
}

/* Aspecto 16:9 para banners */
.lazy-wide {
    aspect-ratio: 16 / 9;
    min-height: auto;
}

/* Contenedor de imagen con placeholder */
.lazy-image-container {
    position: relative;
    overflow: hidden;
    background: #f5f5f5;
}

.lazy-image-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #666;
    border-radius: 50%;
    animation: lazy-spinner 0.8s linear infinite;
}

@keyframes lazy-spinner {
    to {
        transform: translate(-50%, -50%) rotate(360deg);
    }
}
