@{
    ViewData["Title"] = "Reports";
    var tournaments = ViewBag.Tournaments as IEnumerable<TournamentDto>;
}

<h2>Reports</h2>
<hr />

<div class="row g-3">
    @foreach (var report in new[] {
        ("PopularEvents", "Popular Events", "Most registered events by count"),
        ("RegistrationByGender", "Registration by Gender", "Event registrations broken down by gender"),
        ("EventSchoolReport", "Event School Report", "Students from each school per event"),
        ("StudentsBySchool", "Students by School", "List of students and their events per school"),
        ("ScoresByEvent", "Scores by Event", "Event results with scores and placements"),
        ("StudentPoints", "Student Points", "Individual student point totals"),
        ("SchoolStandings", "School Standings", "Overall school standings with placement points")
    })
    {
        <div class="col-md-4">
            <div class="card shadow-sm h-100">
                <div class="card-body">
                    <h5 class="card-title">@report.Item2</h5>
                    <p class="card-text text-muted">@report.Item3</p>
                    @if (tournaments != null && tournaments.Any())
                    {
                        <form asp-action="@report.Item1" method="get" class="d-flex gap-2">
                            <select name="tournamentId" class="form-select form-select-sm">
                                @foreach (var t in tournaments) { <option value="@t.TournamentId">@t.Name</option> }
                            </select>
                            <button type="submit" class="btn btn-sm btn-primary text-nowrap">View</button>
                        </form>
                    }
                    else
                    {
                        <p class="text-muted fst-italic">No tournaments available</p>
                    }
                </div>
            </div>
        </div>
    }
</div>
