@component('admin/layouts/main')
  @slot('main')
    <div class="flex justify-between items-center mb-6">
      <h1 class="text-2xl font-bold">Projets</h1>
      <a href="/admin/projects/create" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
        Nouveau projet
      </a>
    </div>
    <div class="bg-white rounded shadow overflow-hidden">
      <table class="min-w-full divide-y divide-gray-200">
        <thead class="bg-gray-50">
          <tr>
            <th class="px-4 py-2 text-left text-sm font-medium text-gray-700">Titre</th>
            <th class="px-4 py-2 text-left text-sm font-medium text-gray-700">Catégorie</th>
            <th class="px-4 py-2 text-left text-sm font-medium text-gray-700">Début</th>
            <th class="px-4 py-2 text-right text-sm font-medium text-gray-700">Actions</th>
          </tr>
        </thead>
        <tbody class="divide-y divide-gray-200">
          @each(p in projects)
            <tr>
              <td class="px-4 py-2">{{ p.title }}</td>
              <td class="px-4 py-2">{{ p.category?.name || '-' }}</td>
              <td class="px-4 py-2">{{ p.start ? p.start.toISODate() : '-' }}</td>
              <td class="px-4 py-2 text-right">
                <a href="/admin/projects/{{ p.id }}/edit" class="text-blue-600 hover:underline mr-2">Modifier</a>
                <form action="/admin/projects/{{ p.id }}/delete" method="post" class="inline">
                  {{{ csrfField() }}}
                  <button type="submit" class="text-red-600 hover:underline" onclick="return confirm('Supprimer ?')">
                    Supprimer
                  </button>
                </form>
              </td>
            </tr>
          @else
            <tr>
              <td colspan="4" class="px-4 py-6 text-center text-gray-500">Aucun projet</td>
            </tr>
          @endeach
        </tbody>
      </table>
    </div>
  @endslot
@end
