<!-- templates/accounts/admin_register.html -->
{% extends 'base.html' %}

{% block title %}Register User - Admin{% endblock %}

{% block content %}
<div class="container mt-4">
    <div class="row">
        <div class="col-md-8 mx-auto">
            <div class="card">
                <div class="card-header">
                    <h3>Register New User</h3>
                </div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        
                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label class="form-label">Username *</label>
                                {{ form.username }}
                                {% if form.username.errors %}
                                <div class="text-danger">{{ form.username.errors }}</div>
                                {% endif %}
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Email *</label>
                                {{ form.email }}
                                {% if form.email.errors %}
                                <div class="text-danger">{{ form.email.errors }}</div>
                                {% endif %}
                            </div>
                        </div>

                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label class="form-label">First Name</label>
                                {{ form.first_name }}
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Last Name</label>
                                {{ form.last_name }}
                            </div>
                        </div>

                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label class="form-label">User Type *</label>
                                {{ form.user_type }}
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Phone Number</label>
                                {{ form.phone_number }}
                            </div>
                        </div>

                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label class="form-label">Date of Birth</label>
                                {{ form.date_of_birth }}
                            </div>
                        </div>

                        <div class="row mb-3">
                            <div class="col-md-6">
                                <label class="form-label">Password *</label>
                                {{ form.password1 }}
                                {% if form.password1.errors %}
                                <div class="text-danger">{{ form.password1.errors }}</div>
                                {% endif %}
                            </div>
                            <div class="col-md-6">
                                <label class="form-label">Confirm Password *</label>
                                {{ form.password2 }}
                                {% if form.password2.errors %}
                                <div class="text-danger">{{ form.password2.errors }}</div>
                                {% endif %}
                            </div>
                        </div>

                        <button type="submit" class="btn btn-primary">Register User</button>
                        <a href="{% url 'user_list' %}" class="btn btn-secondary">Cancel</a>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>

<style>
    input, select {
        width: 100%;
        padding: 8px;
        border: 1px solid #ddd;
        border-radius: 4px;
    }
    .text-danger {
        font-size: 0.9em;
        margin-top: 5px;
    }
</style>
{% endblock %}