@if (Faults.Count == 0)
{
    <div class="empty-state">No faults recorded.</div>
}
else
{
    <div class="table-responsive">
        <table class="table table-sm align-middle dashboard-table">
            <thead>
                <tr>
                    <th scope="col">Observed</th>
                    <th scope="col">Source</th>
                    <th scope="col">Session</th>
                    <th scope="col">Worker</th>
                    <th scope="col">State</th>
                    <th scope="col">Message</th>
                </tr>
            </thead>
            <tbody>
                @foreach (DashboardFaultSummary fault in Faults)
                {
                    <tr>
                        <td>@DashboardDisplay.DateTime(fault.ObservedAt)</td>
                        <td>@fault.Source</td>
                        <td><code>@DashboardDisplay.Text(fault.SessionId)</code></td>
                        <td>@(fault.WorkerProcessId?.ToString(System.Globalization.CultureInfo.InvariantCulture) ?? "-")</td>
                        <td><StatusBadge Text="@fault.State" /></td>
                        <td title="@fault.Message">@DashboardDisplay.Abbreviate(fault.Message)</td>
                    </tr>
                }
            </tbody>
        </table>
    </div>
}

@code {
    [Parameter]
    public IReadOnlyList<DashboardFaultSummary> Faults { get; set; } = [];
}
