/* ===== AI 数字客服对话框 ===== */
.ai-chat-widget {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'PingFang SC', 'Microsoft YaHei', sans-serif;
}

/* 浮动触发按钮 */
.ai-chat-trigger {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #1B5E20, #1565C0);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 20px rgba(27,94,32,0.35);
    transition: transform 0.3s, box-shadow 0.3s;
    position: relative;
    z-index: 2;
}
.ai-chat-trigger:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 30px rgba(27,94,32,0.45);
}
.ai-chat-trigger.active {
    display: none;
}

/* 对话框容器 */
.ai-chat-dialog {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 380px;
    height: 520px;
    min-width: 300px;
    min-height: 400px;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 12px 50px rgba(0,0,0,0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 1px solid rgba(0,0,0,0.08);
}
.ai-chat-dialog.open {
    display: flex;
}

/* 头部 */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 16px;
    background: linear-gradient(135deg, #0f1f30, #0a1c14);
    color: white;
    cursor: move;
    user-select: none;
}
.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 10px;
}
.ai-chat-avatar {
    width: 38px;
    height: 38px;
    border-radius: 10px;
    background: linear-gradient(135deg, #10b981, #2563eb);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 18px;
}
.ai-chat-header-left h4 {
    font-size: 0.95rem;
    margin: 0;
    font-weight: 600;
}
.ai-chat-header-left span {
    font-size: 0.7rem;
    opacity: 0.75;
}
.ai-chat-header-right {
    display: flex;
    gap: 4px;
}
.ai-chat-btn-icon {
    width: 28px;
    height: 28px;
    border-radius: 6px;
    border: none;
    background: rgba(255,255,255,0.12);
    color: white;
    cursor: pointer;
    font-size: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}
.ai-chat-btn-icon:hover {
    background: rgba(255,255,255,0.25);
}

/* 消息区 */
.ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 12px;
}
.ai-chat-msg {
    display: flex;
    max-width: 85%;
}
.ai-chat-msg-user {
    align-self: flex-end;
}
.ai-chat-msg-bot {
    align-self: flex-start;
}
.ai-chat-msg-content {
    padding: 10px 14px;
    border-radius: 12px;
    font-size: 0.88rem;
    line-height: 1.6;
    word-break: break-word;
}
.ai-chat-msg-user .ai-chat-msg-content {
    background: linear-gradient(135deg, #1B5E20, #1565C0);
    color: white;
    border-bottom-right-radius: 4px;
}
.ai-chat-msg-bot .ai-chat-msg-content {
    background: white;
    color: #334155;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}
.ai-chat-msg-loading .ai-chat-msg-content {
    color: #94a3b8;
    font-style: italic;
}

/* 推荐区 */
.ai-chat-recommend {
    padding: 8px 16px;
    background: #f8fafc;
    border-top: 1px solid #e2e8f0;
    display: none;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 80px;
    overflow-y: auto;
}
.ai-chat-recommend.has-items {
    display: flex;
}
.ai-chat-recommend-tag {
    display: inline-block;
    padding: 4px 10px;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 20px;
    font-size: 0.75rem;
    text-decoration: none;
    white-space: nowrap;
    transition: background 0.2s;
}
.ai-chat-recommend-tag:hover {
    background: #bae6fd;
}

/* 输入区 */
.ai-chat-input-area {
    display: flex;
    align-items: center;
    padding: 10px 12px;
    border-top: 1px solid #e2e8f0;
    background: white;
    gap: 8px;
}
.ai-chat-input {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 24px;
    padding: 10px 16px;
    font-size: 0.88rem;
    outline: none;
    transition: border-color 0.2s;
    background: #f8fafc;
}
.ai-chat-input:focus {
    border-color: #10b981;
}
.ai-chat-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #10b981, #2563eb);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, opacity 0.2s;
    flex-shrink: 0;
}
.ai-chat-send:hover {
    transform: scale(1.05);
}
.ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 底部提示 */
.ai-chat-footer {
    padding: 6px;
    text-align: center;
    font-size: 0.65rem;
    color: #94a3b8;
    background: #f8fafc;
    border-top: 1px solid #f1f5f9;
}

/* 拖拽调整大小手柄 */
.ai-chat-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 16px;
    height: 16px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, #e2e8f0 50%);
    border-radius: 0 0 8px 0;
}

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .ai-chat-widget {
        bottom: 16px;
        right: 16px;
    }
    .ai-chat-dialog {
        width: calc(100vw - 32px);
        max-width: 400px;
        height: 480px;
        min-height: 360px;
    }
}
@media (max-width: 480px) {
    .ai-chat-dialog {
        width: calc(100vw - 24px);
        max-width: 360px;
        height: 440px;
        min-height: 320px;
    }
}
