{% extends "base.html" %}
{% block title %}Nouveau service — 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> {{ 'Modifier le service' if service is defined else 'Nouveau service' }}</h1>
        <a href="{{ url_for('services.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="mb-3">
                    <label class="form-label">Nom *</label>
                    <input type="text" name="name" class="form-control" value="{{ service.name if service is defined else '' }}" required>
                </div>
                
                <div class="mb-3">
                    <label class="form-label">Description</label>
                    <textarea name="description" class="form-control" rows="3">{{ service.description if service is defined and service.description else '' }}</textarea>
                </div>
                {% if service is defined %}<div class="form-check mb-3"><input class="form-check-input" type="checkbox" name="is_active" id="is_active" {% if service.is_active %}checked{% endif %}><label class="form-check-label" for="is_active">Service actif</label></div>{% endif %}
                
                <div class="text-end">
                    <button type="submit" class="btn btn-primary">
                        <i class="bi bi-check-lg"></i> Enregistrer
                    </button>
                </div>
            </form>
        </div>
    </div>
</div>
{% endblock %}
