<view class="exam-page">
  <view wx:if="{{loading}}" class="center-tip">正在检查考试资格...</view>

  <view wx:elif="{{blocked}}" class="center-box">
    <text class="tip-title">{{blockTitle}}</text>
    <text class="tip-desc">{{blockReason}}</text>
    <view class="btn-row">
      <view wx:if="{{needRecharge}}" class="btn-primary block" bindtap="goRecharge">去开通会员</view>
      <view class="btn-outline block" bindtap="retryInit">重试</view>
      <view class="btn-outline block" bindtap="goBack">返回</view>
    </view>
  </view>

  <view wx:elif="{{alreadyPassed}}" class="center-box">
    <text class="tip-title">已通过考试</text>
    <text class="tip-desc">无需重复考试，可直接抢单</text>
    <view class="btn-primary block" bindtap="goBack">返回</view>
  </view>

  <view wx:elif="{{finished}}" class="center-box">
    <text class="tip-title">考试通过</text>
    <text class="tip-desc">恭喜通过，现在可以去抢单了</text>
    <view class="btn-primary block" bindtap="goBack">去抢单</view>
  </view>

  <view wx:elif="{{currentQuestion}}" class="exam-body">
    <view class="exam-card">
      <view class="progress">第 {{currentIndex + 1}} / {{total}} 题</view>
      <view class="progress-sub">已错 {{wrongCount}} 题 · 最多可错 {{maxWrong}} 题</view>

      <view class="q-type-tag">{{questionType === 2 ? '多选题' : '单选题'}}</view>
      <view class="q-stem">{{currentQuestion.stem}}</view>

      <view class="q-images" wx:if="{{currentQuestion.displayImages && currentQuestion.displayImages.length}}">
        <image wx:for="{{currentQuestion.displayImages}}" wx:key="*this" class="q-img" src="{{item}}" mode="widthFix" />
      </view>

      <view class="options">
        <view
          wx:for="{{currentQuestion.displayOptions}}"
          wx:key="slot"
          class="opt-item {{item.selected ? 'opt-active' : ''}}"
          data-slot="{{item.slot}}"
          bindtap="onSelectOption"
        >
          <view class="opt-radio {{item.selected ? 'opt-radio-on' : ''}}">
            <view wx:if="{{item.selected}}" class="opt-radio-dot"></view>
          </view>
          <view class="opt-body">
            <text class="opt-label">{{item.label}}</text>
            <text class="opt-text">{{item.text}}</text>
          </view>
        </view>
      </view>

      <view wx:if="{{showExplanation}}" id="explain-box" class="explain-box">
        <text class="explain-title">解析</text>
        <text class="explain-text">{{currentQuestion.explanation || '暂无解析'}}</text>
      </view>
    </view>

    <view class="foot-actions" wx:if="{{questionType === 2}}">
      <view class="btn-primary foot-btn" bindtap="confirmMulti">{{showExplanation ? '重新作答' : '确认本题'}}</view>
    </view>
  </view>
</view>
