/**
 * 通用 Toast 和消息中心组件样式
 * 使用方法：在 HTML 中引入此 CSS 和 toast.js
 */

/* Toast 容器 - 右上角 */
.toast-container {
    position: fixed;
    top: 60px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    pointer-events: none;
}

.toast-container > * {
    pointer-events: auto;
}

/* Toast 项 */
.toast-item {
    position: relative;
    color: white;
    padding: 16px 24px;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
    max-width: 450px;
    word-break: break-word;
    white-space: pre-wrap;
}

.toast-item.show {
    opacity: 1;
    transform: translateX(0);
}

.toast-item.hiding {
    opacity: 0;
    transform: translateX(100%);
}

/* 成功 Toast */
.toast-item.success {
    background: linear-gradient(135deg, #22c55e, #16a34a);
    box-shadow: 0 4px 20px rgba(34, 197, 94, 0.4);
}

/* 错误 Toast */
.toast-item.error {
    background: linear-gradient(135deg, #ef4444, #dc2626);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
    padding-right: 48px;
}

/* 信息 Toast */
.toast-item.info {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    box-shadow: 0 4px 20px rgba(59, 130, 246, 0.4);
}

/* 发送中 Toast */
.toast-item.sending {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast-item.sending .toast-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: toast-spin 0.8s linear infinite;
    flex-shrink: 0;
}

@keyframes toast-spin {
    to { transform: rotate(360deg); }
}

/* 关闭按钮 */
.toast-close {
    position: absolute;
    top: 50%;
    right: 12px;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: white;
    font-size: 20px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    padding: 0;
    line-height: 1;
}

.toast-close:hover {
    opacity: 1;
}

/* 消息中心按钮 */
.message-center-btn {
    position: fixed;
    top: 15px;
    right: 20px;
    z-index: 10000;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #2a2a2a;
    border: 1px solid #444;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: all 0.2s;
}

.message-center-btn:hover {
    background: #3a3a3a;
    border-color: #555;
}

.message-center-btn .badge {
    position: absolute;
    top: -4px;
    right: -4px;
    min-width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 9px;
    font-size: 11px;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
}

.message-center-btn .badge:empty,
.message-center-btn .badge[data-count="0"] {
    display: none;
}

/* 消息中心面板 */
.message-center-panel {
    position: fixed;
    top: 60px;
    right: 20px;
    width: 350px;
    max-height: 70vh;
    background: #1e1e1e;
    border: 1px solid #444;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.5);
    z-index: 10000;
    display: none;
    flex-direction: column;
}

.message-center-panel.show {
    display: flex;
}

.message-center-header {
    padding: 12px 16px;
    border-bottom: 1px solid #333;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.message-center-header h4 {
    margin: 0;
    font-size: 14px;
    color: #e2e8f0;
}

.message-center-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.message-center-clear {
    background: none;
    border: none;
    color: #888;
    font-size: 12px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
}

.message-center-clear:hover {
    background: #333;
    color: #fff;
}

.message-center-close {
    background: none;
    border: none;
    color: #888;
    font-size: 20px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.message-center-close:hover {
    color: #fff;
}

.message-center-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.message-center-item {
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.message-center-item:last-child {
    margin-bottom: 0;
}

.message-center-item.success {
    background: rgba(34, 197, 94, 0.15);
    border-left: 3px solid #22c55e;
}

.message-center-item.error {
    background: rgba(239, 68, 68, 0.15);
    border-left: 3px solid #ef4444;
}

.message-center-item.info {
    background: rgba(59, 130, 246, 0.15);
    border-left: 3px solid #3b82f6;
}

.message-center-time {
    font-size: 11px;
    color: #888;
    margin-bottom: 4px;
}

.message-center-content {
    color: #e2e8f0;
    word-break: break-word;
    white-space: pre-wrap;
}

.message-center-empty {
    text-align: center;
    color: #666;
    padding: 30px;
    font-size: 13px;
}

/* 消息中心滚动条 */
.message-center-list::-webkit-scrollbar {
    width: 6px;
}

.message-center-list::-webkit-scrollbar-track {
    background: transparent;
}

.message-center-list::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 3px;
}

.message-center-list::-webkit-scrollbar-thumb:hover {
    background: #555;
}
