/**
 * @author liangliang
 * 错误提示与错误页面样式
 * 统一管理错误状态容器和全局错误消息弹窗的视觉效果
 */

/* 错误状态页面容器 */
.error-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 320px;
    padding: var(--spacing-xl) var(--spacing-lg);
    background: var(--bg-secondary, #f8fafc);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    box-sizing: border-box;
}

/* 全局消息容器 */
.message-container {
    position: fixed;
    z-index: 9999;
    pointer-events: none;
    transition: all 0.3s ease;
    max-width: 400px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .message-container {
        max-width: calc(100vw - 40px);
        right: 20px !important;
        left: 20px !important;
        top: 20px !important;
    }
    
    .message {
        min-width: 150px;
        font-size: 13px;
        padding: 10px 14px;
    }
}

@media (max-width: 480px) {
    .message-container {
        max-width: calc(100vw - 20px);
        right: 10px !important;
        left: 10px !important;
        top: 10px !important;
    }
    
    .message {
        min-width: 120px;
        font-size: 12px;
        padding: 8px 12px;
        line-height: 1.4;
    }
}

/* 消息元素基础样式 */
.message {
    background: #1890ff;
    color: white;
    padding: 12px 16px;
    margin-bottom: 8px;
    border-radius: 6px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    line-height: 1.4;
    pointer-events: auto;
    cursor: pointer;
    transition: all 0.3s ease;
    transform: translateX(100%);
    opacity: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* 消息类型样式 */
.message-success {
    background: linear-gradient(135deg, #52c41a, #73d13d);
    border-color: rgba(82, 196, 26, 0.2);
}

.message-error {
    background: linear-gradient(135deg, #ff4d4f, #ff7875);
    border-color: rgba(255, 77, 79, 0.2);
}

.message-warning {
    background: linear-gradient(135deg, #faad14, #ffc53d);
    border-color: rgba(250, 173, 20, 0.2);
}

.message-info {
    background: linear-gradient(135deg, #1890ff, #40a9ff);
    border-color: rgba(24, 144, 255, 0.2);
}

/* 消息内容布局 */
.message > div {
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.message i {
    margin-right: 8px;
    flex-shrink: 0;
    font-size: 16px;
}

.message span {
    flex: 1;
    min-width: 0;
    word-break: break-word;
}

/* 消息显示动画 */
.message.show {
    transform: translateX(0);
    opacity: 1;
}

/* 消息悬停效果 */
.message:hover {
    transform: translateX(-5px);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

/* 消息进入动画 */
@keyframes message-slide-in {
    from {
        opacity: 0;
        transform: translateX(100%);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.message.animate-in {
    animation: message-slide-in 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 消息退出动画 */
@keyframes message-slide-out {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100%);
    }
}

.message.animate-out {
    animation: message-slide-out 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* 全局错误消息弹窗（兼容旧版本） */
.error-message {
    position: fixed;
    top: var(--spacing-lg);
    right: var(--spacing-lg);
    min-width: 240px;
    max-width: 90vw;
    background: rgba(239, 68, 68, 0.98);
    color: #fff;
    padding: var(--spacing-md) var(--spacing-lg);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-lg);
    z-index: 9999;
    display: flex;
    align-items: flex-start;
    gap: var(--spacing-sm);
    opacity: 0;
    pointer-events: none;
    transform: translateY(-20px);
    transition: opacity 0.25s, transform 0.25s;
}

/* 显示错误消息时添加 .show 类 */
.error-message.show {
    opacity: 1;
    pointer-events: auto;
    transform: translateY(0);
}

/* 错误消息文本 */
.error-message p {
    margin: 0;
    color: #fff;
    font-size: var(--font-size-base);
    line-height: 1.5;
    word-break: break-word;
}

/* 可选：错误消息关闭按钮 */
.error-message .error-close {
    background: transparent;
    border: none;
    color: #fff;
    font-size: 1.25rem;
    cursor: pointer;
    margin-left: var(--spacing-xs);
    opacity: 0.7;
    transition: opacity 0.2s;
}
.error-message .error-close:hover {
    opacity: 1;
}

/* 错误图标样式（如有） */
.error-message .error-icon {
    font-size: 1.5rem;
    margin-right: var(--spacing-xs);
    flex-shrink: 0;
    color: #fff;
}

/* 动画效果 */
@keyframes error-slide-in {
    from {
        opacity: 0;
        transform: translateY(-30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}
.error-message.show {
    animation: error-slide-in 0.3s cubic-bezier(0.4,0,0.2,1);
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .message {
        background: rgba(255, 255, 255, 0.1);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.2);
    }
    
    .message-success {
        background: linear-gradient(135deg, rgba(82, 196, 26, 0.9), rgba(115, 209, 61, 0.9));
    }
    
    .message-error {
        background: linear-gradient(135deg, rgba(255, 77, 79, 0.9), rgba(255, 120, 117, 0.9));
    }
    
    .message-warning {
        background: linear-gradient(135deg, rgba(250, 173, 20, 0.9), rgba(255, 197, 61, 0.9));
    }
    
    .message-info {
        background: linear-gradient(135deg, rgba(24, 144, 255, 0.9), rgba(64, 169, 255, 0.9));
    }
}

/* 高对比度模式支持 */
@media (prefers-contrast: high) {
    .message {
        border: 2px solid currentColor;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    }
}

/* 减少动画模式支持 */
@media (prefers-reduced-motion: reduce) {
    .message,
    .message-container,
    .error-message {
        transition: none;
        animation: none;
    }
    
    .message {
        transform: translateX(0);
        opacity: 1;
    }
}