/* =================================
   LOADING SPINNER PARA IMÁGENES Y VIDEOS
   ================================= */

/* Wrapper de loading */
.media-loading-wrapper {
    position: relative;
    display: block;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border-radius: 8px;
    overflow: hidden;
}

/* Spinner loading */
.media-loading-wrapper::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin-loader 1s linear infinite;
    z-index: 10;
    pointer-events: none;
}

/* Emoji loading */
.media-loading-wrapper::after {
    content: '⏳';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    z-index: 11;
    opacity: 0.6;
    animation: pulse-emoji 1.5s ease-in-out infinite;
    pointer-events: none;
}

@keyframes spin-loader {
    0% { transform: translate(-50%, -50%) rotate(0deg); }
    100% { transform: translate(-50%, -50%) rotate(360deg); }
}

@keyframes pulse-emoji {
    0%, 100% { transform: translate(-50%, -50%) scale(1); opacity: 0.5; }
    50% { transform: translate(-50%, -50%) scale(1.2); opacity: 0.8; }
}

/* Ocultar spinner cuando está cargado */
.media-loading-wrapper.loaded::before,
.media-loading-wrapper.loaded::after {
    display: none;
}

/* Imagen/video dentro del wrapper */
.media-loading-wrapper img,
.media-loading-wrapper video {
    opacity: 0;
    transition: opacity 0.3s ease-in-out;
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.media-loading-wrapper.loaded img,
.media-loading-wrapper.loaded video {
    opacity: 1;
}

/* Mantener el scroll effect en producto-imagen */
.producto-imagen .media-loading-wrapper {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.producto-imagen .media-loading-wrapper img,
.producto-imagen .media-loading-wrapper video {
    transition: object-position 0.8s ease-in-out, opacity 0.3s ease-in-out;
    position: absolute;
    top: 0;
    left: 0;
}

/* Tamaños específicos */
.producto-card .media-loading-wrapper {
    min-height: 200px;
}

.coleccion-card .media-loading-wrapper {
    min-height: 250px;
    position: relative;
}

.coleccion-card .media-loading-wrapper img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: left center;
}

.coleccion-card .media-loading-wrapper.loaded img {
    transition: object-position 0.8s ease-in-out, opacity 0.3s ease-in-out;
}

.galeria-miniatura .media-loading-wrapper {
    min-height: 80px;
}

.galeria-miniatura .media-loading-wrapper::before {
    width: 30px;
    height: 30px;
    border-width: 3px;
}

.galeria-miniatura .media-loading-wrapper::after {
    font-size: 1rem;
}

/* Responsive */
@media (max-width: 768px) {
    .media-loading-wrapper::before {
        width: 40px;
        height: 40px;
    }
    
    .media-loading-wrapper::after {
        font-size: 1.2rem;
    }
}

/* ==========================================
   LOADING ESPECÍFICO PARA COLECCIONES
   ========================================== */

.coleccion-imagen-container.coleccion-loading {
    position: relative;
    min-height: 250px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.coleccion-imagen-container.coleccion-loading::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 50px;
    height: 50px;
    border: 4px solid #e2e8f0;
    border-top: 4px solid #667eea;
    border-radius: 50%;
    animation: spin-loader 1s linear infinite;
    z-index: 10;
    pointer-events: none;
}

.coleccion-imagen-container.coleccion-loading::after {
    content: '⏳';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 1.5rem;
    z-index: 11;
    opacity: 0.6;
    animation: pulse-emoji 1.5s ease-in-out infinite;
    pointer-events: none;
}

/* Ocultar contenido mientras carga */
.coleccion-imagen-container.coleccion-loading > * {
    opacity: 0;
}

/* Mostrar contenido cuando está cargado */
.coleccion-imagen-container.coleccion-loaded > * {
    opacity: 1;
    transition: opacity 0.3s ease-in-out;
}

/* Ocultar spinner cuando está cargado */
.coleccion-imagen-container.coleccion-loaded::before,
.coleccion-imagen-container.coleccion-loaded::after {
    display: none;
}
