{% extends 'base.html' %}
{% load static %}

{% block content %}
<div class="container-fluid py-4">
    <div class="row justify-content-center">
        <div class="col-lg-6">
            <div class="card shadow-sm border-0">
                <div class="card-header bg-white py-3 fw-bold">
                    <i class="bi bi-exclamation-triangle text-danger me-2"></i>Зафиксировать поломку
                </div>
                <div class="card-body">
                    <form method="post" enctype="multipart/form-data">
                        {% csrf_token %}
                        {% for field in form %}
                        <div class="mb-3">
                            <label class="form-label small fw-bold">{{ field.label }}</label>
                            {{ field }}
                            {% for error in field.errors %}
                            <div class="text-danger small">{{ error }}</div>
                            {% endfor %}
                        </div>
                        {% endfor %}
                        <div class="mt-4 pt-3 border-top">
                            <button type="submit" class="btn btn-danger px-4 rounded-pill">Сохранить поломку</button>
                            <a href="{% url 'fleet_list' %}" class="btn btn-link text-muted">Отмена</a>
                        </div>
                    </form>
                </div>
            </div>
            
            <div class="alert alert-warning mt-4 small shadow-sm border-0">
                <i class="bi bi-info-circle me-2"></i>
                После сохранения статус техники автоматически изменится на "Сломана" или "Ждёт деталь".
            </div>
        </div>
    </div>
</div>

<script>
    document.querySelectorAll('input, select, textarea').forEach(el => {
        if (!el.classList.contains('form-check-input')) {
            el.classList.add('form-control');
        }
    });
</script>
{% endblock %}
