/* ==========================================================================
   1. ESTRUTURA BASE DO PLUGIN (NO SHORTCODE)
   ========================================================================== */
.apm-wrapper {
    width: 100%;
    margin: 20px 0;
}

.apm-container {
    position: relative;
    display: inline-block;
    width: 100%;
}

.apm-base-img {
    display: block;
    width: 100%;
    height: auto;
    cursor: zoom-in !important;
}

.apm-rect {
    position: absolute;
    border: 2px dashed rgba(0, 0, 0, 0.5);
    background-color: rgba(255, 255, 255, 0.1);
    cursor: zoom-in !important;
    transition: all 0.2s ease-in-out;
    z-index: 10;
}

.apm-rect:hover {
    border-style: solid;
    border-color: #000;
    background-color: rgba(255, 255, 255, 0.25);
    box-shadow: 0 0 8px rgba(0,0,0,0.3);
}

/* ==========================================================================
   2. LIGHTBOX / MODAL BASE
   ========================================================================== */
.apm-modal {
    display: none; 
    position: fixed !important; 
    z-index: 999999999 !important; 
    inset: 0 !important;
    width: 100vw !important;
    height: 100vh !important;
    background-color: rgba(0, 0, 0, 0.85) !important; 
    backdrop-filter: blur(5px);
    opacity: 0;
    transition: opacity 0.25s ease-in-out;
    overflow: hidden !important;
}

.apm-modal.apm-active {
    display: block !important;
    opacity: 1 !important;
}

.apm-modal-inner {
    position: absolute !important;
    inset: 0 !important;
    overflow: hidden !important;
}

.apm-modal-content {
    display: block !important;
    border: 4px solid #fff;
    box-shadow: 0 10px 30px rgba(0,0,0,0.6);
    user-select: none !important;
    -webkit-user-drag: none !important;
}

/* ==========================================================================
   VERSION: ZOOM NORMAL (Apenas para Imagens de Detalhes / Caixas)
   ========================================================================== */
.apm-modal:not(.apm-is-superzoom) .apm-modal-inner {
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

.apm-modal:not(.apm-is-superzoom) .apm-modal-content {
    width: auto !important;
    height: auto !important;
    max-width: 80vw !important;
    max-height: 80vh !important;
    object-fit: contain !important;
    transform: scale(0.95);
    transition: transform 0.25s ease-in-out;
    cursor: zoom-out !important;
}

.apm-modal.apm-active :not(.apm-is-superzoom) .apm-modal-content {
    transform: scale(1) !important;
}

/* ==========================================================================
   VERSION: SUPER ZOOM 1:1 REAL (Apenas para Imagem Principal)
   ========================================================================== */
.apm-modal.apm-is-superzoom .apm-modal-content {
    position: absolute !important;
    width: auto !important;
    height: auto !important;
    max-width: none !important;  
    max-height: none !important; 
    cursor: grab !important;
    /* CORREÇÃO MOBILE: Desativa o scroll e pinch nativo do telemóvel na imagem ativa */
    touch-action: none !important; 
}

.apm-modal.apm-is-superzoom .apm-modal-content:active {
    cursor: grabbing !important;
}

/* ==========================================================================
   3. BOTÃO FECHAR (X)
   ========================================================================== */
.apm-close {
    position: absolute;
    top: 25px;
    right: 35px;
    color: #fff !important;
    font-size: 45px;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
    z-index: 1000000000 !important;
    transition: color 0.2s ease;
}

.apm-close:hover {
    color: #ff3b30 !important;
}