/* ============================================================
   Toast notification system - unified API
   ============================================================ */

#toast-container {
    position: fixed;
    top: 80px;
    right: 20px;
    width: 360px;
    max-width: calc(100vw - 32px);
    z-index: 1080;
    display: flex;
    flex-direction: column;
    gap: 10px;
    pointer-events: none;
}

#toast-container .toast-item {
    pointer-events: auto;
}

.toast-item {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 38px 14px 14px;
    border-radius: 10px;
    background: rgba(255, 255, 255, 0.92);
    backdrop-filter: blur(12px) saturate(140%);
    -webkit-backdrop-filter: blur(12px) saturate(140%);
    box-shadow: 0 10px 30px -8px rgba(0, 0, 0, 0.18), 0 2px 6px rgba(0, 0, 0, 0.06);
    border: 1px solid rgba(0, 0, 0, 0.05);
    color: #1e293b;
    overflow: hidden;
    animation: toast-slide-in 0.28s cubic-bezier(0.21, 1, 0.34, 1.05);
    transform-origin: right center;
}

.toast-item::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: var(--toast-accent, #6b7280);
}

.toast-item.toast--success { --toast-accent: #16a34a; }
.toast-item.toast--info    { --toast-accent: #2563eb; }
.toast-item.toast--warning { --toast-accent: #d97706; }
.toast-item.toast--danger  { --toast-accent: #dc2626; }
.toast-item.toast--loading { --toast-accent: #6366f1; }

.toast-icon {
    flex-shrink: 0;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: color-mix(in srgb, var(--toast-accent) 14%, transparent);
    color: var(--toast-accent);
    font-size: 14px;
}

.toast-body {
    flex: 1;
    min-width: 0;
    line-height: 1.4;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    color: #0f172a;
    display: block;
    word-wrap: break-word;
}

.toast-detail {
    margin-top: 3px;
    font-size: 12.5px;
    color: #475569;
    word-wrap: break-word;
}

.toast-detail .toast-timing {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 1px 7px;
    margin-left: 6px;
    border-radius: 999px;
    background: rgba(99, 102, 241, 0.1);
    color: #4338ca;
    font-variant-numeric: tabular-nums;
    font-size: 11.5px;
    font-weight: 500;
}

.toast-close {
    position: absolute;
    top: 8px;
    right: 8px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 0;
    background: transparent;
    color: #94a3b8;
    font-size: 14px;
    line-height: 1;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s, color 0.15s;
}
.toast-close:hover { background: rgba(0, 0, 0, 0.06); color: #1e293b; }

.toast-progress {
    position: absolute;
    left: 4px;
    right: 0;
    bottom: 0;
    height: 2px;
    background: var(--toast-accent);
    opacity: 0.5;
    transform-origin: left center;
    transform: scaleX(1);
    transition: transform linear;
}
.toast-item.toast--paused .toast-progress { transition-duration: 0s !important; }

.toast-item.toast--loading .toast-icon i {
    animation: toast-spin 0.9s linear infinite;
}

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

@keyframes toast-slide-in {
    from { transform: translateX(110%) scale(0.98); opacity: 0; }
    to   { transform: translateX(0)    scale(1);    opacity: 1; }
}
@keyframes toast-slide-out {
    from { transform: translateX(0)    scale(1);    opacity: 1; }
    to   { transform: translateX(110%) scale(0.98); opacity: 0; }
}
@keyframes toast-spin {
    to { transform: rotate(360deg); }
}

@media (max-width: 576px) {
    #toast-container {
        top: 64px;
        left: 10px;
        right: 10px;
        width: auto;
    }
    .toast-item { animation-name: toast-slide-down; }
    @keyframes toast-slide-down {
        from { transform: translateY(-110%); opacity: 0; }
        to   { transform: translateY(0);     opacity: 1; }
    }
}
