/**
 * ACF Gallery Carousel - Styles v1.1.0
 * Responsive optimisé + Support largeur personnalisée
 */

/* ========================================
   RESET & BASE
   ======================================== */
.agc-gallery-container,
.agc-gallery-container *,
.agc-gallery-container *::before,
.agc-gallery-container *::after {
    box-sizing: border-box;
}

.agc-gallery-container {
    display: inline-flex;
    flex-direction: column;
    gap: 15px;
    width: 100%;
    max-width: 100%;
    font-family: inherit;
}

/* ========================================
   CONTAINER POSITIONS
   ======================================== */
.agc-gallery-container.agc-position-bottom {
    flex-direction: column;
}

.agc-gallery-container.agc-position-left {
    flex-direction: row-reverse;
    align-items: flex-start;
}

.agc-gallery-container.agc-position-right {
    flex-direction: row;
    align-items: flex-start;
}

.agc-gallery-container.agc-position-left .agc-main-wrapper,
.agc-gallery-container.agc-position-right .agc-main-wrapper {
    flex: 1;
    min-width: 0;
}

.agc-gallery-container.agc-position-left .agc-thumbnails-wrapper,
.agc-gallery-container.agc-position-right .agc-thumbnails-wrapper {
    width: 120px;
    flex-shrink: 0;
}

.agc-gallery-container.agc-position-left .agc-thumbnails-grid,
.agc-gallery-container.agc-position-right .agc-thumbnails-grid {
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    max-height: 100%;
    scrollbar-width: thin;
}

/* ========================================
   MAIN IMAGE
   ======================================== */
.agc-main-wrapper {
    width: 100%;
    display: flex;
    justify-content: center;
}

.agc-main-image {
    position: relative;
    width: 100%;
    height: 400px;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
}

.agc-main-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: block;
}

.agc-main-image img.agc-loading {
    opacity: 0.5;
}

.agc-main-image:hover img {
    transform: scale(1.02);
}

/* ========================================
   NAVIGATION ARROWS
   ======================================== */
.agc-arrow {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 40px;
    height: 40px;
    border: none;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    z-index: 10;
    padding: 0;
    opacity: 0;
}

.agc-main-image:hover .agc-arrow,
.agc-arrow:focus {
    opacity: 1;
}

.agc-arrow:hover {
    background: rgba(0, 0, 0, 0.7);
    transform: translateY(-50%) scale(1.1);
}

.agc-arrow:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.agc-arrow svg {
    width: 20px;
    height: 20px;
    pointer-events: none;
}

.agc-arrow-prev {
    left: 15px;
}

.agc-arrow-next {
    right: 15px;
}

/* ========================================
   COUNTER
   ======================================== */
.agc-counter {
    position: absolute;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    z-index: 10;
    pointer-events: none;
}

.agc-counter-top-left {
    top: 15px;
    left: 15px;
}

.agc-counter-top-right {
    top: 15px;
    right: 15px;
}

.agc-counter-bottom-left {
    bottom: 15px;
    left: 15px;
}

.agc-counter-bottom-right {
    bottom: 15px;
    right: 15px;
}

/* ========================================
   THUMBNAILS
   ======================================== */
.agc-thumbnails-wrapper {
    width: 100%;
}

.agc-thumbnails-grid {
    display: grid;
    grid-template-columns: repeat(var(--thumbs-per-row, 4), 1fr);
    gap: 10px;
}

.agc-thumbnail {
    position: relative;
    height: 80px;
    border-radius: 6px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
    border: 2px solid transparent;
    padding: 0;
    background: none;
    display: block;
}

.agc-thumbnail::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: transparent;
    pointer-events: none;
    transition: background-color 0.2s ease;
}

.agc-thumbnail:hover {
    opacity: 0.9;
    transform: scale(1.03);
}

.agc-thumbnail:focus {
    outline: 2px solid #fff;
    outline-offset: 2px;
    opacity: 0.9;
}

.agc-thumbnail.active {
    opacity: 1;
    border-color: #fff;
    transform: scale(1);
}

.agc-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    pointer-events: none;
}

/* Side thumbnails - specific styles */
.agc-position-left .agc-thumbnails-grid,
.agc-position-right .agc-thumbnails-grid {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.agc-position-left .agc-thumbnail,
.agc-position-right .agc-thumbnail {
    width: 100%;
    height: 80px;
    flex-shrink: 0;
}

/* ========================================
   MAIN IMAGE LINK (for Elementor lightbox)
   ======================================== */
.agc-main-link {
    display: block;
    width: 100%;
    height: 100%;
}

.agc-main-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center center;
    transition: opacity 0.3s ease, transform 0.3s ease;
    display: block;
}

/* ========================================
   HIDDEN LIGHTBOX LINKS
   ======================================== */
.agc-lightbox-links {
    position: absolute;
    width: 0;
    height: 0;
    overflow: hidden;
    opacity: 0;
    pointer-events: none;
}

/* ========================================
   NO IMAGES MESSAGE
   ======================================== */
.agc-no-images {
    padding: 40px;
    text-align: center;
    background: #f5f5f5;
    border: 2px dashed #ccc;
    border-radius: 8px;
    color: #666;
    font-size: 14px;
}

/* ========================================
   RESPONSIVE - TABLET (max 1024px)
   ======================================== */
@media (max-width: 1024px) {
    .agc-main-image .agc-arrow {
        opacity: 1;
    }
    
    .agc-arrow {
        width: 36px;
        height: 36px;
    }
    
    .agc-arrow svg {
        width: 18px;
        height: 18px;
    }
}

/* ========================================
   RESPONSIVE - TABLET PORTRAIT (max 768px)
   ======================================== */
@media (max-width: 768px) {
    .agc-gallery-container.agc-position-left,
    .agc-gallery-container.agc-position-right {
        flex-direction: column;
    }
    
    .agc-gallery-container.agc-position-left .agc-thumbnails-wrapper,
    .agc-gallery-container.agc-position-right .agc-thumbnails-wrapper {
        width: 100%;
    }
    
    .agc-gallery-container.agc-position-left .agc-thumbnails-grid,
    .agc-gallery-container.agc-position-right .agc-thumbnails-grid {
        flex-direction: row;
        flex-wrap: wrap;
        overflow-y: visible;
        max-height: none;
        display: grid;
        grid-template-columns: repeat(4, 1fr);
    }
    
    .agc-position-left .agc-thumbnail,
    .agc-position-right .agc-thumbnail {
        width: 100%;
        height: 70px;
    }
    
    .agc-thumbnails-grid {
        grid-template-columns: repeat(4, 1fr) !important;
    }
    
    .agc-thumbnail {
        height: 70px;
    }
    
    .agc-main-image {
        height: 350px;
    }
    
    .agc-arrow {
        width: 35px;
        height: 35px;
        opacity: 1;
    }
    
    .agc-arrow svg {
        width: 16px;
        height: 16px;
    }
    
    .agc-arrow-prev {
        left: 10px;
    }
    
    .agc-arrow-next {
        right: 10px;
    }
}

/* ========================================
   RESPONSIVE - MOBILE (max 480px)
   ======================================== */
@media (max-width: 480px) {
    .agc-thumbnails-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 6px;
    }
    
    .agc-position-left .agc-thumbnail,
    .agc-position-right .agc-thumbnail {
        height: 55px;
    }
    
    .agc-main-image {
        height: 250px;
        border-radius: 6px;
    }
    
    .agc-main-image:hover img {
        transform: none;
    }
    
    .agc-thumbnail {
        height: 55px;
        border-radius: 4px;
    }
    
    .agc-arrow {
        width: 32px;
        height: 32px;
    }
    
    .agc-arrow svg {
        width: 14px;
        height: 14px;
    }
    
    .agc-counter {
        font-size: 12px;
        padding: 4px 10px;
    }
}

/* ========================================
   RESPONSIVE - SMALL MOBILE (max 360px)
   ======================================== */
@media (max-width: 360px) {
    .agc-thumbnails-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 4px;
    }
    
    .agc-thumbnail {
        height: 50px;
    }
    
    .agc-main-image {
        height: 200px;
    }
    
    .agc-arrow {
        width: 28px;
        height: 28px;
    }
    
    .agc-arrow-prev {
        left: 8px;
    }
    
    .agc-arrow-next {
        right: 8px;
    }
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes agc-fade-in {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ========================================
   TOUCH DEVICE OPTIMIZATIONS
   ======================================== */
@media (hover: none) and (pointer: coarse) {
    .agc-thumbnail {
        opacity: 0.7;
    }
    
    .agc-thumbnail.active {
        opacity: 1;
    }
    
    .agc-thumbnail:hover {
        transform: none;
    }
    
    .agc-arrow {
        opacity: 1;
    }
    
    .agc-arrow:hover {
        transform: translateY(-50%);
    }
    
    .agc-main-image:hover img,
    .agc-main-link:hover img {
        transform: none;
    }
}

/* ========================================
   REDUCED MOTION
   ======================================== */
@media (prefers-reduced-motion: reduce) {
    .agc-main-image img,
    .agc-main-link img,
    .agc-thumbnail,
    .agc-arrow {
        transition: none;
    }
}

/* ========================================
   HIGH CONTRAST MODE
   ======================================== */
@media (prefers-contrast: high) {
    .agc-thumbnail.active {
        border-width: 3px;
    }
    
    .agc-arrow {
        background: #000;
        border: 2px solid #fff;
    }
    
    .agc-counter {
        background: #000;
        border: 1px solid #fff;
    }
}

/* ========================================
   PRINT STYLES
   ======================================== */
@media print {
    .agc-arrow,
    .agc-counter,
    .agc-lightbox {
        display: none !important;
    }
    
    .agc-main-image {
        height: auto !important;
    }
    
    .agc-thumbnails-grid {
        display: flex;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .agc-thumbnail {
        width: 60px;
        height: 60px;
        opacity: 1;
    }
}

/* ========================================
   CUSTOM SCROLLBAR FOR SIDE THUMBNAILS
   ======================================== */
.agc-position-left .agc-thumbnails-grid::-webkit-scrollbar,
.agc-position-right .agc-thumbnails-grid::-webkit-scrollbar {
    width: 6px;
}

.agc-position-left .agc-thumbnails-grid::-webkit-scrollbar-track,
.agc-position-right .agc-thumbnails-grid::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

.agc-position-left .agc-thumbnails-grid::-webkit-scrollbar-thumb,
.agc-position-right .agc-thumbnails-grid::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

.agc-position-left .agc-thumbnails-grid::-webkit-scrollbar-thumb:hover,
.agc-position-right .agc-thumbnails-grid::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.5);
}
