/* Galeria em mosaico (página do imóvel)
   Complementa as regras base de .gallery-modal / .modal-container / .thumbnails-sidebar /
   .main-gallery / .gallery-header / .cta-buttons do styles.<versão>.min.css */

/* ---------- Miniaturas (lateral esquerda) ---------- */
.gallery-mosaic-modal .thumbnails-sidebar {
    position: relative;
    flex: 0 0 180px;
    overscroll-behavior: contain;
}

.gallery-mosaic-modal .thumb-item {
    position: relative;
    flex: 0 0 auto;
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9;
    padding: 0;
    border: 2px solid transparent;
    border-radius: 5px;
    overflow: hidden;
    background: var(--color-4);
    opacity: 0.5;
    cursor: pointer;
    transition: opacity 0.3s ease, border-color 0.3s ease;
}

.gallery-mosaic-modal .thumb-item:hover,
.gallery-mosaic-modal .thumb-item:focus-visible {
    opacity: 0.85;
}

.gallery-mosaic-modal .thumb-item.is-active {
    opacity: 1;
    border-color: var(--color-7);
}

.gallery-mosaic-modal .thumb-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ---------- Palco: mosaico + visualizador ---------- */
.gallery-mosaic-modal .main-gallery {
    min-height: 0;
}

.gallery-mosaic-modal .mosaic-stage {
    position: relative;
    flex: 1;
    min-height: 0;
    container-type: inline-size;
}

.gallery-mosaic-modal .slide-counter {
    min-height: 40px;
    display: flex;
    align-items: center;
}

/* ---------- Mosaico ---------- */
.gallery-mosaic {
    position: absolute;
    inset: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    display: grid;
    grid-template-columns: repeat(12, minmax(0, 1fr));
    grid-auto-flow: row dense;
    grid-auto-rows: 17vw;
    grid-auto-rows: 18.5cqw;
    align-content: start;
    gap: 10px;
    scrollbar-width: thin;
}

.mosaic-item {
    position: relative;
    grid-column: span 4;
    padding: 0;
    border: 0;
    border-radius: 5px;
    overflow: hidden;
    background: var(--color-4);
    cursor: zoom-in;
}

.mosaic-item img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.5s ease;
}

.mosaic-item:hover img {
    transform: scale(1.04);
}

.mosaic-item:focus-visible {
    outline: 3px solid var(--color-7);
    outline-offset: -3px;
}

.mosaic-item.is-video::after {
    content: "\f04b";
    font-family: "Font Awesome 5 Free", "Font Awesome 6 Free", sans-serif;
    font-weight: 900;
    position: absolute;
    top: 50%;
    left: 50%;
    width: 64px;
    height: 64px;
    margin: -32px 0 0 -32px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding-left: 4px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 22px;
    pointer-events: none;
}

/* Padrão repetido a cada 9 fotos (desktop):
   [ 1 grande | 2 pequenas ]  [ 2 pequenas | 1 grande ]  [ 3 iguais ] */
@media (min-width: 769px) {
    .mosaic-item.m-pat:nth-child(9n + 1),
    .mosaic-item.m-pat:nth-child(9n + 6) {
        grid-column: span 8;
        grid-row: span 2;
    }

    .mosaic-item.m-pat:nth-child(9n + 5) {
        grid-column: 1 / span 4;
    }

    .mosaic-item.m-pat:nth-child(9n + 6) {
        grid-column: 5 / span 8;
    }

    /* Resto (menos de 9 fotos): linhas de 3; última linha preenche a largura */
    .mosaic-item.m-full {
        grid-column: span 12;
    }

    .mosaic-item.m-half {
        grid-column: span 6;
    }
}

/* ---------- Visualizador com zoom ---------- */
.gallery-viewer {
    position: absolute;
    inset: 0;
    z-index: 5;
    display: flex;
    flex-direction: column;
    border-radius: 5px;
    overflow: hidden;
    background: var(--color-1);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0s linear 0.25s;
}

.gallery-viewer.is-open {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.25s ease;
}

.viewer-swiper {
    flex: 1;
    width: 100%;
    min-height: 0;
}

.viewer-swiper .swiper-slide {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 100%;
}

.viewer-swiper .swiper-zoom-container {
    width: 100%;
    height: 100%;
    cursor: zoom-in;
}

.gallery-viewer.is-zoomed .swiper-zoom-container {
    cursor: grab;
}

.viewer-swiper .swiper-zoom-container > img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    user-select: none;
}

.viewer-video-box {
    height: 100%;
    max-width: 100%;
    aspect-ratio: 9 / 16;
    background: #000;
    border-radius: 5px;
    overflow: hidden;
}

.viewer-video-box iframe {
    display: block;
    width: 100%;
    height: 100%;
    border: 0;
}

.viewer-toolbar {
    position: absolute;
    top: 10px;
    left: 10px;
    right: 10px;
    z-index: 6;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    pointer-events: none;
}

.viewer-toolbar .viewer-zoom {
    display: flex;
    gap: 8px;
}

.viewer-btn {
    pointer-events: auto;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    min-width: 40px;
    height: 40px;
    padding: 0 12px;
    border: 0;
    border-radius: 20px;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    font-size: 14px;
    cursor: pointer;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.viewer-btn:hover:not(:disabled) {
    background: rgba(0, 0, 0, 0.85);
}

.viewer-btn:disabled {
    opacity: 0.35;
    cursor: default;
}

.viewer-btn:focus-visible {
    outline: 2px solid var(--color-7);
    outline-offset: 2px;
}

.viewer-prev,
.viewer-next {
    position: absolute;
    top: 50%;
    z-index: 6;
    width: 44px;
    height: 44px;
    margin-top: -22px;
    padding: 0;
    border: 0;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.6);
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s ease, opacity 0.2s ease;
}

.viewer-prev { left: 12px; }
.viewer-next { right: 12px; }

.viewer-prev:hover,
.viewer-next:hover {
    background: rgba(0, 0, 0, 0.85);
}

.viewer-prev.swiper-button-disabled,
.viewer-next.swiper-button-disabled {
    opacity: 0.25;
    pointer-events: none;
}

/* ---------- Mobile ---------- */
@media (max-width: 768px) {
    .gallery-mosaic-modal .thumbnails-sidebar {
        flex: 0 0 auto;
    }

    .gallery-mosaic-modal .thumb-item {
        width: 120px;
    }

    .gallery-mosaic {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        grid-auto-rows: 38vw;
        grid-auto-rows: 38cqw;
    }

    .mosaic-item {
        grid-column: span 1;
    }

    .mosaic-item:nth-child(3n + 1) {
        grid-column: span 2;
    }

    .viewer-prev,
    .viewer-next {
        display: none;
    }

    .viewer-btn .viewer-btn-label {
        display: none;
    }
}

@media (prefers-reduced-motion: reduce) {
    .mosaic-item img,
    .gallery-viewer,
    .gallery-viewer.is-open {
        transition: none;
    }
}
