/* ==========================================================================
   RESET E CONFIGURAÇÕES GERAIS
   ========================================================================== */
.aemg-masonry {
    width: 100%;
    position: relative;
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ==========================================================================
   LAYOUT MASONRY REAL - POSICIONAMENTO ABSOLUTO
   ========================================================================== */
.aemg-item {
    position: absolute;
    box-sizing: border-box;
    transition: transform 0.3s ease;
    cursor: pointer;
    z-index: 1;
}

.aemg-item:hover {
    z-index: 2;
    transform: translateY(-2px);
}

/* Container da mídia - garante proporção */
.aemg-media {
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
    background-color: transparent;
}

/* Imagens e vídeos - proporção preservada */
.aemg-item img,
.aemg-item video {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

/* ==========================================================================
   LAYOUT PARA ITEM ÚNICO
   ========================================================================== */
.aemg-masonry.single-item {
    display: flex !important;
    justify-content: center !important;
    align-items: center !important;
    height: auto !important;
}

.aemg-single-item {
    position: static !important;
    max-width: 800px !important;
    width: 100% !important;
}

/* ==========================================================================
   LIGHTBOX (POP-UP) - DESIGN MELHORADO SEM CÍRCULOS
   ========================================================================== */
.aemg-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.aemg-lightbox.active {
    display: block;
    opacity: 1;
}

.aemg-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    cursor: pointer;
    z-index: 1;
}

.aemg-lightbox-content {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px;
    box-sizing: border-box;
}

/* Botão de fechar - ÍCONE LIMPO SEM CÍRCULO */
.aemg-lightbox-close {
    position: fixed;
    top: 25px;
    right: 25px;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    color: white;
    font-size: 40px;
    font-weight: 300;
    cursor: pointer;
    z-index: 3;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    line-height: 1;
    padding: 0;
}

.aemg-lightbox-close:hover {
    color: #ff6b6b;
    transform: scale(1.2);
}

/* Container da mídia - centralizado */
.aemg-lightbox-media {
    max-width: 90%;
    max-height: 85%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

/* CORREÇÃO PARA ITENS VERTICAIS: limitar altura e largura */
.aemg-lightbox-media img,
.aemg-lightbox-media video {
    max-width: 90vw; /* Limite de largura */
    max-height: 85vh; /* Limite de altura */
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border-radius: 4px;
}

.aemg-lightbox-media video {
    background: #000;
}

/* Navegação - setas limpas SEM CÍRCULOS */
.aemg-lightbox-nav {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 100%;
    display: flex;
    justify-content: space-between;
    padding: 0 20px;
    z-index: 2;
    pointer-events: none;
}

.aemg-lightbox-prev,
.aemg-lightbox-next {
    pointer-events: all;
    width: 60px;
    height: 60px;
    background: transparent;
    border: none;
    color: white;
    font-size: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    opacity: 0.7;
    padding: 0;
    line-height: 1;
}

.aemg-lightbox-prev:hover,
.aemg-lightbox-next:hover {
    opacity: 1;
    transform: scale(1.2);
}

/* Contador (ex: 1/4) - também limpo */
.aemg-lightbox-counter {
    position: fixed;
    top: 30px;
    left: 30px;
    background: transparent;
    color: white;
    font-size: 16px;
    font-weight: 500;
    z-index: 3;
    opacity: 0.8;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Legenda */
.aemg-lightbox-caption {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    max-width: 80%;
    text-align: center;
    font-size: 16px;
    z-index: 3;
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    opacity: 0.9;
}

/* ==========================================================================
   ANIMAÇÕES
   ========================================================================== */
@keyframes mediaFadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ==========================================================================
   LAYOUT RESPONSIVO
   ========================================================================== */
@media (max-width: 767px) {
    /* No mobile, desativa masonry e usa layout normal */
    .aemg-masonry {
        display: grid !important;
        grid-template-columns: 1fr !important;
        height: auto !important;
    }
    
    .aemg-item {
        position: static !important;
        width: 100% !important;
        margin-bottom: 1vh !important;
        transform: none !important;
    }
    
    .aemg-lightbox-content {
        padding: 20px;
    }
    
    .aemg-lightbox-close {
        top: 20px;
        right: 20px;
        font-size: 35px;
        width: 35px;
        height: 35px;
    }
    
    .aemg-lightbox-prev,
    .aemg-lightbox-next {
        width: 50px;
        height: 50px;
        font-size: 35px;
    }
    
    .aemg-lightbox-counter {
        top: 25px;
        left: 25px;
        font-size: 15px;
    }
    
    .aemg-lightbox-caption {
        bottom: 20px;
        font-size: 15px;
        padding: 10px 20px;
    }
    
    .aemg-lightbox-media {
        max-width: 95%;
        max-height: 80%;
    }
    
    /* Correção extra para itens verticais no mobile */
    .aemg-lightbox-media img,
    .aemg-lightbox-media video {
        max-width: 95vw;
        max-height: 75vh;
    }
}

@media (max-width: 480px) {
    .aemg-lightbox-close {
        top: 15px;
        right: 15px;
        font-size: 30px;
        width: 30px;
        height: 30px;
    }
    
    .aemg-lightbox-prev,
    .aemg-lightbox-next {
        width: 45px;
        height: 45px;
        font-size: 30px;
    }
    
    .aemg-lightbox-counter {
        top: 20px;
        left: 20px;
        font-size: 14px;
    }
    
    .aemg-lightbox-caption {
        bottom: 15px;
        font-size: 14px;
        padding: 8px 16px;
    }
}

/* ==========================================================================
   EFEITO DE DESTAQUE AO PASSAR O MOUSE
   ========================================================================== */
.aemg-lightbox-close:active,
.aemg-lightbox-prev:active,
.aemg-lightbox-next:active {
    transform: scale(0.95);
}

/* ==========================================================================
   ESTILOS PARA MODO DE EDIÇÃO DO ELEMENTOR
   ========================================================================== */
.elementor-editor-active .aemg-item {
    cursor: default;
}

.elementor-editor-active .aemg-item:hover {
    transform: none;
}