/**
 * 学霸网 AI 客服聊天组件样式
 */

/* 聊天组件容器 */
.xueba-ai-chat-widget {
    position: fixed;
    right: 20px;
    top: 50%;
    transform: translateY(-50%);
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 聊天图标按钮 */
.xueba-ai-chat-icon {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
}

.xueba-ai-chat-icon:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.xueba-ai-chat-icon svg {
    width: 30px;
    height: 30px;
    fill: white;
}

/* 未读消息提示 */
.xueba-ai-chat-badge {
    position: absolute;
    top: -5px;
    right: -5px;
    width: 20px;
    height: 20px;
    background: #ff4757;
    border-radius: 50%;
    color: white;
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    display: none;
}

.xueba-ai-chat-badge.show {
    display: flex;
}

/* 聊天窗口 */
.xueba-ai-chat-window {
    position: absolute;
    right: 80px;
    top: 50%;
    transform: translateY(-50%);
    width: 380px;
    height: 550px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-50%) scale(0.9);
    transition: all 0.3s ease;
}

.xueba-ai-chat-window.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(-50%) scale(1);
}

/* 聊天头部 */
.xueba-ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.xueba-ai-chat-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.xueba-ai-chat-avatar {
    width: 44px;
    height: 44px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.xueba-ai-chat-avatar svg {
    width: 28px;
    height: 28px;
    fill: #667eea;
}

.xueba-ai-chat-title {
    flex: 1;
}

.xueba-ai-chat-title h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.xueba-ai-chat-title p {
    margin: 2px 0 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.xueba-ai-chat-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
}

.xueba-ai-chat-status-dot {
    width: 8px;
    height: 8px;
    background: #2ecc71;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(46, 204, 113, 0); }
    100% { box-shadow: 0 0 0 0 rgba(46, 204, 113, 0); }
}

.xueba-ai-chat-close {
    width: 32px;
    height: 32px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.xueba-ai-chat-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

.xueba-ai-chat-close svg {
    width: 16px;
    height: 16px;
    fill: white;
}

/* 聊天消息区域 */
.xueba-ai-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.xueba-ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.xueba-ai-chat-messages::-webkit-scrollbar-track {
    background: transparent;
}

.xueba-ai-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

/* 消息气泡 */
.xueba-ai-message {
    display: flex;
    margin-bottom: 16px;
    animation: messageSlide 0.3s ease;
}

@keyframes messageSlide {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.xueba-ai-message.user {
    justify-content: flex-end;
}

.xueba-ai-message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 10px;
}

.xueba-ai-message.bot .xueba-ai-message-avatar {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.xueba-ai-message.user .xueba-ai-message-avatar {
    background: #e3f2fd;
    margin-right: 0;
    margin-left: 10px;
    order: 2;
}

.xueba-ai-message-avatar svg {
    width: 20px;
    height: 20px;
    fill: white;
}

.xueba-ai-message.user .xueba-ai-message-avatar svg {
    fill: #667eea;
}

.xueba-ai-message-content {
    max-width: 75%;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.xueba-ai-message.bot .xueba-ai-message-content {
    background: white;
    color: #333;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.xueba-ai-message.user .xueba-ai-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border-bottom-right-radius: 4px;
    order: 1;
}

.xueba-ai-message-content a {
    color: #667eea;
    text-decoration: none;
    font-weight: 500;
}

.xueba-ai-message-content a:hover {
    text-decoration: underline;
}

.xueba-ai-message.user .xueba-ai-message-content a {
    color: #ffd700;
}

.xueba-ai-message-time {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
    text-align: right;
}

.xueba-ai-message.bot .xueba-ai-message-time {
    text-align: left;
    margin-left: 46px;
}

/* 加载动画 */
.xueba-ai-message-loading {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 16px;
}

.xueba-ai-message-loading span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: loadingBounce 1.4s infinite ease-in-out both;
}

.xueba-ai-message-loading span:nth-child(1) {
    animation-delay: -0.32s;
}

.xueba-ai-message-loading span:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes loadingBounce {
    0%, 80%, 100% {
        transform: scale(0);
    }
    40% {
        transform: scale(1);
    }
}

/* 反馈按钮 */
.xueba-ai-feedback {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-top: 8px;
    margin-left: 46px;
    padding: 8px 12px;
    background: #f8f9fa;
    border-radius: 12px;
    font-size: 12px;
    color: #666;
}

.xueba-ai-feedback-text {
    margin-right: 4px;
}

.xueba-ai-feedback-btn {
    background: none;
    border: none;
    cursor: pointer;
    font-size: 16px;
    padding: 4px 8px;
    border-radius: 50%;
    transition: all 0.2s ease;
    opacity: 0.7;
}

.xueba-ai-feedback-btn:hover {
    opacity: 1;
    background: #e9ecef;
    transform: scale(1.1);
}

.xueba-ai-feedback-btn.helpful:hover {
    background: #d4edda;
}

.xueba-ai-feedback-btn.unhelpful:hover {
    background: #f8d7da;
}

.xueba-ai-feedback-thanks {
    color: #28a745;
    font-size: 12px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* 快速回复按钮 */
.xueba-ai-quick-replies {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    margin-left: 46px;
}

.xueba-ai-quick-reply {
    padding: 8px 14px;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 16px;
    font-size: 13px;
    color: #667eea;
    cursor: pointer;
    transition: all 0.2s ease;
}

.xueba-ai-quick-reply:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

/* 输入区域 */
.xueba-ai-chat-input-area {
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e8e8e8;
}

.xueba-ai-chat-input-wrapper {
    display: flex;
    align-items: center;
    gap: 10px;
    background: #f5f5f5;
    border-radius: 24px;
    padding: 6px 6px 6px 16px;
}

.xueba-ai-chat-input {
    flex: 1;
    border: none;
    background: transparent;
    font-size: 14px;
    outline: none;
    padding: 8px 0;
    resize: none;
    max-height: 100px;
    font-family: inherit;
}

.xueba-ai-chat-input::placeholder {
    color: #999;
}

.xueba-ai-chat-send {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    flex-shrink: 0;
}

.xueba-ai-chat-send:hover {
    transform: scale(1.05);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.4);
}

.xueba-ai-chat-send:disabled {
    background: #ccc;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.xueba-ai-chat-send svg {
    width: 18px;
    height: 18px;
    fill: white;
}

/* 底部提示 */
.xueba-ai-chat-footer {
    padding: 8px 20px;
    background: #f8f9fa;
    border-top: 1px solid #e8e8e8;
    text-align: center;
    font-size: 12px;
    color: #999;
}

.xueba-ai-chat-footer a {
    color: #667eea;
    text-decoration: none;
}

/* 课程卡片 */
.xueba-ai-course-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 10px;
}

.xueba-ai-course-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
    background: #f8f9fa;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.xueba-ai-course-item:hover {
    background: #e3f2fd;
}

.xueba-ai-course-thumb {
    width: 60px;
    height: 45px;
    border-radius: 4px;
    object-fit: cover;
    background: #ddd;
}

.xueba-ai-course-info {
    flex: 1;
    min-width: 0;
}

.xueba-ai-course-title {
    font-size: 13px;
    font-weight: 500;
    color: #333;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.xueba-ai-course-meta {
    font-size: 11px;
    color: #999;
    margin-top: 4px;
}

/* 响应式设计 */
@media (max-width: 480px) {
    .xueba-ai-chat-widget {
        right: 15px;
    }
    
    .xueba-ai-chat-window {
        position: fixed;
        right: 0;
        left: 0;
        top: auto;
        bottom: 0;
        width: 100%;
        height: 80vh;
        border-radius: 16px 16px 0 0;
        transform: translateY(100%);
    }
    
    .xueba-ai-chat-window.active {
        transform: translateY(0);
    }
    
    .xueba-ai-chat-icon {
        width: 50px;
        height: 50px;
    }
    
    .xueba-ai-chat-icon svg {
        width: 24px;
        height: 24px;
    }
}

/* 动画效果 */
.xueba-ai-chat-icon {
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% {
        transform: translateY(0);
    }
    50% {
        transform: translateY(-5px);
    }
}

/* 提示消息 */
.xueba-ai-toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%) translateY(-100px);
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 1000000;
    opacity: 0;
    transition: all 0.3s ease;
}

.xueba-ai-toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

/* 欢迎消息样式 */
.xueba-ai-welcome-message {
    background: linear-gradient(135deg, #667eea15 0%, #764ba215 100%);
    border-left: 3px solid #667eea;
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 16px;
}

.xueba-ai-welcome-message p {
    margin: 0;
    font-size: 14px;
    color: #333;
    line-height: 1.6;
}

/* 热门推荐区域 */
.xueba-ai-hot-courses {
    margin: 16px 0;
    padding: 12px;
    background: linear-gradient(135deg, #fff9e6 0%, #fff5d6 100%);
    border-radius: 12px;
    border: 1px solid #ffe4b5;
}

.xueba-ai-hot-courses-title {
    font-size: 14px;
    font-weight: 600;
    color: #ff8c00;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.xueba-ai-hot-courses-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.xueba-ai-hot-course-item {
    display: block;
    padding: 10px 12px;
    background: white;
    border-radius: 8px;
    text-decoration: none;
    transition: all 0.2s ease;
    border: 1px solid #f0f0f0;
}

.xueba-ai-hot-course-item:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    border-color: #667eea;
}

.xueba-ai-hot-course-title {
    font-size: 13px;
    color: #333;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.xueba-ai-hot-course-meta {
    font-size: 11px;
    color: #999;
    display: flex;
    gap: 12px;
}

.xueba-ai-hot-course-meta span {
    display: flex;
    align-items: center;
    gap: 3px;
}