/**
 * Grille Vidéo Lightbox - Frontend Styles
 * Version: 1.0.0
 */

/* ===== CONTENEUR PRINCIPAL ===== */
.gvl-container {
    position: relative;
    width: 100%;
    margin: 0 auto;
}

/* ===== GRILLE VIDÉOS ===== */
.gvl-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 20px;
    width: 100%;
}

/* Mode Carousel */
.gvl-grid.gvl-carousel {
    display: flex;
    overflow-x: auto;
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
}

.gvl-grid.gvl-carousel::-webkit-scrollbar {
    display: none; /* Chrome, Safari */
}

.gvl-grid.gvl-carousel .gvl-video-card {
    flex: 0 0 auto;
    scroll-snap-align: start;
    width: calc((100% - 80px) / 5);
}

/* ===== CARTE VIDÉO ===== */
.gvl-video-card {
    position: relative;
    aspect-ratio: 9/16;
    overflow: hidden;
    border-radius: 12px;
    background: #000;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.gvl-video-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

/* Mode Expanded (quand vidéo ouverte inline) */
.gvl-video-card.gvl-expanded {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) !important;
    z-index: 9999;
    width: 90vw;
    max-width: 500px;
    max-height: 90vh;
    aspect-ratio: 9/16;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.8);
    animation: gvlExpandIn 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes gvlExpandIn {
    from {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 0;
    }
    to {
        transform: translate(-50%, -50%) scale(1);
        opacity: 1;
    }
}

/* Bouton de carte (toute la surface cliquable) */
.gvl-card-button {
    position: relative;
    width: 100%;
    height: 100%;
    border: none;
    padding: 0;
    background: transparent;
    cursor: pointer;
    display: block;
}

.gvl-card-button:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* ===== THUMBNAIL ===== */
.gvl-thumbnail {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gvl-video-card:hover .gvl-thumbnail {
    transform: scale(1.05);
}

/* ===== OVERLAY DÉGRADÉ ===== */
.gvl-overlay {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40%;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), transparent);
    pointer-events: none;
    opacity: 0.6;
    z-index: 1;
}

/* ===== BADGE ===== */
.gvl-badge {
    position: absolute;
    padding: 8px 12px;
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    border-radius: 4px;
    opacity: 0.8;
    z-index: 2;
    pointer-events: none;
}

/* Positions badge */
.gvl-badge-top-left {
    top: 12px;
    left: 12px;
}

.gvl-badge-top-center {
    top: 12px;
    left: 50%;
    transform: translateX(-50%);
}

.gvl-badge-top-right {
    top: 12px;
    right: 12px;
}

.gvl-badge-bottom-left {
    bottom: 12px;
    left: 12px;
}

.gvl-badge-bottom-center {
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
}

.gvl-badge-bottom-right {
    bottom: 12px;
    right: 12px;
}

/* ===== VIDÉO INLINE (Lecture dans la grille) ===== */
.gvl-inline-video {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: inherit;
    z-index: 3;
    background-color: #000;
}

/* Bouton Agrandir (pendant lecture inline) */
.gvl-expand-btn {
    position: absolute;
    bottom: 60px;
    right: 15px;
    width: 40px;
    height: 40px;
    background-color: rgba(0, 0, 0, 0.7);
    border: 2px solid #fff;
    border-radius: 8px;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 4;
    transition: all 0.3s ease;
}

.gvl-expand-btn:hover {
    background-color: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.gvl-expand-btn:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

.gvl-expand-btn svg {
    width: 24px;
    height: 24px;
}

/* Carte en mode lecture */
.gvl-video-card.gvl-playing {
    z-index: 10;
}

/* ===== ICÔNE PLAY ===== */
.gvl-play-icon {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    background-color: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: transform 0.3s ease, background-color 0.3s ease;
    pointer-events: none;
    z-index: 2;
}

.gvl-play-icon svg {
    width: 28px;
    height: 28px;
    margin-left: 3px; /* Centrage visuel */
}

.gvl-video-card:hover .gvl-play-icon {
    transform: translate(-50%, -50%) scale(1.2);
    background-color: rgba(0, 0, 0, 0.7);
}

/* ===== PAGINATION ===== */
.gvl-pagination {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 30px;
    padding: 20px 0;
}

.gvl-pagination-prev,
.gvl-pagination-next {
    width: 40px;
    height: 40px;
    border: 2px solid #ddd;
    background: #fff;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    color: #333;
}

.gvl-pagination-prev:hover,
.gvl-pagination-next:hover {
    background: #4A90E2;
    border-color: #4A90E2;
    color: #fff;
}

.gvl-pagination-prev:disabled,
.gvl-pagination-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

.gvl-pagination-numbers {
    display: flex;
    gap: 8px;
}

.gvl-pagination-numbers button {
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 2px solid #ddd;
    background: #fff;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
    color: #333;
    transition: all 0.3s ease;
}

.gvl-pagination-numbers button:hover {
    background: #f0f0f0;
}

.gvl-pagination-numbers button.active {
    background: #4A90E2;
    border-color: #4A90E2;
    color: #fff;
}

/* Ellipsis pour pagination */
.gvl-pagination-numbers .gvl-ellipsis {
    border: none;
    background: transparent;
    cursor: default;
    pointer-events: none;
}

/* ===== NAVIGATION CAROUSEL ===== */
.gvl-carousel-nav {
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    display: flex;
    justify-content: space-between;
    pointer-events: none;
    z-index: 10;
}

.gvl-carousel-prev,
.gvl-carousel-next {
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    pointer-events: all;
}

.gvl-carousel-prev {
    margin-left: -25px;
}

.gvl-carousel-next {
    margin-right: -25px;
}

.gvl-carousel-prev:hover,
.gvl-carousel-next:hover {
    background: #fff;
    transform: scale(1.1);
}

.gvl-carousel-prev:disabled,
.gvl-carousel-next:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Mobile : Boutons plus petits et mieux positionnés */
@media (max-width: 767px) {
    .gvl-carousel-prev,
    .gvl-carousel-next {
        width: 40px;
        height: 40px;
    }
    
    .gvl-carousel-prev {
        margin-left: 10px; /* Visible dans l'écran */
    }
    
    .gvl-carousel-next {
        margin-right: 10px; /* Visible dans l'écran */
    }
    
    .gvl-carousel-prev svg,
    .gvl-carousel-next svg {
        width: 20px;
        height: 20px;
    }
}

/* ===== LIGHTBOX ===== */
.gvl-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 99999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.gvl-lightbox.active {
    display: flex;
    opacity: 1;
}

.gvl-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.95);
    cursor: pointer;
}

.gvl-lightbox-content {
    position: relative;
    z-index: 1;
    margin: auto;
    max-width: 40vw;
    max-height: 80vh;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.gvl-video-wrapper {
    position: relative;
    width: 100%;
    aspect-ratio: 9/16;
}

.gvl-video-player {
    width: 100%;
    height: 100%;
    border-radius: 12px;
    background: #000;
}

/* Bouton Fermer */
.gvl-lightbox-close {
    position: absolute;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: all 0.3s ease;
}

.gvl-lightbox-close:hover {
    background: #fff;
    transform: rotate(90deg);
}

.gvl-lightbox-close:focus {
    outline: 3px solid #4A90E2;
    outline-offset: 2px;
}

/* Bouton Plein Écran */
.gvl-fullscreen-btn {
    position: absolute;
    bottom: 70px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.7);
    border: 2px solid #fff;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    transition: all 0.3s ease;
    z-index: 10;
}

.gvl-fullscreen-btn:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

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

/* Tablette */
@media (max-width: 1024px) {
    .gvl-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .gvl-grid.gvl-carousel .gvl-video-card {
        width: calc((100% - 40px) / 3);
    }
    
    .gvl-lightbox-content {
        max-width: 60vw;
    }
    
    /* Carousel nav visible sur tablette */
    .gvl-carousel-prev {
        margin-left: 5px;
    }
    
    .gvl-carousel-next {
        margin-right: 5px;
    }
}

/* Mobile */
@media (max-width: 767px) {
    .gvl-grid {
        grid-template-columns: 1fr;
        gap: 15px;
    }
    
    .gvl-grid.gvl-carousel .gvl-video-card {
        width: 85vw;
    }
    
    .gvl-video-card {
        max-width: 500px;
        margin: 0 auto;
    }
    
    .gvl-lightbox-content {
        max-width: 90vw;
        max-height: 90vh;
    }
    
    .gvl-play-icon {
        width: 50px;
        height: 50px;
    }
    
    .gvl-play-icon svg {
        width: 24px;
        height: 24px;
    }
    
    .gvl-badge {
        font-size: 12px;
        padding: 6px 10px;
    }
    
    /* Carousel : Boutons plus visibles sur mobile */
    .gvl-carousel-prev,
    .gvl-carousel-next {
        width: 40px;
        height: 40px;
        background: rgba(255, 255, 255, 0.95); /* Plus opaque */
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3); /* Ombre plus visible */
    }
    
    .gvl-carousel-prev {
        margin-left: 10px; /* Visible dans l'écran */
    }
    
    .gvl-carousel-next {
        margin-right: 10px; /* Visible dans l'écran */
    }
    
    .gvl-carousel-prev svg,
    .gvl-carousel-next svg {
        width: 20px;
        height: 20px;
    }
}

/* Très petit mobile */
@media (max-width: 480px) {
    .gvl-pagination-numbers button {
        min-width: 35px;
        height: 35px;
        font-size: 14px;
    }
    
    .gvl-pagination-prev,
    .gvl-pagination-next {
        width: 35px;
        height: 35px;
    }
}

/* ===== ACCESSIBILITÉ ===== */

/* Réduction du mouvement (prefers-reduced-motion) */
@media (prefers-reduced-motion: reduce) {
    .gvl-video-card,
    .gvl-thumbnail,
    .gvl-play-icon,
    .gvl-lightbox,
    .gvl-pagination-prev,
    .gvl-pagination-next,
    .gvl-lightbox-close {
        transition: none !important;
        animation: none !important;
    }
}

/* Focus visible pour navigation clavier */
.gvl-card-button:focus-visible,
.gvl-pagination-prev:focus-visible,
.gvl-pagination-next:focus-visible,
.gvl-pagination-numbers button:focus-visible,
.gvl-lightbox-close:focus-visible,
.gvl-fullscreen-btn:focus-visible {
    outline: 3px solid #4A90E2;
    outline-offset: 3px;
}

/* Masquer les vidéos au-delà de la page courante (pagination) */
.gvl-video-card.gvl-hidden {
    display: none;
}

/* ===== MODE ÉDITION ELEMENTOR ===== */
.elementor-editor-active .gvl-lightbox {
    pointer-events: none;
}

/* ===== ANIMATIONS SUPPLÉMENTAIRES ===== */
@keyframes gvlFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

/* Spinner de chargement (optionnel) */
.gvl-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: gvlSpin 0.8s linear infinite;
}

@keyframes gvlSpin {
    to {
        transform: rotate(360deg);
    }
}

/* ===== OVERLAY DE BACKDROP (quand vidéo expanded inline) ===== */
.gvl-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    z-index: 9998;
    animation: gvlFadeIn 0.3s ease;
}

/* Masquer contrôles vidéo personnalisés si natifs activés */
.gvl-video-player::-webkit-media-controls {
    /* Permet contrôles natifs */
}
