{% extends "base.html" %}

{% block title %}New User - {{ app_name }}{% endblock %}

{% block content %}
<div class="container-fluid">
    <div class="row">
        <div class="col-12">
            <div class="d-flex justify-content-between align-items-center mb-4">
                <div>
                    <nav aria-label="breadcrumb">
                        <ol class="breadcrumb">
                            <li class="breadcrumb-item"><a href="{{ url_for('admin.admin_dashboard') }}">Admin</a></li>
                            <li class="breadcrumb-item"><a href="{{ url_for('admin.list_users') }}">Users</a></li>
                            <li class="breadcrumb-item active">New</li>
                        </ol>
                    </nav>
                    <h1 class="h3 mb-0">
                        <i class="fas fa-user-plus text-primary"></i> New User
                    </h1>
                </div>
                <div>
                    <a href="{{ url_for('admin.list_users') }}" class="btn btn-secondary">
                        <i class="fas fa-arrow-left"></i> Back to Users
                    </a>
                </div>
            </div>
        </div>
    </div>

    <div class="row">
        <div class="col-lg-8">
            <div class="card">
                <div class="card-header">
                    <h5 class="mb-0">
                        <i class="fas fa-id-card"></i> User Information
                    </h5>
                </div>
                <div class="card-body">
                    <form method="POST" action="{{ url_for('admin.create_user') }}">
                        <div class="row">
                            <div class="col-md-6">
                                <div class="mb-3">
                                    <label for="username" class="form-label">Username *</label>
                                    <input type="text" class="form-control" id="username" name="username" required value="{{ request.form.get('username','') }}" placeholder="Enter username">
                                    <div class="form-text">Lowercase; must be unique.</div>
                                </div>
                            </div>
                            <div class="col-md-6">
                                <div class="mb-3">
                                    <label for="role" class="form-label">Role *</label>
                                    <select class="form-select" id="role" name="role" required>
                                        {% set current_role = request.form.get('role','user') %}
                                        <option value="user" {% if current_role == 'user' %}selected{% endif %}>User</option>
                                        <option value="admin" {% if current_role == 'admin' %}selected{% endif %}>Admin</option>
                                    </select>
                                </div>
                            </div>
                        </div>

                        <div class="d-flex justify-content-between">
                            <a href="{{ url_for('admin.list_users') }}" class="btn btn-secondary">
                                <i class="fas fa-times"></i> Cancel
                            </a>
                            <button type="submit" class="btn btn-primary">
                                <i class="fas fa-save"></i> Create User
                            </button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}


