/**
 * CSS do Lightbox Responsivo - Rancho Paraíso
 * Versão 3.0 - Totalmente otimizado para todos os dispositivos
 */

/* ===== ESTRUTURA BASE ===== */
.lightbox {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

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

/* Backdrop */
.lightbox-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.92);
    cursor: zoom-out;
}

/* Container principal */
.lightbox-content {
    position: relative;
    width: 90vw;
    max-width: 1200px;
    height: 85vh;
    max-height: 800px;
    background: #000;
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    z-index: 1;
}

/* ===== VIEWPORT E SLIDES ===== */
.lightbox-viewport {
    flex: 1;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.lightbox-track {
    display: flex;
    height: 100%;
    width: 100%;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.lightbox-slide {
    min-width: 100%;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
}

.lightbox-image-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.lightbox-slide img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    border-radius: 4px;
    user-select: none;
    -webkit-user-select: none;
    -webkit-touch-callout: none;
}

/* ===== CONTROLES DE NAVEGAÇÃO ===== */
.lightbox-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    z-index: 3;
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.lightbox-close:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

.lightbox-prev,
.lightbox-next {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    background: rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    width: 48px;
    height: 48px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s ease;
    z-index: 2;
}

.lightbox-prev {
    left: 1rem;
}

.lightbox-next {
    right: 1rem;
}

.lightbox-prev:hover,
.lightbox-next:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-prev:active,
.lightbox-next:active {
    transform: translateY(-50%) scale(0.95);
}

/* ===== FOOTER (CONTADOR E THUMBNAILS) ===== */
.lightbox-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(transparent, rgba(0, 0, 0, 0.8));
    padding: 1.5rem 1rem 1rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.lightbox-counter {
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

/* Thumbnails */
.lightbox-thumbnails {
    display: none;
    gap: 0.5rem;
    justify-content: center;
    align-items: center;
    max-width: 100%;
    overflow-x: auto;
    padding: 0.5rem;
    -webkit-overflow-scrolling: touch;
}

.lightbox-thumbnail {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    border: 2px solid transparent;
    border-radius: 4px;
    overflow: hidden;
    cursor: pointer;
    opacity: 0.6;
    transition: all 0.2s ease;
    background: #222;
    padding: 0;
}

.lightbox-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lightbox-thumbnail:hover {
    opacity: 0.9;
    transform: scale(1.05);
}

.lightbox-thumbnail.active {
    opacity: 1;
    border-color: #2ca6a4;
}

.lightbox-thumbnail-more {
    flex-shrink: 0;
    width: 50px;
    height: 50px;
    background: rgba(255, 255, 255, 0.1);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}

/* ===== LOADING ===== */
.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #fff;
    font-size: 2rem;
    display: none;
    z-index: 4;
}

.lightbox-loading i {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ===== RESPONSIVIDADE ===== */

/* Tablets */
@media (max-width: 992px) {
    .lightbox-content {
        width: 95vw;
        height: 90vh;
    }
    
    .lightbox-prev,
    .lightbox-next {
        width: 44px;
        height: 44px;
        font-size: 18px;
    }
}

/* Smartphones */
@media (max-width: 768px) {
    .lightbox-content {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }
    
    .lightbox-image-wrapper {
        padding: 0.5rem;
    }
    
    /* Botões de navegação menores e semi-transparentes */
    .lightbox-prev,
    .lightbox-next {
        width: 40px;
        height: 40px;
        font-size: 16px;
        background: rgba(0, 0, 0, 0.5);
    }
    
    .lightbox-prev {
        left: 0.5rem;
    }
    
    .lightbox-next {
        right: 0.5rem;
    }
    
    /* Fechar menor */
    .lightbox-close {
        width: 40px;
        height: 40px;
        font-size: 20px;
        top: 0.5rem;
        right: 0.5rem;
    }
    
    /* Footer mais compacto */
    .lightbox-footer {
        padding: 1rem 0.5rem 0.5rem;
    }
    
    /* Thumbnails menores */
    .lightbox-thumbnail,
    .lightbox-thumbnail-more {
        width: 40px;
        height: 40px;
    }
    
    .lightbox-thumbnails {
        gap: 0.25rem;
    }
}

/* Smartphones pequenos */
@media (max-width: 480px) {
    .lightbox-prev,
    .lightbox-next {
        width: 36px;
        height: 36px;
        font-size: 14px;
    }
    
    .lightbox-close {
        width: 36px;
        height: 36px;
        font-size: 18px;
    }
    
    .lightbox-counter {
        font-size: 12px;
    }
}

/* Landscape em mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .lightbox-content {
        height: 100vh;
    }
    
    .lightbox-footer {
        padding: 0.5rem;
        background: rgba(0, 0, 0, 0.8);
    }
    
    .lightbox-thumbnails {
        display: none; /* Esconder thumbnails em landscape mobile */
    }
    
    .lightbox-prev,
    .lightbox-next {
        top: auto;
        bottom: 1rem;
        transform: none;
    }
    
    .lightbox-prev {
        left: 1rem;
    }
    
    .lightbox-next {
        right: 1rem;
    }
}

/* Desktop grande */
@media (min-width: 1400px) {
    .lightbox-content {
        max-width: 1400px;
        max-height: 900px;
    }
    
    .lightbox-thumbnail,
    .lightbox-thumbnail-more {
        width: 60px;
        height: 60px;
    }
}

/* ===== ACESSIBILIDADE ===== */

/* Focus visible */
.lightbox-close:focus-visible,
.lightbox-prev:focus-visible,
.lightbox-next:focus-visible,
.lightbox-thumbnail:focus-visible {
    outline: 3px solid #2ca6a4;
    outline-offset: 2px;
}

/* Modo de alto contraste */
@media (prefers-contrast: high) {
    .lightbox-backdrop {
        background: #000;
    }
    
    .lightbox-prev,
    .lightbox-next,
    .lightbox-close {
        border: 2px solid #fff;
    }
}

/* Preferência por movimento reduzido */
@media (prefers-reduced-motion: reduce) {
    .lightbox,
    .lightbox-track {
        transition: none;
    }
    
    @keyframes spin {
        to { transform: none; }
    }
}

/* ===== SUPORTE TOUCH ===== */

/* Desabilitar seleção em elementos interativos */
.lightbox-prev,
.lightbox-next,
.lightbox-close,
.lightbox-thumbnail {
    -webkit-tap-highlight-color: transparent;
    -webkit-touch-callout: none;
    -webkit-user-select: none;
    user-select: none;
}

/* Área de toque mínima para acessibilidade */
@media (hover: none) and (pointer: coarse) {
    .lightbox-prev,
    .lightbox-next,
    .lightbox-close,
    .lightbox-thumbnail {
        min-width: 44px;
        min-height: 44px;
    }
    
    /* Visual feedback para toque */
    .lightbox-prev:active,
    .lightbox-next:active,
    .lightbox-close:active {
        opacity: 0.7;
    }
}

/* ===== CORREÇÕES ESPECÍFICAS PARA iOS ===== */
@supports (-webkit-touch-callout: none) {
    .lightbox-content {
        /* Prevenir problemas com safe area no iPhone X+ */
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }
    
    .lightbox-viewport {
        /* Prevenir zoom indesejado */
        touch-action: pan-x pan-y;
    }
}

/* ===== PRINT ===== */
@media print {
    .lightbox {
        display: none !important;
    }
}