/**
 * 通用消息组件样式
 * 包含 Toast（消息提示）和 Modal（确认对话框）
 */

/* ==================== Toast 消息提示样式 ==================== */

/* ========== 容器样式 ========== */
.toast-container {
    position: fixed;
    display: flex;
    flex-direction: column;
    gap: 12px;
    pointer-events: none;
}

.toast-container.toast-top-center,
.toast-container.toast-bottom-center {
    align-items: center;
}

.toast-container.toast-top-right,
.toast-container.toast-bottom-right {
    align-items: flex-end;
}

/* ========== Toast 主体样式 ========== */
.toast {
    pointer-events: auto;
    min-width: 300px;
    max-width: 500px;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    background: #fff;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.toast.toast-show {
    opacity: 1;
    transform: translateY(0);
}

.toast.toast-hide {
    opacity: 0;
    transform: translateY(-20px);
}

/* 底部位置的入场动画方向 */
.toast-container.toast-bottom-center .toast,
.toast-container.toast-bottom-right .toast {
    transform: translateY(20px);
}

.toast-container.toast-bottom-center .toast.toast-show,
.toast-container.toast-bottom-right .toast.toast-show {
    transform: translateY(0);
}

.toast-container.toast-bottom-center .toast.toast-hide,
.toast-container.toast-bottom-right .toast.toast-hide {
    transform: translateY(20px);
}

/* ========== Toast 内容布局 ========== */
.toast-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* ========== 图标样式 ========== */
.toast-icon {
    flex-shrink: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-icon svg {
    width: 100%;
    height: 100%;
}

/* ========== 消息文本样式 ========== */
.toast-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.5;
    color: #333;
    word-break: break-word;
}

/* ========== 关闭按钮样式 ========== */
.toast-close {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    padding: 0;
    border: none;
    background: transparent;
    cursor: pointer;
    opacity: 0.6;
    transition: opacity 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-close:hover {
    opacity: 1;
}

.toast-close svg {
    width: 100%;
    height: 100%;
}

/* ========== Toast 类型样式 ========== */

/* Success - 成功 */
.toast.toast-success {
    border-left: 4px solid #52c41a;
    background: #f6ffed;
}

.toast.toast-success .toast-icon {
    color: #52c41a;
}

.toast.toast-success .toast-message {
    color: #135200;
}

.toast.toast-success .toast-close {
    color: #52c41a;
}

/* Error - 错误 */
.toast.toast-error {
    border-left: 4px solid #ff4d4f;
    background: #fff2f0;
}

.toast.toast-error .toast-icon {
    color: #ff4d4f;
}

.toast.toast-error .toast-message {
    color: #5c0011;
}

.toast.toast-error .toast-close {
    color: #ff4d4f;
}

/* Warning - 警告 */
.toast.toast-warning {
    border-left: 4px solid #faad14;
    background: #fffbe6;
}

.toast.toast-warning .toast-icon {
    color: #faad14;
}

.toast.toast-warning .toast-message {
    color: #613400;
}

.toast.toast-warning .toast-close {
    color: #faad14;
}

/* Info - 信息 */
.toast.toast-info {
    border-left: 4px solid #1890ff;
    background: #e6f7ff;
}

.toast.toast-info .toast-icon {
    color: #1890ff;
}

.toast.toast-info .toast-message {
    color: #003a8c;
}

.toast.toast-info .toast-close {
    color: #1890ff;
}

/* ==================== Modal 确认对话框样式 ==================== */

/* ========== 遮罩层 ========== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.modal-overlay.modal-show {
    opacity: 1;
}

/* ========== Modal 容器 ========== */
.modal-container {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    min-width: 400px;
    max-width: 500px;
    opacity: 0;
    transform: scale(0.9);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-container.modal-show {
    opacity: 1;
    transform: scale(1);
}

/* ========== 头部 ========== */
.modal-header {
    padding: 20px 24px 16px;
    border-bottom: 1px solid #f0f0f0;
}

.modal-title {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: #333;
}

/* ========== 内容区 ========== */
.modal-body {
    padding: 24px;
    display: flex;
    gap: 16px;
    align-items: flex-start;
}

.modal-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-icon svg {
    width: 100%;
    height: 100%;
}

.modal-message {
    flex: 1;
    font-size: 14px;
    line-height: 1.6;
    color: #666;
    padding-top: 8px;
}

/* ========== 底部按钮区 ========== */
.modal-footer {
    padding: 16px 24px 20px;
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    border-top: 1px solid #f0f0f0;
}

.modal-btn {
    padding: 8px 20px;
    border: none;
    border-radius: 4px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s;
    min-width: 80px;
}

.modal-btn:hover {
    opacity: 0.8;
}

.modal-btn:active {
    transform: scale(0.98);
}

.modal-btn-cancel {
    background: #fff;
    color: #666;
    border: 1px solid #d9d9d9;
}

.modal-btn-cancel:hover {
    color: #333;
    border-color: #999;
}

.modal-btn-confirm {
    background: #1890ff;
    color: #fff;
}

/* ========== Modal 类型样式 ========== */

/* Confirm - 确认 */
.modal-container.modal-confirm .modal-icon {
    color: #1890ff;
}

.modal-container.modal-confirm .modal-btn-confirm {
    background: #1890ff;
}

.modal-container.modal-confirm .modal-btn-confirm:hover {
    background: #40a9ff;
}

/* Warning - 警告 */
.modal-container.modal-warning .modal-icon {
    color: #faad14;
}

.modal-container.modal-warning .modal-btn-confirm {
    background: #faad14;
}

.modal-container.modal-warning .modal-btn-confirm:hover {
    background: #ffc53d;
}

/* Danger - 危险 */
.modal-container.modal-danger .modal-icon {
    color: #ff4d4f;
}

.modal-container.modal-danger .modal-btn-confirm {
    background: #ff4d4f;
}

.modal-container.modal-danger .modal-btn-confirm:hover {
    background: #ff7875;
}

/* Alert - 提示 */
.modal-container.modal-alert .modal-icon {
    color: #1890ff;
}

/* ==================== 响应式设计 ==================== */
@media (max-width: 768px) {
    /* Toast 响应式 */
    .toast {
        min-width: 280px;
        max-width: calc(100vw - 40px);
        padding: 14px 16px;
    }

    .toast-message {
        font-size: 13px;
    }

    .toast-icon {
        width: 20px;
        height: 20px;
    }

    .toast-close {
        width: 14px;
        height: 14px;
    }

    .toast-container.toast-top-center,
    .toast-container.toast-top-right {
        top: 10px !important;
        right: 10px !important;
        left: 10px !important;
        transform: none !important;
    }

    .toast-container.toast-bottom-center,
    .toast-container.toast-bottom-right {
        bottom: 10px !important;
        right: 10px !important;
        left: 10px !important;
        transform: none !important;
    }

    .toast-container {
        align-items: stretch !important;
    }

    /* Modal 响应式 */
    .modal-container {
        min-width: 320px;
        max-width: calc(100vw - 40px);
        margin: 20px;
    }

    .modal-header {
        padding: 16px 20px 12px;
    }

    .modal-title {
        font-size: 16px;
    }

    .modal-body {
        padding: 20px;
        gap: 12px;
    }

    .modal-icon {
        width: 40px;
        height: 40px;
    }

    .modal-message {
        font-size: 13px;
    }

    .modal-footer {
        padding: 12px 20px 16px;
        gap: 10px;
    }

    .modal-btn {
        padding: 8px 16px;
        font-size: 13px;
        min-width: 70px;
    }
}

/* ==================== 打印时隐藏 ==================== */
@media print {
    .toast-container,
    .modal-overlay {
        display: none !important;
    }
}

/* ==================== 深色模式支持 ==================== */
@media (prefers-color-scheme: dark) {
    /* Toast 深色模式 */
    .toast {
        background: #1f1f1f;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    }

    .toast-message {
        color: #e8e8e8;
    }

    .toast.toast-success {
        background: #162312;
        border-left-color: #52c41a;
    }

    .toast.toast-success .toast-message {
        color: #95de64;
    }

    .toast.toast-error {
        background: #2a1215;
        border-left-color: #ff4d4f;
    }

    .toast.toast-error .toast-message {
        color: #ff7875;
    }

    .toast.toast-warning {
        background: #2b2111;
        border-left-color: #faad14;
    }

    .toast.toast-warning .toast-message {
        color: #ffc53d;
    }

    .toast.toast-info {
        background: #111d2c;
        border-left-color: #1890ff;
    }

    .toast.toast-info .toast-message {
        color: #69c0ff;
    }

    /* Modal 深色模式 */
    .modal-overlay {
        background: rgba(0, 0, 0, 0.7);
    }

    .modal-container {
        background: #1f1f1f;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
    }

    .modal-header {
        border-bottom-color: #333;
    }

    .modal-title {
        color: #e8e8e8;
    }

    .modal-message {
        color: #b8b8b8;
    }

    .modal-footer {
        border-top-color: #333;
    }

    .modal-btn-cancel {
        background: #2a2a2a;
        color: #b8b8b8;
        border-color: #444;
    }

    .modal-btn-cancel:hover {
        color: #e8e8e8;
        border-color: #666;
    }
}

/* ==================== 无障碍支持 ==================== */
.toast-close:focus,
.modal-btn:focus {
    outline: 2px solid currentColor;
    outline-offset: 2px;
}

/* ==================== 减少动画效果 ==================== */
@media (prefers-reduced-motion: reduce) {
    .toast {
        transition: opacity 0.2s;
    }

    .toast.toast-show,
    .toast.toast-hide {
        transform: translateY(0);
    }

    .modal-overlay,
    .modal-container {
        transition: opacity 0.2s;
    }

    .modal-container.modal-show {
        transform: scale(1);
    }
}

/* ==================== Modal按钮Loading效果样式 ==================== */
.modal-btn-loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.modal-btn-loading::before {
    content: '';
    position: absolute;
    left: 50%;
    top: 50%;
    width: 16px;
    height: 16px;
    margin: -8px 0 0 -8px;
    border: 2px solid transparent;
    border-top: 2px solid currentColor;
    border-radius: 50%;
    animation: modal-btn-spin 1s linear infinite;
}

.modal-btn-loading .modal-btn-text {
    opacity: 0;
}

@keyframes modal-btn-spin {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}
