{% extends 'base.html' %}
{% block title %}{{ title }} - RepairsHub{% endblock %}
{% block content %}
<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card shadow-sm">
                <div class="card-body p-4">
                    <h2 class="h4 mb-4">{{ title }}</h2>
                    <form method="post" novalidate>
                        {% csrf_token %}
                        
                        <div class="row g-3">
                            <div class="col-md-6">
                                <label class="form-label fw-medium">Job Reference *</label>
                                {{ form.job_ref }}
                                {% if form.job_ref.errors %}<div class="text-danger small mt-1">{{ form.job_ref.errors.0 }}</div>{% endif %}
                            </div>

                            <div class="col-md-6">
                                <label class="form-label fw-medium">Client *</label>
                                {{ form.client }}
                                {% if form.client.errors %}<div class="text-danger small mt-1">{{ form.client.errors.0 }}</div>{% endif %}
                            </div>
                            
                            {% if company.is_uprn_required %}
                            <div class="col-md-6">
                                <label class="form-label fw-medium">UPRN *</label>
                                {{ form.uprn }}
                                {% if form.uprn.errors %}<div class="text-danger small mt-1">{{ form.uprn.errors.0 }}</div>{% endif %}
                            </div>
                            {% endif %}

                            <div class="col-12">
                                <label class="form-label fw-medium">Address Line 1 *</label>
                                {{ form.address_line_1 }}
                                {% if form.address_line_1.errors %}<div class="text-danger small mt-1">{{ form.address_line_1.errors.0 }}</div>{% endif %}
                            </div>

                            <div class="col-md-6">
                                <label class="form-label fw-medium">Address Line 2</label>
                                {{ form.address_line_2 }}
                            </div>

                            <div class="col-md-6">
                                <label class="form-label fw-medium">Address Line 3</label>
                                {{ form.address_line_3 }}
                            </div>

                            <div class="col-md-6">
                                <label class="form-label fw-medium">Postcode *</label>
                                {{ form.postcode }}
                                {% if form.postcode.errors %}<div class="text-danger small mt-1">{{ form.postcode.errors.0 }}</div>{% endif %}
                            </div>

                            <div class="col-md-6">
                                <label class="form-label fw-medium">Current Status</label>
                                {{ form.status }}
                                {% if form.status.errors %}<div class="text-danger small mt-1">{{ form.status.errors.0 }}</div>{% endif %}
                            </div>

                            <div class="col-12">
                                <hr class="my-4 text-muted opacity-25">
                            </div>

                            <div class="col-12">
                                <label class="form-label fw-medium">Description</label>
                                {{ form.description }}
                            </div>

                            <div class="col-12">
                                <label class="form-label fw-medium">Actions Required</label>
                                {{ form.action }}
                            </div>

                            <div class="col-12">
                                <label class="form-label fw-medium">Notes</label>
                                {{ form.notes }}
                            </div>

                            <div class="col-12 mt-5">
                                <button type="submit" class="btn btn-primary w-100 py-3">Save Repair Job</button>
                                <a href="{% if form.instance.pk %}{% url 'job_detail' form.instance.pk %}{% else %}{% url 'job_list' %}{% endif %}" class="btn btn-link w-100 text-muted mt-2">Cancel</a>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}