{{-- 手动评分题目显示组件 --}}
<div class="space-y-4">
    <div class="flex items-center justify-between">
        <h2 class="text-2xl font-bold">题目与作答</h2>
        <div class="badge badge-info badge-lg">共 {{ count($questions) }} 题</div>
    </div>

    @if(count($questions) > 0)
        <div class="space-y-4">
            @foreach($questions as $question)
                <div class="card bg-base-100 shadow-xl">
                    <div class="card-body">
                        {{-- 题目标题 --}}
                        <div class="flex items-center gap-2 mb-3">
                            <span class="badge badge-primary badge-lg">第 {{ $question['question_number'] }} 题</span>
                            <span class="badge badge-outline">{{ $question['question_type'] ?? '未知类型' }}</span>
                            <span class="badge badge-ghost">{{ $question['score'] ?? 0 }}分</span>
                            
                            {{-- 评分结果 --}}
                            <div class="ml-auto flex items-center gap-2">
                                @if(isset($question['is_correct']))
                                    @if($question['is_correct'])
                                        <div class="badge badge-success badge-lg gap-2">
                                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M5 13l4 4L19 7"></path>
                                            </svg>
                                            正确
                                        </div>
                                    @else
                                        <div class="badge badge-error badge-lg gap-2">
                                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
                                            </svg>
                                            错误
                                        </div>
                                    @endif
                                @endif
                                
                                @if(isset($question['actual_score']))
                                    <div class="text-2xl font-bold">
                                        {{ $question['actual_score'] }}<span class="text-sm opacity-70">/{{ $question['score'] }}</span>
                                    </div>
                                @endif
                            </div>
                        </div>
                        
                        <div class="divider my-2"></div>
                        
                        {{-- 题目内容 --}}
                        <div class="mb-3">
                            <div class="font-semibold mb-2 flex items-center gap-2">
                                <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M8.228 9c.549-1.165 2.03-2 3.772-2 2.21 0 4 1.343 4 3 0 1.4-1.278 2.575-3.006 2.907-.542.104-.994.54-.994 1.093m0 3h.01M21 12a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                                </svg>
                                题目
                            </div>
                            <div class="prose max-w-none pl-6">
                                @math($question['content'] ?? '题目内容缺失')
                            </div>
                        </div>
                        
                        {{-- 学生答案 --}}
                        <div class="alert alert-info mb-3">
                            <svg class="w-5 h-5 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15.232 5.232l3.536 3.536m-2.036-5.036a2.5 2.5 0 113.536 3.536L6.5 21.036H3v-3.572L16.732 3.732z"></path>
                            </svg>
                            <div class="w-full">
                                <div class="font-semibold">学生答案</div>
                                <div class="mt-1">
                                    @if(isset($question['student_answer']) && $question['student_answer'])
                                        @math($question['student_answer'])
                                    @else
                                        <span class="opacity-70 italic">未作答</span>
                                    @endif
                                </div>
                            </div>
                        </div>
                        
                        {{-- 正确答案 --}}
                        <div class="alert alert-success">
                            <svg class="w-5 h-5 shrink-0" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12l2 2 4-4m6 2a9 9 0 11-18 0 9 9 0 0118 0z"></path>
                            </svg>
                            <div class="w-full">
                                <div class="font-semibold">正确答案</div>
                                <div class="mt-1">@math($question['answer'] ?? '答案缺失')</div>
                            </div>
                        </div>

                        {{-- AI分析解析 --}}
                        @if(isset($question['ai_analysis']) && $question['ai_analysis'])
                            <div class="card bg-gradient-to-r from-blue-50 to-indigo-50 border border-blue-200">
                                <div class="card-body p-4">
                                    <div class="flex items-center gap-2 mb-3">
                                        <div class="badge badge-info badge-lg gap-2">
                                            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9.663 17h4.673M12 3v1m6.364 1.636l-.707.707M21 12h-1M4 12H3m3.343-5.657l-.707-.707m2.828 9.9a5 5 0 117.072 0l-.548.547A3.374 3.374 0 0014 18.469V19a2 2 0 11-4 0v-.531c0-.895-.356-1.754-.988-2.386l-.548-.547z"></path>
                                            </svg>
                                            AI智能解析
                                        </div>
                                        @if(isset($question['ai_analysis']['confidence_score']))
                                            <div class="badge badge-ghost badge-sm">
                                                置信度: {{ number_format($question['ai_analysis']['confidence_score'] * 100, 1) }}%
                                            </div>
                                        @endif
                                        @if(isset($question['ai_analysis']['ai_model']))
                                            <div class="badge badge-ghost badge-sm">
                                                模型: {{ $question['ai_analysis']['ai_model'] }}
                                            </div>
                                        @endif
                                    </div>

                                    <div class="space-y-3">
                                        {{-- 知识点分析 --}}
                                        @if(isset($question['ai_analysis']['knowledge_points']) && !empty($question['ai_analysis']['knowledge_points']))
                                            <div class="bg-white rounded-lg p-3">
                                                <div class="font-semibold text-sm mb-2 flex items-center gap-1">
                                                    <svg class="w-4 h-4 text-blue-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 6.253v13m0-13C10.832 5.477 9.246 5 7.5 5S4.168 5.477 3 6.253v13C4.168 18.477 5.754 18 7.5 18s3.332.477 4.5 1.253m0-13C13.168 5.477 14.754 5 16.5 5c1.747 0 3.332.477 4.5 1.253v13C19.832 18.477 18.247 18 16.5 18c-1.746 0-3.332.477-4.5 1.253"></path>
                                                    </svg>
                                                    知识点
                                                </div>
                                                <div class="flex flex-wrap gap-1">
                                                    @foreach($question['ai_analysis']['knowledge_points'] as $kp)
                                                        <span class="badge badge-primary badge-sm">{{ $kp }}</span>
                                                    @endforeach
                                                </div>
                                            </div>
                                        @endif

                                        {{-- 薄弱点分析 --}}
                                        @if(isset($question['ai_analysis']['weak_points']) && !empty($question['ai_analysis']['weak_points']))
                                            <div class="bg-yellow-50 rounded-lg p-3 border border-yellow-200">
                                                <div class="font-semibold text-sm mb-2 flex items-center gap-1">
                                                    <svg class="w-4 h-4 text-yellow-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M12 9v2m0 4h.01m-6.938 4h13.856c1.54 0 2.502-1.667 1.732-3L13.732 4c-.77-1.333-2.694-1.333-3.464 0L3.34 16c-.77 1.333.192 3 1.732 3z"></path>
                                                    </svg>
                                                    薄弱点识别
                                                </div>
                                                <div class="text-sm text-gray-700">
                                                    {{ is_array($question['ai_analysis']['weak_points']) ? implode('、', $question['ai_analysis']['weak_points']) : $question['ai_analysis']['weak_points'] }}
                                                </div>
                                            </div>
                                        @endif

                                        {{-- 掌握度分析 --}}
                                        @if(isset($question['ai_analysis']['mastery_scores']) && !empty($question['ai_analysis']['mastery_scores']))
                                            <div class="bg-green-50 rounded-lg p-3 border border-green-200">
                                                <div class="font-semibold text-sm mb-2 flex items-center gap-1">
                                                    <svg class="w-4 h-4 text-green-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 19v-6a2 2 0 00-2-2H5a2 2 0 00-2 2v6a2 2 0 002 2h2a2 2 0 002-2zm0 0V9a2 2 0 012-2h2a2 2 0 012 2v10m-6 0a2 2 0 002 2h2a2 2 0 002-2m0 0V5a2 2 0 012-2h2a2 2 0 012 2v14a2 2 0 01-2 2h-2a2 2 0 01-2-2z"></path>
                                                    </svg>
                                                    掌握度分析
                                                </div>
                                                @if(is_array($question['ai_analysis']['mastery_scores']))
                                                    <div class="space-y-1">
                                                        @foreach($question['ai_analysis']['mastery_scores'] as $point => $score)
                                                            <div class="flex justify-between items-center text-sm">
                                                                <span>{{ $point }}:</span>
                                                                <span class="badge badge-{{ $score >= 0.8 ? 'success' : ($score >= 0.6 ? 'warning' : 'error') }} badge-sm">
                                                                    {{ number_format($score * 100, 1) }}%
                                                                </span>
                                                            </div>
                                                        @endforeach
                                                    </div>
                                                @else
                                                    <div class="text-sm text-gray-700">
                                                        {{ $question['ai_analysis']['mastery_scores'] }}
                                                    </div>
                                                @endif
                                            </div>
                                        @endif

                                        {{-- 稳定性分析 --}}
                                        @if(isset($question['ai_analysis']['stability_scores']) && !empty($question['ai_analysis']['stability_scores']))
                                            <div class="bg-purple-50 rounded-lg p-3 border border-purple-200">
                                                <div class="font-semibold text-sm mb-2 flex items-center gap-1">
                                                    <svg class="w-4 h-4 text-purple-500" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                                                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M7 12l3-3 3 3 4-4M8 21l4-4 4 4M3 4h18M4 4h16v12a1 1 0 01-1 1H5a1 1 0 01-1-1V4z"></path>
                                                    </svg>
                                                    稳定性分析
                                                </div>
                                                @if(is_array($question['ai_analysis']['stability_scores']))
                                                    <div class="space-y-1">
                                                        @foreach($question['ai_analysis']['stability_scores'] as $point => $score)
                                                            <div class="flex justify-between items-center text-sm">
                                                                <span>{{ $point }}:</span>
                                                                <span class="badge badge-{{ $score >= 0.8 ? 'success' : ($score >= 0.6 ? 'warning' : 'error') }} badge-sm">
                                                                    {{ number_format($score * 100, 1) }}%
                                                                </span>
                                                            </div>
                                                        @endforeach
                                                    </div>
                                                @else
                                                    <div class="text-sm text-gray-700">
                                                        {{ $question['ai_analysis']['stability_scores'] }}
                                                    </div>
                                                @endif
                                            </div>
                                        @endif
                                    </div>
                                </div>
                            </div>
                        @endif
                    </div>
                </div>
            @endforeach
        </div>
    @else
        <div class="card bg-base-100 shadow-xl">
            <div class="card-body">
                <div class="text-center py-12">
                    <svg class="w-16 h-16 mx-auto mb-4 opacity-30" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                        <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 12h6m-6 4h6m2 5H7a2 2 0 01-2-2V5a2 2 0 012-2h5.586a1 1 0 01.707.293l5.414 5.414a1 1 0 01.293.707V19a2 2 0 01-2 2z"></path>
                    </svg>
                    <p class="text-lg opacity-70">暂无题目数据</p>
                </div>
            </div>
        </div>
    @endif
</div>
