/* ===== AI智能客服聊天弹窗 ===== */
#chatbot-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Hiragino Sans GB", "Microsoft YaHei", sans-serif;
}

/* 悬浮按钮 */
#chatbot-fab {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(37, 99, 235, 0.4);
    transition: all 0.3s;
    border: none;
    position: relative;
}
#chatbot-fab:hover { transform: scale(1.08); box-shadow: 0 6px 28px rgba(37, 99, 235, 0.5); }
#chatbot-fab svg { width: 30px; height: 30px; }
#chatbot-fab .fab-pulse {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    border-radius: 50%;
    border: 2px solid rgba(37, 99, 235, 0.5);
    animation: fabPulse 2s infinite;
}
@keyframes fabPulse {
    0% { transform: scale(1); opacity: 0.8; }
    70% { transform: scale(1.4); opacity: 0; }
    100% { transform: scale(1.4); opacity: 0; }
}
#chatbot-fab .fab-badge {
    position: absolute;
    top: -4px; right: -4px;
    background: #ef4444;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    width: 20px; height: 20px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    display: none;
}

/* 聊天窗口 */
#chatbot-panel {
    position: fixed;
    bottom: 92px;
    right: 20px;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 560px;
    max-height: calc(100vh - 120px);
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 48px rgba(0, 0, 0, 0.18);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid #e2e8f0;
}
#chatbot-panel.open { display: flex; }

/* 头部 */
#chatbot-header {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    padding: 16px 18px;
    display: flex;
    align-items: center;
    gap: 12px;
}
#chatbot-header .header-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}
#chatbot-header .header-info { flex: 1; }
#chatbot-header .header-title { font-size: 15px; font-weight: 700; }
#chatbot-header .header-status { font-size: 12px; opacity: 0.85; display: flex; align-items: center; gap: 5px; }
#chatbot-header .header-status .dot {
    width: 7px; height: 7px; border-radius: 50%; background: #4ade80; display: inline-block;
    animation: dotBlink 1.5s infinite;
}
@keyframes dotBlink { 0%, 100% { opacity: 1; } 50% { opacity: 0.4; } }
#chatbot-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    padding: 4px 8px;
    opacity: 0.85;
    line-height: 1;
}
#chatbot-close:hover { opacity: 1; }

/* 消息区 */
#chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.chat-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
}
.chat-msg .msg-avatar {
    width: 30px; height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
}
.chat-msg .msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}
.chat-msg.user {
    flex-direction: row-reverse;
    align-self: flex-end;
}
.chat-msg.user .msg-avatar { background: #dbeafe; }
.chat-msg.user .msg-bubble {
    background: #2563eb;
    color: #fff;
    border-bottom-right-radius: 4px;
}
.chat-msg.assistant .msg-avatar { background: #ede9fe; }
.chat-msg.assistant .msg-bubble {
    background: #fff;
    color: #1e293b;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}
.chat-msg.system {
    align-self: center;
    max-width: 90%;
}
.chat-msg.system .msg-bubble {
    background: #f1f5f9;
    color: #64748b;
    font-size: 12px;
    border-radius: 20px;
    padding: 6px 14px;
    text-align: center;
}

/* 快捷问题 */
#chatbot-quick {
    padding: 0 16px 10px;
    background: #f8fafc;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.chat-quick-btn {
    background: #fff;
    border: 1px solid #dbeafe;
    color: #2563eb;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}
.chat-quick-btn:hover { background: #eff6ff; border-color: #93c5fd; }

/* 输入区 */
#chatbot-inputbar {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
#chatbot-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    padding: 10px 14px;
    font-size: 14px;
    outline: none;
    resize: none;
    max-height: 90px;
    font-family: inherit;
    line-height: 1.5;
}
#chatbot-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,0.1); }
#chatbot-send {
    background: linear-gradient(135deg, #2563eb, #7c3aed);
    color: #fff;
    border: none;
    border-radius: 10px;
    width: 44px;
    height: 40px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}
#chatbot-send:hover { opacity: 0.9; transform: scale(1.04); }
#chatbot-send svg { width: 18px; height: 18px; }
#chatbot-send:disabled { opacity: 0.5; cursor: not-allowed; }

/* 正在输入 */
.chat-typing {
    display: inline-flex;
    gap: 4px;
    padding: 12px 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
}
.chat-typing span {
    width: 7px; height: 7px;
    border-radius: 50%;
    background: #94a3b8;
    animation: typing 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
    30% { transform: translateY(-5px); opacity: 1; }
}

/* 移动端适配 */
@media (max-width: 480px) {
    #chatbot-panel {
        bottom: 0;
        right: 0;
        width: 100vw;
        height: 100vh;
        max-height: 100vh;
        max-width: 100vw;
        border-radius: 0;
        border: none;
    }
    #chatbot-fab { bottom: 20px; right: 20px; width: 52px; height: 52px; }
    #chatbot-fab svg { width: 26px; height: 26px; }
    /* 手机版：客服球移到右下角贴边（底部预订栏上方，不挡分享按钮） */
    #chatbot-widget { bottom: 84px; right: 6px; }
}

/* 线路预订链接样式 */
.chat-msg .msg-bubble a.chat-route-link {
    display: block;
    margin: 8px 0;
    padding: 12px 14px;
    background: #eff6ff;
    border: 1px solid #bfdbfe;
    border-radius: 10px;
    color: #1d4ed8;
    font-weight: 600;
    text-decoration: none;
    font-size: 13px;
    line-height: 1.5;
    transition: all 0.2s;
}
.chat-msg .msg-bubble a.chat-route-link:hover {
    background: #dbeafe;
    border-color: #60a5fa;
    box-shadow: 0 2px 8px rgba(37,99,235,0.12);
}

/* ===== 线路链接卡片（橙色，飞猪风格） ===== */
.chat-msg .msg-bubble a.chat-route-link {
    background: linear-gradient(135deg,#fff7ed,#ffe8d6);
    border: 1px solid #ffd9b3;
    color: #1a1a1a;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(255,106,0,.12);
}
.chat-msg .msg-bubble a.chat-route-link:hover {
    background: #ffe8d6;
    border-color: #ffb37a;
    box-shadow: 0 4px 14px rgba(255,106,0,.2);
}
.chat-msg .msg-bubble a.chat-route-link::after {
    content: '立即预订 →';
    display: inline-block;
    margin-top: 6px;
    padding: 4px 14px;
    border-radius: 16px;
    background: linear-gradient(135deg,#ff7d2b,#ff5a00);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
}
