/* ========================================
   AI 智能客服对话窗口样式
   module/QinxueTheme/Asset/css/chat.css
   ======================================== */

/* ---------- 浮动容器 ---------- */
.qx-chat-float {
    position: fixed;
    right: 20px;
    bottom: 30px;
    z-index: 99999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

/* ---------- 对话面板 ---------- */
.qx-chat-panel {
    display: none;
    width: 360px;
    height: 520px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0,0,0,0.18);
    overflow: hidden;
    margin-bottom: 12px;
    flex-direction: column;
    animation: qxChatIn 0.3s ease;
    position: absolute;
    right: 0;
    bottom: 56px;
}
.qx-chat-panel.open {
    display: flex;
}
@keyframes qxChatIn {
    from { opacity: 0; transform: translateY(12px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---------- 头部 ---------- */
.qx-chat-header {
    background: var(--theme-color, #0062c0);
    color: #fff;
    padding: 14px 18px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
    cursor: pointer;
    user-select: none;
}
.qx-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.qx-chat-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(255,255,255,0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}
.qx-chat-header-info h4 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: #fff !important;
}
.qx-chat-header-info p {
    margin: 2px 0 0;
    font-size: 11px;
    opacity: 0.8;
}
.qx-chat-header-close {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,0.15);
    border: none;
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.qx-chat-header-close:hover {
    background: rgba(255,255,255,0.3);
}

/* ---------- 消息区域 ---------- */
.qx-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f5f7fa;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.qx-chat-body::-webkit-scrollbar {
    width: 4px;
}
.qx-chat-body::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 4px;
}

/* ---------- 消息气泡 ---------- */
.qx-msg {
    display: flex;
    gap: 8px;
    max-width: 85%;
    animation: qxMsgIn 0.25s ease;
}
@keyframes qxMsgIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.qx-msg.ai {
    align-self: flex-start;
}
.qx-msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}
.qx-msg-avatar {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
}
.qx-msg.ai .qx-msg-avatar {
    background: var(--theme-color, #0062c0);
    color: #fff;
}
.qx-msg.user .qx-msg-avatar {
    background: #666;
    color: #fff;
}
.qx-msg-bubble {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
    white-space: pre-wrap;
}
.qx-msg.ai .qx-msg-bubble {
    background: #fff;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.qx-msg.user .qx-msg-bubble {
    background: var(--theme-color, #0062c0);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.qx-msg-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
}
.qx-msg.ai .qx-msg-time { text-align: left; }
.qx-msg.user .qx-msg-time { text-align: right; }

/* ---------- 打字指示器 ---------- */
.qx-typing {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #fff;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    box-shadow: 0 1px 4px rgba(0,0,0,0.06);
}
.qx-typing-dots {
    display: flex;
    gap: 3px;
}
.qx-typing-dots span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: qxTypingDot 1.4s infinite ease-in-out;
}
.qx-typing-dots span:nth-child(1) { animation-delay: 0s; }
.qx-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.qx-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes qxTypingDot {
    0%, 60%, 100% { transform: scale(0.6); opacity: 0.4; }
    30% { transform: scale(1); opacity: 1; }
}

/* ---------- 信息收集提示条 ---------- */
.qx-contact-notice {
    background: #e8f5e9;
    border: 1px solid #c8e6c9;
    border-radius: 8px;
    padding: 10px 12px;
    margin: 4px 0;
    font-size: 12px;
    color: #2e7d32;
    display: flex;
    align-items: center;
    gap: 6px;
    animation: qxMsgIn 0.3s ease;
}
.qx-contact-notice .icon { font-size: 16px; }

/* ---------- 底部输入区 ---------- */
.qx-chat-footer {
    padding: 10px 14px;
    border-top: 1px solid #eee;
    background: #fff;
    display: flex;
    flex-shrink: 0;
    flex-direction: column;
    gap: 6px;
}
.qx-chat-input-row {
    display: flex;
    gap: 8px;
    align-items: flex-end;
}
.qx-chat-input {
    flex: 1;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 9px 16px;
    font-size: 13px;
    outline: none;
    resize: none;
    font-family: inherit;
    line-height: 1.4;
    max-height: 80px;
    transition: border-color 0.2s;
}
.qx-chat-input:focus {
    border-color: var(--theme-color, #0062c0);
}
.qx-chat-send {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: #191919;
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    transition: transform 0.2s, box-shadow 0.2s, background 0.2s;
}
.qx-chat-send:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(25,25,25,0.35);
    background: #2b2b2b;
}
.qx-chat-send .qx-chat-send-icon {
    display: block;
    width: 18px;
    height: 18px;
}
.qx-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}
.qx-chat-quick {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}
.qx-chat-quick-btn {
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    background: #fafafa;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.qx-chat-quick-btn:hover {
    border-color: var(--theme-color, #0062c0);
    color: var(--theme-color, #0062c0);
    background: #f0f4ff;
}

/* ---------- 触发按钮 ---------- */
.qx-chat-toggle {
    height: 36px;
    padding: 0 14px;
    border-radius: 18px;
    background: var(--theme-color, #0062c0);
    color: #fff;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 12.5px;
    font-weight: 700;
    white-space: nowrap;
    letter-spacing: 1px;
    box-shadow: 0 3px 12px rgba(0,98,192,0.4);
    transition: all 0.3s;
    animation: qxBreathe 3s ease-in-out infinite;
}

@keyframes qxBreathe {
    0%, 100% { box-shadow: 0 3px 12px rgba(0,98,192,0.4); transform: scale(1); }
    50% { box-shadow: 0 3px 22px rgba(0,98,192,0.55); transform: scale(1.04); }
}
.qx-chat-toggle:hover {
    animation: none !important;
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(0,98,192,0.55);
}
.qx-chat-toggle i {
    transition: transform 0.3s;
}
.qx-chat-toggle:hover i {
    transform: rotate(-10deg);
}

/* ---------- 欢迎消息中的快捷按钮 ---------- */
.qx-msg-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
    flex-wrap: wrap;
}
.qx-msg-action-btn {
    font-size: 12px;
    padding: 6px 14px;
    border-radius: 16px;
    border: 1px solid var(--theme-color, #0062c0);
    background: rgba(0,98,192,0.06);
    color: var(--theme-color, #0062c0);
    cursor: pointer;
    transition: all 0.2s;
}
.qx-msg-action-btn:hover {
    background: var(--theme-color, #0062c0);
    color: #fff;
}

/* ---------- 移动端适配 ---------- */
@media (max-width: 768px) {
    .qx-chat-float {
        right: 10px;
        bottom: 20px;
    }
    .qx-chat-panel {
        width: calc(100vw - 20px);
        height: 60vh;
        min-height: 380px;
        position: fixed;
        right: 10px;
        bottom: 76px;
    }
    .qx-chat-toggle {
        height: 40px;
        padding: 0 14px;
        font-size: 13px;
    }
    .qx-chat-toggle i {
        font-size: 15px;
    }
}
