/* ═══════════════════════════════════════════════════════════════════════════════
   DUTRA IMÓVEIS — GALLERY CSS
   Mobile-first | Responsivo | Sem dependências
   ═══════════════════════════════════════════════════════════════════════════════ */

/* ─────────────────────────────────────────────────────────────────────────────
   ANIMAÇÕES
   ───────────────────────────────────────────────────────────────────────────── */

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

@keyframes slideInUp {
    from {
        transform: translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@keyframes scale-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   MODAL GALLERY
   ───────────────────────────────────────────────────────────────────────────── */

#gallery-modall {
    animation: fadeIn 0.3s ease-out;
}

#gallery-modall.hidden {
    display: none !important;
}

/* ─────────────────────────────────────────────────────────────────────────────
   FOTO PRINCIPAL
   ───────────────────────────────────────────────────────────────────────────── */

#gallery-main-image {
    animation: fadeIn 0.4s ease-out;
    image-rendering: auto;
    image-rendering: crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* Mobile: Foto em tela cheia */
@media (max-width: 768px) {
    #gallery-main-image {
        width: 100%;
        height: auto;
        max-height: 60vh;
    }
}

/* Desktop: Foto com ratio 4:3 */
@media (min-width: 769px) {
    #gallery-main-image {
        max-width: 100%;
        max-height: 100%;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   THUMBNAILS
   ───────────────────────────────────────────────────────────────────────────── */

#gallery-thumbnails-mobile,
#gallery-thumbnails-desktop {
    display: flex;
    gap: 8px;
}

/* Mobile: Thumbnails em linha horizontal com scroll */
#gallery-thumbnails-mobile {
    flex-direction: row;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch; /* Smooth scroll em iOS */
    padding: 8px;
}

#gallery-thumbnails-mobile .gallery-thumbnail {
    min-width: 60px;
    min-height: 60px;
}

#gallery-thumbnails-mobile img {
    width: 60px;
    height: 60px;
}

/* Desktop: Thumbnails em coluna com scroll vertical */
#gallery-thumbnails-desktop {
    flex-direction: column;
    overflow-y: auto;
    padding: 12px;
    max-height: calc(100vh - 100px);
}

#gallery-thumbnails-desktop .gallery-thumbnail {
    min-width: 80px;
    min-height: 80px;
}

#gallery-thumbnails-desktop img {
    width: 100%;
    height: 100%;
}

/* ─────────────────────────────────────────────────────────────────────────────
   THUMBNAIL ESTILO
   ───────────────────────────────────────────────────────────────────────────── */

.gallery-thumbnail {
    position: relative;
    border: 3px solid transparent;
    border-radius: 4px;
    transition: all 0.3s ease;
    cursor: pointer;
}

.gallery-thumbnail img {
    object-fit: cover;
    display: block;
    border-radius: 2px;
}

.gallery-thumbnail:hover {
    opacity: 1 !important;
    border-color: rgba(255, 255, 255, 0.5);
    transform: scale(1.05);
}

.gallery-thumbnail.active {
    border-color: #ffffff;
    opacity: 1;
    box-shadow: 0 0 8px rgba(255, 255, 255, 0.3);
}

/* ─────────────────────────────────────────────────────────────────────────────
   BOTÕES DE NAVEGAÇÃO (Desktop)
   ───────────────────────────────────────────────────────────────────────────── */

@media (min-width: 769px) {
    button[onclick*="prevPhoto"],
    button[onclick*="nextPhoto"] {
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
    }

    button[onclick*="prevPhoto"]:hover,
    button[onclick*="nextPhoto"]:hover {
        background-color: rgba(255, 255, 255, 0.5) !important;
        transform: scale(1.1);
    }

    button[onclick*="prevPhoto"]:active,
    button[onclick*="nextPhoto"]:active {
        transform: scale(0.95);
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   CONTADOR DE FOTOS
   ───────────────────────────────────────────────────────────────────────────── */

#current-photo,
#total-photos {
    font-weight: bold;
    color: #ffb700;
}

/* ─────────────────────────────────────────────────────────────────────────────
   MODAL HEADER
   ───────────────────────────────────────────────────────────────────────────── */

#gallery-modall > div:first-child {
    animation: slideInUp 0.3s ease-out;
}

#gallery-title {
    font-weight: 700;
    letter-spacing: -0.5px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   RESPONSIVIDADE DETALHADA
   ───────────────────────────────────────────────────────────────────────────── */

/* Smartphones (320px até 480px) */
@media (max-width: 480px) {
    #gallery-modall > div:first-child {
        padding: 12px;
    }

    #gallery-title {
        font-size: 16px;
    }

    #current-photo,
    #total-photos {
        font-size: 12px;
    }

    #gallery-thumbnails-mobile img {
        width: 50px;
        height: 50px;
    }
}

/* Tablets (481px até 768px) */
@media (481px) and (max-width: 768px) {
    #gallery-modall > div:first-child {
        padding: 16px;
    }

    #gallery-title {
        font-size: 18px;
    }

    #gallery-thumbnails-mobile img {
        width: 70px;
        height: 70px;
    }
}

/* Desktops (769px ou mais) */
@media (min-width: 769px) {
    #gallery-modall {
        flex-direction: column;
    }

    #gallery-modall > div:first-child {
        padding: 24px;
    }

    #gallery-title {
        font-size: 24px;
    }

    /* Layout horizontal em desktop */
    #gallery-modall > div:nth-child(2) {
        display: flex !important;
        flex: 1;
        overflow: hidden;
    }

    #gallery-thumbnails-mobile {
        display: none;
    }

    #gallery-thumbnails-desktop {
        display: flex !important;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   SUPORTE A DARK MODE
   ───────────────────────────────────────────────────────────────────────────── */

@media (prefers-color-scheme: dark) {
    #gallery-modall {
        background-color: rgba(0, 0, 0, 0.95);
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   ACESSIBILIDADE
   ───────────────────────────────────────────────────────────────────────────── */

/* Focus visible para navegação por teclado */
button[onclick*="Photo"]:focus-visible,
#gallery-modall button:focus-visible {
    outline: 2px solid #4299e1;
    outline-offset: 2px;
}

/* Respeitar preferência de movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* ─────────────────────────────────────────────────────────────────────────────
   PRINT (para documentação)
   ───────────────────────────────────────────────────────────────────────────── */

@media print {
    #gallery-modall {
        display: none !important;
    }
}

/* ═════════════════════════════════════════════════════════════════════════════
   FIM DO CSS GALLERY
   ═════════════════════════════════════════════════════════════════════════════ */
