/* Global stacking toasts (static/js/toast.js) */
#uf-toast-region {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2147483000;
    display: flex;
    flex-direction: column;
    width: 24rem;
    max-width: calc(100vw - 2rem);
    pointer-events: none;
}

.uf-toast {
    --uf-toast-accent: #2563eb;
    --uf-toast-accent-soft: #dbeafe;
    margin-bottom: 0.5rem;
    max-height: 20rem;
    overflow: hidden;
    pointer-events: auto;
    transition: opacity 200ms ease, transform 200ms ease, max-height 250ms ease, margin-bottom 250ms ease;
}

.uf-toast--success { --uf-toast-accent: #16a34a; --uf-toast-accent-soft: #dcfce7; }
.uf-toast--error   { --uf-toast-accent: #dc2626; --uf-toast-accent-soft: #fee2e2; }
.uf-toast--warning { --uf-toast-accent: #d97706; --uf-toast-accent-soft: #fef3c7; }
.uf-toast--info    { --uf-toast-accent: #2563eb; --uf-toast-accent-soft: #dbeafe; }

.uf-toast--entering {
    opacity: 0;
    transform: translateX(1.5rem);
}

.uf-toast--leaving {
    opacity: 0;
    transform: translateX(1.5rem);
    margin-bottom: 0;
}

.uf-toast--bump .uf-toast-card {
    animation: uf-toast-bump 300ms ease;
}

@keyframes uf-toast-bump {
    0%   { transform: scale(1); }
    40%  { transform: scale(1.03); }
    100% { transform: scale(1); }
}

.uf-toast-card {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.75rem 0.625rem 0.875rem 0.875rem;
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-left: 4px solid var(--uf-toast-accent);
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.12), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.uf-toast-icon {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 9999px;
    background: var(--uf-toast-accent-soft);
    color: var(--uf-toast-accent);
}

.uf-toast-icon svg {
    width: 0.875rem;
    height: 0.875rem;
}

.uf-toast-body {
    flex: 1;
    min-width: 0;
    padding-top: 0.125rem;
}

.uf-toast-title {
    margin: 0 0 0.125rem;
    font-size: 0.875rem;
    font-weight: 600;
    line-height: 1.25rem;
    color: #111827;
}

.uf-toast-message {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.25rem;
    color: #374151;
    white-space: pre-line;
    overflow-wrap: anywhere;
}

.uf-toast-count {
    flex-shrink: 0;
    margin-top: 0.125rem;
    padding: 0 0.375rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
    line-height: 1.25rem;
    background: var(--uf-toast-accent-soft);
    color: var(--uf-toast-accent);
}

.uf-toast-close {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 1.75rem;
    height: 1.75rem;
    margin: -0.125rem 0 0;
    padding: 0;
    border: 0;
    border-radius: 0.375rem;
    background: transparent;
    color: #9ca3af;
    cursor: pointer;
    transition: background-color 150ms ease, color 150ms ease;
}

.uf-toast-close:hover {
    background: #f3f4f6;
    color: #374151;
}

.uf-toast-close:focus-visible {
    outline: 2px solid var(--uf-toast-accent);
    outline-offset: 1px;
}

.uf-toast-close svg {
    width: 1rem;
    height: 1rem;
}

.uf-toast-progress {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--uf-toast-accent-soft);
}

.uf-toast-progress-bar {
    height: 100%;
    background: var(--uf-toast-accent);
    opacity: 0.7;
    transform-origin: left center;
}

.dark .uf-toast-card {
    background: #1f2937;
    border-color: #374151;
    border-left-color: var(--uf-toast-accent);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5), 0 4px 6px -4px rgba(0, 0, 0, 0.4);
}

.dark .uf-toast-title { color: #f9fafb; }
.dark .uf-toast-message { color: #e5e7eb; }
.dark .uf-toast-close { color: #9ca3af; }
.dark .uf-toast-close:hover { background: #374151; color: #f3f4f6; }

.dark .uf-toast--success { --uf-toast-accent: #4ade80; --uf-toast-accent-soft: rgba(74, 222, 128, 0.15); }
.dark .uf-toast--error   { --uf-toast-accent: #f87171; --uf-toast-accent-soft: rgba(248, 113, 113, 0.15); }
.dark .uf-toast--warning { --uf-toast-accent: #fbbf24; --uf-toast-accent-soft: rgba(251, 191, 36, 0.15); }
.dark .uf-toast--info    { --uf-toast-accent: #60a5fa; --uf-toast-accent-soft: rgba(96, 165, 250, 0.15); }

@media (max-width: 639px) {
    #uf-toast-region {
        top: 0.75rem;
        left: 0.75rem;
        right: 0.75rem;
        width: auto;
        max-width: none;
    }

    .uf-toast--entering,
    .uf-toast--leaving {
        transform: translateY(-0.75rem);
    }
}

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

    .uf-toast--bump .uf-toast-card {
        animation: none;
    }
}
