{% extends 'base.html' %}
{% load static %}
{% block title %}SMS Message Detail{% endblock %}
{% block content %}
<div class="container-fluid">
    <div class="d-flex justify-content-between align-items-center mb-4">
        <h1 class="h3 mb-0">SMS Message Detail</h1>
        <a href="{% url 'communication:sms_list' %}" 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 d-flex justify-content-between align-items-center">
                    <h6 class="m-0 font-weight-bold text-primary"><i class="fas fa-sms me-2"></i>{{ sms.get_message_type_display }}</h6>
                    <span class="badge bg-{% if sms.status == 'sent' %}success{% elif sms.status == 'failed' %}danger{% else %}secondary{% endif %} fs-6">{{ sms.get_status_display }}</span>
                </div>
                <div class="card-body">
                    <table class="table table-borderless">
                        <tr><td class="text-muted fw-bold" width="35%">Type</td><td>{{ sms.get_message_type_display }}</td></tr>
                        <tr><td class="text-muted fw-bold">Sent Time</td><td>{{ sms.sent_time|date:"l, d F Y H:i"|default:"Draft — not sent" }}</td></tr>
                        <tr><td class="text-muted fw-bold">Recipients</td><td>{{ sms.phone_numbers|length }} number{{ sms.phone_numbers|length|pluralize }}</td></tr>
                    </table>
                    <hr>
                    <h6 class="text-muted text-uppercase small">Message Content</h6>
                    <div class="alert alert-light" style="white-space:pre-line;">{{ sms.message }}</div>
                    <h6 class="text-muted text-uppercase small mt-3">Phone Numbers</h6>
                    <div class="d-flex flex-wrap gap-2">
                        {% for phone in sms.phone_numbers %}<span class="badge bg-secondary">{{ phone }}</span>{% endfor %}
                    </div>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
