/* ============================================
   Toast 通知
   ============================================ */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 100000;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
    max-width: calc(100vw - 48px);
}

.toast {
    position: relative;
    pointer-events: auto;
    min-width: 300px;
    max-width: 420px;
    padding: 16px 16px 16px 18px;
    display: flex;
    align-items: center;
    gap: 14px;
    border-radius: 16px;
    background: linear-gradient(180deg, rgba(30, 30, 34, 0.96) 0%, rgba(18, 18, 20, 0.98) 100%);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow:
        0 1px 0 rgba(255, 255, 255, 0.06) inset,
        0 -1px 0 rgba(0, 0, 0, 0.5) inset,
        0 20px 40px -14px rgba(0, 0, 0, 0.75),
        0 0 0 1px rgba(0, 0, 0, 0.35);
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);
    overflow: hidden;
    isolation: isolate;
    cursor: default;
    animation: toastIn 0.4s cubic-bezier(0.22, 1, 0.36, 1);
    will-change: transform, opacity;
}

.toast.leaving {
    animation: toastOut 0.32s cubic-bezier(0.55, 0, 0.68, 0.19) forwards;
    pointer-events: none;
}

/* 顶部氛围光晕 */
.toast::before {
    content: "";
    position: absolute;
    top: -60%;
    left: -10%;
    width: 240px;
    height: 240px;
    background: radial-gradient(circle, var(--glow) 0%, transparent 65%);
    pointer-events: none;
    z-index: 0;
    opacity: 0.9;
}

/* 顶部进度条 */
.toast::after {
    content: "";
    position: absolute;
    top: 0;
    left: 0;
    height: 2px;
    width: 100%;
    background: linear-gradient(90deg, var(--accent) 0%, var(--accent2) 100%);
    transform-origin: left center;
    transform: scaleX(1);
    animation: toastProgress var(--duration, 3000ms) linear forwards;
    box-shadow: 0 0 12px var(--accent);
    z-index: 2;
    border-radius: 2px;
}

.toast.paused::after {
    animation-play-state: paused;
}

/* 图标 */
.toast-icon {
    position: relative;
    width: 38px;
    height: 38px;
    flex-shrink: 0;
    border-radius: 11px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95rem;
    color: var(--accent);
    background: var(--icon-bg);
    border: 1px solid var(--icon-border);
    box-shadow:
        0 0 20px -4px var(--accent),
        0 1px 0 rgba(255, 255, 255, 0.08) inset;
    z-index: 1;
}
.toast-icon::after {
    content: "";
    position: absolute;
    inset: -6px;
    border-radius: inherit;
    background: radial-gradient(circle, var(--glow) 0%, transparent 70%);
    pointer-events: none;
    z-index: -1;
}

/* 消息文本 */
.toast-message {
    flex: 1;
    font-size: 0.88rem;
    font-weight: 500;
    color: rgba(255, 255, 255, 0.92);
    line-height: 1.45;
    letter-spacing: 0.2px;
    word-break: break-word;
    z-index: 1;
}

/* 关闭按钮 */
.toast-close {
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    border-radius: 7px;
    border: none;
    background: transparent;
    color: rgba(255, 255, 255, 0.35);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.72rem;
    transition: all 0.2s ease;
    z-index: 1;
}
.toast-close:hover {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
}
.toast-close:active {
    transform: scale(0.9);
}

/* 成功 */
.toast.success {
    --accent: #86efac;
    --accent2: #22c55e;
    --glow: rgba(134, 239, 172, 0.18);
    --icon-bg: rgba(134, 239, 172, 0.1);
    --icon-border: rgba(134, 239, 172, 0.28);
}

/* 错误 */
.toast.error {
    --accent: #ff8888;
    --accent2: #ef4444;
    --glow: rgba(255, 136, 136, 0.18);
    --icon-bg: rgba(255, 136, 136, 0.1);
    --icon-border: rgba(255, 136, 136, 0.28);
}

/* 信息（兼容默认） */
.toast.info,
.toast:not(.success):not(.error) {
    --accent: #93c5fd;
    --accent2: #3b82f6;
    --glow: rgba(147, 197, 253, 0.18);
    --icon-bg: rgba(147, 197, 253, 0.1);
    --icon-border: rgba(147, 197, 253, 0.28);
}

/* ============================================
   动画
   ============================================ */
@keyframes toastIn {
    0% {
        opacity: 0;
        transform: translateX(48px) scale(0.94);
    }
    60% {
        opacity: 1;
        transform: translateX(-4px) scale(1.005);
    }
    100% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
}

@keyframes toastOut {
    0% {
        opacity: 1;
        transform: translateX(0) scale(1);
    }
    100% {
        opacity: 0;
        transform: translateX(60px) scale(0.9);
    }
}

@keyframes toastProgress {
    from { transform: scaleX(1); }
    to   { transform: scaleX(0); }
}

/* ============================================
   移动端
   ============================================ */
@media (max-width: 480px) {
    .toast-container {
        top: 12px;
        right: 12px;
        left: 12px;
        max-width: none;
    }
    .toast {
        min-width: 0;
        max-width: none;
        padding: 14px 14px 14px 16px;
        border-radius: 14px;
        gap: 12px;
    }
    .toast-icon {
        width: 34px;
        height: 34px;
        border-radius: 10px;
        font-size: 0.85rem;
    }
    .toast-message {
        font-size: 0.84rem;
    }
}

/* 尊重系统的减少动效偏好 */
@media (prefers-reduced-motion: reduce) {
    .toast,
    .toast.leaving,
    .toast::after {
        animation-duration: 0.001ms !important;
    }
    .toast::after {
        display: none;
    }
}