/* ==========================================================================
   Comgrap Pop-up — Estilos Frontend del Modal
   Diseño moderno, responsive y limpio por defecto
   ========================================================================== */

/* Wrapper principal */
.comgrap-popup-wrapper {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
    z-index: 999999;
}

/* Overlay */
.comgrap-popup-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    cursor: pointer;
}

/* Contenedor del modal */
.comgrap-popup-container {
    position: relative;
    background: #ffffff;
    border-radius: 16px;
    box-shadow: 0 25px 60px rgba(0, 0, 0, 0.15), 0 8px 20px rgba(0, 0, 0, 0.1);
    max-width: min(600px, calc(100vw - 32px));
    width: 100%;
    max-height: calc(100vh - 32px);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1;
    display: flex;
    flex-direction: column;
}

/* Contenido */
.comgrap-popup-content {
    display: flex;
    flex-direction: column;
    align-items: center;
    min-height: 0;
    flex: 1 1 auto;
}

/* Imagen */
.comgrap-popup-image {
    display: block;
    width: 100%;
    height: auto;
    border-radius: 16px 16px 0 0;
}

.comgrap-popup-image-link {
    display: block;
    width: 100%;
    line-height: 0;
    text-decoration: none;
}

.comgrap-popup-image-link .comgrap-popup-image {
    transition: opacity 0.2s ease;
}

.comgrap-popup-image-link:hover .comgrap-popup-image {
    opacity: 0.92;
}

/* Si no hay botón, la imagen tiene border-radius completo */
.comgrap-popup-content > .comgrap-popup-image:only-child,
.comgrap-popup-content > .comgrap-popup-image-link:only-child .comgrap-popup-image {
    border-radius: 16px;
}

/* Botón de cierre */
.comgrap-popup-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 36px;
    height: 36px;
    border: none;
    background: rgba(0, 0, 0, 0.5);
    color: #ffffff;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background-color 0.2s ease, transform 0.2s ease;
    padding: 0;
}

.comgrap-popup-close:hover {
    background: rgba(0, 0, 0, 0.75);
    transform: scale(1.1);
}

.comgrap-popup-close:focus {
    outline: 2px solid #ffffff;
    outline-offset: 2px;
}

/* Botón opcional */
.comgrap-popup-button-wrapper {
    padding: 16px 24px 20px;
    text-align: center;
    width: 100%;
    box-sizing: border-box;
}

.comgrap-popup-button {
    display: inline-block;
    padding: 12px 32px;
    background: #2563eb;
    color: #ffffff;
    text-decoration: none;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    letter-spacing: 0.3px;
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    cursor: pointer;
    border: none;
    box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}

.comgrap-popup-button:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
    box-shadow: 0 4px 14px rgba(37, 99, 235, 0.4);
    color: #ffffff;
    text-decoration: none;
}

.comgrap-popup-button:active {
    transform: translateY(0);
    box-shadow: 0 1px 4px rgba(37, 99, 235, 0.3);
}

/* ==========================================================================
   Animaciones de entrada
   ========================================================================== */

/* Fade */
.comgrap-popup-anim-fade {
    opacity: 0;
    transition: opacity 0.3s ease;
}

.comgrap-popup-anim-fade.comgrap-popup-visible {
    opacity: 1;
}

/* Zoom */
.comgrap-popup-anim-zoom {
    opacity: 0;
    transform: scale(0.85);
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.comgrap-popup-anim-zoom.comgrap-popup-visible {
    opacity: 1;
    transform: scale(1);
}

/* Slide Up */
.comgrap-popup-anim-slide-up {
    opacity: 0;
    transform: translateY(40px);
    transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
}

.comgrap-popup-anim-slide-up.comgrap-popup-visible {
    opacity: 1;
    transform: translateY(0);
}

/* Animación de salida */
.comgrap-popup-wrapper.comgrap-popup-closing .comgrap-popup-container {
    opacity: 0 !important;
    transform: scale(0.95) !important;
    transition: opacity 0.2s ease, transform 0.2s ease !important;
}

.comgrap-popup-wrapper.comgrap-popup-closing .comgrap-popup-overlay {
    opacity: 0 !important;
    transition: opacity 0.2s ease !important;
}

/* ==========================================================================
   Responsive
   ========================================================================== */

/* Tablet */
@media (max-width: 1024px) {
    .comgrap-popup-container {
        max-width: min(90vw, calc(100vw - 32px));
    }
}

/* Mobile */
@media (max-width: 768px) {
    .comgrap-popup-wrapper {
        padding: 12px;
        align-items: center;
    }

    .comgrap-popup-container {
        max-width: calc(100vw - 24px);
        max-height: calc(100vh - 24px);
        border-radius: 12px;
    }

    .comgrap-popup-image {
        border-radius: 12px 12px 0 0;
    }

    .comgrap-popup-content > .comgrap-popup-image:only-child,
    .comgrap-popup-content > .comgrap-popup-image-link:only-child .comgrap-popup-image {
        border-radius: 12px;
    }

    .comgrap-popup-close {
        top: 6px;
        right: 6px;
        width: 32px;
        height: 32px;
        font-size: 20px;
    }

    .comgrap-popup-button-wrapper {
        padding: 12px 16px 16px;
    }

    .comgrap-popup-button {
        padding: 14px 28px;
        font-size: 16px;
        width: 100%;
        text-align: center;
        box-sizing: border-box;
        min-height: 48px;
    }
}

/* Mobile pequeño */
@media (max-width: 480px) {
    .comgrap-popup-wrapper {
        padding: 8px;
    }

    .comgrap-popup-container {
        max-width: calc(100vw - 16px);
        max-height: calc(100vh - 16px);
        border-radius: 10px;
    }

    .comgrap-popup-image {
        border-radius: 10px 10px 0 0;
    }

    .comgrap-popup-content > .comgrap-popup-image:only-child,
    .comgrap-popup-content > .comgrap-popup-image-link:only-child .comgrap-popup-image {
        border-radius: 10px;
    }
}

/* Scrollbar suave para modales con contenido largo */
.comgrap-popup-container::-webkit-scrollbar {
    width: 6px;
}

.comgrap-popup-container::-webkit-scrollbar-track {
    background: transparent;
}

.comgrap-popup-container::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

.comgrap-popup-container::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 0, 0, 0.25);
}

/* Comportamiento móvil: ocultar (se aplica vía JS según opción global) */

@media (max-width: 768px) {
    .comgrap-popup-mobile-hide {
        display: none !important;
    }

    .comgrap-popup-mobile-fullscreen .comgrap-popup-container {
        max-width: 100vw;
        max-height: 100vh;
        width: 100%;
        height: 100%;
        border-radius: 0;
    }

    .comgrap-popup-mobile-fullscreen .comgrap-popup-image {
        border-radius: 0;
    }
}
