/* ===== 薯芯云 AI 客服样式（支持昼夜切换） ===== */
:root {
    --ai-bg: #0a0e17;
    --ai-card: #111827;
    --ai-border: #1a2332;
    --ai-border-light: #253044;
    --ai-text: #e8edf5;
    --ai-text-2: #8b98ab;
    --ai-text-3: #5a6a80;
    --ai-primary: #3b82f6;
    --ai-primary-2: #60a5fa;
    --ai-hover: rgba(59, 130, 246, 0.04);
}

/* 白天模式变量覆盖 */
body.theme-light {
    --ai-bg: #f8fafc;
    --ai-card: #ffffff;
    --ai-border: #e2e8f0;
    --ai-border-light: #cbd5e1;
    --ai-text: #1e293b;
    --ai-text-2: #475569;
    --ai-text-3: #94a3b8;
    --ai-primary: #3b82f6;
    --ai-primary-2: #2563eb;
    --ai-hover: rgba(59, 130, 246, 0.03);
}

/* ===== 悬浮按钮 ===== */
.ai-fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(59, 130, 246, 0.4);
    transition: all 0.3s;
    z-index: 9998;
    padding: 0;
    line-height: 1;
}

.ai-fab::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(59, 130, 246, 0.4);
    animation: ai-fab-pulse 2.5s ease-in-out infinite;
    pointer-events: none;
}
@keyframes ai-fab-pulse {
    0%, 100% { transform: scale(1); opacity: 0.5; }
    50% { transform: scale(1.15); opacity: 0; }
}

.ai-fab:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 24px rgba(59, 130, 246, 0.55);
}

.ai-fab .ai-fab-icon {
    font-size: 24px;
    line-height: 1;
    position: relative;
    z-index: 1;
}
.ai-fab .ai-fab-close {
    font-size: 20px;
    line-height: 1;
    position: relative;
    z-index: 1;
    display: none;
}

/* ===== 聊天窗口 ===== */
.ai-chat {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 360px;
    max-height: 520px;
    background: var(--ai-card);
    border: 1px solid var(--ai-border-light);
    border-radius: 10px;
    display: none;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 9997;
    opacity: 0;
    transform: translateY(20px);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}
.ai-chat.open {
    opacity: 1;
    transform: translateY(0);
}

/* 聊天头部 */
.ai-chat-header {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 14px 16px;
    background: var(--ai-card);
    border-bottom: 1px solid var(--ai-border);
    position: relative;
}
.ai-chat-header::before {
    content: '';
    position: absolute;
    top: -1px;
    left: 16px;
    right: 16px;
    height: 1px;
    background: var(--ai-primary);
}
.ai-avatar {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    background: rgba(59, 130, 246, 0.1);
    color: var(--ai-primary-2);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 16px;
}
.ai-header-info { flex: 1; }
.ai-header-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--ai-text);
}
.ai-header-status {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    color: #4ade80;
}
.ai-status-dot {
    width: 5px;
    height: 5px;
    border-radius: 50%;
    background: #4ade80;
    animation: ai-pulse 2s infinite;
}
@keyframes ai-pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

/* 消息区域 */
.ai-messages {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-height: 200px;
    max-height: 320px;
    background: var(--ai-bg);
}
.ai-messages::-webkit-scrollbar {
    width: 4px;
}
.ai-messages::-webkit-scrollbar-thumb {
    background: var(--ai-border-light);
    border-radius: 2px;
}

/* 消息气泡 */
.ai-msg {
    max-width: 85%;
    padding: 9px 12px;
    border-radius: 8px;
    font-size: 12px;
    line-height: 1.6;
    word-wrap: break-word;
    animation: ai-msg-in 0.3s ease;
}
@keyframes ai-msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}
.ai-msg-user {
    align-self: flex-end;
    background: var(--ai-primary);
    color: #fff;
    border-bottom-right-radius: 3px;
}
.ai-msg-bot {
    align-self: flex-start;
    background: var(--ai-card);
    border: 1px solid var(--ai-border);
    color: var(--ai-text-2);
    border-bottom-left-radius: 3px;
}

/* 多按钮容器 */
.ai-msg-buttons {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 10px;
}

/* 按钮消息 */
.ai-msg-button {
    display: inline-block;
    padding: 6px 14px;
    background: rgba(59, 130, 246, 0.08);
    border: 1px solid rgba(59, 130, 246, 0.25);
    border-radius: 4px;
    color: var(--ai-primary-2);
    font-size: 11px;
    text-decoration: none;
    transition: all 0.25s;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.ai-msg-button:hover {
    background: var(--ai-primary);
    color: #fff;
    border-color: var(--ai-primary);
}

/* 打字动画 */
.ai-typing {
    display: flex;
    gap: 4px;
    align-items: center;
    padding: 4px 0;
}
.ai-typing span {
    width: 5px;
    height: 5px;
    background: var(--ai-text-3);
    border-radius: 50%;
    animation: ai-typing 1.4s infinite;
}
.ai-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ai-typing {
    0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
    30% { opacity: 1; transform: translateY(-3px); }
}

/* 快捷问题 */
.ai-quick {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    padding: 8px 12px;
    border-top: 1px solid var(--ai-border);
    background: var(--ai-card);
}
.ai-quick-btn {
    padding: 4px 10px;
    background: var(--ai-bg);
    border: 1px solid var(--ai-border-light);
    border-radius: 14px;
    color: var(--ai-text-2);
    font-size: 10px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}
.ai-quick-btn:hover {
    border-color: var(--ai-primary);
    color: var(--ai-primary-2);
}

/* 输入区域 */
.ai-input-area {
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    border-top: 1px solid var(--ai-border);
    background: var(--ai-card);
}
.ai-input {
    flex: 1;
    background: var(--ai-bg);
    border: 1px solid var(--ai-border-light);
    border-radius: 4px;
    color: var(--ai-text);
    font-size: 12px;
    padding: 8px 10px;
    outline: none;
    transition: border-color 0.2s;
}
.ai-input::placeholder {
    color: var(--ai-text-3);
}
.ai-input:focus {
    border-color: var(--ai-primary);
}
.ai-send-btn {
    width: 34px;
    height: 34px;
    border-radius: 4px;
    background: var(--ai-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
    font-size: 13px;
    padding: 0;
}
.ai-send-btn:hover {
    background: var(--ai-primary-2);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.4);
}

/* ===== 移动端适配 ===== */
@media (max-width: 480px) {
    .ai-chat {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 80px;
        max-height: 60vh;
    }
    .ai-fab {
        bottom: 20px;
        right: 20px;
        width: 48px;
        height: 48px;
    }
    .ai-fab .ai-fab-icon {
        font-size: 20px;
    }
    .ai-fab .ai-fab-close {
        font-size: 18px;
    }
}