<!-- templates/species/cares/registration_results.html -->
{% extends 'main.html' %}
{% load static %}

{% block content %}
<div class="container mt-4">
    <div class="row">
        <div class="col-12">
            <div class="card shadow">
                <div class="card-header bg-success text-white d-flex justify-content-between align-items-center">
                    <h3 class="mb-0">Your CARES Registrations</h3>
                </div>
                <div class="card-body">
                    <div class="alert alert-info">
                        <strong>{{ registration_count }}</strong> registration{{ registration_count|pluralize }} found for <strong>{{ email }}</strong>
                    </div>
                    
                    {% if registrations %}
                        <div class="table-responsive">
                            <table class="table table-striped table-hover">
                                <thead>
                                    <tr>
                                        <th>Species</th>
                                        <th style='text-align:center'>Club</th>
                                        <th style='text-align:center'>Family</th>
                                        <th style='text-align:center'>Classification</th>
                                        <th style='text-align:center'>Status</th>
                                        <th style='text-align:center'>Submitted</th>
                                        <th style='text-align:center'>Last Updated</th>
                                    </tr>
                                </thead>
                                <tbody>
                                    {% for registration in registrations %}
                                        <tr>
                                            <td>
                                                <strong>{{ registration.species.name }}</strong>
                                                {% if registration.species.common_name %}
                                                    <br><small class="text-muted">{{ registration.species.common_name }}</small>
                                                {% endif %}
                                            </td>
                                            <td style='text-align:center'>{{ registration.affiliate_club.acronym }}</td>
                                            <td style='text-align:center'>{{ registration.species.get_cares_family_display }}</td>
                                            <td style='text-align:center'>{{ registration.species.get_cares_classification_display }}</td>
                                            <td style='text-align:center'>{{ registration.get_status_display }}</td>
                                            <td style='text-align:center'>{{ registration.date_requested|date:"Y-m-d" }}</td>
                                            <td style='text-align:center'>
                                                {% if registration.last_report_date %}
                                                    {{ registration.last_report_date|date:"Y-m-d" }}
                                                {% else %}
                                                    {{ registration.lastUpdated|date:"Y-m-d" }}
                                                {% endif %}
                                            </td>
                                        </tr>
                                    {% endfor %}
                                </tbody>
                            </table>
                        </div>
                    {% else %}
                        <div class="alert alert-warning">
                            <h5>No registrations found</h5>
                            <p>We couldn't find any CARES registrations for <strong>{{ email }}</strong>.</p>
                            <p>Please:</p>
                            <ul>
                                <li>Check that you entered the correct email address</li>
                                <li>Contact your club liaison if you believe this is an error</li>
                            </ul>
                        </div>
                    {% endif %}
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock content %}