/* Galleria Modale Fullscreen CSS */

.fmg-modal {
    display: none;
    position: fixed;
    z-index: 999999;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
}

.fmg-modal-backdrop {
    position: absolute;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.fmg-modal-content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.fmg-close {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 10;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.fmg-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

.fmg-gallery-container {
    width: 90%;
    max-width: 1400px;
    height: 90vh;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.fmg-main-image-wrapper {
    position: relative;
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 0;
}

#fmg-main-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

.fmg-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.2);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    opacity: 0.7;
}

.fmg-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    opacity: 1;
    transform: translateY(-50%) scale(1.1);
}

.fmg-prev {
    left: 20px;
}

.fmg-next {
    right: 20px;
}

.fmg-image-counter {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: white;
    padding: 8px 20px;
    border-radius: 25px;
    font-size: 14px;
    font-weight: 500;
    letter-spacing: 1px;
}

.fmg-thumbnails-wrapper {
    width: 100%;
    overflow-x: auto;
    padding: 10px 0;
}

.fmg-thumbnails {
    display: flex;
    gap: 10px;
    justify-content: center;
    min-width: min-content;
}

.fmg-thumbnail {
    width: 80px;
    height: 80px;
    cursor: pointer;
    opacity: 0.5;
    transition: all 0.3s ease;
    border: 2px solid transparent;
    border-radius: 8px;
    overflow: hidden;
    flex-shrink: 0;
}

.fmg-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.fmg-thumbnail.active {
    opacity: 1;
    border-color: white;
    transform: scale(1.1);
}

.fmg-thumbnail:hover {
    opacity: 0.8;
    transform: scale(1.05);
}

.fmg-thumbnails-wrapper::-webkit-scrollbar {
    height: 6px;
}

.fmg-thumbnails-wrapper::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.fmg-thumbnails-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.fmg-thumbnails-wrapper::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}

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

@keyframes slideUp {
    from {
        transform: translateY(30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.fmg-modal.show {
    display: block;
    animation: fadeIn 0.3s ease;
}

.fmg-modal.show .fmg-gallery-container {
    animation: slideUp 0.4s ease;
}

/* Mobile optimizations */
@media (max-width: 768px) {
    .fmg-gallery-container {
        width: 100%;
        height: 100vh;
        height: 100dvh; /* Dynamic viewport height for mobile browsers */
        gap: 10px;
        padding: 0;
    }
    
    .fmg-main-image-wrapper {
        padding: 0 5px;
    }
    
    #fmg-main-image {
        border-radius: 0;
        box-shadow: none; /* Remove shadow on mobile for performance */
    }
    
    .fmg-nav {
        width: 45px;
        height: 45px;
        background: rgba(0, 0, 0, 0.6);
        opacity: 1;
    }
    
    .fmg-prev {
        left: 10px;
    }
    
    .fmg-next {
        right: 10px;
    }
    
    .fmg-thumbnail {
        width: 60px;
        height: 60px;
    }
    
    .fmg-close {
        width: 40px;
        height: 40px;
        top: 10px;
        right: 10px;
    }
    
    .fmg-image-counter {
        bottom: 10px;
        padding: 6px 15px;
        font-size: 12px;
    }
    
    /* Hide navigation buttons on small mobile - rely on swipe */
    @media (max-width: 480px) {
        .fmg-nav {
            opacity: 0.3;
        }
        
        .fmg-nav:active {
            opacity: 1;
            transform: translateY(-50%) scale(0.95);
        }
    }
    
    /* Improve thumbnail scrolling on mobile */
    .fmg-thumbnails-wrapper {
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        scroll-behavior: smooth;
        padding: 5px 0;
    }
    
    .fmg-thumbnails {
        padding: 0 10px;
    }
    
    /* Prevent zoom on double tap */
    .fmg-modal * {
        touch-action: manipulation;
    }
    
    /* Landscape mode adjustments */
    @media (orientation: landscape) and (max-height: 500px) {
        .fmg-thumbnails-wrapper {
            display: none; /* Hide thumbnails in landscape on small devices */
        }
        
        .fmg-gallery-container {
            gap: 0;
        }
        
        .fmg-close {
            top: 5px;
            right: 5px;
        }
    }
}

/* High resolution displays */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    .fmg-nav,
    .fmg-close {
        border-width: 0.5px;
    }
}

/* iOS specific fixes */
@supports (-webkit-touch-callout: none) {
    .fmg-modal {
        position: fixed;
        -webkit-transform: translateZ(0); /* Fix iOS position:fixed issues */
    }
}

/* Android specific optimizations */
@media (pointer: coarse) {
    .fmg-nav,
    .fmg-close,
    .fmg-thumbnail {
        transition-duration: 0.1s; /* Faster feedback on touch devices */
    }
}
