/**
 * 聊天机器人组件样式
 */

/* 主容器 */
.chatbot-widget {
    position: fixed;
    z-index: 10001;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* 最小化状态 */
.chatbot-minimized {
    display: none;
    align-items: center;
    justify-content: center;
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    cursor: pointer;
    transition: transform 0.2s, box-shadow 0.2s;
}

.chatbot-minimized:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2);
}

.chatbot-restore-btn {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* 聊天面板 */
.chatbot-panel {
    display: flex;
    flex-direction: column;
    width: 400px;
    height: 600px;
    background: white;
    border-radius: 12px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.12);
    overflow: hidden;
}

/* 标题栏 */
.chatbot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    cursor: grab;
    user-select: none;
}

.chatbot-header:active {
    cursor: grabbing;
}

.chatbot-title {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 16px;
    font-weight: 600;
}

.chatbot-actions {
    display: flex;
    gap: 8px;
}

.chatbot-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 6px;
    color: white;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chatbot-btn:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* 消息区域 */
.chatbot-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
}

.chatbot-messages::-webkit-scrollbar {
    width: 6px;
}

.chatbot-messages::-webkit-scrollbar-track {
    background: transparent;
}

.chatbot-messages::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 3px;
}

.chatbot-messages::-webkit-scrollbar-thumb:hover {
    background: #a0aec0;
}

/* 欢迎消息 */
.chatbot-welcome {
    text-align: center;
    padding: 40px 20px;
}

.chatbot-welcome-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.chatbot-welcome-text h3 {
    font-size: 18px;
    font-weight: 600;
    color: #2d3748;
    margin: 0 0 12px 0;
}

.chatbot-welcome-text p {
    font-size: 14px;
    color: #718096;
    line-height: 1.6;
    margin: 8px 0;
}

.chatbot-tip {
    background: #edf2f7;
    border-left: 3px solid #667eea;
    padding: 8px 12px;
    border-radius: 4px;
    margin-top: 16px !important;
}

/* 消息气泡 */
.chatbot-message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: fadeIn 0.3s ease-in;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.chatbot-message-avatar {
    flex-shrink: 0;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    background: white;
}

.chatbot-message-content {
    flex: 1;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.6;
    word-wrap: break-word;
}

.chatbot-message-user .chatbot-message-content {
    background: #667eea;
    color: white;
    border-bottom-right-radius: 4px;
}

.chatbot-message-system .chatbot-message-content {
    background: white;
    color: #2d3748;
    border: 1px solid #e2e8f0;
    border-bottom-left-radius: 4px;
}

/* AI 简洁回答样式 */
.chatbot-answer .chatbot-message-content {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    padding: 16px;
}

.chatbot-answer-label {
    font-size: 11px;
    opacity: 0.9;
    margin-bottom: 8px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chatbot-answer-text {
    font-size: 16px;
    font-weight: 600;
    line-height: 1.6;
}

/* 检索结果样式 */
.chatbot-result .chatbot-message-content {
    padding: 0;
    overflow: hidden;
}

.chatbot-result-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: #f7fafc;
}

.chatbot-result-source {
    font-weight: 600;
    color: #2d3748;
    font-size: 13px;
}

.chatbot-result-similarity {
    font-size: 12px;
    color: #48bb78;
    font-weight: 500;
}

.chatbot-result-similarity.weak {
    color: #ed8936;
}

.chatbot-result-divider {
    height: 1px;
    background: #e2e8f0;
}

.chatbot-result-content {
    padding: 16px;
    color: #2d3748;
    line-height: 1.8;
}

.chatbot-result-actions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: #f7fafc;
    border-top: 1px solid #e2e8f0;
}

.chatbot-result-btn {
    flex: 1;
    padding: 8px 12px;
    background: white;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    color: #4a5568;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
}

.chatbot-result-btn:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* 快捷问题 */
.chatbot-quick-questions {
    padding: 12px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.chatbot-quick-title {
    font-size: 12px;
    font-weight: 600;
    color: #718096;
    margin-bottom: 8px;
}

.chatbot-quick-list {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.chatbot-quick-btn {
    padding: 6px 12px;
    background: #edf2f7;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    color: #4a5568;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.chatbot-quick-btn:hover {
    background: #667eea;
    border-color: #667eea;
    color: white;
}

/* 输入区域 */
.chatbot-input-area {
    display: flex;
    align-items: flex-end;
    gap: 8px;
    padding: 16px 20px;
    background: white;
    border-top: 1px solid #e2e8f0;
}

.chatbot-input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid #cbd5e0;
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    max-height: 100px;
    overflow-y: auto;
}

.chatbot-input:focus {
    border-color: #667eea;
}

.chatbot-input::-webkit-scrollbar {
    width: 4px;
}

.chatbot-input::-webkit-scrollbar-thumb {
    background: #cbd5e0;
    border-radius: 2px;
}

.chatbot-send-btn {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    background: #667eea;
    border: none;
    border-radius: 8px;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chatbot-send-btn:hover {
    background: #5a67d8;
}

.chatbot-send-btn:active {
    transform: scale(0.95);
}

/* 状态栏 */
.chatbot-status {
    padding: 8px 20px;
    background: #edf2f7;
    border-top: 1px solid #e2e8f0;
    font-size: 13px;
    color: #4a5568;
    text-align: center;
}

/* 响应式 */
@media (max-width: 768px) {
    .chatbot-panel {
        width: 100vw;
        height: 100vh;
        border-radius: 0;
    }

    .chatbot-widget {
        left: 0 !important;
        top: 0 !important;
    }

    .chatbot-header {
        cursor: default;
    }
}

/* 暗色模式支持 */
@media (prefers-color-scheme: dark) {
    .chatbot-panel {
        background: #1a202c;
    }

    .chatbot-messages {
        background: #2d3748;
    }

    .chatbot-message-system .chatbot-message-content {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .chatbot-result-header,
    .chatbot-result-actions {
        background: #1a202c;
    }

    .chatbot-result-source {
        color: #e2e8f0;
    }

    .chatbot-result-content {
        color: #e2e8f0;
    }

    .chatbot-result-divider {
        background: #4a5568;
    }

    .chatbot-quick-questions,
    .chatbot-input-area {
        background: #1a202c;
        border-top-color: #4a5568;
    }

    .chatbot-quick-btn {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .chatbot-input {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .chatbot-result-btn {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }

    .chatbot-status {
        background: #1a202c;
        border-top-color: #4a5568;
        color: #a0aec0;
    }

    .chatbot-welcome-text h3 {
        color: #e2e8f0;
    }

    .chatbot-welcome-text p {
        color: #a0aec0;
    }

    .chatbot-tip {
        background: #2d3748;
        border-left-color: #667eea;
    }
}

/* 拟态弹窗动画 */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}
