@component('admin/layouts/main')
  @slot('main')
    <h1 class="text-2xl font-bold mb-6">{{ training ? 'Modifier la formation' : 'Nouvelle formation' }}</h1>
    <form action="{{ training ? `/admin/trainings/${training.id}` : '/admin/trainings' }}" method="post" class="bg-white p-6 rounded shadow max-w-xl">
      {{{ csrfField() }}}
      <div class="space-y-4">
        <div>
          <label for="name" class="block text-sm font-medium text-gray-700 mb-1">Nom</label>
          <input type="text" name="name" id="name" value="{{ training?.name || '' }}" required
            class="w-full px-3 py-2 border rounded" />
        </div>
        <div class="grid grid-cols-2 gap-4">
          <div>
            <label for="start" class="block text-sm font-medium text-gray-700 mb-1">Début</label>
            <input type="date" name="start" id="start" value="{{ training?.start ? training.start.toISODate() : '' }}"
              class="w-full px-3 py-2 border rounded" />
          </div>
          <div>
            <label for="end" class="block text-sm font-medium text-gray-700 mb-1">Fin</label>
            <input type="date" name="end" id="end" value="{{ training?.end ? training.end.toISODate() : '' }}"
              class="w-full px-3 py-2 border rounded" />
          </div>
        </div>
        <div>
          <label for="skill" class="block text-sm font-medium text-gray-700 mb-1">Compétence</label>
          <textarea name="skill" id="skill" class="w-full px-3 py-2 border rounded">{{ training?.skill || '' }}</textarea>
        </div>
        <div>
          <label for="place" class="block text-sm font-medium text-gray-700 mb-1">Lieu</label>
          <input type="text" name="place" id="place" value="{{ training?.place || '' }}"
            class="w-full px-3 py-2 border rounded" />
        </div>
        <button type="submit" class="bg-blue-600 text-white px-4 py-2 rounded hover:bg-blue-700">
          Enregistrer
        </button>
      </div>
    </form>
  @endslot
@end
