/* Hallmark · component: toast · genre: modern-minimal · theme: existing (Ascendum teal tokens, Poppins) · states: 8 · contrast: pass · v2.0.0 */
/* critique: notices that do not interrupt; errors stay until read, the rest leave on their own with a visible countdown. */

/* Tokens propios: la vista de Login no carga Masterpage.css. */
:root {
    --toast-superficie: #ffffff;
    --toast-texto: #26363b;
    --toast-tenue: #5b6b70;
    --toast-hover: #eef3f4;
    --toast-foco: #0f7c87;
    --toast-sombra: 0 12px 32px rgba(0, 47, 54, 0.16), 0 2px 6px rgba(0, 47, 54, 0.08);

    --toast-exito: #1d7a4c;
    --toast-exito-fondo: #e7f4ec;
    --toast-error: #b3261e;
    --toast-error-fondo: #fbeaea;
    --toast-aviso: #9a5b00;
    --toast-aviso-fondo: #fdf1dc;
    --toast-info: #0b6973;
    --toast-info-fondo: #e3f1f2;

    --toast-radio: 10px;
    --toast-ancho: 380px;
    --toast-espacio: 16px;
}

.toast-region {
    position: fixed;
    top: var(--toast-espacio);
    right: var(--toast-espacio);
    /* Por encima de todo: modales de Bootstrap (1050), modales propios de las vistas
       (.mc-followup-modal 9999, .endoso-modal 10020, .inventory-modal 99999) y
       SweetAlert, que algunas vistas suben hasta 1000000. Es el valor máximo permitido. */
    z-index: 2147483647;
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: min(var(--toast-ancho), calc(100% - 2 * var(--toast-espacio)));
    pointer-events: none;
}

.toast {
    --toast-color: var(--toast-info);
    --toast-color-fondo: var(--toast-info-fondo);

    position: relative;
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto;
    gap: 12px;
    align-items: start;
    padding: 16px 12px 16px 16px;
    overflow: hidden;
    background: var(--toast-superficie);
    color: var(--toast-texto);
    border-radius: var(--toast-radio);
    box-shadow: var(--toast-sombra);
    font: inherit;
    font-size: 15px;
    line-height: 1.45;
    pointer-events: auto;
    transform: translateX(0);
    opacity: 1;
    transition: transform 220ms cubic-bezier(0.2, 0.8, 0.2, 1), opacity 220ms ease;
}

.toast--entrando,
.toast--saliendo {
    transform: translateX(24px);
    opacity: 0;
}

.toast--exito { --toast-color: var(--toast-exito); --toast-color-fondo: var(--toast-exito-fondo); }
.toast--error { --toast-color: var(--toast-error); --toast-color-fondo: var(--toast-error-fondo); }
.toast--aviso { --toast-color: var(--toast-aviso); --toast-color-fondo: var(--toast-aviso-fondo); }
.toast--info  { --toast-color: var(--toast-info);  --toast-color-fondo: var(--toast-info-fondo); }

.toast__icono {
    display: grid;
    place-items: center;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: var(--toast-color-fondo);
    color: var(--toast-color);
    font-size: 17px;
}

.toast__contenido {
    min-width: 0;
    overflow-wrap: break-word;
    padding-top: 4px;
}

.toast__titulo {
    margin: 0;
    font-weight: 600;
    font-size: 15px;
    color: var(--toast-texto);
}

.toast__mensaje {
    margin: 2px 0 0;
    color: var(--toast-tenue);
    white-space: pre-line;
}

.toast__titulo:empty,
.toast__mensaje:empty {
    display: none;
}

.toast__cerrar {
    display: grid;
    place-items: center;
    width: 30px;
    height: 30px;
    margin: 0;
    padding: 0;
    border: 0;
    border-radius: 6px;
    background: transparent;
    color: var(--toast-tenue);
    font: inherit;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.toast__cerrar:hover,
.toast__cerrar.is-hover {
    background: var(--toast-hover);
    color: var(--toast-texto);
}

.toast__cerrar:focus-visible,
.toast__cerrar.is-focus {
    outline: 2px solid var(--toast-foco);
    outline-offset: 1px;
    transition: none;
}

.toast__cerrar:active,
.toast__cerrar.is-active {
    transform: scale(0.94);
}

.toast__cerrar:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

/* Cuenta regresiva: solo en los toasts que se cierran solos. */
.toast__tiempo {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--toast-color);
    opacity: 0.55;
    transform-origin: left center;
    animation: toast-tiempo linear forwards;
}

.toast:hover .toast__tiempo,
.toast:focus-within .toast__tiempo {
    animation-play-state: paused;
}

@keyframes toast-tiempo {
    from { transform: scaleX(1); }
    to { transform: scaleX(0); }
}

@media (max-width: 540px) {
    .toast-region {
        left: var(--toast-espacio);
        width: auto;
    }
}

@media (prefers-reduced-motion: reduce) {
    .toast,
    .toast__cerrar {
        transition: opacity 120ms linear;
    }

    .toast--entrando,
    .toast--saliendo {
        transform: none;
    }

    .toast__tiempo {
        display: none;
    }
}
