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

{% block content %}
<div class="container-fluid">
    <div class="row mb-4">
        <div class="col">
            <h1><i class="bi bi-calendar2-event"></i> {{ title }}</h1>
        </div>
    </div>
    
    <div class="row">
        <div class="col-md-6">
            <div class="card">
                <div class="card-body">
                    <form method="POST">
                        <div class="mb-3">
                            <label for="name" class="form-label">Nom</label>
                            <input type="text" class="form-control" id="name" name="name" value="{{ closure.name }}" required>
                        </div>
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label for="start_date" class="form-label">Du</label>
                                <input type="date" class="form-control" id="start_date" name="start_date" 
                                       value="{{ closure.start_date.strftime('%Y-%m-%d') if closure.start_date else '' }}" required>
                            </div>
                            <div class="col-md-6">
                                <label for="end_date" class="form-label">Au</label>
                                <input type="date" class="form-control" id="end_date" name="end_date"
                                       value="{{ closure.end_date.strftime('%Y-%m-%d') if closure.end_date else '' }}" required>
                            </div>
                        </div>
                        <div class="mb-3">
                            <label for="work_hours_type" class="form-label">Travail pendant cette période</label>
                            <select class="form-select" id="work_hours_type" name="work_hours_type">
                                <option value="none" {% if closure.work_hours_type == 'none' %}selected{% endif %}>Non travaillé (congé)</option>
                                <option value="reduced" {% if closure.work_hours_type == 'reduced' %}selected{% endif %}>Horaires réduits</option>
                                <option value="custom" {% if closure.work_hours_type == 'custom' %}selected{% endif %}>Horaires spécifiques</option>
                            </select>
                            <small class="text-muted">
                                <i class="bi bi-info-circle"></i> 
                                Sélectionnez "Horaires réduits" ou "Horaires spécifiques" si vous travaillez pendant les vacances avec des horaires différents.
                            </small>
                        </div>
                        <div class="mb-3">
                            <label for="notes" class="form-label">Notes / Horaires précis</label>
                            <textarea class="form-control" id="notes" name="notes" rows="3">{{ closure.notes or '' }}</textarea>
                            <small class="text-muted">Indiquez les horaires précis si vous travaillez pendant cette période.</small>
                        </div>
                        <div class="d-flex justify-content-between">
                            <a href="{{ url_for('planning.availability') }}" class="btn btn-secondary">
                                <i class="bi bi-x"></i> Annuler
                            </a>
                            <button type="submit" class="btn btn-primary">
                                <i class="bi bi-check"></i> Enregistrer
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}