<div>
    {{-- OCR 识别结果弹窗 --}}
    @if($showResults)
        <div class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50">
            <div class="relative top-20 mx-auto p-5 border w-11/12 md:w-3/4 lg:w-1/2 shadow-lg rounded-md bg-white">
                <div class="mt-3">
                    <h3 class="text-lg font-medium text-gray-900 mb-4">OCR 识别结果</h3>

                    {{-- 试卷信息 --}}
                    <div class="mb-6 bg-gray-50 rounded-lg p-4">
                        <h4 class="text-md font-medium text-gray-900 mb-3">试卷信息</h4>
                        <div class="grid grid-cols-2 gap-4 text-sm">
                            <div>
                                <span class="text-gray-600">试卷名称：</span>
                                <span class="font-medium">{{ $paperInfo['name'] ?? '未知' }}</span>
                            </div>
                            <div>
                                <span class="text-gray-600">试卷类型：</span>
                                <span class="font-medium">{{ $paperInfo['type'] ?? '未知' }}</span>
                            </div>
                            <div>
                                <span class="text-gray-600">题目数量：</span>
                                <span class="font-medium">{{ $paperInfo['total_questions'] ?? 0 }} 道</span>
                            </div>
                        </div>
                    </div>

                    {{-- 识别到的题目 --}}
                    <div class="mb-6">
                        <h4 class="text-md font-medium text-gray-900 mb-3">识别到的题目</h4>
                        <div class="space-y-3 max-h-96 overflow-y-auto">
                            @foreach($questions as $index => $question)
                                <div class="border border-gray-200 rounded-lg p-4">
                                    <div class="flex items-start justify-between">
                                        <div class="flex-1">
                                            <div class="flex items-center mb-2">
                                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium bg-blue-100 text-blue-800 mr-2">
                                                    第 {{ $question['question_number'] ?? ($index + 1) }} 题
                                                </span>
                                                <span class="inline-flex items-center px-2.5 py-0.5 rounded-full text-xs font-medium
                                                    @if(($question['question_type'] ?? '') === 'choice')
                                                        bg-green-100 text-green-800
                                                    @elseif(($question['question_type'] ?? '') === 'fill')
                                                        bg-yellow-100 text-yellow-800
                                                    @else
                                                        bg-purple-100 text-purple-800
                                                    @endif
                                                ">
                                                    {{ ($question['question_type'] ?? '未知') }}
                                                </span>
                                            </div>
                                            <p class="text-sm text-gray-800 mb-2">{{ $question['question_text'] ?? $question['content'] ?? '' }}</p>

                                            {{-- 选择题选项 --}}
                                            @if(($question['question_type'] ?? '') === 'choice' && !empty($question['options']))
                                                <div class="mt-2 space-y-1">
                                                    @foreach($question['options'] as $option)
                                                        <div class="text-xs text-gray-600">
                                                            {{ $option['key'] ?? '' }}. {{ $option['value'] ?? '' }}
                                                        </div>
                                                    @endforeach
                                                </div>
                                            @endif

                                            {{-- 正确答案提示 --}}
                                            @if(!empty($question['correct_answer']))
                                                <div class="mt-2 flex items-center text-xs">
                                                    <svg class="h-4 w-4 text-green-500 mr-1" 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>
                                                    <span class="text-green-600">参考答案：{{ $question['correct_answer'] }}</span>
                                                </div>
                                            @else
                                                <div class="mt-2 flex items-center text-xs">
                                                    <svg class="h-4 w-4 text-yellow-500 mr-1" 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>
                                                    <span class="text-yellow-600">未找到参考答案</span>
                                                </div>
                                            @endif
                                        </div>
                                    </div>
                                </div>
                            @endforeach
                        </div>
                    </div>

                    {{-- 操作按钮 --}}
                    <div class="flex justify-end space-x-3">
                        <button type="button" wire:click="rejectResults" class="px-4 py-2 border border-gray-300 rounded-md text-gray-700 hover:bg-gray-50 transition-colors">
                            重新上传
                        </button>
                        <button type="button" wire:click="acceptResults" class="px-4 py-2 bg-blue-600 text-white rounded-md hover:bg-blue-700 transition-colors">
                            确认导入
                        </button>
                    </div>
                </div>
            </div>
        </div>
    @endif
</div>
