{% extends "base.html" %}

{% block title %}平台总览{% endblock %}

{% block content %}
  <section class="page-header">
    <span class="eyebrow">Overview</span>
    <h1 class="page-title">批次总览</h1>
    <p class="page-lead">从这里直接进入知识库、文件中心、审核工作台和审计页。保留必要信息，不堆大段说明。</p>
  </section>

  <section class="metric-grid">
    {% for metric in hero_metrics %}
      <article class="metric-card">
        <div class="metric-label">{{ metric.label }}</div>
        <div class="metric-value">{{ metric.value }}</div>
      </article>
    {% endfor %}
  </section>

  <section class="grid-2">
    <a class="link-card" href="{% url 'platform_ui:knowledge-base' %}">
      <h3>知识库配置</h3>
      <p>查看规则树、知识源和切片策略。</p>
    </a>
    <a class="link-card" href="{% url 'documents:list' %}">
      <h3>资料包</h3>
      <p>导入资料包，按产品名称搜索并跳转关联会话。</p>
    </a>
    <a class="link-card" href="{% url 'chat:index' %}">
      <h3>审核智能体</h3>
      <p>进入会话工作台，查看节点式审核结果。</p>
    </a>
    <a class="link-card" href="{% url 'audit:list' %}">
      <h3>处理历史</h3>
      <p>查看每次执行的输入、输出和通知留痕。</p>
    </a>
  </section>

  <section class="panel">
    <div class="section-heading">
      <div>
        <h2 class="section-title">已配置审核场景</h2>
        <p class="section-copy">保留现有场景列表，直接进入使用。</p>
      </div>
    </div>

    {% if scenario_issues %}
      <div class="stack" style="margin-bottom: 18px;">
        <div class="muted">配置异常</div>
        {% for issue in scenario_issues %}
          <article class="notice notice-error"><strong>{{ issue.file_name }}</strong>：{{ issue.message }}</article>
        {% endfor %}
      </div>
    {% endif %}

    <div class="grid-2">
      {% for scenario in scenarios %}
        <article class="panel">
          <div class="badge-row">
            <span class="pill">{{ scenario.id }}</span>
            <span class="pill {% if scenario.rag.enabled %}pill-success{% else %}pill-signal{% endif %}">RAG {% if scenario.rag.enabled %}开启{% else %}关闭{% endif %}</span>
          </div>
          <h3 style="margin: 14px 0 8px;">{{ scenario.name }}</h3>
          <p>{{ scenario.description }}</p>
          <p class="muted" style="margin-top: 10px;">适用题型：
            {% if scenario.applicable_questions %}
              {{ scenario.applicable_questions|join:"、" }}
            {% else %}
              暂未配置
            {% endif %}
          </p>
          <div class="button-row" style="margin-top: 16px;">
            <a class="button button-primary" href="{% url 'chat:index' %}">进入审核智能体</a>
          </div>
        </article>
      {% empty %}
        <div class="notice">暂无可用场景，请检查 `configs/` 目录和 YAML 配置内容。</div>
      {% endfor %}
    </div>
  </section>
{% endblock %}
