/* =========================================================================
   SISTEMA DE VISUALIZAÇÃO DE IMAGEM EM POPUP
   ========================================================================= */

/* =========================================================================
   MODAL PRINCIPAL
   ========================================================================= */

.ver-imagem-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ver-imagem-modal.ativo {
    opacity: 1;
    pointer-events: auto;
}

/* Backdrop */
.ver-imagem-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    cursor: pointer;
    transition: background 0.3s ease;
}

.ver-imagem-modal.ativo .ver-imagem-backdrop {
    background: rgba(0, 0, 0, 0.9);
}

/* Container do conteúdo */
.ver-imagem-content {
    position: relative;
    z-index: 1;
    max-width: 95vw;
    max-height: 95vh;
    width: auto;
    height: auto;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
}

/* Wrapper da imagem */
.ver-imagem-wrapper {
    position: relative;
    max-width: 100%;
    max-height: 100%;
    transition: opacity 0.3s ease;
}

.ver-imagem-wrapper img {
    max-width: 100%;
    max-height: 95vh;
    width: auto;
    height: auto;
    display: block;
    border-radius: 8px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 3px solid rgba(255, 255, 255, 0.1);
    object-fit: contain;
    animation: verImagemZoomIn 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

@keyframes verImagemZoomIn {
    0% {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    100% {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* Botão fechar */
.ver-imagem-close {
    position: absolute;
    top: -15px;
    right: -15px;
    width: 44px;
    height: 44px;
    background: linear-gradient(135deg, #ffffff 0%, #f8f9fa 100%);
    border: 2px solid rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    line-height: 1;
    color: #495057;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
    z-index: 2;
    padding: 0;
    margin: 0;
}

.ver-imagem-close:hover {
    background: linear-gradient(135deg, #dc3545 0%, #c82333 100%);
    color: white;
    transform: scale(1.1) rotate(90deg);
    box-shadow: 0 6px 20px rgba(220, 53, 69, 0.5);
    border-color: #dc3545;
}

.ver-imagem-close:active {
    transform: scale(0.95) rotate(90deg);
}

.ver-imagem-close:focus-visible {
    outline: 3px solid rgba(255, 255, 255, 0.8);
    outline-offset: 3px;
}

.ver-imagem-close span {
    display: block;
    font-weight: bold;
}

/* Loader */
.ver-imagem-loader {
    position: absolute;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 8px;
    z-index: 1;
}

.ver-imagem-loader.active {
    display: flex;
}

.loader-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: verImagemSpin 0.8s linear infinite;
}

@keyframes verImagemSpin {
    to {
        transform: rotate(360deg);
    }
}

/* =========================================================================
   ELEMENTOS CLICÁVEIS (IMAGENS E LINKS)
   ========================================================================= */

/* Base - Imagem clicável (quando é uma tag img) */
img.ver-imagem-popup {
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-block;
}

img.ver-imagem-popup:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
}

/* Base - Link como botão (quando é uma tag a) */
a.ver-imagem-popup {
    display: inline-block;
    padding: 8px 16px;
    background: linear-gradient(135deg, #007bff 0%, #0056b3 100%);
    color: white !important;
    text-decoration: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
    border: none;
    cursor: pointer;
}

a.ver-imagem-popup:hover {
    background: linear-gradient(135deg, #0056b3 0%, #004085 100%);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
    color: white !important;
    text-decoration: none;
}

a.ver-imagem-popup:active {
    transform: translateY(0);
}

/* =========================================================================
   ESTILOS ESPECÍFICOS PARA CONTEXTOS
   ========================================================================= */

/* No carrinho principal - imagens pequenas (detalhe-imagem) */
.detalhe-imagem img.ver-imagem-popup {
    width: 100%;
    max-width: 150px;
    height: auto;
    border-radius: 6px;
    border: 2px solid #e9ecef;
    display: block;
    object-fit: cover;
    cursor: pointer;
}

.detalhe-imagem img.ver-imagem-popup:hover {
    border-color: #007bff;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    transform: scale(1.05);
}

/* Botão no ticket detalhes (carrinho principal) */
.ticket-detalhes a.ver-imagem-popup,
.mini-detalhes a.ver-imagem-popup {
    display: inline-block;
    padding: 6px 12px;
    margin-top: 8px;
    font-size: 13px;
    background-color: #0071a1 !important;
    color: #fff !important;
    border-radius: 6px;
    text-decoration: none !important;
    transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(0, 113, 161, 0.3);
    border: none;
}

.ticket-detalhes a.ver-imagem-popup:hover,
.mini-detalhes a.ver-imagem-popup:hover {
    background-color: #005b84 !important;
    text-decoration: none !important;
    color: white !important;
    transform: translateY(-1px);
    box-shadow: 0 3px 8px rgba(0, 91, 132, 0.4);
}

/* Mini carrinho - imagens pequenas */
.mini-imagens img.ver-imagem-popup {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    border: 1px solid #dee2e6;
    object-fit: cover;
    cursor: pointer;
    display: block;
}

.mini-imagens img.ver-imagem-popup:hover {
    border-color: #007bff;
    transform: scale(1.1);
}

/* Mini carrinho - links/botões */
.mini-imagens a.ver-imagem-popup,
.woocommerce-mini-cart-item .mini-imagens a.ver-imagem-popup {
    display: inline-block;
    padding: 4px 8px;
    font-size: 11px;
    margin: 2px;
    background: linear-gradient(135deg, #6c757d 0%, #495057 100%) !important;
    color: white !important;
    text-decoration: none !important;
    border: none;
}

.mini-imagens a.ver-imagem-popup:hover,
.woocommerce-mini-cart-item .mini-imagens a.ver-imagem-popup:hover {
    background: linear-gradient(135deg, #495057 0%, #343a40 100%) !important;
    transform: translateY(-1px);
    color: white !important;
    text-decoration: none !important;
}

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

.ver-imagem-modal[aria-hidden="true"] {
    display: none;
}

/* Foco visível */
a.ver-imagem-popup:focus-visible,
img.ver-imagem-popup:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: 2px;
    border-radius: 4px;
}

/* Prevenir seleção durante animação */
.ver-imagem-modal.ativo * {
    user-select: none;
}

.ver-imagem-modal.ativo img {
    user-select: none;
    -webkit-user-drag: none;
}
