{% extends "base.html" %}
{% block content %}
<section class="grid-cards">
  <article class="card glass">
    <h3 data-i18n="dashboard.gateway_status">Gateway 状态</h3>
    <div class="metric {{ 'ok' if gateway.running else 'bad' }}">
      <span data-i18n="{{ 'dashboard.gateway_running' if gateway.running else 'dashboard.gateway_stopped' }}">{{ '运行中' if gateway.running else '已停止' }}</span>
    </div>
    <p>PID: {{ gateway.pid or '-' }}</p>
  </article>
  <article class="card glass">
    <h3 data-i18n="dashboard.total_sessions">会话总数</h3>
    <div class="metric">{{ conversation_total }}</div>
    <p data-i18n="dashboard.cover_all_channels">覆盖所有渠道</p>
  </article>
  <article class="card glass">
    <h3 data-i18n="dashboard.total_messages">消息总量</h3>
    <div class="metric">{{ message_total }}</div>
    <p data-i18n="dashboard.aggregated_by_recorder">按 recorder 数据聚合</p>
  </article>
</section>

<section class="card glass">
  <h3 data-i18n="dashboard.channel_overview">渠道概览</h3>
  <table class="table">
    <thead><tr><th data-i18n="common.channel">渠道</th><th data-i18n="common.sessions">会话数</th><th data-i18n="common.messages">消息数</th></tr></thead>
    <tbody>
      {% for ch in channels %}
      <tr>
        <td>{{ ch.name }}</td>
        <td>{{ ch.conversation_count }}</td>
        <td>{{ ch.message_count }}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</section>

<section class="card glass">
  <h3 data-i18n="dashboard.recent_errors">最近错误</h3>
  <pre class="logs">{% for line in errors %}{{ line }}
{% endfor %}</pre>
</section>
{% endblock %}
