/* ===== 聊天弹窗 ===== */
.chat-widget {
    position: fixed;
    right: 90px;
    bottom: 100px;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(10,37,64,.25);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    z-index: 9999;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(.96);
    transition: all .3s cubic-bezier(.4, 0, .2, 1);
    pointer-events: none;
}
.chat-widget.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
    pointer-events: auto;
}

/* 聊天头 */
.chat-header {
    background: linear-gradient(135deg, #165DFF, #0040c9);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}
.chat-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255,255,255,.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.chat-info { flex: 1; }
.chat-name {
    font-size: 14px;
    font-weight: 700;
    margin-bottom: 2px;
}
.chat-status {
    font-size: 11px;
    opacity: .85;
    display: flex;
    align-items: center;
    gap: 5px;
}
.chat-status .dot {
    width: 7px;
    height: 7px;
    background: #22c55e;
    border-radius: 50%;
    animation: pulse 2s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: .4; }
}
.chat-close {
    width: 28px;
    height: 28px;
    border: 0;
    background: rgba(255,255,255,.15);
    color: #fff;
    border-radius: 50%;
    font-size: 20px;
    line-height: 1;
    cursor: pointer;
    transition: background .2s;
    flex-shrink: 0;
}
.chat-close:hover { background: rgba(255,255,255,.25); }

/* 消息区 */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-messages::-webkit-scrollbar { width: 5px; }
.chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

.msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: msgIn .3s ease;
}
@keyframes msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.msg-bot { align-self: flex-start; }
.msg-user { align-self: flex-end; flex-direction: row-reverse; }

.msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    background: #e2e8f0;
    flex-shrink: 0;
}
.msg-user .msg-avatar { background: #165DFF; color: #fff; }

.msg-bubble {
    background: #fff;
    padding: 10px 13px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.6;
    color: #1e293b;
    box-shadow: 0 1px 2px rgba(0,0,0,.05);
    word-break: break-word;
}
.msg-bot .msg-bubble {
    border-top-left-radius: 4px;
}
.msg-user .msg-bubble {
    background: #165DFF;
    color: #fff;
    border-top-right-radius: 4px;
}

/* 快捷回复按钮 */
.quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}
.quick-reply {
    padding: 5px 10px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    color: #165DFF;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    transition: all .2s;
}
.quick-reply:hover {
    background: #165DFF;
    color: #fff;
    border-color: #165DFF;
}

/* 聊天历史分隔线 */
.chat-separator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 0;
    margin: 4px 0;
}
.chat-separator::before,
.chat-separator::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e2e8f0;
}
.chat-separator span {
    font-size: 11px;
    color: #94a3b8;
    white-space: nowrap;
}

/* 输入区 */
.chat-input-wrap {
    display: flex;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.chat-input {
    flex: 1;
    padding: 9px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 999px;
    font-size: 13px;
    outline: none;
    transition: border-color .2s;
    font-family: inherit;
}
.chat-input:focus { border-color: #165DFF; }
.chat-send {
    width: 36px;
    height: 36px;
    border: 0;
    background: #165DFF;
    color: #fff;
    border-radius: 50%;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background .2s;
    flex-shrink: 0;
}
.chat-send:hover { background: #0040c9; }

/* 响应式 */
@media (max-width: 768px) {
    .float-wrap { right: 16px; bottom: 16px; }
    .float-btn { width: 48px; height: 48px; font-size: 21px; }
    .wa-tip { display: none; }

    .chat-widget {
        right: 12px;
        left: 12px;
        width: auto;
        bottom: 84px;
        height: 480px;
        border-radius: 14px;
    }
}


