/**
 * GALLERY MODAL - JM EMPREENDIMENTOS
 * Modal customizado para galeria de imagens
 * Design clean e responsivo seguindo o padrão do projeto
 */

/* ===== OVERLAY E HOVER DOS TILES ===== */
.tile,
.v2-location__frame[data-gallery-item],
.v2-masterplan__frame[data-gallery-item] {
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.tile:hover,
.v2-location__frame[data-gallery-item]:hover,
.v2-masterplan__frame[data-gallery-item]:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.tile__overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(34, 59, 90, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
    border-radius: 16px;
}

.tile:hover .tile__overlay,
.v2-location__frame[data-gallery-item]:hover .tile__overlay,
.v2-masterplan__frame[data-gallery-item]:hover .tile__overlay {
    opacity: 1;
}

.tile__icon {
    font-size: 32px;
    color: #FFFFFF;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

/* ===== ESTILOS ESPECÍFICOS PARA FRAMES ===== */
.v2-location__frame[data-gallery-item],
.v2-masterplan__frame[data-gallery-item] {
    border-radius: 16px;
    overflow: hidden;
    background: var(--sand);
    box-shadow: 0 0 0 0 rgba(0, 0, 0, 0);
    margin: 2px;
}

.v2-location__frame[data-gallery-item] img,
.v2-masterplan__frame[data-gallery-item] img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s ease, opacity 0.3s ease;
    border-radius: 16px;
}

/* ===== MODAL DA GALERIA ===== */
.gallery-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.gallery-modal.is-open {
    opacity: 1;
    visibility: visible;
}

.gallery-modal__backdrop {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(5px);
}

.gallery-modal__container {
    position: sticky;
    width: 90%;
    max-width: 1200px;
    max-height: 90vh;
    background: #FFFFFF;
    border-radius: 16px;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    transition: transform 0.3s ease;
}

.gallery-modal.is-open .gallery-modal__container {
    transform: scale(1);
}

/* ===== BOTÕES DE CONTROLE ===== */
.gallery-modal__close {
    position: absolute;
    top: 16px;
    right: 16px;
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    color: var(--blue);
}

.gallery-modal__close:hover {
    background: #FFFFFF;
    transform: scale(1.1);
}

.gallery-modal__nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 10;
    transition: all 0.2s ease;
    color: var(--blue);
}

.gallery-modal__nav:hover {
    background: #FFFFFF;
    transform: translateY(-50%) scale(1.1);
}

.gallery-modal__nav--prev {
    left: 16px;
}

.gallery-modal__nav--next {
    right: 16px;
}

.gallery-modal__nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    transform: translateY(-50%);
}

.gallery-modal__nav:disabled:hover {
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.9);
}

/* ===== CONTEÚDO DA GALERIA ===== */
.gallery-modal__content {
    position: relative;
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
}

.gallery-modal__image {
    width: 100%;
    height: 70vh;
    object-fit: contain;
    background: #F8F9FA;
}

.gallery-modal__info {
    padding: 24px;
    background: #FFFFFF;
    border-top: 1px solid #E9ECEF;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.gallery-modal__title {
    font-family: var(--font-body);
    font-size: 20px;
    font-weight: 600;
    color: var(--blue);
    margin: 0;
}

.gallery-modal__counter {
    font-family: var(--font-body);
    font-size: 16px;
    color: #6C757D;
    font-weight: 500;
}

/* ===== RESPONSIVIDADE ===== */
/* Media query específica para tablets */
@media (max-width: 768px) and (min-width: 481px) {
    .gallery-modal__container {
        width: 95%;
        max-height: 90vh;
        /* Garantir que o background seja visível no tablet */
        background: #FFFFFF !important;
        /* Melhorar renderização */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        /* Garantir que o container seja visível */
        display: flex;
        flex-direction: column;
        /* Garantir altura mínima */
        min-height: 400px;
        top: 0;
        bottom: 15rem;
    }
    
    .gallery-modal__image {
        height: 60vh;
        min-height: 300px;
        /* Garantir que a imagem seja visível */
        background: #F8F9FA;
        /* Garantir que a imagem ocupe o espaço disponível */
        flex: 1;
        object-fit: contain;
    }
    
    .gallery-modal__close {
        top: 12px;
        right: 12px;
        width: 40px;
        height: 40px;
        /* Garantir que o botão seja visível */
        z-index: 10001;
    }
    
    .gallery-modal__nav {
        width: 48px;
        height: 48px;
        /* Garantir que os botões sejam visíveis */
        z-index: 10001;
    }
    
    .gallery-modal__nav--prev {
        left: 12px;
    }
    
    .gallery-modal__nav--next {
        right: 12px;
    }
    
    .gallery-modal__content {
        /* Garantir que o conteúdo seja visível */
        height: 100%;
        display: flex;
        flex-direction: column;
        flex: 1;
    }
    
    .gallery-modal__info {
        padding: 16px;
        flex-direction: column;
        gap: 8px;
        text-align: center;
        /* Garantir que a info seja visível */
        background: #FFFFFF !important;
        /* Garantir que a info não seja cortada */
        flex-shrink: 0;
    }
    
    .gallery-modal__title {
        font-size: 18px;
    }
}

/* Media query para mobile pequeno */

@media (max-width: 480px) {
    .gallery-modal__container {
        width: 100%;
        height: 70vh;
        max-height: 100vh;
        border-radius: 0;
        /* Garantir que o background branco seja visível */
        background: #FFFFFF !important;
        /* Melhorar renderização no mobile */
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
        /* Garantir que o container seja visível */
        display: flex;
        flex-direction: column;
        top: 0;
        bottom: 5rem;
    }
    
    .gallery-modal__image {
        height: 70vh;
        /* Garantir que a imagem seja visível */
        background: #F8F9FA;
    }
    
    .gallery-modal__close {
        top: 8px;
        right: 8px;
        width: 36px;
        height: 36px;
        /* Garantir que o botão seja visível */
        z-index: 10001;
    }
    
    .gallery-modal__nav {
        width: 44px;
        height: 44px;
        /* Garantir que os botões sejam visíveis */
        z-index: 10001;
    }
    
    .gallery-modal__nav--prev {
        left: 8px;
    }
    
    .gallery-modal__nav--next {
        right: 8px;
    }
    
    /* Garantir que o conteúdo seja visível */
    .gallery-modal__content {
        height: 100%;
        display: flex;
        flex-direction: column;
    }
    
    .gallery-modal__info {
        /* Garantir que a info seja visível */
        background: #FFFFFF !important;
        flex-shrink: 0;
    }
}

/* ===== ANIMAÇÕES DE ENTRADA/SAÍDA ===== */
@keyframes galleryModalFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

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

.gallery-modal.is-opening .gallery-modal__container {
    animation: galleryModalFadeIn 0.3s ease;
}

.gallery-modal.is-closing .gallery-modal__container {
    animation: galleryModalFadeOut 0.3s ease;
}

/* ===== ACESSIBILIDADE ===== */
@media (prefers-reduced-motion: reduce) {
    .gallery-modal,
    .gallery-modal__container,
    .tile,
    .tile__overlay {
        transition: none;
    }
    
    .gallery-modal.is-opening .gallery-modal__container,
    .gallery-modal.is-closing .gallery-modal__container {
        animation: none;
    }
}

/* ===== FOCUS INDICATORS ===== */
.gallery-modal__close:focus,
.gallery-modal__nav:focus {
    outline: 3px solid var(--accent);
    outline-offset: 2px;
}

/* ===== LOADING STATE ===== */
.gallery-modal__image[data-loading="true"] {
    background: linear-gradient(90deg, #F0F0F0 25%, #E0E0E0 50%, #F0F0F0 75%);
    background-size: 200% 100%;
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% {
        background-position: 200% 0;
    }
    100% {
        background-position: -200% 0;
    }
}

/* ===== PRINT STYLES ===== */
@media print {
    .gallery-modal {
        display: none !important;
    }
}
