{% extends "base.html" %}
{% block title %}Nouvelle intervention — GMAO{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1><i class="bi bi-plus-circle"></i> Nouvelle intervention</h1>
        <a href="{{ url_for('interventions.index') }}" class="btn btn-secondary">
            <i class="bi bi-arrow-left"></i> Retour
        </a>
    </div>

    <div class="card">
        <div class="card-body">
            <form method="POST">
                <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
                
                <div class="row mb-3">
                    <div class="col-md-8">
                        <label class="form-label">Titre *</label>
                        <input type="text" name="title" class="form-control" required>
                    </div>
                    <div class="col-md-4">
                        <label class="form-label">Priorité</label>
                        <select name="priority" class="form-select">
                            <option value="basse">Basse</option>
                            <option value="normale" selected>Normale</option>
                            <option value="haute">Haute</option>
                            <option value="urgente">Urgente</option>
                        </select>
                    </div>
                </div>

                <div class="row mb-3">
                    <div class="col-md-6">
                        <label class="form-label">Type</label>
                        <select name="intervention_type" class="form-select">
                            <option value="corrective">Corrective</option>
                            <option value="preventive">Préventive</option>
                            <option value="ameliorative">Améliorative</option>
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Lot</label>
                        <select name="lot_id" class="form-select">
                            <option value="">-- Sélectionner --</option>
                            {% for lot in lots %}
                            <option value="{{ lot.id }}">{{ lot.name }}</option>
                            {% endfor %}
                        </select>
                    </div>
                </div>

                <div class="row mb-3">
                    <div class="col-md-6">
                        <label class="form-label">Équipement</label>
                        <select name="equipment_id" class="form-select">
                            <option value="">-- Sélectionner --</option>
                            {% for equipment in equipments %}
                            <option value="{{ equipment.id }}">{{ equipment.name }}</option>
                            {% endfor %}
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Salle</label>
                        <select name="room_id" class="form-select">
                            <option value="">-- Sélectionner --</option>
                            {% for room in rooms %}
                            <option value="{{ room.id }}">{{ room.name }}</option>
                            {% endfor %}
                        </select>
                    </div>
                </div>

                <div class="mb-3">
                    <label class="form-label">Description</label>
                    <textarea name="description" class="form-control" rows="4"></textarea>
                </div>

                <div class="mb-3">
                    <label class="form-label">Notes</label>
                    <textarea name="notes" class="form-control" rows="2"></textarea>
                </div>

                <div class="text-end">
                    <button type="submit" class="btn btn-primary">
                        <i class="bi bi-check-lg"></i> Créer l'intervention
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}