/* ========================================
   STYLES GALERIE AUTOMATIQUE - MAGIC LENA'S RANCH
   Galerie moderne avec détection automatique des images
   ======================================== */



/* ========================================
   SECTIONS DE GALERIE
   ======================================== */

.sous-section-galerie {
    margin: 60px 0;
    animation: fadeInUp 0.6s ease-out;
}

.sous-section-galerie h2 {
    color: rgb(143, 12, 99);
    font-family: 'Dancing Script', cursive;
    font-size: 2.2rem;
    margin: 40px 0 30px 0;
    text-align: center;
    position: relative;
    padding-bottom: 15px;
}

/* Ligne décorative sous les titres */
.sous-section-galerie h2::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 100px;
    height: 3px;
    background: linear-gradient(90deg, transparent, rgb(192, 204, 28), transparent);
    border-radius: 2px;
}

/* Section vide (aucune image) */
.section-vide {
    background: rgba(255, 255, 255, 0.9);
    border: 2px dashed rgba(143, 12, 99, 0.3);
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    margin: 30px auto;
    max-width: 500px;
    color: rgb(143, 12, 99);
}

.section-vide p {
    margin: 10px 0;
    font-size: 1.1rem;
}

.section-vide code {
    background: rgba(143, 12, 99, 0.1);
    padding: 4px 8px;
    border-radius: 5px;
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
}

/* ========================================
   GRILLE DE GALERIE
   ======================================== */

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 25px;
    margin: 40px 0;
    padding: 0 10px;
}

/* ========================================
   ITEMS DE GALERIE
   ======================================== */

.gallery-item {
    background: rgba(255, 255, 255, 0.95);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.1);
    transition: all 0.4s ease;
    position: relative;
    cursor: pointer;
}

.gallery-item:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 20px 40px rgba(143, 12, 99, 0.2);
}

/* Conteneur d'image - TAILLE AJUSTÉE POUR MINIATURES SEULES */
.image-container {
    position: relative;
    overflow: hidden;
    height: 280px; /* Augmenté car plus de légende en bas */
    /* FORÇAGE POUR ÉVITER TOUT DÉPLACEMENT */
    transform: none !important;
    will-change: auto !important;
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.4s ease;
    border-radius: 20px; /* Bordures arrondies pour correspondre au conteneur */
    /* FORÇAGE ABSOLU POUR EMPÊCHER TOUT DÉPLACEMENT */
    transform: none !important;
    position: static !important;
    top: auto !important;
    left: auto !important;
    will-change: auto !important;
}

.gallery-item:hover .image-container img {
    /* Seul effet autorisé : zoom léger au hover */
    transform: scale(1.05) !important;
}

/* Overlay d'informations au survol - SIMPLIFIÉ */
.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        135deg, 
        rgba(143, 12, 99, 0.9) 0%, 
        rgba(55, 5, 26, 0.8) 100%
    );
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 20px;
    opacity: 0;
    transition: all 0.3s ease;
    color: white;
    border-radius: 20px; /* Correspondre au conteneur */
}

.gallery-item:hover .image-overlay {
    opacity: 1;
}

.image-info h4 {
    font-size: 1.2rem;
    margin-bottom: 10px;
    color: white;
    text-align: left;
    font-family: 'Dancing Script', cursive;
}

.image-info p {
    font-size: 0.9rem;
    margin: 5px 0;
    color: rgba(255, 255, 255, 0.9);
    text-align: left;
}

/* Actions sur l'image - SIMPLIFIÉES */
.image-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    align-items: flex-end;
}

.btn-action {
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}





/* Visionneuse plein écran - IMAGES MÊME LARGEUR */
.fullscreen-viewer {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    backdrop-filter: blur(20px);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    animation: fadeIn 0.3s ease;
    cursor: pointer; /* Cursor pointer pour fermer en cliquant */
}

.fullscreen-viewer.active {
    display: flex;
}

.viewer-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: default; /* Empêcher la fermeture sur le contenu */
}

#fullscreenImage {
    width: 80vw; /* Largeur fixe pour toutes les images */
    max-height: 80vh;
    object-fit: contain; /* Préserver les proportions */
    border-radius: 15px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

/* Contrôles de la visionneuse */
.viewer-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    gap: 10px;
}

.btn-close, .btn-nav {
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    width: 50px;
    height: 50px;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover, .btn-nav:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: scale(1.1);
}

.btn-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
}

.btn-prev {
    left: -80px;
}

.btn-next {
    right: -80px;
}

/* Informations de l'image en plein écran */
.viewer-info {
    margin-top: 20px;
    text-align: center;
    color: white;
    max-width: 600px;
}

.viewer-info h3 {
    font-size: 1.5rem;
    margin-bottom: 10px;
    color: white;
    font-family: 'Dancing Script', cursive;
}

.viewer-info p {
    font-size: 1rem;
    color: rgba(255, 255, 255, 0.8);
}



/* ========================================
   ANIMATIONS
   ======================================== */

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

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

/* Animation de chargement des images - EFFET PARALLAXE SUPPRIMÉ */
.gallery-item img {
    animation: imageLoad 0.5s ease-out;
    /* Plus d'effet parallaxe ou de transformation au scroll */
}

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

/* ========================================
   RESPONSIVE DESIGN
   ======================================== */

@media screen and (max-width: 768px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
        gap: 20px;
        padding: 0 5px;
    }
    
    .gallery-item {
        border-radius: 15px;
    }
    
    .image-container {
        height: 200px;
    }
    
    .sous-section-galerie h2 {
        font-size: 1.8rem;
    }
    
    .gallery-caption {
        padding: 15px;
    }
    
    .image-title {
        font-size: 1rem;
    }
    
    .admin-instructions {
        padding: 25px;
        margin: 60px 0 30px;
    }
    
    .instructions-grid {
        grid-template-columns: 1fr;
        gap: 20px;
    }
    
    .instruction-item {
        padding: 20px;
    }
    
    /* Contrôles visionneuse sur mobile */
    .btn-prev, .btn-next {
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
    }
    
    .btn-prev {
        left: 20px;
    }
    
    .btn-next {
        right: 20px;
    }
    
    .viewer-controls {
        position: fixed;
        top: 20px;
        right: 20px;
    }
}

@media screen and (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .image-container {
        height: 180px;
    }
    
    .sous-section-galerie h2 {
        font-size: 1.5rem;
    }
    
    .admin-instructions h3 {
        font-size: 1.6rem;
    }
    
    .instruction-item h4 {
        font-size: 1.1rem;
    }
    
    /* Overlay simplifié sur mobile */
    .image-overlay {
        background: rgba(0, 0, 0, 0.7);
        padding: 15px;
    }
    
    .image-info h4 {
        font-size: 1rem;
    }
    
    .btn-action {
        width: 35px;
        height: 35px;
        font-size: 1rem;
    }
    
    #fullscreenImage {
        max-height: 60vh;
    }
    
    .viewer-info {
        margin-top: 15px;
        padding: 0 20px;
    }
    
    .viewer-info h3 {
        font-size: 1.2rem;
    }
}



/* Image non trouvée */  
.gallery-item img[style*="display: none"] + .gallery-caption::after {
    content: "📷 Image non disponible";
    display: block;
    color: #dc3545;
    font-size: 0.9rem;
    font-style: italic;
    margin-top: 10px;
}

/* ========================================
   EFFET PARALLAXE SUBTIL
   ======================================== */

@media (prefers-reduced-motion: no-preference) {
    .gallery-item {
        transform-style: preserve-3d;
    }
    
    .gallery-item:hover {
        transform: translateY(-8px) rotateX(5deg) rotateY(2deg);
    }
    
    .image-container img {
        transform-origin: center center;
    }
}

/* ========================================
   MODE SOMBRE (DÉTECTION AUTOMATIQUE)
   ======================================== */

@media (prefers-color-scheme: dark) {
    .gallery-item {
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(10px);
    }
    
    .gallery-caption .image-title {
        color: rgba(255, 255, 255, 0.9);
    }
    
    .image-meta {
        color: rgba(255, 255, 255, 0.7);
    }
    
    .section-stats {
        background: rgba(192, 204, 28, 0.2);
        border-color: rgba(192, 204, 28, 0.3);
    }
    
    .section-stats p {
        color: rgba(255, 255, 255, 0.9);
    }
    
    .admin-instructions {
        background: rgba(0, 0, 0, 0.3);
        border-color: rgba(143, 12, 99, 0.3);
    }
    
    .instruction-item {
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(10px);
    }
    
    .instruction-item h4,
    .instruction-item p,
    .instruction-item li {
        color: rgba(255, 255, 255, 0.9);
    }
}