{% extends "base.html" %}
{% block title %}{{ title }} — GMAO Collège{% endblock %}

{% block content %}
<h1 class="mb-4">{{ title }}</h1>
<div class="card">
    <div class="card-body">
        <form method="POST">
            <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
            <div class="mb-3">
                <label class="form-label">Nom *</label>
                <input type="text" name="name" class="form-control" value="{{ zone.name if zone else '' }}" required placeholder="Ex: Zone Français, Rdc">
            </div>
            <div class="mb-3">
                <label class="form-label">Bâtiment *</label>
                <select name="building_id" class="form-select" required>
                    {% for b in buildings %}
                    <option value="{{ b.id }}" {% if zone and zone.building_id == b.id %}selected{% endif %}>{{ b.name }}</option>
                    {% endfor %}
                </select>
            </div>
            <fieldset class="border rounded p-3 mb-3">
                <legend class="float-none w-auto px-2 fs-6">Durées estimées pour cette zone (espaces verts, minutes)</legend>
                <p class="small text-muted">Laissez vide si cette zone n'est pas concernée. Ces durées sont propres à la zone, pas des valeurs génériques.</p>
                <div class="row g-2">
                    <div class="col-md-3"><label class="form-label" for="mowing_minutes">Tonte</label><input id="mowing_minutes" name="mowing_minutes" type="number" min="1" class="form-control" value="{{ zone.mowing_minutes if zone else '' }}"></div>
                    <div class="col-md-3"><label class="form-label" for="edging_minutes">Bordures</label><input id="edging_minutes" name="edging_minutes" type="number" min="1" class="form-control" value="{{ zone.edging_minutes if zone else '' }}"></div>
                    <div class="col-md-3"><label class="form-label" for="hedge_minutes">Taille des haies</label><input id="hedge_minutes" name="hedge_minutes" type="number" min="1" class="form-control" value="{{ zone.hedge_minutes if zone else '' }}"></div>
                    <div class="col-md-3"><label class="form-label" for="branch_removal_minutes">Ramassage / évacuation</label><input id="branch_removal_minutes" name="branch_removal_minutes" type="number" min="1" class="form-control" value="{{ zone.branch_removal_minutes if zone else '' }}"></div>
                </div>
            </fieldset>
            <div class="mt-3">
                <button type="submit" class="btn btn-primary"><i class="bi bi-check-lg"></i> Enregistrer</button>
                <a href="{{ url_for('zones.index') }}" class="btn btn-outline-secondary">Annuler</a>
            </div>
        </form>
    </div>
</div>
{% endblock %}
