/**
 * 全局样式
 */

/* 基础样式 */
* {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: #f5f5f5;
}

/* 动画 */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fade-in 0.3s ease-out;
}

@keyframes slide-in {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.animate-slide-in {
    animation: slide-in 0.3s ease-out;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

.animate-pulse {
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

.animate-spin {
    animation: spin 1s linear infinite;
}

/* 滚动条样式 */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

/* 卡片样式 */
.card {
    background: white;
    border-radius: 0.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    transition: box-shadow 0.3s;
}

.card:hover {
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 1rem;
    border-radius: 0.375rem;
    font-weight: 500;
    transition: all 0.2s;
    cursor: pointer;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #5a67d8 0%, #6b46c1 100%);
    transform: translateY(-1px);
}

.btn-secondary {
    background: #f3f4f6;
    color: #374151;
}

.btn-secondary:hover:not(:disabled) {
    background: #e5e7eb;
}

.btn-success {
    background: #10b981;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #059669;
}

.btn-danger {
    background: #ef4444;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #dc2626;
}

/* 输入框样式 */
input, textarea, select {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, textarea:focus, select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* 标签样式 */
.tag {
    display: inline-flex;
    align-items: center;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 500;
}

/* 导航样式 */
.nav-item {
    display: flex;
    align-items: center;
    padding: 0.75rem 1rem;
    color: #4b5563;
    border-radius: 0.5rem;
    transition: all 0.2s;
}

.nav-item:hover {
    background: #f3f4f6;
    color: #667eea;
}

.nav-item.active {
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    color: #667eea;
    font-weight: 500;
}

/* 模态框样式 */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 50;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s;
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: white;
    border-radius: 1rem;
    max-width: 90%;
    max-height: 90vh;
    overflow: auto;
    transform: scale(0.9);
    transition: transform 0.3s;
}

.modal-overlay.active .modal-content {
    transform: scale(1);
}

/* 表格样式 */
.table {
    width: 100%;
    border-collapse: collapse;
}

.table th, .table td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
}

.table th {
    background: #f9fafb;
    font-weight: 600;
    color: #374151;
}

.table tr:hover td {
    background: #f9fafb;
}

/* 知识图谱节点样式 */
.knowledge-node {
    padding: 0.75rem 1rem;
    background: white;
    border: 2px solid #e5e7eb;
    border-radius: 0.5rem;
    cursor: pointer;
    transition: all 0.2s;
}

.knowledge-node:hover {
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

.knowledge-node.completed {
    border-color: #10b981;
    background: #f0fdf4;
}

.knowledge-node.active {
    border-color: #667eea;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
}

/* 数字人样式 */
.digital-human {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 1000;
}

.digital-human-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
    transition: transform 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.digital-human-btn:hover {
    transform: scale(1.1);
}

.digital-human-panel {
    position: absolute;
    bottom: 70px;
    right: 0;
    width: 420px;
    max-height: 550px;
    background: white;
    border-radius: 1rem;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    transform: scale(0);
    transform-origin: bottom right;
    transition: transform 0.3s;
}

.digital-human-panel.active {
    transform: scale(1);
}

/* AI对话消息样式 */
.digital-human-panel .chat-message {
    font-size: 14px;
    line-height: 1.6;
}

.digital-human-panel #chatMessages {
    font-size: 14px;
}

.digital-human-panel #chatInput {
    font-size: 14px;
}

/* 进度条样式 */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* 关卡样式 */
.level-card {
    background: white;
    border-radius: 1rem;
    padding: 1.5rem;
    border: 2px solid #e5e7eb;
    transition: all 0.3s;
    cursor: pointer;
}

.level-card:hover {
    border-color: #667eea;
    transform: translateY(-4px);
    box-shadow: 0 10px 20px rgba(102, 126, 234, 0.2);
}

.level-card.locked {
    opacity: 0.6;
    cursor: not-allowed;
}

.level-card.completed {
    border-color: #10b981;
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.05) 0%, rgba(16, 185, 129, 0.1) 100%);
}

/* 响应式 */
@media (max-width: 768px) {
    .digital-human-panel {
        width: 300px;
        right: -10px;
    }
    
    .modal-content {
        max-width: 95%;
        margin: 1rem;
    }
}

/* 打印样式 */
@media print {
    .digital-human,
    .no-print {
        display: none !important;
    }
}

/* ========================================
   AI 对话框样式 - 知小行
   ======================================== */

/* 对话框容器 */
.ai-chat-widget {
    position: fixed;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.ai-chat-widget.bottom-right {
    bottom: 24px;
    right: 24px;
}

.ai-chat-widget.bottom-left {
    bottom: 24px;
    left: 24px;
}

/* 触发按钮 */
.ai-chat-trigger {
    position: relative;
    cursor: pointer;
    transition: transform 0.3s ease;
}

.ai-chat-trigger:hover {
    transform: scale(1.05);
}

.ai-notification-badge {
    position: absolute;
    top: -4px;
    right: -4px;
    background: #ef4444;
    color: white;
    font-size: 12px;
    min-width: 20px;
    height: 20px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 6px;
}

/* 对话框 */
.ai-chat-dialog {
    position: absolute;
    bottom: 80px;
    right: 0;
    width: 380px;
    max-height: 600px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

@keyframes slide-up {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.animate-slide-up {
    animation: slide-up 0.3s ease-out;
}

/* 对话框头部 */
.ai-chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.ai-chat-header h3 {
    margin: 0;
    font-size: 16px;
}

.ai-chat-header p {
    margin: 0;
    font-size: 12px;
    opacity: 0.9;
}

/* 消息区域 */
.ai-chat-messages {
    flex: 1;
    padding: 16px;
    overflow-y: auto;
    min-height: 300px;
    max-height: 400px;
    background: #fafafa;
}

.ai-chat-messages .message {
    margin-bottom: 16px;
    animation: fade-in 0.3s ease-out;
}

.ai-chat-messages .message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
}

.ai-chat-messages .user-message .message-bubble {
    border-bottom-right-radius: 4px;
    margin-left: auto;
}

.ai-chat-messages .assistant-message .message-bubble {
    border-bottom-left-radius: 4px;
}

/* 输入区域 */
.ai-chat-input-area {
    padding: 16px;
    border-top: 1px solid #f0f0f0;
    background: white;
}

.ai-chat-input-area input {
    font-size: 14px;
}

/* 思考中指示器 */
.ai-typing-indicator {
    padding: 0 16px 8px;
}

/* 快捷操作按钮 */
.quick-action {
    transition: all 0.2s ease;
}

.quick-action:hover {
    background-color: #e5e7eb !important;
    transform: translateY(-1px);
}

/* 形象切换动画 */
.avatar-switching {
    animation: avatar-switch 0.3s ease-in-out;
}

@keyframes avatar-switch {
    0% {
        opacity: 1;
        transform: scale(1);
    }
    50% {
        opacity: 0.5;
        transform: scale(0.95);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

/* 响应式调整 */
@media (max-width: 480px) {
    .ai-chat-dialog {
        width: calc(100vw - 32px);
        max-width: 380px;
        right: -8px;
    }
    
    .ai-chat-widget.bottom-right {
        right: 16px;
        bottom: 16px;
    }
}

/* ========================================
   知小行形象样式
   ======================================== */

.zhixiaoxing-container {
    position: relative;
    display: inline-block;
}

.zhixiaoxing-avatar {
    transition: all 0.3s ease;
    image-rendering: -webkit-optimize-contrast;
}

.zhixiaoxing-avatar:hover {
    transform: scale(1.05);
}

.zhixiaoxing-state {
    transition: all 0.2s ease;
}

/* 状态指示器动画 */
@keyframes glow {
    0%, 100% {
        box-shadow: 0 0 10px rgba(102, 126, 234, 0.5);
    }
    50% {
        box-shadow: 0 0 20px rgba(102, 126, 234, 0.8);
    }
}

.zhixiaoxing-active {
    animation: glow 2s infinite;
}

/* 聊天消息 Markdown 样式 */
.message-content {
    line-height: 1.7;
}

.message-content p {
    margin: 0.25rem 0;
}

.message-content h1,
.message-content h2,
.message-content h3 {
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    color: inherit;
}

.message-content strong {
    font-weight: 600;
}

.message-content em {
    font-style: italic;
}

.message-content code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

.message-content pre {
    margin: 0.5rem 0;
    border-radius: 0.5rem;
    overflow-x: auto;
}

.message-content pre code {
    display: block;
    font-size: 0.85em;
    line-height: 1.5;
}

.message-content blockquote {
    margin: 0.5rem 0;
    padding-left: 0.75rem;
    border-left: 3px solid #a78bfa;
    color: #6b7280;
    font-style: italic;
}

.message-content a {
    color: #6366f1;
    text-decoration: underline;
}

.message-content a:hover {
    color: #4f46e5;
}

.message-content hr {
    margin: 0.75rem 0;
    border: none;
    border-top: 1px solid #e5e7eb;
}

.message-content li {
    margin: 0.125rem 0;
}

/* 用户消息中的代码样式调整 */
.bg-purple-600 .message-content code {
    background-color: rgba(255, 255, 255, 0.2);
    color: #fff;
}

.bg-purple-600 .message-content pre {
    background-color: rgba(0, 0, 0, 0.3);
}

.bg-purple-600 .message-content a {
    color: #c4b5fd;
}
