<view class="page">
  <view class="page-header page-header-pink" style="padding-top: {{statusBarHeight + 24}}px;">
    <view class="nav-back" bindtap="onBack">‹ 返回</view>
    <view class="page-header-title">多光谱扫描</view>
    <view class="page-header-subtitle">{{scanning ? '正在采集数据 (' + spectrumIndex + '/4)...' : '扫描完成'}}</view>
  </view>

  <view class="page-content">
    <view class="scan-container" wx:if="{{scanning}}">
      <view class="face-outline">
        <view class="scan-line"></view>
      </view>
      <view class="scan-progress-bar">
        <view class="scan-progress-fill" style="width: {{scanProgress}}%"></view>
      </view>
      <view class="scan-status">固件序贯扫描中：红光 → 紫外光 → 黄光 → 红外光</view>
    </view>

    <view class="scan-result" wx:if="{{!scanning && spectrumData.length > 0}}">
      <view class="spectrum-group" wx:for="{{spectrumData}}" wx:key="name">
        <view class="spectrum-title">{{item.name}} (第{{index + 1}}组)</view>
        <view class="pd-list">
          <view class="pd-item" wx:for="{{item.items}}" wx:for-item="pd" wx:key="label">
            <view class="pd-region">{{pd.label}}</view>
            <view class="pd-value">{{pd.value}}</view>
            <view class="pd-bar-bg" wx:if="{{pd.value > 0}}">
              <view class="pd-bar-fill" style="width: {{pd.barWidth}}%"></view>
            </view>
          </view>
        </view>
      </view>
      <view class="vbat-info" wx:if="{{vbat > 0}}">
        电池电压: {{vbat}}mV ({{battery}}%)
      </view>
    </view>

    <view class="scan-result" wx:if="{{!scanning && spectrumData.length === 0 && !error}}">
      <view class="empty-hint">未收到扫描数据</view>
    </view>

    <view class="scan-error" wx:if="{{!scanning && error}}">{{error}}</view>

    <button class="btn-primary mt-30" wx:if="{{!scanning}}" bindtap="onNext">下一步</button>
  </view>
</view>
