/* ========================================
   Toast 组件样式
   ======================================== */

/* Toast 容器 - 默认右上 */
.toast-container {
    position: fixed;
    z-index: 10000;
    pointer-events: none;
    max-width: 400px;
    width: 100%;
}

/* 位置变体 */
.toast-container,
.toast-container[data-position="top-right"] {
    top: calc(var(--header-height, 64px) + var(--space-4, 16px));
    right: var(--space-5, 20px);
}

.toast-container[data-position="top-left"] {
    top: calc(var(--header-height, 64px) + var(--space-4, 16px));
    left: var(--space-5, 20px);
    right: auto;
}

.toast-container[data-position="top-center"] {
    top: calc(var(--header-height, 64px) + var(--space-4, 16px));
    left: 50%;
    right: auto;
    transform: translateX(-50%);
}

.toast-container[data-position="bottom-right"] {
    bottom: var(--space-5, 20px);
    right: var(--space-5, 20px);
    top: auto;
}

.toast-container[data-position="bottom-left"] {
    bottom: var(--space-5, 20px);
    left: var(--space-5, 20px);
    right: auto;
    top: auto;
}

.toast-container[data-position="bottom-center"] {
    bottom: var(--space-5, 20px);
    left: 50%;
    right: auto;
    top: auto;
    transform: translateX(-50%);
}

/* 左侧位置的入场动画方向 */
.toast-container[data-position="top-left"] .toast,
.toast-container[data-position="bottom-left"] .toast {
    transform: translateX(-100%);
}

.toast-container[data-position="top-left"] .toast.show,
.toast-container[data-position="bottom-left"] .toast.show {
    transform: translateX(0);
}

.toast-container[data-position="top-left"] .toast.hide,
.toast-container[data-position="bottom-left"] .toast.hide {
    transform: translateX(-100%);
}

/* 居中位置的入场动画方向 */
.toast-container[data-position="top-center"] .toast,
.toast-container[data-position="bottom-center"] .toast {
    transform: translateY(-20px);
    opacity: 0;
}

.toast-container[data-position="top-center"] .toast.show,
.toast-container[data-position="bottom-center"] .toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-container[data-position="top-center"] .toast.hide,
.toast-container[data-position="bottom-center"] .toast.hide {
    transform: translateY(-20px);
    opacity: 0;
}

/* Toast 项目 */
.toast {
    background: var(--surface);
    border-radius: var(--radius-lg);
    box-shadow: var(--elevation-3);
    margin-bottom: var(--space-3);
    padding: var(--space-4);
    position: relative;
    pointer-events: auto;
    border-left: 4px solid var(--color-info);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    max-width: 400px;
    word-wrap: break-word;
    /* 统一过渡时间 */
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 隐藏状态辅助类（收起空间用） */
.toast.hide {
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
}

/* Toast 类型样式 */
.toast.success {
    border-left-color: var(--color-success);
    background: linear-gradient(135deg, var(--color-success-bg) 0%, var(--surface) 100%);
}

.toast.error {
    border-left-color: var(--color-error);
    background: linear-gradient(135deg, var(--color-error-bg) 0%, var(--surface) 100%);
}

.toast.warning {
    border-left-color: var(--color-warning);
    background: linear-gradient(135deg, var(--color-warning-bg) 0%, var(--surface) 100%);
}

.toast.info {
    border-left-color: var(--color-info);
    background: linear-gradient(135deg, var(--color-info-bg) 0%, var(--surface) 100%);
}

/* Toast 内容 */
.toast-content {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
}

/* Toast 图标 */
.toast-icon {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
    margin-top: 2px;
}

.toast.success .toast-icon {
    color: var(--color-success);
}

.toast.error .toast-icon {
    color: var(--color-error);
}

.toast.warning .toast-icon {
    color: var(--color-warning);
}

.toast.info .toast-icon {
    color: var(--color-info);
}

/* Toast 文本内容 */
.toast-text {
    flex: 1;
    min-width: 0;
}

.toast-title {
    font-weight: 600;
    font-size: 14px;
    line-height: 1.4;
    color: var(--on-surface);
    margin: 0 0 4px 0;
}

.toast-message {
    font-size: 13px;
    line-height: 1.5;
    color: var(--on-surface-variant);
    margin: 0;
}

/* 只有消息时的样式 */
.toast-text.message-only .toast-message {
    color: var(--on-surface);
    font-size: 14px;
}

/* Toast 关闭按钮 */
.toast-close {
    position: absolute;
    top: var(--space-2);
    right: var(--space-2);
    width: 24px;
    height: 24px;
    border: none;
    background: none;
    cursor: pointer;
    color: var(--on-surface-variant);
    transition: color 0.2s ease;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
}

.toast-close:hover {
    color: var(--on-surface);
    background: rgba(0, 0, 0, 0.05);
}

.toast-close svg {
    width: 14px;
    height: 14px;
}

/* Toast 进度条 */
.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 2px;
    background: currentColor;
    opacity: 0.3;
    transition: width linear;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
}

.toast.success .toast-progress {
    color: var(--color-success);
}

.toast.error .toast-progress {
    color: var(--color-error);
}

.toast.warning .toast-progress {
    color: var(--color-warning);
}

.toast.info .toast-progress {
    color: var(--color-info);
}

/* 深色主题适配 */
[data-theme="dark"] .toast {
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .toast-close:hover {
    background: rgba(255, 255, 255, 0.1);
}

/* 移动端适配 */
@media (max-width: 768px) {
    .toast-container {
        top: calc(var(--header-height) + var(--space-3));
        /* 导航栏高度 + 12px间距（移动端稍小） */
        right: var(--space-3);
        left: var(--space-3);
        max-width: none;
        width: calc(100% - var(--space-6));
        /* 左右各留12px边距 */
    }

    .toast {
        margin-bottom: var(--space-2);
        padding: var(--space-3);
        max-width: none;
        width: 100%;
        box-sizing: border-box;
    }
}

@media (max-width: 480px) {
    .toast-container {
        right: var(--space-2);
        left: var(--space-2);
        width: calc(100% - var(--space-4));
        /* 左右各留8px边距 */
    }

    .toast {
        padding: var(--space-3);
    }

    .toast-title {
        font-size: 13px;
    }

    .toast-message {
        font-size: 12px;
    }

    .toast-text.message-only .toast-message {
        font-size: 13px;
    }
}

/* 自定义动画类型效果 (Slide 为默认) */
.toast.animation-fade {
    transform: none !important;
    opacity: 0;
}

.toast.animation-fade.show {
    transform: none !important;
    opacity: 1;
}

.toast.animation-fade.hide {
    transform: none !important;
    opacity: 0;
}

.toast.animation-zoom {
    transform: scale(0.8) !important;
    opacity: 0;
}

.toast.animation-zoom.show {
    transform: scale(1) !important;
    opacity: 1;
}

.toast.animation-zoom.hide {
    transform: scale(0.8) !important;
    opacity: 0;
}

/* 无障碍支持 */
@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: opacity 0.1s ease;
        transform: none !important;
    }

    .toast.show {
        transform: none !important;
    }

    .toast.hide {
        transform: none !important;
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .toast {
        border: 2px solid currentColor;
        box-shadow: none;
    }

    .toast-close {
        border: 1px solid currentColor;
    }
}