{% extends "admin/base.html" %}
{% block title %}{{ 'Edit Group' if group else 'New Group' }}{% endblock %}
{% block content %}
<div class="d-flex align-items-center gap-2 mb-4">
    <a href="{{ url_for('site_admin.groups') }}" class="btn btn-sm btn-outline-secondary">
        <i class="bi bi-arrow-left"></i>
    </a>
    <h2 class="mb-0">{{ 'Edit Group' if group else 'Create New Group' }}</h2>
</div>

<div class="row">
    <div class="col-md-6">
        <div class="card border-secondary">
            <div class="card-body">
                <form method="post">
                    <input type="hidden" name="_csrf_token" value="{{ csrf_token() }}">
                    <div class="mb-3">
                        <label class="form-label">Group Name *</label>
                        <input type="text" name="name" class="form-control" required
                               value="{{ group.name if group else request.form.get('name', '') }}">
                    </div>
                    <div class="mb-4">
                        <label class="form-label">Description</label>
                        <textarea name="description" class="form-control" rows="3">{{ group.description if group else request.form.get('description', '') }}</textarea>
                    </div>
                    <div class="d-flex gap-2">
                        <button type="submit" class="btn btn-success">
                            <i class="bi bi-check-lg me-1"></i>{{ 'Save' if group else 'Create' }}
                        </button>
                        <a href="{{ url_for('site_admin.groups') }}" class="btn btn-outline-secondary">Cancel</a>
                    </div>
                </form>
            </div>
        </div>
    </div>
</div>
{% endblock %}
