/* AI助手样式 */

/* 浮动按钮 */
.ai-float-btn {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    cursor: move; /* 改为move，提示可拖拽 */
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    border: 3px solid white;
    user-select: none; /* 防止拖拽时选中文本 */
}

/* 头部操作按钮 */
.ai-header-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.ai-action-btn {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background 0.3s;
}

.ai-action-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* 图表容器 */
.ai-chart-container {
    margin: 15px 0;
    padding: 15px;
    background: #f8f9fa;
    border-radius: 8px;
    border: 1px solid #e9ecef;
}

.ai-chart-container canvas {
    max-width: 100%;
    height: auto !important;
}

.ai-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 30px rgba(102, 126, 234, 0.6);
}

.ai-float-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
}

/* 通知红点 */
.ai-notification-dot {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #ff4757;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 11px;
    font-weight: bold;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.2); }
}

/* 对话窗口 */
.ai-chat-window {
    position: fixed;
    bottom: 100px;
    right: 30px;
    width: 380px;
    height: 600px;
    min-width: 300px;
    min-height: 400px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    z-index: 99998;
    display: none;
    flex-direction: column;
    overflow: hidden;
    border: 2px solid #e0e0e0;
    animation: slideUp 0.3s ease;
    cursor: default;
    /* 允许调整大小 */
    resize: both;
}

/* 拖动时鼠标样式 */
.ai-chat-window.dragging {
    cursor: move;
    opacity: 0.9;
}

/* 调整大小时鼠标样式 */
.ai-chat-window:active {
    cursor: nwse-resize;
}

/* 自定义调整大小手柄 */
.ai-resize-handle {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 20px;
    height: 20px;
    cursor: nwse-resize;
    background: linear-gradient(135deg, transparent 50%, #667eea 50%);
    border-bottom-right-radius: 18px;
}

/* 拖动时鼠标样式 */
.ai-chat-window.dragging {
    cursor: move;
    opacity: 0.9;
}

/* 头部可拖动区域 */
.ai-chat-header {
    cursor: move;
    user-select: none;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 头部 */
.ai-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 15px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}

.ai-header-avatar {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    border: 2px solid white;
    background: white;
}

.ai-header-info {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.ai-header-name {
    font-size: 16px;
    font-weight: bold;
}

.ai-header-status {
    font-size: 12px;
    opacity: 0.9;
}

.ai-close-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 24px;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-close-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 消息区域 */
.ai-chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    background: #f8f9fa;
    background-image: 
        radial-gradient(circle at 20% 50%, rgba(102, 126, 234, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(118, 75, 162, 0.05) 0%, transparent 50%);
}

.ai-message {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.ai-message-bot {
    flex-direction: row;
}

.ai-message-user {
    flex-direction: row-reverse;
}

.ai-msg-avatar {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    flex-shrink: 0;
}

.ai-msg-content {
    max-width: 75%;
}

.ai-msg-text {
    background: white;
    padding: 10px 15px;
    border-radius: 18px;
    margin-bottom: 5px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    line-height: 1.5;
    font-size: 14px;
}

.ai-message-user .ai-msg-text {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

/* 输入区域 */
.ai-chat-input-area {
    padding: 15px;
    background: white;
    border-top: 1px solid #e0e0e0;
}

.ai-quick-actions {
    display: flex;
    gap: 8px;
    margin-bottom: 10px;
    flex-wrap: wrap;
}

.ai-quick-btn {
    padding: 6px 12px;
    border: 1px solid #667eea;
    background: white;
    color: #667eea;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-quick-btn:hover {
    background: #667eea;
    color: white;
}

.ai-input-wrapper {
    display: flex;
    gap: 10px;
}

#ai-input {
    flex: 1;
    padding: 10px 15px;
    border: 2px solid #e0e0e0;
    border-radius: 25px;
    outline: none;
    font-size: 14px;
    transition: border-color 0.3s;
}

#ai-input:focus {
    border-color: #667eea;
}

.ai-send-btn {
    padding: 10px 20px;
    border: none;
    border-radius: 25px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: pointer;
    font-size: 14px;
    font-weight: bold;
    transition: all 0.2s;
}

.ai-send-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
}

.ai-send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* 加载动画 */
.ai-typing-indicator {
    display: flex;
    gap: 5px;
    padding: 10px 15px;
    background: white;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    width: fit-content;
}

.ai-typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #667eea;
    animation: typingBounce 1.4s infinite;
}

.ai-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.ai-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typingBounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

/* 响应式设计 */
@media (max-width: 480px) {
    .ai-chat-window {
        width: calc(100vw - 20px);
        right: 10px;
        bottom: 80px;
        height: calc(100vh - 100px);
    }
    
    .ai-float-btn {
        bottom: 20px;
        right: 20px;
    }
}

/* 任务完成通知 */
.ai-task-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    animation: slideInRight 0.3s ease;
    cursor: pointer;
    max-width: 350px;
    border-left: 4px solid #4caf50;
}

.ai-notification-content {
    display: flex;
    align-items: center;
    padding: 15px;
    gap: 12px;
}

.ai-notification-icon {
    font-size: 24px;
}

.ai-notification-text {
    flex: 1;
}

.ai-notification-title {
    font-weight: bold;
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
}

.ai-notification-message {
    font-size: 13px;
    color: #666;
}

.ai-notification-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-notification-close:hover {
    color: #333;
}

.ai-notification-hide {
    animation: slideOutRight 0.3s ease;
}

@keyframes slideInRight {
    from {
        opacity: 0;
        transform: translateX(100px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes slideOutRight {
    from {
        opacity: 1;
        transform: translateX(0);
    }
    to {
        opacity: 0;
        transform: translateX(100px);
    }
}

/* 欢迎提示 */
.ai-welcome-tip {
    position: fixed;
    bottom: 100px;
    right: 30px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.2);
    z-index: 99999;
    animation: fadeInUp 0.3s ease;
    cursor: pointer;
    max-width: 300px;
    border-left: 4px solid #667eea;
}

.ai-tip-content {
    display: flex;
    align-items: center;
    padding: 15px;
    gap: 12px;
}

.ai-tip-icon {
    font-size: 24px;
}

.ai-tip-text {
    flex: 1;
}

.ai-tip-title {
    font-weight: bold;
    font-size: 14px;
    color: #333;
    margin-bottom: 4px;
}

.ai-tip-message {
    font-size: 13px;
    color: #666;
}

.ai-tip-close {
    background: none;
    border: none;
    font-size: 20px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.ai-tip-close:hover {
    color: #333;
}

.ai-tip-hide {
    animation: fadeOut 0.3s ease;
}

/* Markdown 内容样式 */
.ai-msg-text table {
    border-collapse: collapse;
    width: 100%;
    margin: 10px 0;
    font-size: 13px;
}

.ai-msg-text table th,
.ai-msg-text table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
}

.ai-msg-text table th {
    background-color: #667eea;
    color: white;
    font-weight: bold;
}

.ai-msg-text table tr:nth-child(even) {
    background-color: #f9f9f9;
}

.ai-msg-text table tr:hover {
    background-color: #f5f5f5;
}

.ai-msg-text code {
    background-color: #f4f4f4;
    padding: 2px 6px;
    border-radius: 3px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
}

.ai-msg-text pre {
    background-color: #f4f4f4;
    padding: 10px;
    border-radius: 5px;
    overflow-x: auto;
    margin: 10px 0;
}

.ai-msg-text pre code {
    background: none;
    padding: 0;
}

.ai-msg-text h1,
.ai-msg-text h2,
.ai-msg-text h3 {
    margin-top: 15px;
    margin-bottom: 10px;
    color: #333;
}

.ai-msg-text h1 {
    font-size: 20px;
    border-bottom: 2px solid #667eea;
    padding-bottom: 5px;
}

.ai-msg-text h2 {
    font-size: 18px;
}

.ai-msg-text h3 {
    font-size: 16px;
}

.ai-msg-text ul,
.ai-msg-text ol {
    margin: 10px 0;
    padding-left: 30px;
}

.ai-msg-text li {
    margin: 5px 0;
}

.ai-msg-text blockquote {
    border-left: 4px solid #667eea;
    padding-left: 15px;
    margin: 10px 0;
    color: #666;
    font-style: italic;
}

.ai-msg-text a {
    color: #667eea;
    text-decoration: none;
}

.ai-msg-text a:hover {
    text-decoration: underline;
}

.ai-msg-text img {
    max-width: 100%;
    border-radius: 5px;
    margin: 10px 0;
}

/* 复制按钮 */
.ai-copy-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(102, 126, 234, 0.8);
    color: white;
    border: none;
    border-radius: 3px;
    padding: 5px 10px;
    font-size: 12px;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.3s;
}

.ai-message:hover .ai-copy-btn {
    opacity: 1;
}

.ai-copy-btn:hover {
    background: #667eea;
}

/* 图表容器样式 */
.ai-chart-container {
    margin: 15px 0;
    padding: 15px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-height: 300px;
    overflow: hidden;
}

.ai-chart-container canvas {
    max-width: 100%;
    max-height: 250px;
}

/* 消息操作按钮 */
.ai-msg-actions {
    display: flex;
    gap: 5px;
    margin-top: 8px;
    opacity: 0;
    transition: opacity 0.3s;
}

.ai-message:hover .ai-msg-actions {
    opacity: 1;
}

.ai-msg-action-btn {
    background: none;
    border: 1px solid #ddd;
    border-radius: 3px;
    padding: 3px 8px;
    font-size: 12px;
    cursor: pointer;
    color: #666;
    transition: all 0.3s;
}

.ai-msg-action-btn:hover {
    background: #667eea;
    color: white;
    border-color: #667eea;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeOut {
    from {
        opacity: 1;
        transform: translateY(0);
    }
    to {
        opacity: 0;
        transform: translateY(20px);
    }
}

/* 正在思考动画 */
.ai-thinking-dots {
    background: white;
    padding: 15px 20px;
    border-radius: 18px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

.ai-thinking-dots span {
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    animation: ai-thinking 1.4s infinite ease-in-out both;
}

.ai-thinking-dots span:nth-child(1) {
    animation-delay: -0.32s;
}

.ai-thinking-dots span:nth-child(2) {
    animation-delay: -0.16s;
}

.ai-thinking-dots span:nth-child(3) {
    animation-delay: 0s;
}

@keyframes ai-thinking {
    0%, 80%, 100% {
        transform: scale(0.6);
        opacity: 0.4;
    }
    40% {
        transform: scale(1);
        opacity: 1;
    }
}

/* 流式输出光标闪烁效果 */
.ai-streaming-cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    background: #667eea;
    margin-left: 2px;
    animation: cursor-blink 1s infinite;
}

@keyframes cursor-blink {
    0%, 50% {
        opacity: 1;
    }
    51%, 100% {
        opacity: 0;
    }
}

/* 文件下载区域 */
.ai-file-download {
    margin: 10px 0;
    padding: 10px;
    background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
    border-radius: 8px;
    border: 1px solid #e1e8ed;
}

/* 下载按钮 */
.ai-download-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.3);
}

.ai-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    background: linear-gradient(135deg, #764ba2 0%, #667eea 100%);
}

.ai-download-btn:active {
    transform: translateY(0);
    box-shadow: 0 2px 6px rgba(102, 126, 234, 0.3);
}

.ai-download-btn::before {
    content: "📥";
    font-size: 16px;
}

/* 语音输入按钮 */
.ai-voice-btn {
    padding: 10px 15px;
    border: 2px solid #667eea;
    border-radius: 25px;
    background: white;
    color: #667eea;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

.ai-voice-btn:hover {
    background: #667eea;
    color: white;
    transform: scale(1.05);
}

.ai-voice-btn.ai-voice-active {
    background: #ff4757;
    color: white;
    border-color: #ff4757;
    animation: voicePulse 1.5s infinite;
}

@keyframes voicePulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(255, 71, 87, 0);
    }
}

/* 语音播放按钮 */
.ai-speak-btn {
    padding: 10px 15px;
    border: 2px solid #667eea;
    border-radius: 25px;
    background: white;
    color: #667eea;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

.ai-speak-btn:hover {
    background: #667eea;
    color: white;
    transform: scale(1.05);
}

.ai-speak-btn.ai-speak-active {
    background: #4caf50;
    color: white;
    border-color: #4caf50;
    animation: speakPulse 1.5s infinite;
}

@keyframes speakPulse {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(76, 175, 80, 0.7);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(76, 175, 80, 0);
    }
}

/* 语音控制区域 */
.ai-voice-controls {
    display: flex;
    justify-content: center;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #e0e0e0;
}

.ai-voice-toggle {
    padding: 6px 12px;
    border: 1px solid #ddd;
    background: white;
    color: #666;
    border-radius: 15px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.ai-voice-toggle:hover {
    background: #f0f0f0;
    border-color: #667eea;
    color: #667eea;
}

/* 消息中的语音播放按钮 */
.ai-msg-speak-btn {
    background: none;
    border: none;
    font-size: 16px;
    cursor: pointer;
    padding: 5px;
    margin-left: 10px;
    opacity: 0.6;
    transition: opacity 0.3s;
}

.ai-msg-speak-btn:hover {
    opacity: 1;
}

.ai-message:hover .ai-msg-speak-btn {
    opacity: 1;
}

/* 图片上传按钮 */
.ai-image-btn {
    padding: 10px 15px;
    border: 2px solid #667eea;
    border-radius: 25px;
    background: white;
    color: #667eea;
    cursor: pointer;
    font-size: 18px;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 50px;
}

.ai-image-btn:hover {
    background: #667eea;
    color: white;
    transform: scale(1.05);
}

/* 图片预览 */
.ai-image-preview {
    max-width: 200px;
    max-height: 150px;
    border-radius: 8px;
    margin: 10px 0;
    border: 2px solid #e0e0e0;
}

.ai-image-preview-container {
    position: relative;
    display: inline-block;
    margin: 10px 0;
}

.ai-image-remove-btn {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(255, 0, 0, 0.8);
    color: white;
    border: none;
    border-radius: 50%;
    width: 25px;
    height: 25px;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
}
