/* Modal de alerta reutilizable ("¡Alto! No puedes continuar") */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;700;800&display=swap');

.meg-backdrop {
    position: fixed;
    inset: 0;
    z-index: 20000; /* por encima de los modales bootstrap (1050) y sweetalert (10000) */
    display: none;
    align-items: center;
    justify-content: center;
    padding: 16px;
    background: rgba(0, 0, 0, 0.55);
    font-family: 'Poppins', 'Ubuntu', sans-serif;
}

.meg-backdrop.meg-visible {
    display: flex;
    animation: megFadeIn .2s ease-out;
}

body.meg-abierto {
    overflow: hidden;
}

/* El contenedor no hace scroll: cabecera y botón quedan fijos y solo se desplaza el cuerpo */
.meg-contenedor {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 600px;
    max-height: calc(100vh - 32px);
    overflow: hidden;
    background: #F7F7F7;
    border-radius: 18px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    animation: megZoomIn .2s ease-out;
}

.meg-cerrar-x {
    position: absolute;
    top: 8px;
    right: 12px;
    z-index: 2;
    border: none;
    background: transparent;
    color: #000000;
    font-size: 28px;
    line-height: 1;
    cursor: pointer;
}

/* ---------- Cabecera: ilustración + título en 2 partes ---------- */
/* Cabecera compacta: se recorta un poco arriba y abajo de la ilustración (sin tocar al personaje) */
.meg-imagen {
    position: relative;
    flex: 0 0 auto;
    background: #FECE02;
    border-radius: 18px 18px 0 0;
    overflow: hidden;
    aspect-ratio: 1648 / 760;
}

.meg-imagen img {
    display: block;
    width: 100%;
    height: 100%;
    opacity: 1;
    transition: opacity .25s ease-out;
    object-fit: cover;
    object-position: 50% 12%;
}

/* El título va en el espacio libre a la izquierda del personaje
   (la curva negra de la ilustración empieza ~72% de alto) */
.meg-titulo {
    position: absolute;
    top: 0;
    bottom: 22%;
    left: 0;
    width: 52%;
    display: flex;
    flex-direction: column;
    justify-content: center;
    padding: 12px 0 0 28px;
}

.meg-titulo-1 {
    color: #FFFFFF;
    font-size: clamp(32px, 8vw, 50px);
    font-weight: 800;
    line-height: 1;
    letter-spacing: -1px;
    text-shadow: 0 2px 0 rgba(0, 0, 0, 0.06);
}

.meg-titulo-2 {
    margin-top: 6px;
    color: #111111;
    font-size: clamp(19px, 4.8vw, 30px);
    font-weight: 800;
    line-height: 1.05;
    letter-spacing: -0.5px;
    text-wrap: balance;
}

/* ---------- Cuerpo: tarjetas Motivo / Solución ---------- */
.meg-cuerpo {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overscroll-behavior: contain;
    padding: 16px 18px 4px;
    scrollbar-width: thin;
    scrollbar-color: #C9C9C9 transparent;
}

.meg-cuerpo::-webkit-scrollbar { width: 6px; }
.meg-cuerpo::-webkit-scrollbar-thumb { background: #C9C9C9; border-radius: 3px; }

.meg-tarjeta {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 12px;
    padding: 14px 18px;
    border-radius: 14px;
}

/* En la solución el ícono va arriba para que no "flote" cuando el contenido es alto */
.meg-tarjeta-solucion {
    align-items: flex-start;
}

.meg-tarjeta-motivo {
    background: #FDECEE;
}

.meg-tarjeta-solucion {
    background: #EAF6EE;
}

.meg-icono {
    flex: 0 0 auto;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    border-radius: 50%;
}

.meg-icono svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #FFFFFF;
    stroke-width: 3.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.meg-tarjeta-motivo .meg-icono {
    background: #E8394F;
}

.meg-tarjeta-solucion .meg-icono {
    background: #1E9A55;
}

.meg-tarjeta-texto {
    flex: 1 1 auto;
    min-width: 0;
}

.meg-etiqueta {
    display: block;
    margin-bottom: 2px;
    font-size: 17px;
    font-weight: 700;
    line-height: 1.2;
}

.meg-tarjeta-motivo .meg-etiqueta {
    color: #E03A4E;
}

.meg-tarjeta-solucion .meg-etiqueta {
    color: #1E8B4E;
}

.meg-texto {
    margin: 0;
    color: #1F1F1F;
    font-size: 14px;
    line-height: 1.5;
}

.meg-texto strong {
    font-weight: 700;
    color: #000000;
}

/* ---------- Texto largo: se recorta a 4 líneas con "Ver más / Ver menos" ---------- */
/* Se recorta por alto (4 líneas) para que funcione también con HTML (párrafos y listas) */
.meg-texto.meg-recortado {
    position: relative;
    max-height: 6em; /* 4 líneas x line-height 1.5 */
    overflow: hidden;
}

.meg-texto.meg-recortado::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 1.5em;
    pointer-events: none;
}

.meg-tarjeta-motivo .meg-texto.meg-recortado::after {
    background: linear-gradient(rgba(253, 236, 238, 0), #FDECEE);
}

.meg-tarjeta-solucion .meg-texto.meg-recortado::after {
    background: linear-gradient(rgba(234, 246, 238, 0), #EAF6EE);
}

/* HTML que viene de la BD (mensaje_cliente_html) */
.meg-texto p {
    margin: 0 0 6px;
}

.meg-texto p:last-child,
.meg-texto ul:last-child,
.meg-texto ol:last-child {
    margin-bottom: 0;
}

.meg-texto ul,
.meg-texto ol {
    margin: 0 0 8px;
    padding-left: 20px;
}

.meg-texto li {
    margin-bottom: 2px;
}

.meg-ver-mas {
    display: none;
    margin-top: 4px;
    padding: 0;
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 14px;
    font-weight: 700;
    text-decoration: underline;
    cursor: pointer;
}

.meg-ver-mas.meg-activo {
    display: inline-block;
}

.meg-ver-mas:focus { outline: none; }
.meg-ver-mas:focus-visible { outline: 2px solid currentColor; outline-offset: 2px; border-radius: 4px; }

/* ---------- Solución por casos (pestañas) ----------
   Si el HTML trae varios bloques "<p><strong>Título:</strong></p> + contenido" se muestran como pestañas
   y solo se ve un caso a la vez (p.ej. "Si ocurre al Activar" / "Si ocurre al Validar"). */
.meg-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 10px;
}

.meg-tab {
    padding: 5px 12px;
    border: 1.5px solid #1E9A55;
    border-radius: 16px;
    background: #FFFFFF;
    color: #16733F;
    font-family: inherit;
    font-size: 12.5px;
    font-weight: 600;
    line-height: 1.3;
    cursor: pointer;
    transition: background .15s, color .15s;
}

.meg-tab:hover { background: #DDF0E4; }
.meg-tab:focus { outline: none; }
.meg-tab:focus-visible { outline: 2px solid #16733F; outline-offset: 2px; }

.meg-tab.meg-tab-activa {
    background: #1E9A55;
    color: #FFFFFF;
}

.meg-panel[hidden] { display: none; }

.meg-tarjeta-motivo .meg-ver-mas { color: #C42B3F; }
.meg-tarjeta-solucion .meg-ver-mas { color: #16733F; }

.meg-ver-mas::after {
    content: '';
    display: inline-block;
    width: 6px;
    height: 6px;
    margin-left: 6px;
    border-right: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: translateY(-3px) rotate(45deg);
    transition: transform .2s;
}

.meg-ver-mas[aria-expanded="true"]::after {
    transform: translateY(0) rotate(-135deg);
}

/* ---------- Botón ---------- */
.meg-acciones {
    flex: 0 0 auto;
    display: flex;
    justify-content: center;
    padding: 8px 20px 18px;
}

.meg-btn {
    min-width: 190px;
    padding: 11px 26px;
    border: none;
    border-radius: 26px;
    background: #FACC33;
    color: #000000;
    font-family: inherit;
    font-weight: 700;
    letter-spacing: .5px;
    cursor: pointer;
    transition: filter .15s;
}

.meg-btn:hover,
.meg-btn:focus {
    filter: brightness(.93);
    outline: none;
}

@keyframes megFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes megZoomIn {
    from { transform: scale(.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

/* Pantallas bajas (portátiles): cabecera aún más compacta */
@media (max-height: 760px) {
    .meg-imagen { aspect-ratio: 1648 / 640; }
    .meg-imagen img { object-position: 50% 8%; }
    .meg-titulo-1 { font-size: clamp(28px, 7vw, 42px); }
    .meg-titulo-2 { font-size: clamp(17px, 4.2vw, 26px); }
}

@media (max-width: 480px) {
    .meg-titulo { padding-left: 16px; width: 54%; }
    .meg-titulo-2 { margin-top: 3px; }
    .meg-tarjeta { gap: 12px; padding: 14px; }
    .meg-icono { width: 40px; height: 40px; }
    .meg-icono svg { width: 20px; height: 20px; }
    .meg-etiqueta { font-size: 16px; }
    .meg-texto { font-size: 14px; }
    .meg-btn { width: 100%; }
}

/* index.css (temas/celuya/general/index.css) tiene una regla global "div { padding: 0 !important; }"
   que anula los espacios del modal dentro del sistema. Se fuerzan aquí con mayor especificidad. */
#modal-error-gateway.meg-backdrop { padding: 16px !important; }
#modal-error-gateway .meg-titulo { padding: 12px 0 0 28px !important; }
#modal-error-gateway .meg-cuerpo { padding: 16px 18px 4px !important; }
#modal-error-gateway .meg-tarjeta { padding: 14px 18px !important; }
#modal-error-gateway .meg-acciones { padding: 8px 20px 18px !important; }
#modal-error-gateway .meg-imagen,
#modal-error-gateway .meg-contenedor,
#modal-error-gateway .meg-tarjeta-texto { padding: 0 !important; }

@media (max-width: 480px) {
    #modal-error-gateway .meg-titulo { padding: 0 0 0 16px !important; }
    #modal-error-gateway .meg-cuerpo { padding: 16px 14px 4px !important; }
    #modal-error-gateway .meg-tarjeta { padding: 14px !important; }
    #modal-error-gateway .meg-acciones { padding: 8px 14px 14px !important; }
}

#modal-error-gateway .meg-texto ul,
#modal-error-gateway .meg-texto ol { padding-left: 20px !important; }

/* ---------- Cargando imagen de la cabecera ---------- */
.meg-imagen.meg-cargando img { opacity: 0; }
.meg-cargando-img {
    display: none;
    position: absolute;
    top: 50%;
    right: 22%;
    z-index: 1;
    width: 38px;
    height: 38px;
    margin-top: -19px;
    border: 4px solid rgba(0, 0, 0, 0.15);
    border-top-color: #000000;
    border-radius: 50%;
    animation: megGirar .8s linear infinite;
}
.meg-imagen.meg-cargando .meg-cargando-img { display: block; }
@keyframes megGirar { to { transform: rotate(360deg); } }
