/* ModelsGlaze Gallery Styles */

/* 
 * Thumbnails: dimensioni fluide (percentuali)
 * Layout masonry con colonne responsive
 * Le immagini mantengono le proporzioni con object-fit: contain
 * Sfondo nero per foto con aspect ratio diverse
 */

.mg-gallery-container {
    width: 100%;
    margin: 20px 0;
}

.mg-gallery-grid {
    display: grid;
    gap: 0;
    width: 100%;
}

/* Layout Masonry - Grid flessibile con colonne che si adattano automaticamente */
.mg-gallery-masonry .mg-gallery-grid {
    display: grid !important;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* Colonne auto-riempite, min 150px */
    gap: 0;
    width: 100%;
}

@media (max-width: 1200px) {
    .mg-gallery-masonry .mg-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* Colonne auto-riempite anche su tablet */
    }
}

@media (max-width: 768px) {
    .mg-gallery-masonry .mg-gallery-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 colonne mobile */
        gap: 0;
    }
    
    .mg-gallery-masonry .mg-gallery-item {
        width: 100%;
        min-width: unset;
        max-width: 100%;
    }
    
    .mg-gallery-masonry .mg-gallery-image {
        width: 100% !important;
        max-width: 100% !important;
        height: auto !important;
    }
    
    .mg-gallery-masonry .mg-gallery-image.mg-gallery-nsfw-placeholder {
        width: 100% !important;
        max-width: 100% !important;
        object-fit: cover !important;
        object-position: center !important;
    }
}

/* Layout Grid */
.mg-gallery-grid-layout .mg-gallery-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* Colonne auto-riempite, min 150px */
}

@media (max-width: 1200px) {
    .mg-gallery-grid-layout .mg-gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); /* Colonne auto-riempite anche su tablet */
    }
}

@media (max-width: 768px) {
    .mg-gallery-grid-layout .mg-gallery-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 colonne mobile */
    }
    
    .mg-gallery-grid-layout .mg-gallery-item,
    .mg-gallery-grid-layout .mg-gallery-image {
        width: 100%;
        max-width: 100%;
    }
}

/* Layout List */
.mg-gallery-list .mg-gallery-grid {
    grid-template-columns: 1fr;
    max-width: 250px;
    margin: 0 auto;
}

.mg-gallery-list .mg-gallery-item {
    width: 250px;
    max-width: 100%;
    margin: 0 auto 10px;
}

.mg-gallery-list .mg-gallery-image {
    width: 250px;
    max-width: 100%;
}

.mg-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 0;
    background: #000;
    break-inside: avoid;
    margin-bottom: 0;
    box-sizing: border-box;
}

/* Item con placeholder NSFW - background scuro per eliminare parti bianche */
.mg-gallery-item.mg-gallery-item-nsfw {
    background: #1f2937 !important;
}

/* Link con placeholder NSFW - riempie tutto lo spazio */
.mg-gallery-item-nsfw .mg-gallery-link {
    height: 100% !important;
    display: flex !important;
    align-items: stretch !important;
}

/* Layout Masonry - elementi con dimensioni fluide */
.mg-gallery-masonry .mg-gallery-item {
    width: 100%;
    margin-bottom: 0;
}

.mg-gallery-link {
    display: block;
    position: relative;
    width: 100%;
    text-decoration: none;
}

.mg-gallery-image {
    width: 100%;
    max-width: 100%;
    height: auto;
    display: block;
    transition: transform 0.3s ease;
    object-fit: contain;
    object-position: center;
    background-color: #000;
}

/* Layout Masonry - immagini con dimensioni fluide, altezza proporzionale */
.mg-gallery-masonry .mg-gallery-image {
    width: 100% !important;
    max-width: 100% !important;
    height: auto !important;
}

/* Desktop: max-width 150px per le thumbnails, affiancate senza spazi */
@media (min-width: 769px) {
    .mg-gallery-masonry .mg-gallery-item {
        max-width: 150px;
        width: 100%;
        margin: 0;
    }
    
    .mg-gallery-masonry .mg-gallery-image {
        max-width: 150px !important;
        width: 100% !important;
    }
    
    .mg-gallery-masonry .mg-gallery-image.mg-gallery-nsfw-placeholder {
        max-width: 150px !important;
        width: 100% !important;
    }
    
    .mg-gallery-grid-layout .mg-gallery-item {
        max-width: 150px;
        width: 100%;
        margin: 0;
    }
    
    .mg-gallery-grid-layout .mg-gallery-image {
        max-width: 150px !important;
        width: 100% !important;
    }
}

/* Placeholder NSFW - dimensioni fluide, riempie completamente il container */
.mg-gallery-image.mg-gallery-nsfw-placeholder {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
    background-color: #1f2937 !important; /* Colore di sfondo del placeholder */
    display: block !important;
}

/* Layout Masonry - placeholder NSFW con dimensioni fluide */
.mg-gallery-masonry .mg-gallery-image.mg-gallery-nsfw-placeholder {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    object-position: center !important;
}

/* Item NSFW - assicura che il background copra tutto lo spazio */
.mg-gallery-item-nsfw {
    background: #1f2937 !important;
}

.mg-gallery-item:hover .mg-gallery-image {
    transform: scale(1.02);
}

.mg-gallery-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0,0,0,0.7), transparent);
    padding: 15px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.mg-gallery-item:hover .mg-gallery-overlay {
    opacity: 1;
}

.mg-gallery-title {
    color: white;
    font-size: 14px;
    font-weight: 600;
}

.mg-gallery-empty {
    text-align: center;
    padding: 40px;
    color: #666;
}

.mg-gallery-error {
    padding: 20px;
    background: #fee;
    border: 1px solid #fcc;
    color: #c33;
    border-radius: 4px;
}

/* Stili per foto NSFW quando show_nsfw è attivo */
.mg-gallery-image.mg-gallery-nsfw {
    opacity: 0.7;
    filter: blur(3px);
    transition: opacity 0.3s ease, filter 0.3s ease;
}

.mg-gallery-item:hover .mg-gallery-image.mg-gallery-nsfw {
    opacity: 0.9;
    filter: blur(1px);
}

.mg-gallery-nsfw-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
    z-index: 10;
    pointer-events: none;
}

.mg-gallery-debug {
    font-family: monospace;
    font-size: 12px;
    line-height: 1.6;
}

