/* ===== 在线客服系统样式 ===== */

/* 客服按钮 */
.chat-button {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 9998;
}

.chat-button:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.6);
}

.chat-button .chat-icon {
    width: 28px;
    height: 28px;
    display: block;
}

.chat-button .close-icon {
    width: 28px;
    height: 28px;
    display: none;
}

.chat-button.active .chat-icon {
    display: none;
}

.chat-button.active .close-icon {
    display: block;
}

.notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    font-weight: bold;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

/* 客服窗口 */
.chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    animation: slideUp 0.3s ease;
    /* 👇 添加：强制深色文字 */
    color: #1e293b;
}

.chat-window.active {
    display: flex;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 头部 */
.chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* 👇 添加：头部保持白色文字 */
    color: white;
}

/* 👇 添加：确保头部所有子元素都是白色 */
.chat-header * {
    color: white !important;
}

.status-dot {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    background: #10b981;
    border: 2px solid white;
    border-radius: 50%;
}

/* 消息区域 */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: #f9fafb;
    /* 👇 添加：消息区域深色文字 */
    color: #1e293b;
}

.message {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: bold;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

.message-content {
    flex: 1;
}

.message-content p {
    background: white;
    padding: 10px 14px;
    border-radius: 12px;
    margin-bottom: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    /* 👇 添加：机器人消息深色文字 */
    color: #1e293b;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-content p {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    /* 👇 修改：用户消息保持白色文字 */
    color: white !important;
    text-align: right;
}

/* 快捷回复 */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.quick-reply {
    background: white;
    border: 1px solid #e5e7eb;
    padding: 8px 12px;
    border-radius: 20px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s ease;
    /* 👇 添加：按钮深色文字 */
    color: #1e293b;
}

.quick-reply:hover {
    background: #667eea;
    /* 👇 修改：悬停时白色文字 */
    color: white !important;
    border-color: #667eea;
}

/* 模式切换 */
.chat-mode-switch {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #f3f4f6;
    border-bottom: 1px solid #e5e7eb;
}

.mode-btn {
    flex: 1;
    padding: 8px;
    border: none;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s ease;
    /* 👇 添加：按钮深色文字 */
    color: #64748b;
}

.mode-btn.active {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    /* 👇 修改：激活状态白色文字 */
    color: white !important;
}

/* 输入区 */
.chat-input-container {
    border-top: 1px solid #e5e7eb;
    /* 👇 添加：输入区白色背景 */
    background: white;
}

.chat-input-wrapper {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: white;
}

#chatInput {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 24px;
    outline: none;
    font-size: 14px;
    /* 👇 添加：输入框深色文字 */
    color: #1e293b;
    background: white;
}

/* 👇 添加：输入框占位符颜色 */
#chatInput::placeholder {
    color: #94a3b8;
}

#chatInput:focus {
    border-color: #667eea;
}

.send-button {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.send-button:hover {
    transform: scale(1.05);
}

/* 👇 添加：发送按钮图标白色 */
.send-button svg {
    color: white;
}

/* 响应式 */
@media (max-width: 768px) {
    .chat-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 120px);
        right: 16px;
        bottom: 90px;
    }
    
    .chat-button {
        bottom: 16px;
        right: 16px;
    }
}

/* ===== 👇 额外添加：修复深色背景页面的兼容性 ===== */

/* 确保客服窗口不受页面样式影响 */
.chat-window,
.chat-window * {
    box-sizing: border-box;
}

/* 消息文字强制深色（除了用户消息） */
.bot-message .message-content p,
.bot-message .message-content span,
.bot-message .message-content div {
    color: #1e293b !important;
}

/* 用户消息强制白色 */
.user-message .message-content p,
.user-message .message-content span,
.user-message .message-content div {
    color: white !important;
}

/* 时间戳样式（如果有） */
.message-time {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 4px;
}

/* 打字指示器（如果有） */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 10px 14px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #94a3b8;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); }
    30% { transform: translateY(-10px); }
}