/* Estilos para el frontend del plugin Mosaico de Imágenes */

/* Contenedor principal del mosaico */
.mosaic-container {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin: 20px 0;
    line-height: 0;
    overflow: hidden;
}

.mosaic-item {
    flex-grow: 1;
    height: 250px;
    position: relative;
    overflow: hidden;
}

.mosaic-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Efecto hover en desktop */
.mosaic-item:hover img {
    transform: scale(1.05);
}

/* Overlay sutil en hover */
.mosaic-item::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0);
    transition: background 0.3s ease;
    z-index: 1;
    pointer-events: none;
}

.mosaic-item:hover::before {
    background: rgba(0, 0, 0, 0.1);
}

/* Responsive - Tablet: 4 columnas */
@media (max-width: 1024px) and (min-width: 769px) {
    .mosaic-container {
        display: grid;
        grid-template-columns: repeat(4, 1fr);
        gap: 6px;
        height: auto;
    }
    
    .mosaic-item {
        height: 150px; /* 50% de la altura original */
        flex-grow: 0;
        flex-basis: auto;
    }
}

/* Responsive - Mobile: 3 columnas */
@media (max-width: 768px) {
    .mosaic-container {
        display: grid;
        grid-template-columns: repeat(3, 1fr);
        gap: 4px;
        height: auto;
        margin: 15px 0;
    }
    
    .mosaic-item {
        height: 120px; /* 40% de la altura original */
        flex-grow: 0;
        flex-basis: auto;
    }
    
    /* Deshabilitar hover en mobile */
    .mosaic-item:hover img {
        transform: none;
    }
    
    .mosaic-item:hover::before {
        background: rgba(0, 0, 0, 0);
    }
}

/* Responsive - Mobile muy pequeño: 2 columnas */
@media (max-width: 480px) {
    .mosaic-container {
        grid-template-columns: repeat(2, 1fr);
        gap: 3px;
        margin: 10px 0;
    }
    
    .mosaic-item {
        height: 100px; /* Aún más pequeñas */
    }
}

/* Lightbox modal */
.mosaic-lightbox {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
    animation: fadeIn 0.3s ease;
}

.mosaic-lightbox.active {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

/* Imagen del lightbox */
.mosaic-lightbox img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    animation: zoomIn 0.3s ease;
}

/* Botón de cerrar */
.mosaic-close {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 40px;
    font-weight: bold;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 1000000;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

.mosaic-close:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

/* Controles de navegación del lightbox (para futuras mejoras) */
.mosaic-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.5);
    color: white;
    border: none;
    padding: 15px;
    cursor: pointer;
    font-size: 24px;
    transition: all 0.3s ease;
    border-radius: 4px;
}

.mosaic-nav:hover {
    background: rgba(0, 0, 0, 0.8);
}

.mosaic-prev {
    left: 20px;
}

.mosaic-next {
    right: 20px;
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes zoomIn {
    from {
        transform: scale(0.8);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

/* Loading para imágenes */
.mosaic-item.loading {
    background: #f5f5f5;
    position: relative;
}

.mosaic-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid #ddd;
    border-top: 2px solid #0073aa;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Mensaje cuando no hay imágenes */
.mosaic-empty {
    text-align: center;
    padding: 40px 20px;
    color: #666;
    font-style: italic;
    background: #f9f9f9;
    border-radius: 8px;
    margin: 20px 0;
}

/* Responsive para lightbox */
@media (max-width: 768px) {
    .mosaic-close {
        font-size: 30px;
        top: 15px;
        right: 15px;
        width: 50px;
        height: 50px;
    }
    
    .mosaic-lightbox {
        padding: 10px;
    }
    
    .mosaic-lightbox img {
        max-width: 95%;
        max-height: 95%;
    }
    
    .mosaic-nav {
        padding: 10px;
        font-size: 20px;
    }
    
    .mosaic-prev {
        left: 10px;
    }
    
    .mosaic-next {
        right: 10px;
    }
}

@media (max-width: 480px) {
    .mosaic-close {
        font-size: 24px;
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
    }
    
    .mosaic-lightbox {
        padding: 5px;
    }
    
    .mosaic-nav {
        display: none; /* Ocultar navegación en móviles muy pequeños */
    }
}

/* Estados especiales */
.mosaic-container.loading {
    opacity: 0.7;
    pointer-events: none;
}

/* Accesibilidad */
.mosaic-item img[alt=""],
.mosaic-item img:not([alt]) {
    outline: 2px solid #dc3232;
    outline-offset: 2px;
}

/* Focus para teclado */
.mosaic-item img:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

.mosaic-close:focus {
    outline: 3px solid #0073aa;
    outline-offset: 2px;
}

/* Print styles */
@media print {
    .mosaic-lightbox {
        display: none !important;
    }
    
    .mosaic-container {
        display: block;
    }
    
    .mosaic-item {
        display: inline-block;
        width: 48%;
        height: auto;
        margin: 1%;
        break-inside: avoid;
    }
    
    .mosaic-item img {
        width: 100%;
        height: auto;
    }
}