{% extends "base.html" %}
{% block title %}Ajouter un lot — GMAO{% endblock %}
{% block content %}
<div class="container-fluid">
  <div class="d-flex justify-content-between align-items-center mb-4">
    <div><h1><i class="bi bi-boxes"></i> Ajouter un lot</h1>
      <p class="text-muted mb-0">Un lot regroupe des équipements et leurs actions de maintenance préventive.</p></div>
    <a href="{{ url_for('lots.index') }}" class="btn btn-secondary">Annuler</a>
  </div>
  <div class="card"><div class="card-body">
    <form method="post">
      <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
      <div class="mb-3"><label for="name" class="form-label">Nom du lot <span class="text-danger">*</span></label>
        <input id="name" name="name" class="form-control" required maxlength="500" value="{{ request.form.get('name','') }}" placeholder="Ex. Éclairage des salles"></div>
      <div class="mb-3"><label for="category_id" class="form-label">Catégorie</label>
        <select id="category_id" name="category_id" class="form-select"><option value="">-- À choisir --</option>{% for category in categories %}<option value="{{ category.id }}" {% if request.form.get('category_id')|int == category.id %}selected{% endif %}>{{ category.name }}</option>{% endfor %}</select></div>
      <div class="form-check mb-3"><input id="is_present" name="is_present" class="form-check-input" type="checkbox" checked><label for="is_present" class="form-check-label">Ce lot est présent dans l'établissement</label></div>
      <button class="btn btn-primary" type="submit"><i class="bi bi-check-lg"></i> Créer le lot</button>
    </form>
  </div></div>
</div>
{% endblock %}
