/* ============================================================
   AtlasMPS — Toast Notifications (server-rendered, api/views/alerts.php)
   The same glass card as showToast()'s .ui-toast (GLASS UI block in
   atlasmps-custom.css): a round status icon, a title and a line of detail,
   a round dismiss button, and a hairline that runs out as it auto-dismisses.
   Colors come from the --ui-* status tokens, with fallbacks.
   ============================================================ */

.sa-toast-container {
    position: fixed;
    top: calc(1rem + env(safe-area-inset-top, 0px));
    right: calc(1rem + env(safe-area-inset-right, 0px));
    z-index: 9999;
    animation: saToastSlideIn 0.36s cubic-bezier(0.32, 0.72, 0, 1);
}

@keyframes saToastSlideIn {
    from {
        opacity: 0;
        transform: translateX(24px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.sa-toast {
    --_t-tint: var(--ui-grey-tint, rgba(118, 112, 106, 0.13));
    --_t-ink: var(--ui-label-2, #5B544E);
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    min-width: 320px;
    max-width: 380px;
    padding: 0.75rem 0.75rem 0.85rem;
    background: rgba(255, 255, 255, 0.88);
    -webkit-backdrop-filter: saturate(1.5) blur(24px);
    backdrop-filter: saturate(1.5) blur(24px);
    border: 1px solid rgba(255, 255, 255, 0.62);
    border-radius: 14px;
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.7),
        0 0 0 1px rgba(23, 20, 18, 0.08),
        0 2px 6px rgba(23, 20, 18, 0.06),
        0 16px 40px -12px rgba(23, 20, 18, 0.28);
    position: relative;
    overflow: hidden;
}

/* Icon */
.sa-toast__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
    font-size: 0.9rem;
    background: var(--_t-tint);
    color: var(--_t-ink);
}

/* Body */
.sa-toast__body {
    flex: 1;
    min-width: 0;
    padding-top: 3px;
}

.sa-toast__title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ui-label-1, #26221E);
    line-height: 1.35;
    margin-bottom: 0.125rem;
    overflow-wrap: anywhere;
}

.sa-toast__msg {
    font-size: 0.8rem;
    color: var(--ui-label-2, #5B544E);
    line-height: 1.4;
    overflow-wrap: anywhere;
}

/* Close button */
.sa-toast__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 50%;
    color: var(--ui-label-3, #8A827A);
    cursor: pointer;
    font-size: 0.7rem;
    flex-shrink: 0;
    transition: background-color 0.15s, color 0.15s;
}

.sa-toast__close:hover {
    color: var(--ui-label-1, #26221E);
    background: var(--ui-fill-hover, rgba(28, 25, 23, 0.045));
}

.sa-toast__close:focus-visible {
    outline: 2px solid rgba(40, 35, 32, 0.55);
    outline-offset: 1px;
}

/* Progress (auto-dismiss): a hairline in the status color that runs out. */
.sa-toast__progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    width: 100%;
    border-radius: 999px;
    background: var(--_t-ink);
    opacity: 0.35;
    animation: saToastProgress 6s linear forwards;
}

@keyframes saToastProgress {
    from { width: 100%; }
    to { width: 0%; }
}

/* Status colors */
.sa-toast--success { --_t-tint: var(--ui-green-tint, rgba(36, 160, 84, 0.12)); --_t-ink: var(--ui-green, #1E7B45); }
.sa-toast--error { --_t-tint: var(--ui-red-tint, rgba(220, 60, 48, 0.11)); --_t-ink: var(--ui-red, #BF3328); }
.sa-toast--warning { --_t-tint: var(--ui-amber-tint, rgba(232, 146, 12, 0.15)); --_t-ink: var(--ui-amber, #9A5600); }
.sa-toast--info { --_t-tint: var(--ui-grey-tint, rgba(118, 112, 106, 0.13)); --_t-ink: var(--ui-label-2, #5B544E); }

/* Auto-dismiss after animation */
.sa-toast-container {
    animation: saToastSlideIn 0.36s cubic-bezier(0.32, 0.72, 0, 1),
               saToastFadeOut 0.3s ease 5.7s forwards;
}

@keyframes saToastFadeOut {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(24px);
    }
}

@media (prefers-reduced-motion: reduce) {
    .sa-toast-container { animation: saToastFadeOut 0.3s ease 5.7s forwards; }
}

@media (prefers-reduced-transparency: reduce) {
    .sa-toast { background: #fff; -webkit-backdrop-filter: none; backdrop-filter: none; }
    [data-theme-mode="dark"] .sa-toast { background: #1E1E20; }
}

/* Mobile */
@media (max-width: 576px) {
    .sa-toast-container {
        top: calc(0.75rem + env(safe-area-inset-top, 0px));
        right: 0.75rem;
        left: 0.75rem;
    }

    .sa-toast {
        min-width: auto;
        max-width: 100%;
    }
}

/* Dark theme */
[data-theme-mode="dark"] .sa-toast {
    background: rgba(28, 28, 30, 0.88);
    border-color: rgba(255, 255, 255, 0.09);
    box-shadow:
        inset 0 1px 0 rgba(255, 255, 255, 0.06),
        0 0 0 1px rgba(0, 0, 0, 0.4),
        0 16px 40px -12px rgba(0, 0, 0, 0.7);
}

[data-theme-mode="dark"] .sa-toast__close:hover {
    background: rgba(255, 255, 255, 0.06);
}
