<view class="container">
  <view class="hero fade-up">
    <view class="hero-badge">BATCH SCAN</view>
    <view class="hero-title">批量文本筛查</view>
    <view class="hero-sub">每行一条文本，适用于活动文案、客服话术、私信模板的集中检测。</view>
  </view>

  <view class="card fade-up fade-up-delay-1">
    <view class="card-title">批量输入</view>
    <view class="card-desc">请按“每行一条”粘贴文本内容，系统会自动跳过空行。</view>
    <textarea class="textarea" placeholder="示例：&#10;点击链接领取红包&#10;今天下午三点开会" value="{{inputText}}" bindinput="onInput" />

    <view class="btn-row">
      <button class="btn btn-ghost" bindtap="fillDemo">填充示例</button>
      <button class="btn btn-primary" loading="{{loading}}" bindtap="submit">开始识别</button>
    </view>
  </view>

  <view class="card fade-up fade-up-delay-2" wx:if="{{summary}}">
    <view class="card-title">识别汇总</view>
    <view class="grid-3">
      <view class="kpi">
        <view class="kpi-value">{{summary.total}}</view>
        <view class="kpi-label">总条数</view>
      </view>
      <view class="kpi">
        <view class="kpi-value">{{summary.spam_count}}</view>
        <view class="kpi-label">垃圾信息</view>
      </view>
      <view class="kpi">
        <view class="kpi-value">{{summary.ham_count}}</view>
        <view class="kpi-label">正常信息</view>
      </view>
    </view>

    <view class="field">
      <view class="row">
        <text class="label">垃圾占比</text>
        <text class="value">{{summary.spam_ratio_text}}</text>
      </view>
      <view class="progress-track">
        <view class="progress-fill" style="width: {{summary.spam_ratio_text}};"></view>
      </view>
    </view>

    <view class="field">
      <view class="row">
        <text class="label">拦截占比</text>
        <text class="value">{{summary.blocked_ratio_text}}</text>
      </view>
      <view class="progress-track">
        <view class="progress-fill-safe" style="width: {{summary.blocked_ratio_text}};"></view>
      </view>
    </view>
  </view>

  <view class="card fade-up fade-up-delay-3" wx:if="{{items.length}}">
    <view class="card-title">明细结果</view>
    <view class="list-item" wx:for="{{items}}" wx:key="index">
      <view class="item-title">{{item.text}}</view>
      <view class="row">
        <text class="label">判定结果</text>
        <text class="{{item.prediction === 'spam' ? 'status-spam' : 'status-ham'}}">{{item.prediction_text}}</text>
      </view>
      <view class="row">
        <text class="label">置信度</text>
        <text class="value">{{item.confidence_text}}</text>
      </view>
      <view class="progress-track">
        <view class="{{item.prediction === 'spam' ? 'progress-fill' : 'progress-fill-safe'}}" style="width: {{item.confidence_text}};"></view>
      </view>
      <view class="field" wx:if="{{item.reason_tokens && item.reason_tokens.length}}">
        <text class="field-label">风险关键词</text>
        <view class="chip-group">
          <text class="tag tag-danger" wx:for="{{item.reason_tokens}}" wx:for-item="tokenItem" wx:key="token" data-token="{{tokenItem.token}}" data-weight="{{tokenItem.weight}}" bindtap="showTokenWeight">{{tokenItem.token}}</text>
        </view>
      </view>
    </view>
  </view>
</view>
