{% extends 'base.html' %}
{% load static %}
{% block title %}Edit Profile — Parent Portal{% endblock %}
{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h3 mb-0">Edit Profile</h1>
        <a href="{% url 'parents:parent_profile' %}" class="btn btn-outline-secondary"><i class="fas fa-arrow-left me-2"></i>Back</a>
    </div>
    <div class="row justify-content-center">
        <div class="col-md-7">
            <div class="card shadow">
                <div class="card-header py-3 bg-primary text-white"><h6 class="m-0"><i class="fas fa-user-edit me-2"></i>Update Contact Information</h6></div>
                <div class="card-body">
                    <form method="post">
                        {% csrf_token %}
                        {% if form.errors %}<div class="alert alert-danger">Please correct the errors below.</div>{% endif %}
                        {% for field in form %}
                        <div class="mb-3">
                            <label class="form-label fw-bold">{{ field.label }}</label>
                            {{ field }}
                            {% if field.errors %}<div class="text-danger small">{{ field.errors }}</div>{% endif %}
                        </div>
                        {% endfor %}
                        <div class="d-flex justify-content-end gap-2 mt-4">
                            <a href="{% url 'parents:parent_profile' %}" class="btn btn-secondary">Cancel</a>
                            <button type="submit" class="btn btn-primary"><i class="fas fa-save me-2"></i>Save Changes</button>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</div>
{% block extra_js %}
<script>
document.querySelectorAll('input:not(.form-check-input), select, textarea').forEach(el => {
    if (!el.classList.contains('form-control') && !el.classList.contains('form-select')) {
        el.classList.add(el.tagName === 'SELECT' ? 'form-select' : 'form-control');
    }
});
</script>
{% endblock %}
{% endblock %}
