.levels-lc-gallery-container {
    position: relative;
}

.levels-lc-gallery-spinner {
    width: 60px;
    height: 60px;
    border: 5px solid #e0e0e0;
    border-top: 5px solid #333;
    border-radius: 50%;
    animation: levels-lc-spin 1s linear infinite;
    display: block;
}

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

.levels-lc-gallery-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    grid-auto-rows: 1fr;
    gap: 0;
    width: 100%;
    aspect-ratio: 3 / 1.32;
    margin: 0;
    margin-bottom: 0 !important;
}

.levels-lc-gallery-item {
    overflow: hidden;
    position: relative;
    cursor: pointer;
    transition: opacity 0.45s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Couche de fond pour contenir le zoom au survol dans le container */
.levels-lc-gallery-item-bg {
    position: absolute;
    inset: 0;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    transform: scale(1);
    transform-origin: center center;
    backface-visibility: hidden;
    transition: transform 0.6s cubic-bezier(0.16, 1, 0.3, 1);
}

.levels-lc-gallery-item:hover {
    opacity: 0.9;
}

.levels-lc-gallery-item:hover .levels-lc-gallery-item-bg {
    transform: scale(1.03);
}

.levels-lc-gallery-item.loading {
    background-size: auto;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
}

.levels-lc-gallery-item.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 200px;
    max-width: 200px;
    height: 200px;
    max-height: 200px;
    background-image: var(--placeholder-image);
    background-size: contain;
    background-position: center;
    background-repeat: no-repeat;
    transition: opacity 0.8s ease, transform 0.8s ease;
    z-index: 1;
}

.levels-lc-gallery-item:not(.loading)::after {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.95);
    pointer-events: none;
}

/* Masquer le background-image de l'élément quand on est en mode loading */
.levels-lc-gallery-item.loading {
    background-image: none !important;
}

.levels-lc-gallery-item-loader {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 20;
    opacity: 1;
    visibility: visible;
    transition: opacity 0.8s ease, visibility 0.8s ease;
}

.levels-lc-gallery-item-loader.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}


.levels-lc-gallery-item.large {
    grid-column: 1;
    grid-row: 1 / 3;
}

.levels-lc-gallery-item.small.right-top {
    grid-column: 2;
    grid-row: 1;
}

.levels-lc-gallery-item.small.right-bottom {
    grid-column: 2;
    grid-row: 2;
}

/* Grille pour les images restantes (après les 3 premières) */
.levels-lc-gallery-grid-continued {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    grid-auto-rows: minmax(0, 1fr);
    gap: 0;
    width: 100%;
    margin: 0;
}

.levels-lc-gallery-grid-continued .levels-lc-gallery-item {
    height: 100%;
    aspect-ratio: 1 / 0.66;
}

/* Overlay "VOIR TOUTES LES PHOTOS" */
.levels-lc-gallery-item.has-view-all-overlay {
    position: relative;
}

.levels-lc-gallery-view-all-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 1;
    transition: opacity 0.3s ease, background-color 0.3s ease;
    z-index: 10;
}

.levels-lc-gallery-item.has-view-all-overlay:hover .levels-lc-gallery-view-all-overlay {
    background-color: rgba(0, 0, 0, 0.75);
}

.levels-lc-gallery-view-all-text {
    color: #fff;
    font-family: "Bai Jamjuree", sans-serif;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    text-transform: uppercase;
    padding: 20px;
    transition: transform 0.3s ease, background-color 0.3s ease;
    letter-spacing: 1px;
}

.levels-lc-gallery-view-all-overlay:hover .levels-lc-gallery-view-all-text {
    transform: scale(1.05);
}

@media (max-width: 768px) {
    .levels-lc-gallery-grid {
        grid-template-columns: 1fr;
        aspect-ratio: auto;
    }
    
    .levels-lc-gallery-item.large {
        grid-row: span 1;
        grid-column: 1;
        aspect-ratio: 1 / 0.66;
    }
    
    .levels-lc-gallery-item.small.right-top,
    .levels-lc-gallery-item.small.right-bottom {
        grid-column: 1;
        aspect-ratio: 1 / 0.66;
    }
    
    /* Masquer les images intermédiaires en mobile (sauf la première et la dernière) */
    .levels-lc-gallery-item.hide-mobile {
        display: none !important;
    }
    
    .levels-lc-gallery-grid-continued {
        grid-template-columns: 1fr;
        aspect-ratio: auto;
    }
    
    .levels-lc-gallery-grid-continued .levels-lc-gallery-item {
        aspect-ratio: 1 / 0.66;
    }
    
    .levels-lc-gallery-view-all-text {
        font-size: 14px;
        padding: 15px;
    }
}

/* Lightbox Styles */
.levels-lc-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.levels-lc-lightbox.levels-lc-lightbox-active {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 1;
}

.levels-lc-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(2px);
}

.levels-lc-lightbox-content {
    position: relative;
    z-index: 1;
    max-width: 90vw;
    max-height: 85vh;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 120px;
}

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

.levels-lc-lightbox-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    align-items: center;
    justify-content: center;
}

.levels-lc-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: levels-lc-spin 0.8s linear infinite;
}

@keyframes levels-lc-spin {
    to {
        transform: rotate(360deg);
    }
}

.levels-lc-lightbox-close,
.levels-lc-lightbox-prev,
.levels-lc-lightbox-next {
    position: absolute;
    z-index: 2;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.3);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 24px;
    line-height: 1;
    padding: 0;
}

.levels-lc-lightbox-close span,
.levels-lc-lightbox-prev span,
.levels-lc-lightbox-next span {
    margin-top: -5px;
}

.levels-lc-lightbox-close:hover,
.levels-lc-lightbox-prev:hover,
.levels-lc-lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.5);
}

.levels-lc-lightbox-close {
    top: 20px;
    right: 20px;
}

.levels-lc-lightbox-prev {
    left: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.levels-lc-lightbox-next {
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
}

.levels-lc-lightbox-counter {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    color: #fff;
    font-size: 16px;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

.levels-lc-lightbox-thumbnails {
    position: absolute;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 2;
    display: flex;
    gap: 10px;
    max-width: 90vw;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 10px;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.5) rgba(255, 255, 255, 0.1);
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    cursor: grab;
}

.levels-lc-lightbox-thumbnails:active {
    cursor: grabbing;
}

.levels-lc-lightbox-thumbnails .levels-lc-lightbox-thumbnail {
    cursor: pointer;
}

.levels-lc-lightbox-thumbnails::-webkit-scrollbar {
    height: 8px;
}

.levels-lc-lightbox-thumbnails::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.levels-lc-lightbox-thumbnails::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.5);
    border-radius: 4px;
}

.levels-lc-lightbox-thumbnails::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.7);
}

.levels-lc-lightbox-thumbnail {
    width: 80px;
    height: 80px;
    min-width: 80px;
    background-size: cover;
    background-position: center;
    border-radius: 4px;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s ease;
    opacity: 0.6;
    position: relative;
}

.levels-lc-lightbox-thumbnail:hover {
    opacity: 1;
    transform: scale(1.1);
    border-color: rgba(255, 255, 255, 0.5);
    z-index: 1;
}

.levels-lc-lightbox-thumbnail.active {
    opacity: 1;
    border-color: #fff;
    box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}

.levels-lc-lightbox-thumbnail:hover::before {
    content: '';
    position: absolute;
    top: -220px;
    left: 50%;
    transform: translateX(-50%);
    width: 200px;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-image: var(--thumbnail-preview-image);
    border-radius: 4px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.5);
    border: 2px solid #fff;
    z-index: 10;
    pointer-events: none;
    animation: levels-lc-thumbnail-preview 0.3s ease;
}

@keyframes levels-lc-thumbnail-preview {
    from {
        opacity: 0;
        transform: translateX(-50%) scale(0.8);
    }
    to {
        opacity: 1;
        transform: translateX(-50%) scale(1);
    }
}

@media (max-width: 768px) {
    .levels-lc-lightbox-content {
        max-width: 95vw;
        max-height: 70vh;
        margin-bottom: 100px;
    }
    
    .levels-lc-lightbox-image {
        max-height: 70vh;
    }
    
    .levels-lc-lightbox-close,
    .levels-lc-lightbox-prev,
    .levels-lc-lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 20px;
    }
    
    .levels-lc-lightbox-prev {
        left: 10px;
    }
    
    .levels-lc-lightbox-next {
        right: 10px;
    }
    
    .levels-lc-lightbox-close {
        top: 10px;
        right: 10px;
    }
    
    .levels-lc-lightbox-thumbnails {
        bottom: 10px;
        gap: 8px;
    }
    
    .levels-lc-lightbox-thumbnail {
        width: 60px;
        height: 60px;
        min-width: 60px;
    }
    
    .levels-lc-lightbox-thumbnail:hover::after {
        width: 150px;
        height: 150px;
        top: -80px;
    }
    
    .levels-lc-lightbox-counter {
        bottom: 70px;
        font-size: 14px;
        padding: 6px 12px;
    }
}
