{% extends 'base.html' %}
{% load crispy_forms_tags %}

{% block title %}{% if form.instance.pk %}Update{% else %}Add{% endif %} Staff Member{% endblock %}

{% block content %}
<div class="container">
    <div class="row justify-content-center">
        <div class="col-md-8">
            <div class="card shadow">
                <div class="card-header bg-primary text-white">
                    <h4 class="mb-0">
                        <i class="fas fa-user-edit me-2"></i>
                        {% if form.instance.pk %}Update{% else %}Add New{% endif %} Staff Member
                    </h4>
                </div>
                <div class="card-body">
                    <form method="post" enctype="multipart/form-data">
                        {% csrf_token %}
                        
                        <div class="mb-3">
                            {{ form.user|as_crispy_field }}
                            <small class="form-text text-muted">
                                Select an existing staff user or create a new one in the admin panel.
                            </small>
                        </div>
                        
                        <div class="mb-3">
                            {{ form.services|as_crispy_field }}
                            <small class="form-text text-muted">
                                Select the services this staff member can provide.
                            </small>
                        </div>
                        
                        <div class="mb-3">
                            {{ form.bio|as_crispy_field }}
                        </div>
                        
                        <div class="mb-3 form-check">
                            {{ form.is_active|as_crispy_field }}
                        </div>
                        
                        <div class="d-flex justify-content-between mt-4">
                            <a href="{% url 'appointments:staff-list' %}" class="btn btn-outline-secondary">
                                <i class="fas fa-arrow-left me-1"></i> Back to List
                            </a>
                            <div>
                                <button type="submit" class="btn btn-primary">
                                    <i class="fas fa-save me-1"></i> {% if form.instance.pk %}Update{% else %}Create{% endif %} Staff
                                </button>
                            </div>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}

{% block extra_js %}
<script>
    document.addEventListener('DOMContentLoaded', function() {
        // Initialize any JavaScript plugins or custom behavior here
        // For example, you could initialize a rich text editor for the bio field
        // or add date/time pickers if needed
    });
</script>
{% endblock %}
