<view class="container">
  <view class="hero fade-up">
    <view class="hero-badge">CONTROL CENTER</view>
    <view class="hero-title">{{user ? ('欢迎，' + user.nickname) : '社区内容风控工作台'}}</view>
    <view class="hero-sub">发布内容将实时进入朴素贝叶斯识别流程，疑似垃圾信息自动拦截并支持申诉。</view>
    <view class="hero-meta" wx:if="{{modelInfo}}">
      <text class="hero-metric">版本 {{modelInfo.version || '未训练'}}</text>
      <text class="hero-metric">阈值 {{thresholdText}}</text>
      <text class="hero-metric">样本 {{modelInfo.sample_count || 0}}</text>
    </view>
  </view>

  <view class="card fade-up fade-up-delay-1" wx:if="{{modelInfo}}">
    <view class="card-title">检测引擎状态</view>
    <view class="grid-2">
      <view class="kpi">
        <view class="kpi-label">模型版本</view>
        <view class="kpi-value">{{modelInfo.version || '未训练'}}</view>
      </view>
      <view class="kpi">
        <view class="kpi-label">训练样本</view>
        <view class="kpi-value">{{modelInfo.sample_count || 0}}</view>
      </view>
      <view class="kpi">
        <view class="kpi-label">垃圾阈值</view>
        <view class="kpi-value">{{thresholdText}}</view>
      </view>
      <view class="kpi">
        <view class="kpi-label">最近训练</view>
        <view class="kpi-value small">{{modelInfo.trained_at || '--'}}</view>
      </view>
    </view>
  </view>

  <view class="card fade-up fade-up-delay-2">
    <view class="card-title">用户功能</view>
    <view class="card-desc">常用操作入口，覆盖发布、检测、历史和账号设置。</view>
    <view class="grid-2">
      <view class="module-card" wx:for="{{userModules}}" wx:key="name" data-path="{{item.path}}" bindtap="goto">
        <view class="module-name">{{item.name}}</view>
        <view class="module-desc">{{item.desc}}</view>
        <view class="module-tag">{{item.tag}}</view>
      </view>
    </view>
  </view>

  <view class="card fade-up fade-up-delay-3" wx:if="{{user && user.is_admin}}">
    <view class="card-title">管理员功能</view>
    <view class="card-desc">支持阈值调节、复核处理、样本维护和用户管理。</view>
    <view class="grid-2">
      <view class="module-card" wx:for="{{adminModules}}" wx:key="name" data-path="{{item.path}}" bindtap="goto">
        <view class="module-name">{{item.name}}</view>
        <view class="module-desc">{{item.desc}}</view>
        <view class="module-tag">{{item.tag}}</view>
      </view>
    </view>
  </view>

  <button class="btn btn-ghost fade-up fade-up-delay-3" bindtap="logout">退出登录</button>
</view>
