/* =============== AI 智能客服聊天窗 =============== */
.xdb-chat-fab {
    position: fixed;
    right: 18px;
    bottom: 220px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1e5fff, #4f8cff);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(30,95,255,.4);
    z-index: 9990;
    transition: all .2s;
    border: none;
    font-size: 26px;
}
.xdb-chat-fab:hover { transform: scale(1.08); box-shadow: 0 10px 28px rgba(30,95,255,.55); }
.xdb-chat-fab .badge {
    position: absolute;
    top: -4px; right: -4px;
    background: #ff3b30;
    color: #fff;
    font-size: 10px;
    width: 18px; height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.xdb-chat-fab.pulse::after {
    content: '';
    position: absolute; inset: 0;
    border-radius: 50%;
    background: rgba(30,95,255,.6);
    animation: xdb-pulse 1.8s infinite;
}
@keyframes xdb-pulse {
    0%   { transform: scale(1); opacity: 1; }
    100% { transform: scale(1.6); opacity: 0; }
}

.xdb-chat-panel {
    position: fixed;
    right: 18px;
    bottom: 290px;
    width: 360px;
    max-width: calc(100vw - 36px);
    height: 540px;
    max-height: calc(100vh - 320px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,.18);
    z-index: 9991;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e6ebf2;
    animation: xdb-chat-in .25s ease-out;
}
.xdb-chat-panel.open { display: flex; }
@keyframes xdb-chat-in {
    from { opacity: 0; transform: translateY(20px) scale(.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.xdb-chat-header {
    background: linear-gradient(135deg, #1e5fff, #4f8cff);
    color: #fff;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}
.xdb-chat-header .avatar {
    width: 40px; height: 40px;
    background: rgba(255,255,255,.25);
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 22px;
    flex-shrink: 0;
}
.xdb-chat-header .info { flex: 1; min-width: 0; }
.xdb-chat-header .name { font-weight: 600; font-size: 15px; }
.xdb-chat-header .desc { font-size: 11px; opacity: .85; display: flex; align-items: center; gap: 4px; }
.xdb-chat-header .desc::before {
    content: ''; width: 6px; height: 6px;
    background: #4ade80; border-radius: 50%;
    animation: blink 1.4s infinite;
}
@keyframes blink { 50% { opacity: .3; } }
.xdb-chat-header .close {
    background: rgba(255,255,255,.2);
    border: none; color: #fff;
    width: 28px; height: 28px;
    border-radius: 50%;
    cursor: pointer;
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
}
.xdb-chat-header .close:hover { background: rgba(255,255,255,.35); }

.xdb-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    background: #f7faff;
    scroll-behavior: smooth;
}
.xdb-chat-body::-webkit-scrollbar { width: 4px; }
.xdb-chat-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

.xdb-msg { display: flex; gap: 8px; margin-bottom: 12px; align-items: flex-start; }
.xdb-msg .av {
    width: 30px; height: 30px; border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; flex-shrink: 0;
}
.xdb-msg.user { flex-direction: row-reverse; }
.xdb-msg.user .av { background: #1e5fff; color: #fff; }
.xdb-msg.bot .av { background: #f0f4f9; }
.xdb-msg .bubble {
    max-width: 78%;
    padding: 9px 12px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}
.xdb-msg.user .bubble {
    background: #1e5fff;
    color: #fff;
    border-top-right-radius: 3px;
}
.xdb-msg.bot .bubble {
    background: #fff;
    color: #2c3e50;
    border: 1px solid #e6ebf2;
    border-top-left-radius: 3px;
}
.xdb-msg.bot .bubble a { color: #1e5fff; text-decoration: underline; }
.xdb-msg .time {
    font-size: 10px; color: #aab4c4;
    margin-top: 2px;
}

.xdb-typing { display: flex; gap: 4px; padding: 4px 0; }
.xdb-typing span {
    width: 6px; height: 6px; background: #94a3b8; border-radius: 50%;
    animation: typing 1.2s infinite;
}
.xdb-typing span:nth-child(2) { animation-delay: .2s; }
.xdb-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: .4; }
    30% { transform: translateY(-6px); opacity: 1; }
}

.xdb-quick {
    padding: 8px 12px 0;
    background: #f7faff;
    display: flex; gap: 6px; flex-wrap: wrap;
    flex-shrink: 0;
    border-top: 1px solid #e6ebf2;
}
.xdb-quick .q {
    background: #fff;
    border: 1px solid #cbd5e1;
    color: #475569;
    padding: 4px 10px;
    border-radius: 14px;
    font-size: 12px;
    cursor: pointer;
    transition: all .15s;
}
.xdb-quick .q:hover { background: #1e5fff; color: #fff; border-color: #1e5fff; }

.xdb-chat-foot {
    padding: 10px 12px;
    background: #fff;
    display: flex;
    gap: 8px;
    align-items: flex-end;
    border-top: 1px solid #e6ebf2;
    flex-shrink: 0;
}
.xdb-chat-foot textarea {
    flex: 1;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    padding: 8px 10px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    min-height: 38px;
    max-height: 100px;
    line-height: 1.4;
    transition: border-color .15s;
}
.xdb-chat-foot textarea:focus { border-color: #1e5fff; }
.xdb-chat-foot .send {
    background: #1e5fff;
    color: #fff;
    border: none;
    width: 40px; height: 38px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 18px;
    flex-shrink: 0;
    transition: background .15s;
}
.xdb-chat-foot .send:hover:not(:disabled) { background: #1850e0; }
.xdb-chat-foot .send:disabled { background: #cbd5e1; cursor: not-allowed; }

@media (max-width: 480px) {
    .xdb-chat-panel {
        right: 0; bottom: 0;
        width: 100vw; height: 100vh;
        max-width: 100vw; max-height: 100vh;
        border-radius: 0;
    }
    .xdb-chat-fab { right: 12px; bottom: 200px; }
    .xdb-chat-panel { bottom: 0; }
}
