/* Estilos gerais da galeria */
.weg-gallery-container {
    margin-bottom: 20px;
}

.weg-gallery-grid {
    display: grid;
    gap: 10px; /* Espaçamento padrão, pode ser sobrescrito pelo Elementor */
    height: var(--gallery-height, auto); /* Usar variável CSS para altura */
}

.weg-gallery-item {
    position: relative;
    overflow: hidden;
    border-radius: 8px;
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%; /* Garante que o item da galeria ocupe a altura total da sua célula */
}

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

.weg-gallery-item a {
    display: block;
    overflow: hidden;
    border-radius: 8px;
    transition: box-shadow 0.3s ease;
    position: relative;
    width: 100%;
    height: 100%;
    /* Garante que o link ocupe 100% da altura do item da galeria */
}

.weg-gallery-item a:hover {
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
}

.weg-gallery-item:hover img {
    transform: scale(1.05);
}

/* Estilos para o botão +X e overlay */
.weg-gallery-item.weg-has-more a::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 5;
    pointer-events: none;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.weg-more-button {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 14px;
    font-weight: bold;
    z-index: 10;
    cursor: pointer;
    transition: background 0.3s ease, transform 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 40px;
    height: 40px;
    pointer-events: all;
}

.weg-gallery-item.weg-has-more a:hover::after {
    opacity: 0.7;
}

.weg-more-button:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.05);
}


/* Layouts Dinâmicos */

/* 1 IMAGEM */
.weg-layout-1-layout-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

/* 2 IMAGENS */
.weg-layout-2-layout-1 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

/* 3 IMAGENS */
.weg-layout-3-layout-1 {
    grid-template-columns: repeat(3, 1fr);
    grid-template-rows: 1fr;
}

.weg-layout-3-layout-2 {
    grid-template-columns: 2fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.weg-layout-3-layout-2 .weg-gallery-item:first-child {
    grid-column: 1;
    grid-row: span 2;
}

/* 4 IMAGENS */
.weg-layout-4-layout-1 {
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: 1fr;
}

.weg-layout-4-layout-2 {
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.weg-layout-4-layout-2 .weg-gallery-item:first-child {
    grid-column: 1;
    grid-row: span 2;
}

.weg-layout-4-layout-3 {
    grid-template-columns: 1fr 2fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.weg-layout-4-layout-3 .weg-gallery-item:nth-child(2) {
    grid-column: 2;
    grid-row: span 2;
}

.weg-layout-4-layout-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* 5 IMAGENS */
.weg-layout-5-layout-1 {
    grid-template-columns: 2fr 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.weg-layout-5-layout-1 .weg-gallery-item:first-child {
    grid-column: 1;
    grid-row: span 2;
}

.weg-layout-5-layout-2 {
    grid-template-columns: 1fr 2fr 1fr;
    grid-template-rows: 1fr 1fr;
}

.weg-layout-5-layout-2 .weg-gallery-item:nth-child(2) {
    grid-column: 2;
    grid-row: span 2;
}

.weg-layout-5-layout-3 {
    grid-template-columns: 1fr 1fr 2fr;
    grid-template-rows: 1fr 1fr;
}

.weg-layout-5-layout-3 .weg-gallery-item:last-child {
    grid-column: 3;
    grid-row: span 2;
}


/* Responsividade */
@media (max-width: 768px) {
    .weg-gallery-grid {
        grid-template-columns: 1fr !important;
        grid-template-rows: auto !important;
        height: auto !important; /* Altura automática em mobile */
    }
    
    .weg-gallery-grid .weg-gallery-item {
        grid-column: span 1 !important;
        grid-row: span 1 !important;
        aspect-ratio: 16/9;
    }
    
    .weg-more-button {
        bottom: 5px;
        right: 5px;
        padding: 6px 10px;
        font-size: 12px;
    }
}

@media (max-width: 480px) {
    .weg-gallery-grid {
        gap: 5px;
    }
    
    .weg-more-button {
        padding: 4px 8px;
        font-size: 11px;
    }
}

/* Estilos para Lightbox */
.weg-lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 99999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.weg-lightbox-overlay.active {
    opacity: 1;
    visibility: visible;
}

.weg-lightbox-container {
    position: relative;
    max-width: 95%;
    max-height: 95%;
    display: flex;
    justify-content: center;
    align-items: center;
}

.weg-lightbox-content {
    position: relative;
    max-width: 100%;
    max-height: 100%;
}

.weg-lightbox-image {
    max-width: 100%;
    max-height: 100vh;
    object-fit: contain;
    display: block;
}

.weg-lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: none;
}

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

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

.weg-lightbox-close {
    position: absolute;
    top: -50px;
    right: -50px;
    color: #fff;
    font-size: 30px;
    cursor: pointer;
    background: rgba(0, 0, 0, 0.5);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: background 0.3s ease;
}

.weg-lightbox-close:hover {
    background: rgba(0, 0, 0, 0.8);
}

.weg-lightbox-nav {
    position: absolute;
    top: 50%;
    width: calc(100% + 100px);
    left: -50px;
    display: flex;
    justify-content: space-between;
    transform: translateY(-50%);
    pointer-events: none;
}

.weg-lightbox-nav button {
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    border: none;
    padding: 15px 20px;
    cursor: pointer;
    font-size: 24px;
    border-radius: 50%;
    transition: background 0.3s ease, transform 0.2s ease;
    pointer-events: all;
}

.weg-lightbox-nav button:hover {
    background: rgba(0, 0, 0, 0.8);
    transform: scale(1.1);
}

.weg-lightbox-counter {
    position: absolute;
    bottom: -50px;
    left: 50%;
    transform: translateX(-50%);
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 14px;
}

/* Animações de transição */
.weg-fade-in {
    animation: wegFadeIn 0.3s ease;
}

@keyframes wegFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.weg-slide-in {
    animation: wegSlideIn 0.3s ease;
}

@keyframes wegSlideIn {
    from { transform: translateX(100px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.weg-zoom-in {
    animation: wegZoomIn 0.3s ease;
}

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

/* Previne scroll do body quando lightbox está aberto */
body.weg-lightbox-open {
    overflow: hidden;
}
