/* Photo Gallery for Office de Tourisme Pages */

/* Empêcher le scroll horizontal sur mobile */
body {
    overflow-x: hidden;
}

/* Conteneur du carousel original (avant transformation JS) */
.atf-carousel-container {
    position: relative;
    width: 100%;
    margin-bottom: 1rem;
    overflow: hidden;
    background-color: #f5f5f5;
}

.atf-carousel-items {
    position: relative;
    width: 100%;
    display: block;
}

.atf-carousel-item {
    position: relative;
    width: 100%;
    display: block;
}

/* Cacher toutes les images sauf la première avant transformation JS */
.atf-carousel-item:not(:first-child) {
    display: none;
}

.atf-carousel-item img {
    width: 100%;
    height: auto;
    display: block;
    max-height: 60vh;
    object-fit: contain;
}

/* Main photo container - adaptive to device orientation */
.atf-photo-main {
    position: relative;
    width: 100%;
    overflow: hidden;
    margin-bottom: 1rem;
    border-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}

/* Landscape mode (default) */
.atf-photo-main img {
    width: 100%;
    display: block;
    object-fit: contain;
    background-color: #000;
    max-height: 60vh;
}

/* Styles pour la gestion des offices de tourisme sans photo */
/* Pour les OT sans photo (structure originale avec .carousel-item) */
.carousel-item .image-container-ssphoto,
.atf-carousel-container .image-container-ssphoto {
    position: relative;
    width: 100%;
    min-height: 400px;
    display: block;
    background-color: #f0f0f0;
}

.carousel-item .image-container-ssphoto img.ssphoto,
.atf-carousel-container .image-container-ssphoto img.ssphoto {
    width: 100%;
    height: auto;
    display: block;
    min-height: 400px;
    object-fit: cover;
}

.carousel-item .overlay-ssphoto,
.atf-carousel-container .overlay-ssphoto {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    display: flex !important;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    color: white;
    text-align: center;
    pointer-events: none;
}

.carousel-item .centered-text-ssphoto,
.atf-carousel-container .centered-text-ssphoto {
    position: relative;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    width: 80%;
    padding: 20px;
    z-index: 10;
}

.carousel-item .centered-text-ssphoto img,
.atf-carousel-container .centered-text-ssphoto img {
    width: 64px;
    height: 64px;
    margin: 10px auto;
    display: block;
}

.carousel-item .bottom-right-text-ssphoto,
.atf-carousel-container .bottom-right-text-ssphoto {
    position: absolute;
    bottom: 10px;
    right: 10px;
    font-size: 0.8rem;
    text-align: right;
    padding: 5px;
    max-width: 80%;
    z-index: 10;
}

/* Button to show more photos */
.atf-more-photos {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
    z-index: 10;
}

.atf-more-photos:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.05);
}

/* Modal Gallery */
.atf-gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    max-width: 100vw;
    max-height: 100vh;
    background-color: #000;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: opacity 0.3s ease;
    opacity: 0;
    pointer-events: none;
    overflow: hidden;
    box-sizing: border-box;
}

.atf-gallery-modal * {
    box-sizing: border-box;
}

.atf-gallery-modal.show {
    opacity: 1;
    pointer-events: auto;
}

/* Modal Header */
.atf-gallery-header {
    position: relative;
    width: 100%;
    box-sizing: border-box;
    padding: 0;
    z-index: 1002;
}

/* Bouton fermer en haut à droite (style identique au modal des avis) */
.atf-gallery-close {
    position: absolute;
    top: 20px;
    right: 20px;
    z-index: 1003;
    background-color: #f44336;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    margin: 0;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.atf-gallery-close i {
    font-size: 2rem;
    line-height: 1;
}

.atf-gallery-close:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0,0,0,0.4);
}

/* Modal Content */
.atf-gallery-content {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    overflow: hidden;
}

/* Slideshow container */
.atf-gallery-slides {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Individual slide */
.atf-gallery-slide {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.5s ease;
    z-index: 0;
}

.atf-gallery-slide.active {
    opacity: 1;
    z-index: 1;
}

/* Image styling within slides */
.atf-gallery-slide img {
    max-width: 90%;
    max-height: 80vh;
    object-fit: contain;
    display: block;
    margin: 0 auto;
}

/* Navigation arrows */
.atf-gallery-prev,
.atf-gallery-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.5rem;
    transition: background 0.3s ease;
    z-index: 1001;
}

.atf-gallery-prev {
    left: 20px;
}

.atf-gallery-next {
    right: 20px;
}

.atf-gallery-prev:hover,
.atf-gallery-next:hover {
    background: rgba(0, 0, 0, 0.8);
}

/* Auto-play control */
.atf-gallery-controls {
    position: absolute;
    top: 20px;
    left: 20px;
    background: rgba(0, 0, 0, 0.7);
    padding: 10px 15px;
    border-radius: 25px;
    z-index: 1002;
    color: white;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.3s ease;
}

.atf-gallery-controls:hover {
    background: rgba(0, 0, 0, 0.85);
}

.atf-gallery-controls input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
    accent-color: #4CAF50;
    margin: 0;
}

.atf-gallery-controls label {
    margin: 0;
    cursor: pointer;
    user-select: none;
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Indicateur visuel quand l'autoplay est actif */
.atf-gallery-controls.active {
    background: rgba(76, 175, 80, 0.8);
    box-shadow: 0 0 10px rgba(76, 175, 80, 0.5);
}

.atf-gallery-controls.active:hover {
    background: rgba(76, 175, 80, 0.9);
}

/* Animation de l'icône quand l'autoplay est actif */
.atf-gallery-controls.active label i {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.7;
        transform: scale(1.1);
    }
}

/* Portrait mode adjustments */
@media (orientation: portrait) {
    .atf-photo-main {
        max-height: 70vh;
    }
    
    .atf-photo-main img {
        width: 100%;
        object-fit: contain;
        max-height: 70vh;
    }
}

/* Mobile adjustments */
@media (max-width: 600px) {
    /* Empêcher le débordement du modal */
    .atf-gallery-modal {
        width: 100vw;
        height: 100vh;
        overflow: hidden;
    }
    
    .atf-gallery-header {
        padding: 0;
    }
    
    .atf-gallery-content {
        padding: 0 5px;
    }
    
    /* Flèches de navigation plus petites et plus proches des bords */
    .atf-gallery-prev,
    .atf-gallery-next {
        width: 40px;
        height: 40px;
        font-size: 1.2rem;
    }
    
    .atf-gallery-prev {
        left: 5px;
    }
    
    .atf-gallery-next {
        right: 5px;
    }
    
    /* Bouton de fermeture plus petit sur mobile */
    .atf-gallery-close {
        top: 10px;
        right: 10px;
        width: 48px;
        height: 48px;
    }
    
    .atf-gallery-close i {
        font-size: 1.5rem;
    }
    
    /* Contrôles autoplay plus compacts */
    .atf-gallery-controls {
        padding: 5px 10px;
        top: 5px;
        left: 5px;
        font-size: 0.85rem;
        border-radius: 15px;
    }
    
    .atf-gallery-controls input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }
    
    .atf-gallery-controls label {
        font-size: 0.85rem;
        gap: 5px;
    }
    
    .atf-gallery-controls label i {
        font-size: 1rem;
    }
    
    /* Images dans le modal */
    .atf-gallery-slide img {
        max-width: 95%;
        max-height: 75vh;
    }
    
    /* Bouton "plus de photos" */
    .atf-more-photos {
        padding: 5px 8px;
        font-size: 0.8rem;
    }
}
