@model IEnumerable<SchoolPointsSummaryDto>
@{
    ViewData["Title"] = "School Standings";
}

<div class="d-flex justify-content-between align-items-center mb-3">
    <h2 class="mb-0">School Standings</h2>
    <a asp-action="SchoolStandingsExcel" asp-route-tournamentId="@ViewBag.TournamentId" class="btn btn-success"><i class="bi bi-file-earmark-excel"></i> Export to Excel</a>
</div>
<hr />

<div class="card shadow-sm">
    <div class="card-body p-0">
        <table class="table table-striped table-hover mb-0">
            <thead class="table-dark">
                <tr>
                    <th>#</th>
                    <th>School</th>
                    <th class="text-center">Total Points</th>
                    <th class="text-center">1st Place</th>
                    <th class="text-center">2nd Place</th>
                    <th class="text-center">3rd Place</th>
                </tr>
            </thead>
            <tbody>
                @{ int rank = 1; }
                @foreach (var s in Model)
                {
                    <tr class="@(rank <= 3 ? "fw-bold" : "")">
                        <td>
                            @if (rank == 1) { <span class="badge bg-warning text-dark">1st</span> }
                            else if (rank == 2) { <span class="badge bg-secondary">2nd</span> }
                            else if (rank == 3) { <span class="badge bg-dark">3rd</span> }
                            else { @rank }
                        </td>
                        <td>@s.SchoolName @(s.ShortName != null ? $"({s.ShortName})" : "")</td>
                        <td class="text-center"><strong>@s.TotalPoints</strong></td>
                        <td class="text-center">@s.FirstPlaceCount</td>
                        <td class="text-center">@s.SecondPlaceCount</td>
                        <td class="text-center">@s.ThirdPlaceCount</td>
                    </tr>
                    rank++;
                }
            </tbody>
        </table>
    </div>
</div>

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