/* ===== 数字人AI客服样式 ===== */

/* 悬浮按钮 */
.ai-cs-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    width: 64px;
    height: 64px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4fc3f7 0%, #29b6f6 100%);
    box-shadow: 0 8px 24px rgba(79, 195, 247, 0.4);
    cursor: pointer;
    z-index: 100000;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    animation: ai-cs-pulse 2s infinite;
}

.ai-cs-fab:hover {
    transform: scale(1.1);
    box-shadow: 0 12px 32px rgba(79, 195, 247, 0.5);
    will-change: transform;
}

.ai-cs-fab:active {
    transform: scale(0.95);
}

@keyframes ai-cs-pulse {
    0%, 100% { box-shadow: 0 8px 24px rgba(79, 195, 247, 0.4); }
    50% { box-shadow: 0 8px 32px rgba(79, 195, 247, 0.6); }
}

.ai-cs-fab-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    position: relative;
    overflow: hidden;
}

.ai-cs-fab-avatar::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: ai-cs-shine 3s infinite;
}

@keyframes ai-cs-shine {
    0% { left: -100%; }
    50%, 100% { left: 100%; }
}

.ai-cs-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    background: #ff4757;
    color: #fff;
    font-size: 11px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
    border: 2px solid #fff;
}

/* 客服窗口 */
.ai-cs-window {
    position: fixed;
    bottom: 100px;
    right: 24px;
    width: 380px;
    height: 560px;
    background: #fff;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
    z-index: 100001;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: translateY(20px) scale(0.95);
    opacity: 0;
    pointer-events: none;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.3s ease;
    will-change: transform, opacity;
}

.ai-cs-window.active {
    transform: translateY(0) scale(1);
    opacity: 1;
    pointer-events: auto;
}

/* 窗口头部 - 数字人区域 */
.ai-cs-header {
    background: linear-gradient(135deg, #1a365d 0%, #2c5282 50%, #2b6cb0 100%);
    padding: 16px 20px;
    position: relative;
    overflow: hidden;
}

.ai-cs-header::before {
    content: '';
    position: absolute;
    top: -50%;
    right: -20%;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(79, 195, 247, 0.2) 0%, transparent 70%);
    border-radius: 50%;
}

.ai-cs-header-content {
    display: flex;
    align-items: center;
    gap: 14px;
    position: relative;
    z-index: 1;
}

/* 数字人形象 */
.ai-cs-avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4fc3f7, #81d4fa);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 32px;
    position: relative;
    flex-shrink: 0;
    border: 3px solid rgba(255, 255, 255, 0.3);
}

.ai-cs-avatar.speaking {
    animation: ai-cs-avatar-speaking 0.5s ease-in-out infinite;
}

@keyframes ai-cs-avatar-speaking {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.05); }
}

.ai-cs-avatar.speaking {
    will-change: transform;
}

.ai-cs-avatar-status {
    position: absolute;
    bottom: 2px;
    right: 2px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #10b981;
    border: 2px solid #fff;
}

.ai-cs-avatar-status::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #fff;
    animation: ai-cs-status-blink 2s infinite;
}

@keyframes ai-cs-status-blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

.ai-cs-info {
    flex: 1;
    min-width: 0;
}

.ai-cs-name {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-cs-name-tag {
    font-size: 10px;
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
    padding: 2px 6px;
    border-radius: 4px;
    font-weight: 500;
}

.ai-cs-status-text {
    color: rgba(255, 255, 255, 0.8);
    font-size: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.ai-cs-status-text .typing-dots {
    display: inline-flex;
    gap: 2px;
}

.ai-cs-status-text .typing-dots span {
    width: 4px;
    height: 4px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.8);
    animation: ai-cs-typing 1.4s infinite;
}

.ai-cs-status-text .typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ai-cs-status-text .typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ai-cs-typing {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-4px); opacity: 1; }
}

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

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

/* 快捷问题标签 */
.ai-cs-quick-questions {
    padding: 10px 16px;
    background: #f7fafc;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    scrollbar-width: none;
}

.ai-cs-quick-questions::-webkit-scrollbar {
    display: none;
}

.ai-cs-quick-btn {
    flex-shrink: 0;
    padding: 6px 12px;
    border-radius: 16px;
    background: #fff;
    border: 1px solid #e2e8f0;
    color: #4a5568;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.ai-cs-quick-btn:hover {
    background: #ebf8ff;
    border-color: #4fc3f7;
    color: #2b6cb0;
}

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

/* 消息区域 */
.ai-cs-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    background: #f7fafc;
    scroll-behavior: smooth;
}

.ai-cs-messages::-webkit-scrollbar {
    width: 4px;
}

.ai-cs-messages::-webkit-scrollbar-track {
    background: transparent;
}

.ai-cs-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.ai-cs-message {
    display: flex;
    margin-bottom: 16px;
    animation: ai-cs-message-in 0.3s ease;
}

@keyframes ai-cs-message-in {
    from { opacity: 0; transform: translate3d(0, 10px, 0); }
    to { opacity: 1; transform: translate3d(0, 0, 0); }
}

.ai-cs-message.ai {
    justify-content: flex-start;
}

.ai-cs-message.user {
    justify-content: flex-end;
}

.ai-cs-message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
    margin-right: 8px;
}

.ai-cs-message.ai .ai-cs-message-avatar {
    background: linear-gradient(135deg, #4fc3f7, #81d4fa);
}

.ai-cs-message.user .ai-cs-message-avatar {
    background: linear-gradient(135deg, #a0aec0, #718096);
    margin-right: 0;
    margin-left: 8px;
    order: 2;
}

.ai-cs-message-bubble {
    max-width: 75%;
    padding: 10px 14px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
    position: relative;
}

.ai-cs-message.ai .ai-cs-message-bubble {
    background: #fff;
    color: #2d3748;
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.ai-cs-message.user .ai-cs-message-bubble {
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.ai-cs-message-time {
    font-size: 10px;
    color: #a0aec0;
    margin-top: 4px;
    text-align: right;
}

.ai-cs-message.ai .ai-cs-message-time {
    text-align: left;
    padding-left: 40px;
}

/* 消息中的链接 */
.ai-cs-message-bubble a {
    color: #2b6cb0;
    text-decoration: underline;
}

.ai-cs-message.user .ai-cs-message-bubble a {
    color: #fff;
}

/* 输入区域 */
.ai-cs-input-area {
    padding: 12px 16px;
    background: #fff;
    border-top: 1px solid #e2e8f0;
    display: flex;
    gap: 8px;
    align-items: flex-end;
}

.ai-cs-input-wrapper {
    flex: 1;
    position: relative;
}

.ai-cs-input {
    width: 100%;
    min-height: 40px;
    max-height: 100px;
    padding: 10px 36px 10px 14px;
    border: 1px solid #e2e8f0;
    border-radius: 20px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: all 0.2s;
    background: #f7fafc;
    line-height: 1.4;
}

.ai-cs-input:focus {
    border-color: #4fc3f7;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(79, 195, 247, 0.1);
}

.ai-cs-input::placeholder {
    color: #a0aec0;
}

.ai-cs-voice-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    color: #a0aec0;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.ai-cs-voice-btn:hover {
    color: #4fc3f7;
    background: #ebf8ff;
}

.ai-cs-voice-btn.recording {
    color: #ff4757;
    animation: ai-cs-record-pulse 1s infinite;
}

@keyframes ai-cs-record-pulse {
    0%, 100% { transform: translateY(-50%) scale(1); }
    50% { transform: translateY(-50%) scale(1.2); }
}

.ai-cs-send-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4fc3f7, #29b6f6);
    border: none;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.ai-cs-send-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 4px 12px rgba(79, 195, 247, 0.4);
}

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

.ai-cs-send-btn:disabled {
    background: #cbd5e0;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* 欢迎消息卡片 */
.ai-cs-welcome-card {
    background: linear-gradient(135deg, #ebf8ff 0%, #e6fffa 100%);
    border-radius: 12px;
    padding: 14px;
    margin-bottom: 8px;
}

.ai-cs-welcome-title {
    font-size: 14px;
    font-weight: 600;
    color: #2b6cb0;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.ai-cs-welcome-desc {
    font-size: 12px;
    color: #4a5568;
    line-height: 1.6;
    margin-bottom: 10px;
}

.ai-cs-welcome-features {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 6px;
}

.ai-cs-feature-item {
    display: flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: #718096;
}

.ai-cs-feature-item .icon {
    font-size: 14px;
}

/* 响应式 */
@media (max-width: 480px) {
    .ai-cs-window {
        width: calc(100vw - 32px);
        height: calc(100vh - 140px);
        right: 16px;
        bottom: 84px;
        max-height: 700px;
    }
    
    .ai-cs-fab {
        width: 56px;
        height: 56px;
        bottom: 16px;
        right: 16px;
    }
    
    .ai-cs-fab-avatar {
        width: 42px;
        height: 42px;
        font-size: 24px;
    }
}

/* 深色模式适配 */
@media (prefers-color-scheme: dark) {
    .ai-cs-window {
        background: #1a202c;
    }
    
    .ai-cs-quick-questions {
        background: #2d3748;
        border-color: #4a5568;
    }
    
    .ai-cs-quick-btn {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .ai-cs-messages {
        background: #1a202c;
    }
    
    .ai-cs-message.ai .ai-cs-message-bubble {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .ai-cs-input-area {
        background: #1a202c;
        border-color: #4a5568;
    }
    
    .ai-cs-input {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .ai-cs-input:focus {
        background: #2d3748;
    }
}
