{% extends "base.html" %}
{% block title %}{{ page_title }}{% endblock %}
{% block content %}
{% include "core/_nav.html" %}
<main class="page-shell">
  <section class="container py-5">
    <div class="d-flex justify-content-between align-items-end mb-4 flex-wrap gap-3">
      <div>
        <p class="eyebrow mb-2">Case Library</p>
        <h1 class="page-title">Daftar Kasus OPTEMA</h1>
        <p class="section-copy mb-0">Histori masalah yang sudah diproses menjadi keputusan dan action plan.</p>
      </div>
      <a href="{% url 'home' %}#analisis" class="btn btn-optema">Tambah Kasus Baru</a>
    </div>
    <div class="row g-4">
      {% for case in cases %}
        <div class="col-md-6 col-xl-4">
          <a class="case-card h-100" href="{{ case.get_absolute_url }}">
            <span class="case-area">{{ case.get_business_area_display }} · Urgensi {{ case.urgency }}/5</span>
            <h2>{{ case.title }}</h2>
            <p>{{ case.description|truncatechars:130 }}</p>
            <div class="case-meta"><span>Prioritas {{ case.priority_score }}/100</span><span>{{ case.created_at|date:"d M Y" }}</span></div>
          </a>
        </div>
      {% empty %}
        <div class="col-12">
          <div class="empty-state">
            <h2>Case library masih kosong.</h2>
            <p>Buat analisis pertama untuk mulai membangun histori keputusan.</p>
            <a href="{% url 'home' %}#analisis" class="btn btn-optema">Mulai Analisis</a>
          </div>
        </div>
      {% endfor %}
    </div>
  </section>
</main>
{% endblock %}
