/* ============================================
   康茂AI智能助手 - 复刻官方Coze设计
   主色 #e83929（品牌红）/ 背景 #f5f7fa
   ============================================ */

#ai-chat-container {
    position: fixed;
    bottom: 30px;
    right: 30px;
    z-index: 10000;
    font-family: "微软雅黑", "Microsoft YaHei", "PingFang SC", "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    color: #333;
    line-height: 1.5;
}

/* ========== 悬浮球 ========== */
#ai-chat-btn {
    width: 56px;
    height: 56px;
    background: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.3s ease;
    position: relative;
}

#ai-chat-btn:hover {
    transform: scale(1.08);
}

#ai-chat-btn img {
    width: 56px;
    height: 56px;
}

#ai-chat-btn .ai-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    background: #ff4757;
    color: #fff;
    border-radius: 9px;
    font-size: 11px;
    line-height: 18px;
    text-align: center;
    padding: 0 5px;
    display: none;
    font-weight: bold;
    border: 2px solid #fff;
}

/* ========== 对话框（贴顶贴底+圆角） ========== */
#ai-chat-dialog {
    position: fixed;
    top: 8px;
    bottom: 8px;
    right: 30px;
    width: 440px;
    background: #fff;
    border-radius: 16px;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: ai-slideIn 0.25s ease-out;
}

#ai-chat-dialog.ai-show {
    display: flex;
}

@keyframes ai-slideIn {
    from { opacity: 0; transform: translateX(20px); }
    to   { opacity: 1; transform: translateX(0); }
}

/* ========== 品牌头部（紧凑垂直版） ========== */
.ai-chat-brand {
    flex-shrink: 0;
    text-align: center;
    padding: 14px 16px 10px;
    position: relative;
}

.ai-chat-brand-clear,
.ai-chat-brand-close {
    position: absolute;
    top: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    color: #999;
    transition: all 0.2s;
}

.ai-chat-brand-clear:hover {
    background: #e0e0e0;
    color: #e83929;
}

.ai-chat-brand-clear {
    right: 42px;
}

.ai-chat-brand-close {
    right: 12px;
}

.ai-chat-brand-close:hover {
    background: #e0e0e0;
    color: #333;
}

.ai-chat-brand-icon {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    object-fit: cover;
    margin-bottom: 6px;
}

.ai-chat-brand-title {
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
    margin-bottom: 2px;
}

.ai-chat-brand-desc {
    font-size: 12px;
    color: #999;
    line-height: 1.4;
    margin-bottom: 8px;
}

/* 品牌区核心优势标签 */
.ai-chat-tags {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 5px;
}

.ai-chat-tag {
    display: inline-block;
    padding: 2px 10px;
    background: rgba(232, 57, 41, 0.08);
    border-radius: 10px;
    font-size: 11px;
    color: #e83929;
    white-space: nowrap;
}

/* ========== 消息区域 ========== */
.ai-chat-body {
    flex: 1;
    overflow-y: auto;
    padding: 4px 18px 12px;
    background: #f7f8fa;
    border-top: 1px solid #eee;
}

/* 消息条目 */
.ai-chat-msg {
    display: flex;
    margin-bottom: 14px;
    animation: ai-msgIn 0.3s ease-out;
}

@keyframes ai-msgIn {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* AI 消息（左） */
.ai-chat-msg.ai-msg {
    justify-content: flex-start;
    flex-direction: column;
    align-items: flex-start;
}

.ai-msg-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 4px;
    padding-left: 2px;
}

.ai-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ai-name-label {
    font-size: 12px;
    color: #888;
    font-weight: 500;
}

.ai-bubble {
    max-width: 80%;
    padding: 10px 14px;
    background: #fff;
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    font-size: 14px;
    color: #333;
    word-break: break-word;
    line-height: 1.65;
}

/* 用户消息（右） */
.ai-chat-msg.user-msg {
    justify-content: flex-end;
    flex-direction: column;
    align-items: flex-end;
}

.user-name-label {
    font-size: 12px;
    color: #888;
    font-weight: 500;
    margin-bottom: 4px;
    padding-right: 4px;
}

.user-bubble {
    max-width: 80%;
    padding: 10px 14px;
    background: linear-gradient(135deg, #e83929, #c62e1f);
    border-radius: 16px 4px 16px 16px;
    color: #fff;
    font-size: 14px;
    word-break: break-word;
    line-height: 1.65;
}

/* 加载动画 */
.ai-loading {
    display: flex;
    align-items: center;
    padding: 12px 16px;
    background: #fff;
    border-radius: 4px 16px 16px 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.ai-loading-dot {
    width: 7px;
    height: 7px;
    background: #b0b0b0;
    border-radius: 50%;
    margin: 0 3px;
    animation: ai-dotBounce 1.4s ease-in-out infinite;
}

.ai-loading-dot:nth-child(2) { animation-delay: 0.2s; }
.ai-loading-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-dotBounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
    40% { transform: scale(1); opacity: 1; }
}

/* 每条回复后的推荐问题 */
.ai-recommend-questions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-top: 8px;
}

.ai-rec-q {
    padding: 6px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 14px;
    font-size: 12px;
    color: #666;
    cursor: pointer;
    transition: all 0.2s;
    background: #f9f9f9;
}

.ai-rec-q:hover {
    border-color: #e83929;
    color: #e83929;
    background: rgba(232, 57, 41, 0.04);
}

/* ========== 底部输入区 ========== */
.ai-chat-footer {
    flex-shrink: 0;
    padding: 10px 16px 12px;
    border-top: 1px solid #eee;
    background: #fff;
}

.ai-chat-input-wrap {
    display: flex;
    align-items: flex-end;
    gap: 8px;
}

.ai-chat-input {
    flex: 1;
    height: 48px;
    min-height: 48px;
    max-height: 48px;
    padding: 0 16px;
    border: 1px solid #e0e0e0;
    border-radius: 24px;
    font-size: 14px;
    font-family: inherit;
    color: #333;
    outline: none;
    resize: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    line-height: 48px;
    background: #f5f5f5;
    overflow: hidden;
}

.ai-chat-input:focus {
    border-color: #e83929;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(232, 57, 41, 0.1);
}

.ai-chat-input::placeholder {
    color: #aaa;
}

.ai-chat-send {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #e83929, #c62e1f);
    color: #fff;
    font-size: 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-chat-send:hover {
    box-shadow: 0 2px 12px rgba(232, 57, 41, 0.4);
    transform: scale(1.05);
}

.ai-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* ========== 滚动条 ========== */
.ai-chat-body::-webkit-scrollbar { width: 4px; }
.ai-chat-body::-webkit-scrollbar-track { background: transparent; }
.ai-chat-body::-webkit-scrollbar-thumb { background: #ccc; border-radius: 4px; }
.ai-chat-body::-webkit-scrollbar-thumb:hover { background: #999; }

/* ========== 移动端适配 ========== */
@media screen and (max-width: 480px) {
    #ai-chat-container {
        bottom: 14px;
        right: 14px;
    }

    #ai-chat-btn {
        width: 50px;
        height: 50px;
    }

    #ai-chat-btn img {
        width: 50px;
        height: 50px;
    }

    #ai-chat-dialog {
        right: 0;
        width: 100%;
    }

    .ai-chat-brand {
        padding: 18px 16px 10px;
    }
}
