<view class="history-page">
  <custom-nav padding-x="52">
    <view class="history-nav">
      <text class="nav-title">创作记录</text>
    </view>
  </custom-nav>

  <view class="history-content">
    <view class="filter-row">
      <view class="filter-tabs">
        <view
          wx:for="{{filters}}"
          wx:key="key"
          class="filter-chip {{item.active ? 'active' : ''}}"
          data-key="{{item.key}}"
          bindtap="handleFilterTap"
        >{{item.label}}</view>
      </view>
      <view class="failed-btn {{activeFilter === 'failed' ? 'active' : ''}}" bindtap="handleFailedTap">
        <image class="filter-icon icon-placeholder" src="/static/images/filter.png" mode="aspectFit"></image>
        <text>失败记录</text>
      </view>
    </view>

    <view class="record-list" wx:if="{{records.length}}">
      <view wx:for="{{records}}" wx:key="taskId" class="record-card">
        <view class="thumb {{item.sceneClass}}">
          <image class="thumb-placeholder icon-placeholder" src="{{item.coverImage}}" mode="aspectFill"></image>
          <view class="duration-badge">{{item.duration}}</view>
        </view>

        <view class="record-main">
          <text class="record-title">{{item.title}}</text>
          <view class="tag-row">
            <text class="tag">{{item.scene}}</text>
            <text class="tag">{{item.avatar}}</text>
          </view>
          <text class="record-time">{{item.time}}</text>

          <view class="status-line {{item.status}}">
            <text wx:if="{{item.isProcessing}}" class="progress-dot"></text>
            <text>{{item.statusText}}</text>
          </view>

          <view class="action-row">
            <view class="secondary-btn" data-status="{{item.status}}" data-task-id="{{item.taskId}}" bindtap="handleDetail">{{item.secondaryText}}</view>
            <view wx:if="{{item.isDone}}" class="download-btn" data-task-id="{{item.taskId}}" bindtap="handleDownload">
              <image class="download-icon icon-placeholder" src="/static/images/my/image.png" mode="aspectFit"></image>
              <text>下载</text>
            </view>
            <view wx:elif="{{item.isProcessing}}" class="more-btn" data-status="{{item.status}}" data-task-id="{{item.taskId}}" bindtap="handleMore">
              <text></text>
              <text></text>
              <text></text>
            </view>
            <view wx:else class="retry-btn" data-task-id="{{item.taskId}}" bindtap="handleRetry">重新生成</view>
          </view>
        </view>
      </view>
    </view>

    <view wx:elif="{{!loading}}" class="empty-state">暂无创作记录</view>
    <view wx:if="{{loading}}" class="empty-state">加载中...</view>
  </view>
</view>

