<!-- 加载态（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-empty" wx:elif="{{pageState === 'empty'}}">
  <t-empty description="暂无服务记录" />
</view>

<!-- 错误态 -->
<view class="page-error" wx:elif="{{pageState === 'error'}}">
  <t-icon name="close-circle" size="120rpx" color="#e34d59" />
  <text class="error-text">加载失败，请点击重试</text>
  <view class="retry-btn" hover-class="retry-btn--hover" bindtap="onRetry">重试</view>
</view>

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

  <!-- Banner（复用 task-detail 样式）-->
  <view class="banner-area">
    <image src="/assets/images/banner-bg-coral-aurora.svg" class="banner-bg-svg" mode="scaleToFill" />
    <view class="banner-content">
      <view class="customer-info">
        <view class="avatar-box">
          <text class="avatar-text">{{customerInitial}}</text>
        </view>
        <view class="info-right">
          <view class="name-row">
            <text class="customer-name">{{customerName}}</text>
            <view class="name-badges">
              <text class="name-badge">服务 <text class="badge-highlight">{{totalServiceCount}}</text> 次</text>
             
            </view>
          </view>
          <view class="sub-stats">
            <view class="sub-info">
              <text class="phone">{{phoneVisible ? customerPhoneFull : customerPhone}}</text>
              <view class="phone-toggle-btn" bindtap="{{phoneVisible ? 'onCopyPhone' : 'onTogglePhone'}}" hover-class="phone-toggle-btn--hover">
                <text class="phone-toggle-text">{{phoneVisible ? '复制' : '查看'}}</text>
              </view>
            </view>
          </view>
        </view>
      </view>
    </view>
  </view>

  <!-- 月份切换 -->
  <view class="month-switcher">
    <view class="month-btn {{canPrev ? '' : 'disabled'}}" bindtap="onPrevMonth">
      <t-icon name="chevron-left" size="32rpx" color="{{canPrev ? '#777777' : '#dcdcdc'}}" />
    </view>
    <text class="month-label">{{monthLabel}}</text>
    <view class="month-btn {{canNext ? '' : 'disabled'}}" bindtap="onNextMonth">
      <t-icon name="chevron-right" size="32rpx" color="{{canNext ? '#777777' : '#dcdcdc'}}" />
    </view>
  </view>

  <!-- 月度统计概览 -->
  <view class="month-summary">
    <view class="summary-item">
      <text class="summary-label">本月服务</text>
      <text class="summary-value">{{monthCount}}</text>
    </view>
    <view class="summary-divider"></view>
    <view class="summary-item">
      <text class="summary-label">服务时长</text>
      <text class="summary-value value-primary">{{monthHours}}</text>
    </view>
    <view class="summary-divider"></view>
    <view class="summary-item">
      <text class="summary-label">关系指数</text>
      <text class="summary-value value-warning">{{monthRelation}}</text>
    </view>
  </view>

  <!-- 记录列表（service-record-card 组件）-->
  <view class="records-container">

    <!-- 月份数据加载中 -->
    <view class="month-loading" wx:if="{{monthLoading}}">
      <t-loading theme="circular" size="40rpx" />
      <text class="month-loading-text">加载中...</text>
    </view>

    <!-- 无当月记录 -->
    <view class="no-month-data" wx:elif="{{records.length === 0}}">
      <t-icon name="chart-bar" size="100rpx" color="#dcdcdc" />
      <text class="no-month-text">本月暂无服务记录</text>
    </view>

    <service-record-card
      wx:for="{{records}}"
      wx:key="id"
      time="{{item.displayDate}}"
      course-label="{{item.type}}"
      type-class="{{item.typeClass}}"
      type="{{item.recordType}}"
      table-no="{{item.table}}"
      hours="{{item.durationHours}}"
      hours-raw="{{item.durationRaw}}"
      drinks="{{item.drinks}}"
      income="{{item.income}}"
      is-estimate="{{item.isEstimate}}"
    />

    <!-- 底部提示 -->
    <view class="list-footer" wx:if="{{records.length > 0}}">
      <text class="footer-text">— 已加载全部记录 —</text>
    </view>

    <!-- 加载更多 -->
    <view class="loading-more" wx:if="{{loadingMore}}">
      <t-loading theme="circular" size="40rpx" />
    </view>

  </view>

  <!-- AI 悬浮按钮 -->
  <ai-float-button customerId="{{customerId}}" />

</block>

<dev-fab />
