<!-- pages/chat-history/chat-history.wxml — 对话历史 -->

<!-- 加载态（toast 浮层，不白屏） -->
<view class="g-toast-loading" wx:if="{{pageState === 'loading'}}">
  <view class="g-toast-loading-inner">
    <t-loading theme="circular" size="40rpx" />
    <text class="g-toast-loading-text">加载中...</text>
  </view>
</view>

<!-- 错误态 -->
<view class="page-error" wx:elif="{{pageState === 'error'}}">
  <view class="error-content">
    <text class="error-icon">😵</text>
    <text class="error-text">加载失败，请重试</text>
    <view class="retry-btn" hover-class="retry-btn--hover" bindtap="onRetry">
      <text class="retry-btn-text">重新加载</text>
    </view>
  </view>
</view>

<!-- 空态 -->
<view class="page-empty-wrap" wx:elif="{{pageState === 'empty'}}">
  <view class="page-empty">
    <t-empty description="暂无对话记录" />
  </view>
</view>

<!-- 正常态 -->
<view class="page-normal" wx:elif="{{pageState === 'normal'}}">

  <!-- 对话列表 -->
  <view class="chat-list">
    <view
      class="chat-item"
      hover-class="chat-item--hover"
      wx:for="{{list}}"
      wx:key="id"
      data-id="{{item.id}}"
      bindtap="onItemTap"
    >
      <view class="chat-icon-box" style="background: {{item.iconGradient}};">
        <t-icon name="chat" size="40rpx" color="#ffffff" />
      </view>
      <view class="chat-content">
        <view class="chat-top">
          <text class="chat-title text-ellipsis">{{item.title}}</text>
          <text class="chat-time">{{item.timeLabel}}</text>
        </view>
        <view class="chat-bottom">
          <text class="chat-summary text-ellipsis" wx:if="{{item.customerName}}">{{item.customerName}} · {{item.lastMessage}}</text>
          <text class="chat-summary text-ellipsis" wx:else>{{item.lastMessage}}</text>
        </view>
      </view>
      <t-icon name="chevron-right" size="32rpx" color="#c5c5c5" />
    </view>
  </view>

  <!-- 底部提示 -->
  <view class="list-footer">
    <text class="footer-text">— 已加载全部记录 —</text>
  </view>

  <!-- AI 悬浮按钮 -->
  <ai-float-button />
</view>

<dev-fab />
