/* ===== LIGHTBOX AVANÇADO - SISTEMA DE VISUALIZAÇÃO DE IMAGENS ===== */

/* CSS Custom Properties para Lightbox */
:root {
    /* Cores do Lightbox */
    --lightbox-bg: rgba(0, 0, 0, 0.95);
    --lightbox-control-bg: rgba(255, 255, 255, 0.1);
    --lightbox-control-hover: rgba(255, 255, 255, 0.2);
    --lightbox-text: #ffffff;
    
    /* Dimensões */
    --lightbox-control-size: 50px;
    --lightbox-border-radius: 12px;
    
    /* Animações */
    --lightbox-transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Container Principal do Lightbox */
.lightbox-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--lightbox-bg);
    backdrop-filter: blur(10px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: var(--lightbox-transition);
    user-select: none;
}

.lightbox-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* Container da Imagem */
.lightbox-container {
    position: relative;
    max-width: 90vw;
    max-height: 90vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Imagem Principal */
.lightbox-image {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    border-radius: var(--lightbox-border-radius);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    transition: var(--lightbox-transition);
    cursor: grab;
}

.lightbox-image:active {
    cursor: grabbing;
}

.lightbox-image.zoomed {
    cursor: zoom-out;
}

/* Controles de Navegação */
.lightbox-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: var(--lightbox-control-size);
    height: var(--lightbox-control-size);
    background: var(--lightbox-control-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lightbox-text);
    cursor: pointer;
    transition: var(--lightbox-transition);
    font-size: 18px;
    z-index: 10001;
}

.lightbox-nav:hover {
    background: var(--lightbox-control-hover);
    transform: translateY(-50%) scale(1.1);
}

.lightbox-nav:active {
    transform: translateY(-50%) scale(0.95);
}

.lightbox-nav.prev {
    left: -80px;
}

.lightbox-nav.next {
    right: -80px;
}

.lightbox-nav:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Header do Lightbox */
.lightbox-header {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(180deg, rgba(0,0,0,0.8) 0%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    z-index: 10001;
}

.lightbox-info {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.lightbox-title {
    color: var(--lightbox-text);
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.lightbox-subtitle {
    color: rgba(255, 255, 255, 0.7);
    font-size: 14px;
    margin: 0;
}

.lightbox-controls {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Botões de Controle */
.lightbox-btn {
    width: 40px;
    height: 40px;
    background: var(--lightbox-control-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lightbox-text);
    cursor: pointer;
    transition: var(--lightbox-transition);
    font-size: 16px;
}

.lightbox-btn:hover {
    background: var(--lightbox-control-hover);
    transform: scale(1.1);
}

.lightbox-btn:active {
    transform: scale(0.95);
}

/* Botão de Fechar */
.lightbox-close {
    background: rgba(220, 38, 38, 0.2);
    border-color: rgba(220, 38, 38, 0.3);
}

.lightbox-close:hover {
    background: rgba(220, 38, 38, 0.4);
}

/* Footer do Lightbox */
.lightbox-footer {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 20px;
    background: linear-gradient(0deg, rgba(0,0,0,0.8) 0%, transparent 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
}

/* Indicador de Posição */
.lightbox-counter {
    background: var(--lightbox-control-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    padding: 8px 16px;
    color: var(--lightbox-text);
    font-size: 14px;
    font-weight: 500;
}

/* Thumbnails */
.lightbox-thumbnails {
    position: absolute;
    bottom: 80px;
    left: 50%;
    transform: translateX(-50%);
    display: flex;
    gap: 8px;
    max-width: 80vw;
    overflow-x: auto;
    padding: 12px;
    background: var(--lightbox-control-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    scrollbar-width: none;
    -ms-overflow-style: none;
}

.lightbox-thumbnails::-webkit-scrollbar {
    display: none;
}

.lightbox-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: var(--lightbox-transition);
    border: 2px solid transparent;
    flex-shrink: 0;
}

.lightbox-thumbnail:hover {
    transform: scale(1.1);
}

.lightbox-thumbnail.active {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.3);
}

.lightbox-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Zoom Controls */
.lightbox-zoom-controls {
    position: absolute;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 10001;
}

.lightbox-zoom-btn {
    width: 44px;
    height: 44px;
    background: var(--lightbox-control-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--lightbox-text);
    cursor: pointer;
    transition: var(--lightbox-transition);
    font-size: 18px;
}

.lightbox-zoom-btn:hover {
    background: var(--lightbox-control-hover);
    transform: scale(1.1);
}

.lightbox-zoom-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
    pointer-events: none;
}

/* Indicador de Zoom */
.lightbox-zoom-indicator {
    position: absolute;
    left: 20px;
    bottom: 20px;
    background: var(--lightbox-control-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--lightbox-text);
    font-size: 12px;
    font-weight: 500;
    z-index: 10001;
}

/* Loading State */
.lightbox-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--lightbox-text);
}

.lightbox-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(255, 255, 255, 0.2);
    border-top: 3px solid #ffffff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.lightbox-loading-text {
    font-size: 14px;
    font-weight: 500;
}

/* Error State */
.lightbox-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 16px;
    color: var(--lightbox-text);
    text-align: center;
    max-width: 300px;
}

.lightbox-error-icon {
    font-size: 48px;
    color: #dc2626;
}

.lightbox-error-title {
    font-size: 18px;
    font-weight: 600;
    margin: 0;
}

.lightbox-error-message {
    font-size: 14px;
    color: rgba(255, 255, 255, 0.7);
    margin: 0;
}

/* Gestos e Interações */
.lightbox-image.dragging {
    transition: none;
}

/* Responsividade */
@media (max-width: 768px) {
    .lightbox-nav {
        width: 44px;
        height: 44px;
        font-size: 16px;
    }
    
    .lightbox-nav.prev {
        left: -60px;
    }
    
    .lightbox-nav.next {
        right: -60px;
    }
    
    .lightbox-header,
    .lightbox-footer {
        padding: 16px;
    }
    
    .lightbox-title {
        font-size: 16px;
    }
    
    .lightbox-subtitle {
        font-size: 12px;
    }
    
    .lightbox-thumbnails {
        bottom: 60px;
        max-width: 90vw;
    }
    
    .lightbox-thumbnail {
        width: 50px;
        height: 50px;
    }
    
    .lightbox-zoom-controls {
        right: 16px;
    }
    
    .lightbox-zoom-indicator {
        left: 16px;
        bottom: 16px;
    }
}

@media (max-width: 480px) {
    .lightbox-container {
        max-width: 95vw;
        max-height: 85vh;
    }
    
    .lightbox-nav.prev {
        left: 10px;
    }
    
    .lightbox-nav.next {
        right: 10px;
    }
    
    .lightbox-thumbnails {
        display: none;
    }
    
    .lightbox-zoom-controls {
        position: static;
        transform: none;
        flex-direction: row;
        justify-content: center;
        margin-top: 16px;
    }
}

/* Animações de Entrada */
@keyframes lightboxFadeIn {
    from {
        opacity: 0;
        transform: scale(0.9);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes lightboxSlideIn {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.lightbox-image {
    animation: lightboxFadeIn 0.3s ease;
}

/* Suporte a Teclado */
.lightbox-overlay:focus {
    outline: none;
}

/* Prevenção de Scroll */
body.lightbox-open {
    overflow: hidden;
}

/* Metadados da Imagem */
.lightbox-metadata {
    position: absolute;
    top: 80px;
    right: 20px;
    background: var(--lightbox-control-bg);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    padding: 16px;
    color: var(--lightbox-text);
    font-size: 12px;
    max-width: 200px;
    opacity: 0;
    visibility: hidden;
    transition: var(--lightbox-transition);
}

.lightbox-metadata.show {
    opacity: 1;
    visibility: visible;
}

.lightbox-metadata-item {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.lightbox-metadata-item:last-child {
    margin-bottom: 0;
}

.lightbox-metadata-label {
    color: rgba(255, 255, 255, 0.7);
}

.lightbox-metadata-value {
    font-weight: 500;
}

/* ===== GALERIA RESPONSIVA - ESTILOS COMPLEMENTARES ===== */

/* Grid da Galeria Responsiva */
.gallery-grid-responsive {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
    gap: 16px;
    margin-bottom: 16px;
}

.gallery-item-responsive {
    position: relative;
    aspect-ratio: 1;
    border-radius: 12px;
    overflow: hidden;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

.gallery-item-responsive:hover {
    transform: translateY(-4px) scale(1.05);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    border-color: #3b82f6;
}

.gallery-item-wrapper {
    position: relative;
    width: 100%;
    height: 100%;
}

.gallery-item-wrapper.document {
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
}

.gallery-item-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: all 0.3s ease;
}

.gallery-item-responsive:hover .gallery-item-image {
    transform: scale(1.1);
}

.gallery-document-preview {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 16px;
    text-align: center;
    height: 100%;
}

.gallery-document-icon {
    font-size: 32px;
    color: #3b82f6;
    margin-bottom: 8px;
}

.gallery-document-info {
    font-size: 10px;
}

.gallery-document-name {
    font-weight: 600;
    color: #374151;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

.gallery-document-type {
    color: #6b7280;
    text-transform: uppercase;
    font-size: 8px;
}

.gallery-item-loading {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.gallery-overlay-btn span {
    display: none;
}

/* Overlay dos Itens da Galeria */
.gallery-item-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, rgba(0,0,0,0.4), rgba(0,0,0,0.7));
    opacity: 0;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.gallery-item-responsive:hover .gallery-item-overlay {
    opacity: 1;
}

.gallery-overlay-btn {
    width: 36px;
    height: 36px;
    border: none;
    border-radius: 8px;
    background: rgba(255, 255, 255, 0.9);
    color: #374151;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    font-size: 14px;
}

.gallery-overlay-btn:hover {
    background: white;
    transform: scale(1.1);
}

.gallery-overlay-btn.view {
    color: #3b82f6;
}

.gallery-overlay-btn.info {
    color: #059669;
}

.gallery-overlay-btn.download {
    color: #7c3aed;
}

/* Responsividade da Galeria */
@media (max-width: 768px) {
    .gallery-grid-responsive {
        grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
        gap: 12px;
    }
}

@media (max-width: 480px) {
    .gallery-grid-responsive {
        grid-template-columns: repeat(3, 1fr);
    }
    
    .gallery-overlay-btn {
        width: 28px;
        height: 28px;
        font-size: 12px;
    }
}

/* Lightbox Avançado - Estilos Complementares */
.lightbox-document {
    background: #ffffff;
    border-radius: 16px;
    padding: 48px;
    text-align: center;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    max-width: 500px;
    color: #374151;
}

.lightbox-document-icon {
    font-size: 64px;
    color: #3b82f6;
    margin-bottom: 24px;
}

.lightbox-document-name {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
    color: #374151;
}

.lightbox-document-type {
    font-size: 14px;
    color: #6b7280;
    margin-bottom: 24px;
    text-transform: uppercase;
    font-weight: 500;
}

.lightbox-document-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.lightbox-document-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    background: #3b82f6;
    color: white;
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.lightbox-document-btn:hover {
    background: #2563eb;
    transform: translateY(-2px);
}

/* Loading Spinner Grande */
.loading-spinner-large {
    width: 48px;
    height: 48px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top: 4px solid white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

/* Thumbnails do Lightbox Avançado */
.lightbox-thumbnails {
    display: flex;
    gap: 8px;
    max-width: 400px;
    overflow-x: auto;
    padding: 4px;
}

.lightbox-thumbnail {
    width: 60px;
    height: 60px;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    border: 2px solid transparent;
    transition: all 0.3s ease;
    flex-shrink: 0;
}

.lightbox-thumbnail.active {
    border-color: #3b82f6;
}

.lightbox-thumbnail:hover {
    transform: scale(1.05);
}

.lightbox-thumbnail img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lightbox-thumbnail-document {
    width: 100%;
    height: 100%;
    background: rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 20px;
}

/* Estados de Erro */
.lightbox-error {
    background: #ffffff;
    border-radius: 16px;
    padding: 48px;
    text-align: center;
    color: #dc2626;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

.lightbox-error-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.lightbox-error-message {
    font-size: 18px;
    font-weight: 500;
}

/* Animações de Transição */
@keyframes galleryItemAppear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.gallery-item-responsive {
    animation: galleryItemAppear 0.3s ease;
}

/* Prevenção de scroll durante lightbox */
body.lightbox-open {
    overflow: hidden;
}