{% extends 'base.html' %}
{% block title %}Tenant Onboarding{% endblock %}

{% block content %}
<div class="container mt-3">

    <!-- ================= HEADER ================= -->
    <div class="d-flex justify-content-between align-items-center mb-3">
        <div>
            <h4><i class="bi bi-person-plus"></i> Tenant Onboarding</h4>
            <p class="text-muted mb-0">Complete your profile to continue</p>
        </div>

        <div class="d-flex gap-2">
            <a href="{% url 'tenant_dashboard' %}" class="btn btn-outline-dark btn-sm">
                <i class="bi bi-arrow-left"></i> Back
            </a>
        </div>
    </div>

    <div class="card shadow-lg p-4">

        <form method="POST" enctype="multipart/form-data">
            {% csrf_token %}

            <!-- ================= FORM ERRORS ================= -->
            {% if form.errors %}
                <div class="alert alert-danger">
                    Please correct the errors below.
                </div>
            {% endif %}

            <!-- ================= STATIC INFO ================= -->
            <div class="row mb-3">
                <div class="col-md-6">
                    <label class="form-label">Full Name</label>
                    <input type="text" class="form-control"
                           value="{{ request.user.get_full_name }}" readonly>
                </div>

                <div class="col-md-6">
                    <label class="form-label">ID Number</label>
                    <input type="text" class="form-control"
                           value="{{ profile.id_number|default:'' }}" readonly>
                </div>
            </div>

            <hr>

            <!-- ================= REQUIRED INPUTS ================= -->
            <div class="row">

                <div class="col-md-6">
                    <div class="mb-3">
                        <label class="form-label">ID Image</label>
                        {{ form.id_image }}

                        {% if form.id_image.errors %}
                            <div class="text-danger small">
                                {{ form.id_image.errors }}
                            </div>
                        {% endif %}
                    </div>

                    <div class="mb-3">
                        <label class="form-label">M-Pesa Number</label>
                        {{ form.mpesa_number }}

                        {% if form.mpesa_number.errors %}
                            <div class="text-danger small">
                                {{ form.mpesa_number.errors }}
                            </div>
                        {% endif %}
                    </div>
                </div>

                <div class="col-md-6">
                    <div class="mb-3">
                        <label class="form-label">Emergency Contact</label>
                        {{ form.emergency_contact }}

                        {% if form.emergency_contact.errors %}
                            <div class="text-danger small">
                                {{ form.emergency_contact.errors }}
                            </div>
                        {% endif %}
                    </div>
                </div>

            </div>

            <hr>

            <!-- ================= SUBMIT ================= -->
            <div class="d-flex justify-content-end">
                <button type="submit" class="btn btn-primary">
                    <i class="bi bi-check-circle"></i> Submit
                </button>
            </div>

        </form>

    </div>

</div>
{% endblock %}