/**
 * AC Product Gallery CSS
 * Estilização para galeria de imagens de produto com lightbox
 */

/* Container principal da galeria */
.ac-product-gallery {
    max-width: 100%;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    position: relative;
}

/* Layout de 2 colunas */
.ac-gallery-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 15px;
    height: 400px;
}

/* Coluna da imagem principal (esquerda) */
.ac-gallery-main {
    position: relative;
    height: 100%;
}

.ac-main-image-container {
    position: relative;
    overflow: hidden;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    transition: all 0.3s ease;
    cursor: pointer;
    height: 100%;
}

.ac-main-image-container:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.15);
}

.ac-main-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
    /* Otimizações para melhor qualidade de imagem */
    image-rendering: auto;
    image-rendering: -webkit-optimize-contrast;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Força alta qualidade para imagens grandes */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.ac-main-image-container:hover .ac-main-image {
    transform: scale(1.05);
}

/* Ícone de zoom */
.ac-zoom-icon {
    position: absolute;
    top: 15px;
    right: 15px;
    background: rgba(0, 0, 0, 0.6);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    backdrop-filter: blur(10px);
}

.ac-main-image-container:hover .ac-zoom-icon {
    opacity: 1;
}

/* Coluna das thumbnails (direita) */
.ac-gallery-thumbnails {
    display: flex;
    flex-direction: column;
    gap: 10px;
    height: 100%;
}

/* Thumbnails individuais - ajustados para ocupar exatamente 50% cada */
.ac-thumbnail-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    height: calc(50% - 5px); /* 50% da altura menos metade do gap (10px/2) */
    min-height: 0;
}

.ac-thumbnail-item:hover {
    transform: scale(1.02);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
}

.ac-thumbnail-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
    /* Otimizações para melhor qualidade de imagem */
    image-rendering: auto;
    image-rendering: -webkit-optimize-contrast;
    backface-visibility: hidden;
    -webkit-backface-visibility: hidden;
    /* Força alta qualidade para imagens grandes */
    -webkit-transform: translateZ(0);
    transform: translateZ(0);
}

.ac-thumbnail-item:hover img {
    transform: scale(1.1);
}

/* Estado ativo do thumbnail */
.ac-thumbnail-item.active {
    border: 3px solid #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.2);
}

/* Overlay para mais imagens */
.ac-thumbnail-more {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 18px;
    font-weight: 600;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.ac-thumbnail-item:last-child .ac-thumbnail-more {
    opacity: 1;
}



/* Lightbox */
.ac-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(10px);
}

.ac-lightbox.active {
    display: flex;
}

.ac-lightbox-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

.ac-lightbox-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    z-index: 10001;
}

/* Botão fechar */
.ac-lightbox-close {
    position: absolute;
    top: -50px;
    right: 0;
    background: none;
    border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
    z-index: 10002;
    width: 50px;
    height: 50px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: background-color 0.3s ease;
}

.ac-lightbox-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* Conteúdo do lightbox */
.ac-lightbox-content {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.ac-lightbox-image-container {
    position: relative;
    max-width: 100%;
    max-height: 80vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ac-lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
}

/* Loading spinner */
.ac-lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

.ac-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Navegação do lightbox */
.ac-lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(0, 0, 0, 0.6);
    border: none;
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    backdrop-filter: blur(10px);
    z-index: 10002;
}

.ac-lightbox-nav:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: translateY(-50%) scale(1.1);
}

.ac-lightbox-prev {
    left: -80px;
}

.ac-lightbox-next {
    right: -80px;
}

/* Contador */
.ac-lightbox-counter {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: white;
    font-size: 16px;
    font-weight: 500;
    background: rgba(0, 0, 0, 0.6);
    padding: 8px 16px;
    border-radius: 20px;
    backdrop-filter: blur(10px);
}

/* Animações */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

.ac-lightbox-image {
    animation: slideIn 0.3s ease;
}

/* Responsividade */
@media (max-width: 768px) {
    .ac-gallery-thumbnails {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 8px;
    }
    
    .ac-thumbnail-item img {
        height: 60px;
    }
    
    .ac-lightbox-container {
        max-width: 95vw;
        max-height: 95vh;
    }
    
    .ac-lightbox-image-container {
        max-width: 90vw;
        max-height: 70vh;
    }
    
    .ac-lightbox-close {
        top: -40px;
        font-size: 30px;
        width: 40px;
        height: 40px;
    }
    
    .ac-lightbox-nav {
        width: 40px;
        height: 40px;
    }
    
    .ac-lightbox-prev {
        left: -50px;
    }
    
    .ac-lightbox-next {
        right: -50px;
    }
    
    .ac-lightbox-counter {
        bottom: -40px;
        font-size: 14px;
        padding: 6px 12px;
    }
    
    .ac-zoom-icon {
        width: 35px;
        height: 35px;
        top: 10px;
        right: 10px;
    }
    
    .ac-zoom-icon svg {
        width: 20px;
        height: 20px;
    }
}

@media (max-width: 480px) {
    .ac-gallery-thumbnails {
        grid-template-columns: repeat(2, 1fr) !important;
    }
    
    .ac-thumbnail-item img {
        height: 70px;
    }
    
    .ac-lightbox-nav {
        display: none;
    }
    
    .ac-lightbox-image-container {
        max-width: 95vw;
        max-height: 60vh;
    }
}

/* Suporte para toque em dispositivos móveis */
@media (hover: none) and (pointer: coarse) {
    .ac-zoom-icon {
        opacity: 1;
    }
    
    .ac-main-image-container:hover .ac-main-image {
        transform: none;
    }
    
    .ac-thumbnail-item:hover {
        transform: none;
    }
    
    .ac-thumbnail-item:hover img {
        opacity: 1;
    }
}

/* Acessibilidade */
.ac-lightbox-close:focus,
.ac-lightbox-nav:focus,
.ac-thumbnail-item:focus,
.ac-main-image-container:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Modo escuro */
@media (prefers-color-scheme: dark) {
    .ac-main-image-container {
        box-shadow: 0 4px 20px rgba(255, 255, 255, 0.1);
    }
    
    .ac-main-image-container:hover {
        box-shadow: 0 8px 30px rgba(255, 255, 255, 0.15);
    }
    
    .ac-thumbnail-item:hover {
        box-shadow: 0 4px 15px rgba(255, 255, 255, 0.2);
    }
}