<!--银行监管首页-->
<view class="page-container">
  <!-- 顶部用户信息 -->
  <view class="header" wx:if="{{userInfo}}">
    <view class="user-info">
      <image class="avatar" src="{{userInfo.avatar || '/images/default-avatar.png'}}" mode="aspectFill"></image>
      <view class="user-details">
        <text class="username">{{userInfo.name}}</text>
        <text class="role">{{userInfo.role_name}}</text>
      </view>
    </view>
    <view class="header-actions">
      <navigator url="/pages/notification/index" class="notification-btn">
        <image src="/images/icons/notification.png" mode="aspectFit"></image>
        <view class="notification-badge" wx:if="{{riskAlerts.length > 0}}">{{riskAlerts.length}}</view>
      </navigator>
    </view>
  </view>

  <!-- 仪表板统计 -->
  <view class="dashboard-stats">
    <view class="stats-grid">
      <view class="stat-item">
        <text class="stat-number">{{formatNumber(dashboardData.totalLoans)}}</text>
        <text class="stat-label">总贷款数</text>
        <text class="stat-unit">笔</text>
      </view>
      <view class="stat-item">
        <text class="stat-number">{{formatNumber(dashboardData.pendingApprovals)}}</text>
        <text class="stat-label">待审批</text>
        <text class="stat-unit">笔</text>
      </view>
      <view class="stat-item">
        <text class="stat-number">{{formatNumber(dashboardData.riskAlerts)}}</text>
        <text class="stat-label">风险警报</text>
        <text class="stat-unit">个</text>
      </view>
      <view class="stat-item">
        <text 
          class="stat-number" 
          style="color: {{getComplianceScoreColor(dashboardData.complianceScore)}}"
        >
          {{dashboardData.complianceScore}}
        </text>
        <text class="stat-label">合规分数</text>
        <text class="stat-unit">分</text>
      </view>
    </view>
  </view>

  <!-- 快捷操作 -->
  <view class="quick-actions">
    <view class="section-title">快捷操作</view>
    <view class="actions-grid">
      <view 
        class="action-item"
        wx:for="{{quickActions}}"
        wx:key="name"
        data-action="{{item}}"
        bindtap="onQuickAction"
      >
        <view class="action-icon">
          <image src="/images/icons/{{item.icon}}.png" mode="aspectFit"></image>
        </view>
        <text class="action-name">{{item.name}}</text>
      </view>
    </view>
  </view>

  <!-- 风险警报 -->
  <view class="risk-alerts" wx:if="{{riskAlerts.length > 0}}">
    <view class="section-header">
      <text class="section-title">风险警报</text>
      <text class="section-more" bindtap="onViewAllRiskAlerts">查看全部</text>
    </view>
    <view class="alerts-list">
      <view 
        class="alert-item"
        wx:for="{{riskAlerts}}"
        wx:key="id"
        data-alert="{{item}}"
        bindtap="onRiskAlertTap"
      >
        <view class="alert-icon {{formatRiskLevel(item.level).color}}">
          <image src="/images/icons/warning.png" mode="aspectFit"></image>
        </view>
        <view class="alert-content">
          <text class="alert-title">{{item.title}}</text>
          <text class="alert-desc">{{item.description}}</text>
          <text class="alert-time">{{formatTime(item.created_at)}}</text>
        </view>
        <view class="alert-level">
          <text 
            class="level-badge" 
            style="background-color: {{formatRiskLevel(item.level).color}}"
          >
            {{formatRiskLevel(item.level).text}}
          </text>
        </view>
      </view>
    </view>
  </view>

  <!-- 最近活动 -->
  <view class="recent-activities" wx:if="{{recentActivities.length > 0}}">
    <view class="section-header">
      <text class="section-title">最近活动</text>
      <text class="section-more" bindtap="onViewAllActivities">查看全部</text>
    </view>
    <view class="activities-list">
      <view 
        class="activity-item"
        wx:for="{{recentActivities}}"
        wx:key="id"
        data-activity="{{item}}"
        bindtap="onActivityTap"
      >
        <view class="activity-icon">
          <image src="/images/icons/{{item.type}}.png" mode="aspectFit"></image>
        </view>
        <view class="activity-content">
          <text class="activity-title">{{item.title}}</text>
          <text class="activity-desc">{{item.description}}</text>
          <text class="activity-time">{{formatTime(item.created_at)}}</text>
        </view>
        <view class="activity-arrow">
          <image src="/images/icons/arrow-right.png" mode="aspectFit"></image>
        </view>
      </view>
    </view>
  </view>

  <!-- 加载状态 -->
  <view class="loading" wx:if="{{loading}}">
    <view class="loading-spinner"></view>
    <text>加载中...</text>
  </view>

  <!-- 空状态 -->
  <view class="empty" wx:if="{{!loading && recentActivities.length === 0 && riskAlerts.length === 0}}">
    <image class="empty-icon" src="/images/empty-dashboard.png" mode="aspectFit"></image>
    <text class="empty-text">暂无数据</text>
    <text class="empty-desc">系统正在收集监管数据</text>
  </view>
</view>