/* Unified toast notifications. Driven by static/js/toast.js. */
#tg-toast-stack {
    position: fixed;
    top: 1.25rem;
    right: 1.25rem;
    z-index: 10050;
    display: flex;
    flex-direction: column;
    gap: 0.625rem;
    width: min(380px, calc(100vw - 2rem));
    pointer-events: none; /* the stack never blocks the page; only toasts are clickable */
}

.tg-toast {
    --tg-toast-accent: #3b82f6;
    --tg-toast-tint: rgba(59, 130, 246, 0.12);
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.875rem 0.875rem 0.875rem 1rem;
    border-radius: 8px;
    border: 1px solid var(--tg-toast-accent); /* fallback for browsers without color-mix() */
    border: 1px solid color-mix(in srgb, var(--tg-toast-accent) 25%, transparent);
    background: linear-gradient(var(--tg-toast-tint), var(--tg-toast-tint)), var(--bg-card, #ffffff);
    color: var(--text-primary, #1f2937);
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.18);
    font-size: 0.875rem;
    line-height: 1.4;
    overflow: hidden;
    pointer-events: auto;
    animation: tg-toast-in 0.3s ease-out;
}

.tg-toast--success { --tg-toast-accent: #16a34a; --tg-toast-tint: rgba(22, 163, 74, 0.12); }
.tg-toast--error   { --tg-toast-accent: #dc2626; --tg-toast-tint: rgba(220, 38, 38, 0.12); }
.tg-toast--warning { --tg-toast-accent: #d97706; --tg-toast-tint: rgba(245, 158, 11, 0.14); }
.tg-toast--info    { --tg-toast-accent: #2563eb; --tg-toast-tint: rgba(59, 130, 246, 0.12); }

.tg-toast--leaving { animation: tg-toast-out 0.25s ease-in forwards; }

.tg-toast__icon {
    flex: 0 0 auto;
    width: 20px;
    height: 20px;
    margin-top: 1px;
    stroke: var(--tg-toast-accent);
    fill: none;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.tg-toast__msg {
    flex: 1 1 auto;
    min-width: 0;
    overflow-wrap: anywhere;
    white-space: pre-line;
}

.tg-toast__close {
    flex: 0 0 auto;
    width: 22px;
    height: 22px;
    padding: 0;
    border: 0;
    border-radius: 4px;
    background: transparent;
    color: var(--text-secondary, #6b7280);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
}
.tg-toast__close:hover { background: rgba(127, 127, 127, 0.18); color: var(--text-primary, #1f2937); }

.tg-toast__bar {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    height: 3px;
    background: var(--tg-toast-accent);
    opacity: 0.55;
    transform-origin: left;
    animation: tg-toast-bar var(--tg-toast-duration, 10s) linear forwards;
}
.tg-toast:hover .tg-toast__bar,
.tg-toast:focus-within .tg-toast__bar { animation-play-state: paused; }

@keyframes tg-toast-in  { from { transform: translateX(110%); opacity: 0; } to { transform: translateX(0); opacity: 1; } }
@keyframes tg-toast-out { from { transform: translateX(0); opacity: 1; } to { transform: translateX(110%); opacity: 0; } }
@keyframes tg-toast-bar { from { transform: scaleX(1); } to { transform: scaleX(0); } }

@media (prefers-reduced-motion: reduce) {
    .tg-toast, .tg-toast--leaving { animation-duration: 0.01s; }
    .tg-toast__bar { display: none; }
}
