/**
 * DUPLIC - Galeria de Imagens / Lightbox
 * Estilos modernos e responsivos
 */

.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0);
    z-index: 10000;
    display: none;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease, background 0.3s ease;
}

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

.gallery-lightbox.loaded {
    opacity: 1;
    background: rgba(0, 0, 0, 0.95);
}

/* Conteúdo da galeria */
.gallery-content {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.gallery-lightbox.loaded .gallery-content {
    transform: scale(1);
}

.gallery-content img {
    max-width: 100%;
    max-height: 80vh;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    transition: opacity 0.3s ease;
}

/* Legenda com fade bonito */
.gallery-caption {
    position: fixed;
    bottom: 0; /* Valor inicial - será ajustado pelo JavaScript */
    left: 0;
    right: 0;
    background: linear-gradient(
        to top,
        rgba(0, 0, 0, 0.95) 0%,
        rgba(0, 0, 0, 0.75) 30%,
        rgba(0, 0, 0, 0) 100%
    );
    backdrop-filter: blur(8px);
    color: var(--white, #fff);
    padding: 1.25rem 1.5rem 0.35rem 1.5rem; /* Padding inferior mínimo */
    text-align: center;
    z-index: 10001;
    pointer-events: none; /* Não bloquear cliques */
}

.gallery-caption strong {
    display: block;
    font-size: 1.2rem;
    margin-bottom: 0.5rem;
    color: var(--cyan, #00A8E1);
    font-weight: 700;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.gallery-caption p {
    margin: 0 auto;
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.95);
    line-height: 1.5;
    max-width: 700px;
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
}

/* Contador de imagens */
.gallery-counter {
    position: fixed;
    top: 80px;
    right: 20px;
    background: rgba(0, 168, 225, 0.9);
    color: var(--white, #fff);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 2px 10px rgba(0, 168, 225, 0.3);
    z-index: 10001;
}

/* Carrossel de Miniaturas */
.gallery-thumbnails {
    position: fixed;
    bottom: 15px;
    left: 50%;
    transform: translateX(-50%);
    width: 90%;
    max-width: 900px;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(12px);
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.6);
    z-index: 10002;
}

.thumbnails-track {
    display: flex;
    gap: 10px;
    overflow-x: auto;
    overflow-y: hidden;
    scroll-behavior: smooth;
    padding: 5px;
    -webkit-overflow-scrolling: touch;
}

/* Esconder scrollbar mas manter funcionalidade */
.thumbnails-track::-webkit-scrollbar {
    height: 6px;
}

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

.thumbnails-track::-webkit-scrollbar-thumb {
    background: rgba(0, 168, 225, 0.6);
    border-radius: 3px;
}

.thumbnails-track::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 168, 225, 0.9);
}

.gallery-thumb {
    flex-shrink: 0;
    width: 80px;
    height: 80px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 3px solid transparent;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
}

.gallery-thumb img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transition: transform 0.3s ease;
}

.gallery-thumb:hover {
    border-color: rgba(0, 168, 225, 0.5);
    transform: translateY(-3px);
}

.gallery-thumb:hover img {
    transform: scale(1.1);
}

/* Miniatura ativa */
.gallery-thumb.active {
    border-color: var(--cyan, #00A8E1);
    box-shadow: 0 0 15px rgba(0, 168, 225, 0.6);
}

.gallery-thumb.active::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 168, 225, 0.2);
    pointer-events: none;
}

/* Botão fechar */
.gallery-close {
    position: fixed;
    top: 20px;
    right: 20px;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: var(--white, #fff);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
}

.gallery-close:hover {
    background: var(--cyan, #00A8E1);
    border-color: var(--cyan, #00A8E1);
    transform: rotate(90deg) scale(1.1);
}

/* Botões de navegação */
.gallery-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: var(--white, #fff);
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 10001;
}

.gallery-prev {
    left: 20px;
}

.gallery-next {
    right: 20px;
}

.gallery-nav:hover {
    background: var(--cyan, #00A8E1);
    border-color: var(--cyan, #00A8E1);
    transform: translateY(-50%) scale(1.1);
}

.gallery-nav:active {
    transform: translateY(-50%) scale(0.95);
}

/* Loader */
.gallery-loader {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
    align-items: center;
    justify-content: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: var(--cyan, #00A8E1);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* Animações de entrada/saída */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: scale(1);
    }
    to {
        opacity: 0;
        transform: scale(0.9);
    }
}

/* Responsivo */
@media (max-width: 768px) {
    .gallery-content {
        max-width: 95vw;
    }

    .gallery-content img {
        max-height: 60vh;
        border-radius: 4px;
    }

    .gallery-caption {
        /* bottom: calculado dinamicamente pelo JavaScript */
        padding: 1rem 1rem 0.3rem 1rem;
    }

    .gallery-caption strong {
        font-size: 1.05rem;
    }

    .gallery-caption p {
        font-size: 0.9rem;
    }

    .gallery-counter {
        top: 70px;
        right: 10px;
        font-size: 0.85rem;
        padding: 0.4rem 0.8rem;
    }

    .gallery-close {
        top: 10px;
        right: 10px;
        width: 45px;
        height: 45px;
        font-size: 1.3rem;
    }

    .gallery-nav {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }

    .gallery-prev {
        left: 10px;
    }

    .gallery-next {
        right: 10px;
    }

    /* Thumbnails em mobile */
    .gallery-thumbnails {
        width: 95%;
        padding: 10px;
        bottom: 10px;
    }

    .gallery-thumb {
        width: 60px;
        height: 60px;
    }

    .thumbnails-track {
        gap: 8px;
    }
}

@media (max-width: 480px) {
    .gallery-content img {
        max-height: 55vh; /* Ajustado para dar mais espaço para a imagem */
    }

    .gallery-caption {
        /* bottom: calculado dinamicamente pelo JavaScript */
        padding: 0.9rem 0.75rem 0.25rem 0.75rem;
    }

    .gallery-caption strong {
        font-size: 0.95rem;
    }

    .gallery-caption p {
        font-size: 0.85rem;
    }

    .gallery-close,
    .gallery-nav {
        width: 40px;
        height: 40px;
    }

    .gallery-thumb {
        width: 50px;
        height: 50px;
    }
}

/* Acessibilidade */
.gallery-close:focus,
.gallery-nav:focus {
    outline: 2px solid var(--cyan, #00A8E1);
    outline-offset: 2px;
}

/* Desabilitar scroll quando lightbox estiver ativo */
body.gallery-open {
    overflow: hidden;
}

/* Melhorias visuais para portfolio items */
.portfolio-image img {
    cursor: zoom-in;
    transition: transform 0.3s ease, filter 0.3s ease;
}

.portfolio-item:hover .portfolio-image img {
    transform: scale(1.05);
}

/* Indicador de zoom */
.portfolio-image::after {
    content: '\f00e'; /* Font Awesome search-plus icon */
    font-family: 'Font Awesome 6 Free';
    font-weight: 900;
    position: absolute;
    top: 10px;
    right: 10px;
    background: rgba(0, 168, 225, 0.9);
    color: white;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    pointer-events: none;
    font-size: 14px;
}

.portfolio-item:hover .portfolio-image::after {
    opacity: 1;
}

/* Prevenir seleção de texto */
.gallery-lightbox {
    user-select: none;
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
}
