/* WhatsBot Global Toast v1.0
 * Shared notification surface for Backend + Frontend.
 */
:root {
    --wb-toast-success: #22c55e;
    --wb-toast-error: #ef4444;
    --wb-toast-warning: #f59e0b;
    --wb-toast-info: #3b82f6;
    --wb-toast-bg-start: rgba(30, 41, 69, 0.98);
    --wb-toast-bg-end: rgba(43, 55, 88, 0.98);
    --wb-toast-text: #ffffff;
    --wb-toast-muted: #cbd5e1;
}

#wb-toast-container {
    position: fixed;
    inset-block-start: max(18px, env(safe-area-inset-top));
    inset-inline-end: max(18px, env(safe-area-inset-right));
    z-index: 2147483000;
    width: min(360px, calc(100vw - 28px));
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
    direction: ltr;
}

html[dir="rtl"] #wb-toast-container {
    inset-inline-end: max(18px, env(safe-area-inset-left));
    direction: rtl;
}

.wb-toast {
    --wb-toast-accent: var(--wb-toast-info);
    position: relative;
    display: grid;
    grid-template-columns: 38px minmax(0, 1fr) 24px;
    align-items: center;
    gap: 11px;
    min-height: 72px;
    padding: 12px 12px 13px;
    overflow: hidden;
    color: var(--wb-toast-text);
    background:
        radial-gradient(circle at 92% 8%, rgba(255, 255, 255, 0.08), transparent 36%),
        linear-gradient(135deg, var(--wb-toast-bg-start), var(--wb-toast-bg-end));
    border: 1px solid rgba(255, 255, 255, 0.11);
    border-radius: 10px;
    box-shadow: 0 16px 45px rgba(15, 23, 42, 0.34), 0 4px 14px rgba(15, 23, 42, 0.22);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    pointer-events: auto;
    opacity: 0;
    transform: translate3d(28px, -8px, 0) scale(0.97);
    transition: opacity 180ms ease, transform 220ms cubic-bezier(.2,.8,.2,1);
    font-family: inherit;
    text-align: start;
}

html[dir="rtl"] .wb-toast {
    transform: translate3d(-28px, -8px, 0) scale(0.97);
}

.wb-toast.is-visible {
    opacity: 1;
    transform: translate3d(0, 0, 0) scale(1);
}

.wb-toast.is-leaving {
    opacity: 0;
    transform: translate3d(18px, -4px, 0) scale(0.98);
}

html[dir="rtl"] .wb-toast.is-leaving {
    transform: translate3d(-18px, -4px, 0) scale(0.98);
}

.wb-toast--success { --wb-toast-accent: var(--wb-toast-success); }
.wb-toast--error   { --wb-toast-accent: var(--wb-toast-error); }
.wb-toast--warning { --wb-toast-accent: var(--wb-toast-warning); }
.wb-toast--info    { --wb-toast-accent: var(--wb-toast-info); }

.wb-toast__icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    background: color-mix(in srgb, var(--wb-toast-accent) 88%, #fff 12%);
    box-shadow: 0 0 0 5px color-mix(in srgb, var(--wb-toast-accent) 17%, transparent);
    flex: 0 0 auto;
}

@supports not (background: color-mix(in srgb, red, blue)) {
    .wb-toast__icon { background: var(--wb-toast-accent); }
}

.wb-toast__icon svg {
    width: 18px;
    height: 18px;
    display: block;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.wb-toast__content {
    min-width: 0;
    padding-inline: 1px 2px;
}

.wb-toast__title {
    margin: 0 0 3px;
    color: #fff;
    font-size: 13px;
    line-height: 1.25;
    font-weight: 750;
    letter-spacing: 0;
    overflow-wrap: anywhere;
}

.wb-toast__message {
    margin: 0;
    color: var(--wb-toast-muted);
    font-size: 12px;
    line-height: 1.45;
    font-weight: 500;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.wb-toast__close {
    align-self: start;
    width: 24px;
    height: 24px;
    padding: 0;
    border: 0;
    border-radius: 7px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.72);
    background: transparent;
    cursor: pointer;
    transition: background 160ms ease, color 160ms ease, transform 160ms ease;
}

.wb-toast__close:hover,
.wb-toast__close:focus-visible {
    color: #fff;
    background: rgba(255, 255, 255, 0.11);
    transform: scale(1.05);
    outline: none;
}

.wb-toast__close svg {
    width: 13px;
    height: 13px;
    fill: none;
    stroke: currentColor;
    stroke-width: 2.2;
    stroke-linecap: round;
}

.wb-toast__progress {
    position: absolute;
    inset-inline: 0;
    inset-block-end: 0;
    height: 3px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.07);
}

.wb-toast__progress-bar {
    display: block;
    width: 100%;
    height: 100%;
    transform-origin: left center;
    background: var(--wb-toast-accent);
    animation-name: wb-toast-progress;
    animation-timing-function: linear;
    animation-fill-mode: forwards;
}

html[dir="rtl"] .wb-toast__progress-bar {
    transform-origin: right center;
}

.wb-toast.is-paused .wb-toast__progress-bar {
    animation-play-state: paused;
}

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

@media (max-width: 575.98px) {
    #wb-toast-container {
        inset-block-start: max(10px, env(safe-area-inset-top));
        inset-inline: 10px;
        width: auto;
    }

    .wb-toast {
        width: 100%;
        min-height: 68px;
    }
}

@media (prefers-reduced-motion: reduce) {
    .wb-toast,
    .wb-toast__close {
        transition: none !important;
    }

    .wb-toast__progress-bar {
        animation-duration: 1ms !important;
    }
}

/* Hide legacy transient toast surfaces when the global bridge is active. */
html.wb-toast-ready .iziToast-wrapper,
html.wb-toast-ready .bb-toast,
html.wb-toast-ready .tb-toast,
html.wb-toast-ready .tm-toast,
html.wb-toast-ready .cf-toast,
html.wb-toast-ready .commerce-toast,
html.wb-toast-ready #waProfileToast {
    display: none !important;
}
