@model IEnumerable<SportsDivision.Application.DTOs.ReportDtos.EventSchoolReportDto>
@{
    ViewData["Title"] = "Event School Report";
}

<div class="d-flex justify-content-between align-items-center mb-3">
    <h2 class="mb-0">Event School Report</h2>
    <div class="d-flex gap-2">
        <a asp-action="EventSchoolReportExcel" asp-route-tournamentId="@ViewBag.TournamentId" asp-route-eventId="@ViewBag.EventId" asp-route-eventLevelId="@ViewBag.EventLevelId" class="btn btn-success"><i class="bi bi-file-earmark-excel"></i> Export to Excel</a>
        <a asp-action="EventSchoolReportPdf" asp-route-tournamentId="@ViewBag.TournamentId" asp-route-eventId="@ViewBag.EventId" asp-route-eventLevelId="@ViewBag.EventLevelId" class="btn btn-outline-danger"><i class="bi bi-file-earmark-pdf"></i> PDF</a>
    </div>
</div>
<hr />

@foreach (var evt in Model)
{
    <div class="card shadow-sm mb-3">
        <div class="card-header bg-dark text-white">
            <h5 class="mb-0">@evt.EventName - @evt.EventLevelName</h5>
        </div>
        <div class="card-body">
            @foreach (var school in evt.Schools)
            {
                <h6>@school.SchoolName</h6>
                <table class="table table-sm table-hover mb-3">
                    <thead><tr><th>Student</th><th>Performance</th><th>Placement</th><th>Points</th></tr></thead>
                    <tbody>
                        @foreach (var s in school.Students)
                        {
                            <tr>
                                <td>@s.StudentName</td>
                                <td>@(s.RawPerformance?.ToString() ?? "-")</td>
                                <td>@(s.Placement?.ToString() ?? "-")</td>
                                <td>@s.PlacementPoints</td>
                            </tr>
                        }
                    </tbody>
                </table>
            }
        </div>
    </div>
}

<a asp-action="Index" class="btn btn-secondary">Back to Reports</a>
