{% extends 'base.html' %}
{% load static %}
{% block title %}Parent Communication - Rapha-Bethel BNPS{% endblock %}
{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <div><h1 class="h3 mb-0">Parent Communication</h1><p class="text-muted">{{ total_parents }} parent contact{{ total_parents|pluralize }}</p></div>
        <a href="{% url 'communication:sms_compose' %}?recipient_type=parents" class="btn btn-primary"><i class="fas fa-sms me-2"></i>Bulk SMS to Parents</a>
    </div>
    <div class="card shadow">
        <div class="card-header py-3"><h6 class="m-0 font-weight-bold text-primary">Parent Contact Directory</h6></div>
        <div class="card-body p-0">
            <table class="table table-hover mb-0">
                <thead class="table-dark"><tr><th>Parent</th><th>Student</th><th>Phone</th><th>Language</th><th>SMS</th><th>Action</th></tr></thead>
                <tbody>
                    {% for entry in parents %}
                    <tr>
                        <td>
                            <div class="fw-bold">{{ entry.parent.get_full_name }}</div>
                            <small class="text-muted">{{ entry.parent.get_relationship_display }}</small>
                        </td>
                        <td><a href="{% url 'students:student_detail' entry.student.pk %}">{{ entry.student.get_full_name }}</a><br><small class="text-muted">{{ entry.student.current_class|default:"No class" }}</small></td>
                        <td><i class="fas fa-phone text-success me-1"></i>{{ entry.phone }}</td>
                        <td><span class="badge bg-secondary">{{ entry.preferred_language|upper }}</span></td>
                        <td>{% if entry.receive_sms %}<span class="badge bg-success"><i class="fas fa-check"></i></span>{% else %}<span class="badge bg-secondary"><i class="fas fa-times"></i></span>{% endif %}</td>
                        <td>
                            <a href="{% url 'communication:send_parent_message' entry.parent.pk %}" class="btn btn-sm btn-outline-primary" title="Send message">
                                <i class="fas fa-paper-plane"></i>
                            </a>
                        </td>
                    </tr>
                    {% empty %}
                    <tr><td colspan="6" class="text-center py-4 text-muted"><i class="fas fa-users fa-2x mb-2 d-block"></i>No parent contacts found.</td></tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}
