/* ============================================
   AI 客服对话框 - 玻璃态深色科技风
   ============================================ */

/* 按钮容器（与返回顶部共处 floating-actions） */
#ai-chat-btn-wrap {
    position: relative;
}

/* 对话按钮 - 呼吸光晕 */
.ai-chat-btn {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    transition: transform 0.3s, box-shadow 0.3s;
}
.ai-chat-btn::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid rgba(102,126,234,0.3);
    animation: pulse-ring 2.2s ease-out infinite;
}
.ai-chat-btn:hover {
    transform: scale(1.08);
    box-shadow: 0 0 30px rgba(102,126,234,0.5);
}

@keyframes pulse-ring {
    0%   { transform: scale(1);   opacity: 1; }
    100% { transform: scale(1.4); opacity: 0; }
}

/* 对话窗口 - 深色玻璃态 */
.ai-chat-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 400px;
    height: 540px;
    border-radius: 20px;
    overflow: hidden;
    display: none;
    flex-direction: column;
    z-index: 9998;
    border: 1px solid rgba(255,255,255,0.12);
    box-shadow: 0 20px 60px rgba(0,0,0,0.4), 0 0 0 1px rgba(255,255,255,0.05) inset;
}

.ai-chat-window.open {
    display: flex;
}

/* 窗口头部 */
.chat-header {
    background: linear-gradient(135deg, rgba(15,20,40,0.95), rgba(30,20,60,0.95));
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    color: #fff;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.chat-title {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
    font-size: 15px;
}
.chat-title .ai-dot {
    width: 10px; height: 10px;
    background: #00cec9;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(0,206,201,0.6);
    animation: status-pulse 2s ease-in-out infinite;
}
@keyframes status-pulse {
    0%, 100% { opacity: 1; }
    50%      { opacity: 0.4; }
}
.chat-close {
    background: rgba(255,255,255,0.1);
    border: none;
    color: rgba(255,255,255,0.7);
    width: 30px; height: 30px;
    border-radius: 50%;
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
.chat-close:hover {
    background: rgba(255,255,255,0.2);
    color: #fff;
}

/* 消息区 */
.chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    background: rgba(15,20,40,0.92);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
}
.chat-messages::-webkit-scrollbar {
    width: 4px;
}
.chat-messages::-webkit-scrollbar-track {
    background: transparent;
}
.chat-messages::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,0.12);
    border-radius: 2px;
}

/* 消息气泡 */
.chat-message {
    display: flex;
    gap: 10px;
    margin-bottom: 16px;
    animation: msg-in 0.3s ease;
}
@keyframes msg-in {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}
.user-message {
    flex-direction: row-reverse;
}
.message-avatar {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 700;
    flex-shrink: 0;
}
.bot-message .message-avatar {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
}
.user-message .message-avatar {
    background: rgba(162,155,254,0.3);
    color: #a29bfe;
}
.message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 14px;
    line-height: 1.6;
    font-size: 13px;
}
.bot-message .message-content {
    background: rgba(255,255,255,0.06);
    color: rgba(255,255,255,0.85);
    border: 1px solid rgba(255,255,255,0.06);
    border-bottom-left-radius: 4px;
}
.user-message .message-content {
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: #fff;
    border-bottom-right-radius: 4px;
}
.message-content p {
    margin: 0;
}
.message-content p + p {
    margin-top: 8px;
}
.message-content.loading {
    padding: 16px 20px;
}

/* 打字动画 */
.typing {
    display: flex;
    gap: 4px;
}
.typing span {
    width: 7px; height: 7px;
    background: rgba(162,155,254,0.6);
    border-radius: 50%;
    animation: typing-bounce 1.4s infinite;
}
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-bounce {
    0%, 60%, 100% { transform: translateY(0); }
    30%           { transform: translateY(-6px); }
}

/* 输入区 */
.chat-input-area {
    padding: 12px 16px;
    background: rgba(15,20,40,0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-top: 1px solid rgba(255,255,255,0.08);
}
.chat-input-wrapper {
    display: flex;
    gap: 8px;
}
#chat-input {
    flex: 1;
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 24px;
    padding: 12px 18px;
    font-size: 13px;
    outline: none;
    background: rgba(255,255,255,0.05);
    color: rgba(255,255,255,0.9);
    transition: all 0.2s;
}
#chat-input::placeholder {
    color: rgba(255,255,255,0.3);
}
#chat-input:focus {
    border-color: rgba(102,126,234,0.5);
    background: rgba(255,255,255,0.08);
}
.chat-send-btn {
    width: 44px; height: 44px;
    border-radius: 50%;
    border: none;
    background: linear-gradient(135deg, #667eea, #764ba2);
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}
.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 0 15px rgba(102,126,234,0.5);
}

/* 移动端 */
@media (max-width: 480px) {
    .ai-chat-window {
        width: 100vw;
        height: 70vh;
        bottom: 0;
        right: 0;
        border-radius: 20px 20px 0 0;
    }
    .floating-actions {
        bottom: 16px;
        right: 16px;
    }
}
