{% extends 'base.html' %}
{% load static %}
{% block title %}Messages — Parent Portal{% 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">Messages</h1><p class="text-muted">Messages from the school</p></div>
        <a href="{% url 'parents:parent_dashboard' %}" class="btn btn-outline-secondary"><i class="fas fa-arrow-left me-2"></i>Dashboard</a>
    </div>
    <div class="card shadow">
        <div class="card-body p-0">
            <table class="table table-hover mb-0">
                <thead class="table-dark"><tr><th>Type</th><th>Preview</th><th>Date</th><th></th></tr></thead>
                <tbody>
                    {% for msg in messages %}
                    <tr>
                        <td><span class="badge bg-secondary">{{ msg.get_message_type_display }}</span></td>
                        <td>{{ msg.message|truncatechars:80 }}</td>
                        <td class="text-muted small">{{ msg.sent_time|date:"d M Y H:i"|default:"Draft" }}</td>
                        <td><a href="{% url 'parents:parent_message_detail' msg.pk %}" class="btn btn-sm btn-outline-primary"><i class="fas fa-eye"></i></a></td>
                    </tr>
                    {% empty %}
                    <tr><td colspan="4" class="text-center py-4 text-muted"><i class="fas fa-inbox fa-2x mb-2 d-block"></i>No messages from the school yet.</td></tr>
                    {% endfor %}
                </tbody>
            </table>
        </div>
    </div>
</div>
{% endblock %}
