/**
 * Image Gallery Metabox - Frontend Styles
 */

.igm-swiper-wrapper {
    max-width: 100%;
    margin: 40px 0;
    padding: 0;
}

.igm-gallery-swiper {
    width: 100%;
    padding: 0 50px;
    position: relative;
    background: transparent;
}

.igm-gallery-swiper .swiper-wrapper {
    align-items: center;
}

.igm-gallery-swiper .swiper-slide {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: transparent;
    width: 100%;
}

/* Nascondi le slide non attive */
.igm-gallery-swiper .swiper-slide {
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.5s ease, visibility 0.5s ease;
}

.igm-gallery-swiper .swiper-slide-active {
    opacity: 1;
    visibility: visible;
}

.igm-gallery-swiper .swiper-slide img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 600px;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.3s ease;
}

.igm-gallery-swiper .swiper-slide img:hover {
   /* transform: scale(1.02); */
}

/* Caption sotto l'immagine */
.igm-image-caption {
    margin-top: 15px;
    text-align: center;
    color: #666;
    font-size: 14px;
    line-height: 1.6;
    font-style: italic;
    max-width: 100%;
    padding: 0 20px;
}

/* Navigation Buttons */
.igm-gallery-swiper .swiper-button-next,
.igm-gallery-swiper .swiper-button-prev {
    color: #2271b1;
    width: 44px;
    height: 44px;
    background: rgba(255,255,255,0.95);
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
}

.igm-gallery-swiper .swiper-button-next:hover,
.igm-gallery-swiper .swiper-button-prev:hover {
    background: #2271b1;
    color: white;
    transform: scale(1.1);
}

.igm-gallery-swiper .swiper-button-next::after,
.igm-gallery-swiper .swiper-button-prev::after {
    font-size: 18px;
    font-weight: bold;
}

.igm-gallery-swiper .swiper-button-disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Nascondi pagination (dot indicators) */
.igm-gallery-swiper .swiper-pagination {
    display: none;
}

/* Responsive */
@media screen and (max-width: 768px) {
    .igm-gallery-swiper {
        padding: 0 35px;
    }
    
    .igm-gallery-swiper .swiper-button-next,
    .igm-gallery-swiper .swiper-button-prev {
        width: 36px;
        height: 36px;
    }
    
    .igm-gallery-swiper .swiper-button-next::after,
    .igm-gallery-swiper .swiper-button-prev::after {
        font-size: 14px;
    }
    
    .igm-gallery-swiper .swiper-slide img {
        max-height: 400px;
    }
    
    .igm-image-caption {
        font-size: 13px;
        margin-top: 12px;
    }
}

@media screen and (max-width: 480px) {
    .igm-swiper-wrapper {
        margin: 20px 0;
    }
    
    .igm-gallery-swiper {
        padding: 0;
    }
    
    .igm-gallery-swiper .swiper-button-next,
    .igm-gallery-swiper .swiper-button-prev {
        width: 32px;
        height: 32px;
    }
    
    .igm-gallery-swiper .swiper-button-next::after,
    .igm-gallery-swiper .swiper-button-prev::after {
        font-size: 12px;
    }
    
    .igm-gallery-swiper .swiper-slide img {
        max-height: 300px;
        border-radius: 6px;
    }
    
    .igm-image-caption {
        font-size: 12px;
        margin-top: 10px;
        padding: 0 10px;
    }
}

/* Loading State */
.igm-gallery-swiper.loading {
    min-height: 400px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.igm-gallery-swiper.loading::after {
    content: '';
    width: 50px;
    height: 50px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #2271b1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Zoom Effect on Hover */
.igm-gallery-swiper .swiper-slide {
    overflow: visible;
}

.igm-gallery-swiper .swiper-slide img {
    transition: transform 0.5s ease, box-shadow 0.5s ease;
}

.igm-gallery-swiper .swiper-slide:hover img {
    /*transform: scale(1.02);*/
    box-shadow: 0 8px 20px rgba(0,0,0,0.15);
}

/* Custom Scrollbar for touch devices */
.igm-gallery-swiper .swiper-scrollbar {
    background: rgba(0,0,0,0.1);
    border-radius: 10px;
}

.igm-gallery-swiper .swiper-scrollbar-drag {
    background: #2271b1;
    border-radius: 10px;
}

/* ============================================
   LIGHTBOX
   ============================================ */

.igm-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.95);
    z-index: 999999;
    display: none;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

.igm-lightbox.active {
    display: flex;
}

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

.igm-lightbox-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.igm-lightbox-image {
    max-width: 100%;
    max-height: 90vh;
    object-fit: contain;
    border-radius: 4px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    transition: opacity 0.3s ease;
}

.igm-lightbox-caption {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    text-align: center;
    max-width: 80%;
    text-shadow: 0 2px 4px rgba(0,0,0,0.8);
}

.igm-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    font-size: 28px;
    line-height: 46px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.igm-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

.igm-lightbox-prev,
.igm-lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    background: rgba(255, 255, 255, 0.2);
    border: 2px solid white;
    border-radius: 50%;
    color: white;
    font-size: 30px;
    line-height: 56px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
}

.igm-lightbox-prev:hover,
.igm-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.4);
    transform: translateY(-50%) scale(1.1);
}

.igm-lightbox-prev {
    left: 30px;
}

.igm-lightbox-next {
    right: 30px;
}

.igm-lightbox-counter {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 18px;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 20px;
    border-radius: 20px;
}

/* Responsive Lightbox */
@media screen and (max-width: 768px) {
    .igm-lightbox-close {
        top: 10px;
        right: 10px;
        width: 40px;
        height: 40px;
        font-size: 24px;
        line-height: 36px;
    }
    
    .igm-lightbox-prev,
    .igm-lightbox-next {
        width: 50px;
        height: 50px;
        font-size: 24px;
        line-height: 46px;
    }
    
    .igm-lightbox-prev {
        left: 15px;
    }
    
    .igm-lightbox-next {
        right: 15px;
    }
    
    .igm-lightbox-caption {
        font-size: 14px;
        bottom: -40px;
    }
    
    .igm-lightbox-counter {
        font-size: 16px;
        padding: 6px 16px;
    }
}
