/**
 * AI Assistant 样式
 * 版本: 2.0.0
 */

/* 主容器 */
.ai-assistant-widget {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 999999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* 浮动按钮 */
.ai-assistant-float-btn {
    position: fixed;
    bottom: 20px;
    right: 20px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    font-size: 24px;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.2);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 999999;
}

.ai-assistant-float-btn:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.3);
}

.ai-assistant-float-btn:active {
    transform: scale(0.95);
}

/* 聊天窗口 */
.ai-assistant-chat-window {
    position: fixed;
    bottom: 90px;
    right: 20px;
    width: 380px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 999998;
}

.ai-assistant-chat-window.open {
    display: flex;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* 聊天头部 */
.ai-assistant-chat-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 16px 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.ai-assistant-avatar {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.ai-assistant-info {
    flex: 1;
}

.ai-assistant-info h3 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
}

.ai-assistant-status {
    margin: 2px 0 0;
    font-size: 12px;
    opacity: 0.9;
}

.ai-assistant-btn-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    transition: background 0.2s;
}

.ai-assistant-btn-close:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 聊天主体 */
.ai-assistant-chat-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.ai-assistant-welcome-message {
    padding: 20px;
    text-align: center;
    background: #f8f9fa;
    border-bottom: 1px solid #e9ecef;
}

.ai-assistant-welcome-message p {
    margin: 0 0 8px;
    color: #495057;
    font-size: 14px;
}

.ai-assistant-tips {
    font-size: 12px !important;
    color: #6c757d !important;
    margin-top: 8px !important;
}

/* 消息容器 */
.ai-assistant-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

/* 消息样式 */
.ai-assistant-message {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    animation: messageAppear 0.3s ease;
}

@keyframes messageAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-assistant-message-avatar {
    width: 32px;
    height: 32px;
    background: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    flex-shrink: 0;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.ai-assistant-message-user .ai-assistant-message-avatar {
    background: #e3f2fd;
}

.ai-assistant-message-ai .ai-assistant-message-avatar {
    background: #f3e5f5;
}

.ai-assistant-message-content {
    flex: 1;
}

.ai-assistant-message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    font-size: 14px;
    line-height: 1.5;
    color: #212529;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.ai-assistant-message-user .ai-assistant-message-text {
    background: #007bff;
    color: white;
    border-bottom-right-radius: 4px;
}

.ai-assistant-message-ai .ai-assistant-message-text {
    background: white;
    color: #212529;
    border-bottom-left-radius: 4px;
}

.ai-assistant-message-text code {
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'Courier New', monospace;
    font-size: 13px;
    color: #e83e8c;
}

.ai-assistant-message-text a {
    color: #007bff;
    text-decoration: none;
}

.ai-assistant-message-text a:hover {
    text-decoration: underline;
}

/* 输入区域 */
.ai-assistant-input-area {
    border-top: 1px solid #e9ecef;
    background: white;
    padding: 16px;
}

.ai-assistant-input-container {
    display: flex;
    gap: 8px;
    margin-bottom: 8px;
}

.ai-assistant-input {
    flex: 1;
    border: 1px solid #dee2e6;
    border-radius: 24px;
    padding: 12px 16px;
    font-size: 14px;
    line-height: 1.5;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
    max-height: 120px;
    overflow-y: auto;
}

.ai-assistant-input:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.ai-assistant-input::placeholder {
    color: #6c757d;
}

.ai-assistant-btn-send {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 24px;
    padding: 0 24px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 80px;
}

.ai-assistant-btn-send:hover:not(.disabled) {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.ai-assistant-btn-send.disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.ai-assistant-input-actions {
    display: flex;
    gap: 8px;
    justify-content: flex-end;
}

.ai-assistant-btn-action {
    background: none;
    border: 1px solid #dee2e6;
    color: #6c757d;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 14px;
}

.ai-assistant-btn-action:hover {
    background: #f8f9fa;
    border-color: #adb5bd;
    color: #495057;
}

/* 加载动画 */
.ai-assistant-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000000;
}

.ai-assistant-loading-content {
    background: white;
    padding: 30px 40px;
    border-radius: 12px;
    text-align: center;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
}

.ai-assistant-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid #e0e0e0;
    border-top-color: #007bff;
    border-radius: 50%;
    animation: ai-spinner 1s linear infinite;
    margin: 0 auto 20px;
}

@keyframes ai-spinner {
    to { transform: rotate(360deg); }
}

/* 临时消息 */
.ai-assistant-temp-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    font-size: 14px;
    z-index: 1000001;
    animation: slideDown 0.3s ease;
    max-width: 300px;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.ai-assistant-temp-message.success {
    background: #d4edda;
    color: #155724;
    border-left: 4px solid #28a745;
}

.ai-assistant-temp-message.error {
    background: #f8d7da;
    color: #721c24;
    border-left: 4px solid #dc3545;
}

.ai-assistant-temp-message.warning {
    background: #fff3cd;
    color: #856404;
    border-left: 4px solid #ffc107;
}

.ai-assistant-temp-message.info {
    background: #d1ecf1;
    color: #0c5460;
    border-left: 4px solid #17a2b8;
}

/* 滚动条样式 */
.ai-assistant-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-assistant-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 3px;
}

.ai-assistant-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ai-assistant-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .ai-assistant-chat-window {
        width: calc(100vw - 40px);
        height: calc(100vh - 100px);
        bottom: 80px;
        right: 20px;
        left: 20px;
        max-width: 400px;
        margin: 0 auto;
    }
    
    .ai-assistant-float-btn {
        width: 50px;
        height: 50px;
        bottom: 15px;
        right: 15px;
    }
    
    .ai-assistant-float-icon {
        font-size: 20px;
    }
}

@media (max-width: 480px) {
    .ai-assistant-chat-window {
        width: calc(100vw - 20px);
        right: 10px;
        left: 10px;
    }
    
    .ai-assistant-message-text {
        font-size: 13px;
        padding: 10px 14px;
    }
    
    .ai-assistant-input {
        font-size: 13px;
    }
}

/* 深色模式支持 */
@media (prefers-color-scheme: dark) {
    .ai-assistant-chat-window {
        background: #2d3748;
        color: #e2e8f0;
    }
    
    .ai-assistant-messages {
        background: #1a202c;
    }
    
    .ai-assistant-message-text {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .ai-assistant-message-user .ai-assistant-message-text {
        background: #2b6cb0;
        color: white;
    }
    
    .ai-assistant-message-ai .ai-assistant-message-avatar {
        background: #553c9a;
    }
    
    .ai-assistant-input-area {
        background: #2d3748;
        border-top-color: #4a5568;
    }
    
    .ai-assistant-input {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .ai-assistant-input:focus {
        border-color: #63b3ed;
        box-shadow: 0 0 0 3px rgba(99, 179, 237, 0.1);
    }
    
    .ai-assistant-input::placeholder {
        color: #a0aec0;
    }
    
    .ai-assistant-welcome-message {
        background: #2d3748;
        color: #a0aec0;
        border-bottom-color: #4a5568;
    }
    
    .ai-assistant-btn-action {
        background: #4a5568;
        border-color: #718096;
        color: #e2e8f0;
    }
    
    .ai-assistant-btn-action:hover {
        background: #5a6578;
    }
    
    .ai-assistant-temp-message {
        background: #4a5568;
        color: #e2e8f0;
    }
}

/* 打印模式隐藏 */
@media print {
    .ai-assistant-widget {
        display: none !important;
    }
}