/* ==================== AI客服悬浮按钮 ==================== */
.ai-chat-btn {
    position: fixed;
    right: 30px;
    bottom: 100px;
    z-index: 9998;
    display: flex;
    align-items: center;
    justify-content: flex-start;
    width: 54px;
    height: 54px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 20px rgba(26, 75, 140, 0.4), 0 0 40px rgba(37, 99, 235, 0.2);
    background: linear-gradient(135deg, #1a4b8c 0%, #2563eb 100%);
}

.ai-chat-btn:hover {
    width: 160px;
    border-radius: 27px;
    box-shadow: 0 6px 30px rgba(26, 75, 140, 0.6), 0 0 50px rgba(37, 99, 235, 0.3);
}

.ai-chat-btn .btn-icon {
    width: 100%;
    min-width: 54px;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.ai-chat-btn:hover .btn-icon {
    width: 44px;
    min-width: 44px;
    padding-left: 8px;
}

.ai-chat-btn .btn-icon svg {
    width: 26px;
    height: 26px;
    fill: #fff;
    filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.2));
}

.ai-chat-btn .btn-text {
    position: absolute;
    right: 0;
    width: 0;
    opacity: 0;
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.ai-chat-btn:hover .btn-text {
    opacity: 1;
    width: 105px;
    padding-right: 15px;
}

.ai-chat-btn:active {
    transform: scale(0.95);
}

/* ==================== AI客服对话框 ==================== */
.ai-chat-modal {
    position: fixed;
    right: 30px;
    bottom: 170px;
    width: 380px;
    max-width: calc(100vw - 40px);
    max-height: 520px;
    background: rgba(26, 35, 50, 0.95);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-radius: 20px;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(26, 75, 140, 0.2);
    border: 1px solid rgba(26, 75, 140, 0.3);
    z-index: 9999;
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: chatSlideUp 0.3s ease;
}

.ai-chat-modal.active {
    display: flex;
}

@keyframes chatSlideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 对话框头部 */
.ai-chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, rgba(26, 75, 140, 0.15) 0%, rgba(196, 30, 58, 0.1) 100%);
    border-bottom: 1px solid rgba(26, 75, 140, 0.2);
}

.ai-chat-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-chat-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(26, 75, 140, 0.4);
    padding: 3px;
}

.ai-chat-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.ai-chat-title {
    display: flex;
    flex-direction: column;
}

.ai-chat-title h4 {
    color: #fff;
    font-size: 15px;
    font-weight: 600;
    margin: 0;
}

.ai-chat-title span {
    color: #4ade80;
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-chat-title span::before {
    content: '';
    width: 6px;
    height: 6px;
    background: #4ade80;
    border-radius: 50%;
}

.ai-chat-close {
    width: 32px;
    height: 32px;
    border: none;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    color: #fff;
    font-size: 18px;
}

.ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.2);
    transform: rotate(90deg);
}

/* 消息区域 */
.ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    min-height: 300px;
    max-height: 350px;
    overscroll-behavior: contain; /* 阻止滚动穿透 */
}

.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: rgba(26, 75, 140, 0.3);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: rgba(26, 75, 140, 0.5);
}

/* 消息气泡 */
.chat-message {
    display: flex;
    gap: 10px;
    animation: messageIn 0.3s ease;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chat-message.user {
    flex-direction: row-reverse;
}

.chat-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.chat-message.ai .chat-message-avatar {
    background: #fff;
    padding: 2px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.chat-message.ai .chat-message-avatar img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.chat-message.user .chat-message-avatar {
    background: linear-gradient(135deg, #1a4b8c 0%, #2563eb 100%);
    color: #fff;
}

.chat-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.chat-message.ai .chat-message-content {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
    border-bottom-left-radius: 4px;
}

.chat-message.user .chat-message-content {
    background: linear-gradient(135deg, #1a4b8c 0%, #2563eb 100%);
    color: #fff;
    border-bottom-right-radius: 4px;
}

/* 输入区域 */
.ai-chat-input-area {
    padding: 16px 20px;
    background: rgba(0, 0, 0, 0.2);
    border-top: 1px solid rgba(26, 75, 140, 0.2);
    display: flex;
    gap: 10px;
}

.ai-chat-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid rgba(26, 75, 140, 0.3);
    border-radius: 24px;
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
    font-size: 14px;
    outline: none;
    transition: all 0.2s ease;
}

.ai-chat-input::placeholder {
    color: rgba(255, 255, 255, 0.4);
}

.ai-chat-input:focus {
    border-color: rgba(26, 75, 140, 0.6);
    background: rgba(255, 255, 255, 0.08);
}

.ai-chat-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 50%;
    background: linear-gradient(135deg, #1a4b8c 0%, #2563eb 100%);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.ai-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(26, 75, 140, 0.5);
}

.ai-chat-send:active {
    transform: scale(0.95);
}

.ai-chat-send:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.ai-chat-send svg {
    width: 20px;
    height: 20px;
    fill: #fff;
}

/* 加载动画 */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: rgba(26, 75, 140, 0.8);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out;
}

.typing-indicator span:nth-child(1) { animation-delay: 0s; }
.typing-indicator span:nth-child(2) { animation-delay: 0.2s; }
.typing-indicator span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.6;
    }
    30% {
        transform: translateY(-8px);
        opacity: 1;
    }
}

/* 欢迎消息 */
.welcome-message {
    text-align: center;
    padding: 20px;
    color: rgba(255, 255, 255, 0.6);
    font-size: 13px;
}

.welcome-message p {
    margin: 8px 0;
}

.welcome-message .highlight {
    color: #c41e3a;
    font-weight: 600;
}

/* 快捷问题按钮 */
.quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    margin-top: 12px;
}

.quick-question-btn {
    padding: 6px 12px;
    background: rgba(26, 75, 140, 0.15);
    border: 1px solid rgba(26, 75, 140, 0.3);
    border-radius: 16px;
    color: #93c5fd;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.quick-question-btn:hover {
    background: rgba(26, 75, 140, 0.25);
    border-color: rgba(26, 75, 140, 0.5);
    color: #fff;
}

/* 剩余次数提示 */
.remaining-hint {
    text-align: center;
    padding: 8px 16px;
    margin-top: 8px;
    background: rgba(251, 191, 36, 0.15);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 12px;
    color: #fbbf24;
    font-size: 12px;
}

/* 移动端适配 */
@media (max-width: 480px) {
    .ai-chat-btn {
        right: 20px;
        bottom: 80px;
        width: 46px;
        height: 46px;
    }
    
    .ai-chat-btn:hover {
        width: 46px;
        border-radius: 50%;
    }
    
    .ai-chat-btn:hover .btn-text {
        display: none;
    }
    
    .ai-chat-btn:hover .btn-icon {
        width: 100%;
        padding-left: 0;
    }
    
    .ai-chat-modal {
        right: 10px;
        left: 10px;
        bottom: 140px;
        width: auto;
        max-height: 70vh;
    }
    
    .ai-chat-messages {
        min-height: 250px;
        max-height: 45vh;
    }
}
