/**
 * 知识点提取模块样式 - AI全自动提取版
 * 沉迷学习系统集成版
 */

/* ==================== 模态框 ==================== */
.ke-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 9999;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ke-modal-content {
    background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
    border-radius: 20px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    border: 1px solid rgba(167, 139, 250, 0.2);
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
}

/* ==================== 头部 ==================== */
.ke-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.ke-header h2 {
    margin: 0;
    font-size: 1.3rem;
    background: linear-gradient(90deg, #f472b6, #a78bfa);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ke-close {
    background: none;
    border: none;
    color: #a1a1aa;
    font-size: 1.8rem;
    cursor: pointer;
    transition: color 0.2s;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
}

.ke-close:hover {
    color: #f472b6;
    background: rgba(244, 114, 182, 0.1);
}

/* ==================== 内容区 ==================== */
.ke-body {
    padding: 25px;
    overflow-y: auto;
    flex: 1;
}

.ke-step h3 {
    margin: 0 0 20px 0;
    color: #e4e4e7;
    font-size: 1.1rem;
}

/* ==================== 上传区域 ==================== */
.ke-upload-area {
    border: 2px dashed rgba(167, 139, 250, 0.3);
    border-radius: 16px;
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    background: rgba(0, 0, 0, 0.2);
}

.ke-upload-area:hover {
    border-color: #a78bfa;
    background: rgba(167, 139, 250, 0.05);
}

.ke-upload-area.dragover {
    border-color: #f472b6;
    background: rgba(244, 114, 182, 0.1);
}

.ke-upload-icon {
    font-size: 3rem;
    margin-bottom: 15px;
}

.ke-upload-area p {
    color: #a1a1aa;
    margin: 0;
}

/* ==================== AI 分析中 ==================== */
.ke-ai-analyzing {
    text-align: center;
    padding: 40px 20px;
}

.ke-spinner-large {
    width: 60px;
    height: 60px;
    margin: 0 auto 25px;
    border: 4px solid rgba(167, 139, 250, 0.2);
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: ke-spin 1s linear infinite;
}

@keyframes ke-spin {
    to { transform: rotate(360deg); }
}

.ke-analyze-text {
    color: #e4e4e7;
    font-size: 1.1rem;
    margin-bottom: 15px;
}

.ke-analyze-detail {
    color: #71717a;
    font-size: 0.85rem;
    max-height: 200px;
    overflow-y: auto;
    padding: 15px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
    text-align: left;
    font-family: 'Fira Code', monospace;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ==================== 提示文字 ==================== */
.ke-hint {
    color: #a78bfa;
    font-size: 0.9rem;
    margin-bottom: 20px;
    padding: 10px 15px;
    background: rgba(167, 139, 250, 0.1);
    border-radius: 8px;
    border-left: 3px solid #a78bfa;
}

.ke-hint-small {
    color: #71717a;
    font-size: 0.75rem;
    margin-top: 4px;
    display: block;
}

/* ==================== AI 标签 ==================== */
.ke-ai-tag {
    display: inline-block;
    padding: 2px 8px;
    background: linear-gradient(135deg, #a78bfa, #f472b6);
    color: white;
    font-size: 0.7rem;
    border-radius: 4px;
    margin-left: 8px;
    font-weight: 500;
}

/* ==================== 表单 ==================== */
.ke-form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.ke-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ke-form-group label {
    color: #e4e4e7;
    font-size: 0.9rem;
    font-weight: 500;
}

.ke-form-group input,
.ke-form-group textarea,
.ke-form-group select {
    padding: 12px 15px;
    background: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #e4e4e7;
    font-size: 0.95rem;
    transition: all 0.2s;
    font-family: inherit;
}

.ke-form-group input:focus,
.ke-form-group textarea:focus,
.ke-form-group select:focus {
    outline: none;
    border-color: #a78bfa;
    box-shadow: 0 0 0 3px rgba(167, 139, 250, 0.1);
}

.ke-form-group input::placeholder,
.ke-form-group textarea::placeholder {
    color: #71717a;
}

/* 主题标签 */
#ke-subject-topics {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 8px;
}

.ke-topic-tag {
    padding: 6px 12px;
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
    border-radius: 20px;
    font-size: 0.8rem;
    border: 1px solid rgba(167, 139, 250, 0.3);
}

/* ==================== 预览区域 ==================== */
.ke-preview {
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 15px;
}

.ke-preview h4 {
    margin: 0 0 10px 0;
    color: #a78bfa;
    font-size: 0.9rem;
}

.ke-pdf-info {
    margin-bottom: 15px;
    padding: 10px;
    background: rgba(167, 139, 250, 0.1);
    border-radius: 8px;
}

.ke-pdf-info p {
    margin: 5px 0;
    color: #d4d4d8;
    font-size: 0.9rem;
}

.ke-pdf-sample {
    margin-top: 10px;
}

.ke-pdf-sample pre {
    margin: 0;
    color: #71717a;
    font-size: 0.8rem;
    line-height: 1.5;
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ==================== 进度条 ==================== */
.ke-progress {
    margin: 20px 0;
}

.ke-progress-bar {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
}

.ke-progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #a78bfa, #f472b6);
    border-radius: 4px;
    transition: width 0.5s ease;
}

.ke-progress-text {
    text-align: center;
    margin-top: 12px;
    color: #a1a1aa;
    font-size: 0.9rem;
}

/* ==================== 实时内容展示区 ==================== */
.ke-live-content {
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    overflow: hidden;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.ke-live-tabs {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    overflow-x: auto;
}

.ke-live-tab {
    padding: 12px 16px;
    background: none;
    border: none;
    color: #a1a1aa;
    cursor: pointer;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: all 0.2s;
    border-bottom: 2px solid transparent;
}

.ke-live-tab:hover {
    color: #e4e4e7;
    background: rgba(255, 255, 255, 0.05);
}

.ke-live-tab.active {
    color: #a78bfa;
    border-bottom-color: #a78bfa;
    background: rgba(167, 139, 250, 0.1);
}

.ke-live-panel {
    display: none;
    max-height: 350px;
    overflow-y: auto;
    padding: 15px;
}

.ke-live-panel.active {
    display: block;
}

.ke-live-placeholder {
    text-align: center;
    padding: 40px 20px;
    color: #71717a;
    font-size: 0.9rem;
}

/* ==================== 章节列表展示 ==================== */
.ke-chapters-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ke-chapter-item {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    border-left: 3px solid #a78bfa;
}

.ke-chapter-number {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, #a78bfa, #f472b6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 600;
    color: white;
    flex-shrink: 0;
}

.ke-chapter-info {
    flex: 1;
    min-width: 0;
}

.ke-chapter-title {
    color: #e4e4e7;
    font-weight: 500;
    margin-bottom: 4px;
}

.ke-chapter-desc {
    color: #a1a1aa;
    font-size: 0.8rem;
    line-height: 1.4;
}

.ke-chapter-page {
    color: #a78bfa;
    font-size: 0.75rem;
    margin-top: 4px;
}

/* ==================== 知识点列表展示 ==================== */
.ke-knowledge-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.ke-knowledge-group {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 12px;
}

.ke-knowledge-group-title {
    color: #a78bfa;
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 10px;
    padding-bottom: 8px;
    border-bottom: 1px solid rgba(167, 139, 250, 0.2);
}

.ke-knowledge-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 8px 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.ke-knowledge-item:last-child {
    border-bottom: none;
}

.ke-knowledge-type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
    text-transform: uppercase;
    flex-shrink: 0;
}

.ke-knowledge-type.definition {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.ke-knowledge-type.theorem {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.ke-knowledge-type.formula {
    background: rgba(244, 114, 182, 0.2);
    color: #f472b6;
}

.ke-knowledge-type.concept {
    background: rgba(167, 139, 250, 0.2);
    color: #a78bfa;
}

.ke-knowledge-type.method {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.ke-knowledge-content {
    flex: 1;
    color: #d4d4d8;
    font-size: 0.85rem;
    line-height: 1.4;
}

.ke-knowledge-importance {
    color: #fbbf24;
    font-size: 0.75rem;
    flex-shrink: 0;
}

/* ==================== 习题列表展示 ==================== */
.ke-exercises-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.ke-exercise-item {
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    padding: 12px;
    border-left: 3px solid #f472b6;
}

.ke-exercise-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

.ke-exercise-number {
    background: linear-gradient(135deg, #f472b6, #a78bfa);
    color: white;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 600;
}

.ke-exercise-type {
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 500;
}

.ke-exercise-type.calculation {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
}

.ke-exercise-type.proof {
    background: rgba(34, 197, 94, 0.2);
    color: #4ade80;
}

.ke-exercise-type.concept {
    background: rgba(167, 139, 250, 0.2);
    color: #a78bfa;
}

.ke-exercise-type.derivation {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
}

.ke-exercise-type.application {
    background: rgba(244, 114, 182, 0.2);
    color: #f472b6;
}

.ke-exercise-difficulty {
    color: #fbbf24;
    font-size: 0.75rem;
    margin-left: auto;
}

.ke-exercise-content {
    color: #d4d4d8;
    font-size: 0.85rem;
    line-height: 1.5;
}

.ke-exercise-hints {
    margin-top: 10px;
    padding: 10px;
    background: rgba(251, 191, 36, 0.05);
    border-radius: 6px;
}

.ke-exercise-hints strong {
    color: #fbbf24;
    font-size: 0.8rem;
}

.ke-exercise-hints ul {
    margin: 5px 0 0 0;
    padding-left: 18px;
    color: #a1a1aa;
    font-size: 0.8rem;
}

.ke-exercise-hints li {
    margin: 3px 0;
}

/* ==================== 原始输出展示 ==================== */
.ke-raw-output {
    margin: 0;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    color: #a1a1aa;
    font-size: 0.75rem;
    line-height: 1.5;
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}

/* ==================== 统计 ==================== */
.ke-stats {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 25px 0;
    padding: 20px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
}

.ke-stat-item {
    text-align: center;
}

.ke-stat-value {
    display: block;
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(90deg, #a78bfa, #f472b6);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.ke-stat-label {
    color: #a1a1aa;
    font-size: 0.85rem;
}

/* ==================== 按钮 ==================== */
.ke-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin: 20px 0;
}

.ke-btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.1);
    color: #e4e4e7;
    font-weight: 500;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.ke-btn:hover:not(:disabled) {
    background: rgba(255, 255, 255, 0.15);
    transform: translateY(-1px);
}

.ke-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.ke-btn-primary {
    background: linear-gradient(135deg, #a78bfa, #f472b6);
    color: white;
}

.ke-btn-primary:hover:not(:disabled) {
    background: linear-gradient(135deg, #9d7cf7, #f063a8);
    box-shadow: 0 8px 20px rgba(167, 139, 250, 0.3);
}

.ke-btn-secondary {
    background: rgba(167, 139, 250, 0.15);
    color: #a78bfa;
    border: 1px solid rgba(167, 139, 250, 0.3);
}

.ke-btn-secondary:hover:not(:disabled) {
    background: rgba(167, 139, 250, 0.25);
}

/* ==================== 底部 ==================== */
.ke-footer {
    display: flex;
    justify-content: space-between;
    padding: 20px 25px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* ==================== 最终结果预览 ==================== */
.ke-final-preview {
    margin-top: 20px;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 12px;
    padding: 15px;
}

.ke-final-preview h4 {
    margin: 0 0 12px 0;
    color: #a78bfa;
    font-size: 0.9rem;
}

.ke-final-preview pre {
    margin: 0;
    padding: 12px;
    background: rgba(0, 0, 0, 0.4);
    border-radius: 8px;
    color: #a1a1aa;
    font-size: 0.75rem;
    line-height: 1.5;
    font-family: 'Fira Code', 'Consolas', monospace;
    white-space: pre-wrap;
    word-break: break-all;
    max-height: 300px;
    overflow-y: auto;
}

/* ==================== 加载动画 ==================== */
.ke-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #a78bfa;
    border-radius: 50%;
    animation: ke-spin 0.8s linear infinite;
}

/* ==================== 响应式 ==================== */
@media (max-width: 640px) {
    .ke-modal {
        padding: 10px;
    }
    
    .ke-modal-content {
        max-height: 95vh;
    }
    
    .ke-body {
        padding: 15px;
    }
    
    .ke-hint {
        font-size: 0.85rem;
    }
    
    .ke-ai-analyzing {
        padding: 20px 15px;
    }
    
    .ke-spinner-large {
        width: 50px;
        height: 50px;
    }
    
    .ke-analyze-text {
        font-size: 1rem;
    }
    
    .ke-live-tabs {
        flex-wrap: nowrap;
    }
    
    .ke-live-tab {
        padding: 10px 12px;
        font-size: 0.8rem;
    }
    
    .ke-live-panel {
        max-height: 250px;
        padding: 12px;
    }
    
    .ke-stats {
        gap: 20px;
        padding: 15px;
    }
    
    .ke-stat-value {
        font-size: 1.5rem;
    }
    
    .ke-actions {
        flex-direction: column;
    }
    
    .ke-chapter-item {
        padding: 10px;
    }
    
    .ke-exercise-header {
        gap: 6px;
    }
    
    .ke-topic-tag {
        padding: 4px 10px;
        font-size: 0.75rem;
    }
}

/* ==================== 动画 ==================== */
@keyframes ke-fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

.ke-modal[style*="flex"] .ke-modal-content {
    animation: ke-fadeIn 0.3s ease;
}

/* 滚动条美化 */
.ke-live-panel::-webkit-scrollbar,
.ke-final-preview pre::-webkit-scrollbar,
.ke-raw-output::-webkit-scrollbar,
.ke-analyze-detail::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.ke-live-panel::-webkit-scrollbar-track,
.ke-final-preview pre::-webkit-scrollbar-track,
.ke-raw-output::-webkit-scrollbar-track,
.ke-analyze-detail::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.ke-live-panel::-webkit-scrollbar-thumb,
.ke-final-preview pre::-webkit-scrollbar-thumb,
.ke-raw-output::-webkit-scrollbar-thumb,
.ke-analyze-detail::-webkit-scrollbar-thumb {
    background: rgba(167, 139, 250, 0.3);
    border-radius: 3px;
}

.ke-live-panel::-webkit-scrollbar-thumb:hover,
.ke-final-preview pre::-webkit-scrollbar-thumb:hover,
.ke-raw-output::-webkit-scrollbar-thumb:hover,
.ke-analyze-detail::-webkit-scrollbar-thumb:hover {
    background: rgba(167, 139, 250, 0.5);
}
