{% extends "base.html" %}
{% import "macros/ui.html" as m %}

{% block title %}Dashboard — Ontoref{% endblock title %}
{% block nav_dashboard %}active{% endblock nav_dashboard %}

{% block content %}
<div class="mb-6">
  <h1 class="text-2xl font-bold">Dashboard</h1>
  <p class="text-base-content/60 text-sm font-mono mt-1">{{ project_root }}</p>
</div>

<!-- Daemon stats -->
<div class="stats stats-horizontal shadow w-full mb-4 bg-base-200 overflow-x-auto">
  {{ m::stat(title="Uptime", value=uptime_secs ~ "s", desc="seconds since start") }}
  {{ m::stat(title="Cache entries", value=cache_entries) }}
  {{ m::stat(title="Cache hit rate", value=cache_hit_rate, desc=cache_hits ~ " hits / " ~ cache_misses ~ " misses", accent="success") }}
  {{ m::stat(title="Sessions", value=active_actors, accent="primary") }}
  {{ m::stat(title="Notifications", value=notification_count, accent="warning") }}
</div>

<!-- Project status -->
{% if backlog %}
<div class="stats stats-horizontal shadow w-full mb-8 bg-base-200 overflow-x-auto">
  {{ m::stat(title="Backlog total", value=backlog.total) }}
  {{ m::stat(title="Open", value=backlog.open, accent="warning") }}
  {{ m::stat(title="In progress", value=backlog.inprog, accent="info") }}
  {{ m::stat(title="Done", value=backlog.done, accent="success") }}
  {{ m::stat(title="Critical", value=backlog.critical, accent="error") }}
  {{ m::stat(title="ADRs", value=adr_count) }}
  {{ m::stat(title="Modes", value=mode_count) }}
</div>
{% endif %}

<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4">
  <a href="{{ base_url }}/graph" class="card bg-base-200 hover:bg-base-300 transition-colors cursor-pointer">
    <div class="card-body">
      <h2 class="card-title text-primary">Ontology Graph</h2>
      <p class="text-sm text-base-content/60">Nodes, edges, and relationships from <code>.ontology/core.ncl</code></p>
    </div>
  </a>
  <a href="{{ base_url }}/sessions" class="card bg-base-200 hover:bg-base-300 transition-colors cursor-pointer">
    <div class="card-body">
      <h2 class="card-title text-secondary">Active Sessions</h2>
      <p class="text-sm text-base-content/60">{{ active_actors }} actor(s) currently registered</p>
    </div>
  </a>
  <a href="{{ base_url }}/notifications" class="card bg-base-200 hover:bg-base-300 transition-colors cursor-pointer">
    <div class="card-body">
      <h2 class="card-title text-warning">Notifications</h2>
      <p class="text-sm text-base-content/60">{{ notification_count }} notification(s) in store</p>
    </div>
  </a>
  <a href="{{ base_url }}/modes" class="card bg-base-200 hover:bg-base-300 transition-colors cursor-pointer">
    <div class="card-body">
      <h2 class="card-title text-accent">Reflection Modes</h2>
      <p class="text-sm text-base-content/60">NCL DAG workflows in <code>reflection/modes/</code></p>
      {% if mode_count %}<p class="text-xs text-base-content/40 mt-1">{{ mode_count }} modes</p>{% endif %}
    </div>
  </a>
  <a href="{{ base_url }}/backlog" class="card bg-base-200 hover:bg-base-300 transition-colors cursor-pointer">
    <div class="card-body">
      <h2 class="card-title text-info">Backlog</h2>
      {% if backlog %}
      <p class="text-sm text-base-content/60">{{ backlog.open }} open · {{ backlog.inprog }} in progress · {{ backlog.critical }} critical</p>
      {% else %}
      <p class="text-sm text-base-content/60">Work items in <code>reflection/backlog.ncl</code></p>
      {% endif %}
    </div>
  </a>
  <a href="{{ base_url }}/search" class="card bg-base-200 hover:bg-base-300 transition-colors cursor-pointer">
    <div class="card-body">
      <h2 class="card-title">Search</h2>
      <p class="text-sm text-base-content/60">Full-text across nodes, ADRs, and modes</p>
      {% if adr_count %}<p class="text-xs text-base-content/40 mt-1">{{ adr_count }} ADRs</p>{% endif %}
    </div>
  </a>
  <a href="{{ base_url }}/actions" class="card bg-base-200 hover:bg-base-300 transition-colors cursor-pointer">
    <div class="card-body">
      <h2 class="card-title text-primary">Quick Actions</h2>
      <p class="text-sm text-base-content/60">Catalog of runnable tasks and workflows</p>
    </div>
  </a>
  <a href="{{ base_url }}/qa" class="card bg-base-200 hover:bg-base-300 transition-colors cursor-pointer">
    <div class="card-body">
      <h2 class="card-title">Q&amp;A Bookmarks</h2>
      <p class="text-sm text-base-content/60">Saved questions and answers about this project</p>
    </div>
  </a>
</div>
{% endblock content %}
