/* ======================================
   ESTILOS DEL PANEL DE ADMINISTRACIÓN
   ====================================== */

/* Contenedor principal de la vista previa */
.popup-imagen-preview-container {
    margin-top: 15px;
}

/* Contenedor de la vista previa */
.popup-imagen-preview-container {
    clear: both;
    margin: 15px 0;
    min-height: 100px;
}

/* Tarjeta de vista previa */
.popup-imagen-preview {
    width: 150px;
    height: 150px;
    margin: 0;
    padding: 5px;
    background: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 3px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    float: left;
    margin-right: 20px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.popup-imagen-preview img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    border: 1px solid #eee;
    border-radius: 2px;
    background: #fff;
    display: block;
    object-fit: contain;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
    /* Transición eliminada para evitar problemas de rendimiento en móviles */
}

/* Contenedor de botones en el formulario */
.submit-buttons-container {
    clear: both;
    padding-top: 15px;
    border-top: 1px solid #ddd;
    margin-top: 20px;
    padding-top: 20px;
}

/* Botón de eliminar */
.eliminar-imagen-container {
    margin-left: 10px;
    display: inline-block;
    vertical-align: middle;
}

.eliminar-imagen {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    text-decoration: none;
}

.eliminar-imagen .dashicons {
    margin-top: 1px;
}

/* Estilos para el botón de subir imagen */
.upload_imagen {
    display: inline-block;
    background: #2271b1;
    color: #fff;
    text-decoration: none;
    font-size: 13px;
    line-height: 2.15384615;
    min-height: 30px;
    margin: 0;
    padding: 0 10px;
    cursor: pointer;
    border-width: 1px;
    border-style: solid;
    border-color: #2271b1;
    border-radius: 3px;
    white-space: nowrap;
    box-sizing: border-box;
}

/* Estilos para campos con error */
.form-table tr.form-invalid th,
.form-table tr.form-invalid td {
    border-left: 4px solid #dc3232;
    padding-left: 11px;
}

.form-table tr.form-invalid input[type="text"],
.form-table tr.form-invalid input[type="url"],
.form-table tr.form-invalid select {
    border-color: #dc3232;
    box-shadow: 0 0 2px rgba(220, 50, 50, 0.8);
}

/* Estilos para los mensajes de error */
.error-message {
    color: #dc3232;
    margin: 5px 0 0 0;
    font-style: italic;
    display: block;
}

/* Botón de eliminar */
.popup-imagen-preview .eliminar-imagen {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    margin-top: 10px;
    padding: 5px 12px;
    background: #dc3232;
    color: #fff;
    border: 1px solid #dc3232;
    border-radius: 3px;
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
    text-decoration: none;
    transition: all 0.2s ease;
    font-size: 13px;
    line-height: 1.4;
}

.popup-imagen-preview .eliminar-imagen:hover {
    background: #a00;
    border-color: #a00;
    color: #fff;
    transform: translateY(-1px);
    box-shadow: 0 2px 3px rgba(0,0,0,0.1);
}

.popup-imagen-preview .eliminar-imagen:active {
    transform: translateY(0);
    box-shadow: 0 1px 0 rgba(0,0,0,0.1);
}

/* Icono del botón eliminar */
.popup-imagen-preview .eliminar-imagen .dashicons {
    font-size: 16px;
    width: 16px;
    height: 16px;
}

/* Campo de URL de la imagen */
#popup_imagen_url {
    cursor: default;
    background-color: #f9f9f9;
    transition: background-color 0.2s ease;
}

#popup_imagen_url:hover,
#popup_imagen_url:focus {
    background-color: #fff;
    box-shadow: 0 0 0 1px #007cba;
}

/* Botón de subir imagen */
.upload_imagen {
    margin-left: 10px !important;
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.upload_imagen .dashicons {
    margin-top: 1px;
}

/* ======================================
   ESTILOS DEL POPUP EN FRONTEND
   ====================================== */

/* Overlay del popup */
.popup-imagen-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: none; /* Ocultar por defecto */
    justify-content: center;
    align-items: center;
    background-color: #32647d61;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 999999;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
    /* Propiedades de touch eliminadas para mejor compatibilidad */
}

.popup-imagen-overlay.mostrar {
    opacity: 1;
    visibility: visible;
    display: flex !important;
}

/* Contenedor del popup */
.popup-imagen-contenedor {
    position: relative;
    max-width: 90%;
    max-height: 90%;
    background: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    text-align: center;
    overflow: visible;
    margin: 0 auto;
}

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

.popup-imagen-contenedor {
    animation: popupFadeIn 0.3s ease-out;
}

/* Botón de cerrar - Versión escritorio */
.popup-imagen-cerrar {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    background: #32647d; /* Color primario */
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    text-decoration: none;
    z-index: 10;
    border: 2px solid #F27C05; /* Color secundario */
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
    line-height: 1;
}

/* Botón de cierre para móviles */
.popup-cerrar-movil {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 32px;
    height: 32px;
    background: #32647d;
    color: #fff;
    border: 2px solid #F27C05;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    font-weight: bold;
    z-index: 1003;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    -webkit-tap-highlight-color: transparent;
    transition: all 0.2s ease;
    padding: 0;
    margin: 0;
    line-height: 1;
}

/* Efectos para el botón de cierre */
.popup-imagen-cerrar:hover,
.popup-cerrar-movil:hover {
    background: #F27C05;
    border-color: #32647d;
    transform: scale(1.1);
}

.popup-imagen-cerrar:active,
.popup-cerrar-movil:active {
    background: #F27C05;
    border-color: #32647d;
    transform: scale(0.95);
}

/* Imagen del popup */
.popup-imagen {
    max-width: 100%;
    max-height: 90vh;
    height: auto;
    display: block;
    margin: 0 auto;
    padding: 0;
    border: none;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.3);
    -webkit-user-select: none;
       -moz-user-select: none;
        -ms-user-select: none;
            user-select: none;
-webkit-touch-callout: none;
-webkit-tap-highlight-color: transparent;
}

/* Asegurar que el popup sea visible */
#popup-imagen-overlay {
display: none; /* Inicialmente oculto, se mostrará con JS */
}

/* Estilos para cuando el popup está abierto */
.popup-abierto {
    overflow: hidden;
    height: 100%;
    width: 100%;
    position: fixed;
}

/* Clase para mostrar el popup */
.popup-imagen-overlay.mostrar {
    display: flex;
    opacity: 1;
    visibility: visible;
}

/* Para dispositivos móviles */
@media (max-width: 768px) {
    body.popup-abierto {
        position: static;
        overflow-y: visible;
        touch-action: pan-y;
    }
}

/* Estilos responsivos */
@media (max-width: 1024px) {
    .popup-imagen-contenedor {
        max-width: 100%;
        max-height: 100%;
        padding: 0;
        margin: 0;
    }
    
    .popup-imagen {
        max-height: 100vh;
        width: auto;
        margin: 0 auto;
    }
}

/* Para móviles en orientación vertical */
@media (max-width: 767px) {
    .popup-imagen-overlay {
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 15px;
        background: #32647d61;
        display: flex;
        align-items: center;
        justify-content: center;
        box-sizing: border-box;
        overflow: auto;
    }
    
    .popup-imagen-contenedor {
        position: relative;
        display: inline-block;
        max-width: 100%;
        max-height: 100%;
        margin: auto;
        padding: 0;
        border: none;
        background: transparent;
        box-shadow: none;
        line-height: 0;
    }
    
    .popup-imagen {
        max-width: 100%;
        max-height: calc(100vh - 30px);
        width: auto;
        height: auto;
        display: block;
        margin: 0 auto;
        position: relative;
    }
   
    .popup-imagen-preview {
        max-width: 100%;
    }
    
    .popup-cerrar-movil {
        position: absolute;
        top: 0;
        right: 0;
        transform: translate(50%, -50%);
        width: 32px;
        height: 32px;
        background: #32647d;
        color: #fff;
        border: 2px solid #F27C05;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 20px;
        font-weight: bold;
        z-index: 1001;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        -webkit-tap-highlight-color: transparent;
        padding: 0;
        margin: 0;
        line-height: 1;
    }
    
    /* Ocultar botón de escritorio en móviles */
    .popup-imagen-cerrar {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .popup-imagen-contenedor {
        padding: 12px;
        position: relative;
        display: inline-block;
    }
    
    .popup-cerrar-movil {
        display: flex !important;
        position: absolute;
        top: 8px;
        right: 16px;
        transform: translate(50%, -50%);
        width: 32px;
        height: 32px;
        background: #32647d;
        color: #fff;
        border: 2px solid #F27C05;
        border-radius: 50%;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        font-size: 20px;
        font-weight: bold;
        z-index: 1001;
        box-shadow: 0 2px 5px rgba(0,0,0,0.2);
        -webkit-tap-highlight-color: transparent;
        padding: 0;
        margin: 0;
        line-height: 1;
    }
    
    /* Ocultar botón de escritorio en móviles */
    .popup-imagen-cerrar {
        display: none !important;
    }
}

/* Asegurar que el botón móvil esté oculto en escritorio */
@media (min-width: 768px) {
    .popup-cerrar-movil {
        display: none !important;
    }
    
    .popup-imagen-cerrar {
        display: flex !important;
    }
}