/* ========== 智能客服聊天浮窗 ========== */

/* 机器人悬浮按钮 */
.chatbot-toggle {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0A2463, #2563EB);
    border: none;
    cursor: pointer;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 26px;
    transition: transform 0.3s, box-shadow 0.3s;
    animation: chatbotBreath 3s ease-in-out infinite;
}

@keyframes chatbotBreath {
    0%, 100% { box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4); }
    50% { box-shadow: 0 4px 30px rgba(37, 99, 235, 0.6), 0 0 0 6px rgba(37, 99, 235, 0.08); }
}

.chatbot-toggle:hover {
    transform: scale(1.1);
}

.chatbot-toggle.active {
    transform: rotate(135deg);
    background: linear-gradient(135deg, #64748B, #94A3B8);
    animation: none;
}

/* 未读消息提示点 */
.chatbot-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: #EF4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #fff;
    display: none;
}

.chatbot-badge.show {
    display: flex;
    animation: badgeBounce 0.4s ease;
}

@keyframes badgeBounce {
    0% { transform: scale(0); }
    60% { transform: scale(1.3); }
    100% { transform: scale(1); }
}

/* 聊天窗口 */
.chatbot-window {
    position: fixed;
    bottom: 105px;
    right: 30px;
    width: 380px;
    height: 560px;
    max-height: calc(100vh - 140px);
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    transform: translateY(20px) scale(0.95);
    transition: opacity 0.3s, transform 0.3s;
}

.chatbot-window.show {
    display: flex;
    opacity: 1;
    transform: translateY(0) scale(1);
}

/* 聊天头部 */
.chatbot-header {
    background: linear-gradient(135deg, #0A2463, #2563EB);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.chatbot-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #fff;
    flex-shrink: 0;
    position: relative;
}

.chatbot-avatar::after {
    content: '';
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: #22C55E;
    border: 2px solid #0A2463;
}

.chatbot-header-info {
    flex: 1;
}

.chatbot-header-name {
    color: #fff;
    font-size: 16px;
    font-weight: 700;
}

.chatbot-header-status {
    color: rgba(255, 255, 255, 0.7);
    font-size: 12px;
    margin-top: 2px;
}

.chatbot-close {
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 20px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.chatbot-close:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.15);
}

/* 消息区域 */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px 16px;
    background: #F8FAFC;
    scroll-behavior: smooth;
}

.chatbot-messages::-webkit-scrollbar {
    width: 5px;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 10px;
}

/* 欢迎消息 */
.chatbot-welcome {
    text-align: center;
    padding: 20px 10px;
}

.chatbot-welcome-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 12px;
    border-radius: 50%;
    background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    color: #2563EB;
}

.chatbot-welcome-title {
    font-size: 16px;
    font-weight: 700;
    color: #1E293B;
    margin-bottom: 6px;
}

.chatbot-welcome-desc {
    font-size: 13px;
    color: #64748B;
    line-height: 1.5;
}

/* 快捷问题 */
.chatbot-quick {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 0 16px 16px;
    background: #F8FAFC;
}

.chatbot-quick-btn {
    padding: 8px 14px;
    background: #fff;
    border: 1px solid #DBEAFE;
    border-radius: 20px;
    font-size: 12px;
    color: #2563EB;
    cursor: pointer;
    transition: all 0.2s;
}

.chatbot-quick-btn:hover {
    background: #2563EB;
    color: #fff;
    border-color: #2563EB;
    transform: translateY(-2px);
}

/* 消息气泡 */
.chat-msg {
    display: flex;
    margin-bottom: 14px;
    gap: 8px;
    animation: msgSlideIn 0.3s ease;
}

@keyframes msgSlideIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.chat-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    flex-shrink: 0;
}

.chat-msg-bot .chat-msg-avatar {
    background: linear-gradient(135deg, #DBEAFE, #BFDBFE);
    color: #2563EB;
}

.chat-msg-user .chat-msg-avatar {
    background: linear-gradient(135deg, #0A2463, #2563EB);
    color: #fff;
}

.chat-msg-bubble {
    max-width: 260px;
    padding: 10px 14px;
    border-radius: 14px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}

.chat-msg-bot .chat-msg-bubble {
    background: #fff;
    color: #1E293B;
    border: 1px solid #E2E8F0;
    border-top-left-radius: 4px;
}

.chat-msg-user {
    flex-direction: row-reverse;
}

.chat-msg-user .chat-msg-bubble {
    background: linear-gradient(135deg, #0A2463, #2563EB);
    color: #fff;
    border-top-right-radius: 4px;
}

/* 打字指示器 */
.chat-typing {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.chat-typing span {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #94A3B8;
    animation: typingDot 1.4s infinite;
}

.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingDot {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

/* 二维码提示区 */
.chatbot-qrcode {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 16px;
    background: linear-gradient(135deg, #EFF6FF, #DBEAFE);
    border-top: 1px solid #BFDBFE;
    flex-shrink: 0;
}
.chatbot-qrcode-left {
    flex-shrink: 0;
}
.chatbot-qrcode-left img {
    border-radius: 8px;
    border: 2px solid #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.chatbot-qrcode-right {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.chatbot-qrcode-text {
    font-size: 12px;
    color: #1E40AF;
    font-weight: 500;
}
.chatbot-human-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 14px;
    background: linear-gradient(135deg, #07C160, #06AD56);
    color: #fff !important;
    text-decoration: none;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 600;
    transition: transform 0.2s, box-shadow 0.2s;
    box-shadow: 0 2px 8px rgba(7,193,96,0.3);
}
.chatbot-human-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(7,193,96,0.5);
}
.chatbot-human-btn:active {
    transform: translateY(0);
}

/* 输入区域 */
.chatbot-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #E2E8F0;
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.chatbot-input {
    flex: 1;
    padding: 10px 16px;
    border: 1px solid #E2E8F0;
    border-radius: 24px;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
    resize: none;
    height: 42px;
    max-height: 80px;
    font-family: inherit;
}

.chatbot-input:focus {
    border-color: #2563EB;
}

.chatbot-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #0A2463, #2563EB);
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: transform 0.2s;
}

.chatbot-send:hover {
    transform: scale(1.1);
}

.chatbot-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

/* 响应式 */
@media (max-width: 768px) {
    .chatbot-toggle {
        bottom: 20px;
        right: 20px;
        width: 52px;
        height: 52px;
        font-size: 22px;
    }
    .chatbot-window {
        bottom: 85px;
        right: 10px;
        left: 10px;
        width: auto;
        height: calc(100vh - 110px);
    }
    .chat-msg-bubble {
        max-width: 200px;
    }
}
