{% extends "system_settings/base_settings.html" %}

{% block title %}Добавить пользователя{% endblock %}

{% block settings_content %}
<div class="row justify-content-center">
    <div class="col-md-6">
        <div class="card">
            <div class="card-header">
                <h4 class="mb-0">Добавить пользователя</h4>
            </div>
            <div class="card-body">
                {% if messages %}
                {% for message in messages %}
                <div class="alert alert-{{ message.tags }} alert-dismissible fade show" role="alert">
                    {{ message }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
                {% endfor %}
                {% endif %}

                <form method="post">
                    {% csrf_token %}

                    <div class="mb-3">
                        <label for="email" class="form-label">Email *</label>
                        <input type="email" class="form-control" id="email" name="email" required>
                        <div class="form-text">Email пользователя для входа</div>
                    </div>

                    <div class="mb-3">
                        <label for="name" class="form-label">Имя *</label>
                        <input type="text" class="form-control" id="name" name="name" required>
                        <div class="form-text">Полное имя пользователя</div>
                    </div>

                    <div class="mb-3">
                        <label for="role" class="form-label">Роль *</label>
                        <select class="form-select" id="role" name="role" required>
                            <option value="">Выберите роль...</option>
                            {% for role in roles %}
                            <option value="{{ role.code }}">{{ role.name }} - {{ role.description }}</option>
                            {% endfor %}
                        </select>
                    </div>

                    <div class="mb-3">
                        <label for="password" class="form-label">Пароль</label>
                        <input type="text" class="form-control" id="password" name="password">
                        <div class="form-text">Оставьте пустым для автогенерации. Пароль будет показан после создания.
                        </div>
                    </div>

                    <div class="d-flex justify-content-between">
                        <a href="{% url 'system_settings:user_roles:list' %}" class="btn btn-secondary">Отмена</a>
                        <button type="submit" class="btn btn-primary">Создать пользователя</button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}