@extends('layouts.app')

@section('title', 'Disciplinary')

@section('content')
    <x-page-head title="Disciplinary" subtitle="Incidents & warnings">
        <x-slot:actions><a href="{{ route('school.discipline.create') }}" class="btn btn-primary">Log Incident</a></x-slot:actions>
    </x-page-head>
    <x-panel>
        @if ($records->isEmpty())
            <x-empty-state title="No incidents recorded" message="Disciplinary incidents will appear here." />
        @else
            <div class="table-wrap">
                <table>
                    <thead><tr><th>Date</th><th>Student</th><th>Category</th><th>Status</th><th>Recorded By</th><th></th></tr></thead>
                    <tbody>
                        @foreach ($records as $record)
                            <tr>
                                <td>{{ $record->incident_date->format('d M Y') }}</td>
                                <td>{{ $record->student?->full_name }}</td>
                                <td>{{ $record->category ?? '—' }}</td>
                                <td><x-badge variant="blue">{{ $record->status }}</x-badge></td>
                                <td>{{ $record->recordedBy?->full_name ?? '—' }}</td>
                                <td class="text-right"><a href="{{ route('school.discipline.edit', $record) }}" class="btn btn-ghost btn-sm">Edit</a></td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
            <div style="margin-top:16px;">{{ $records->links() }}</div>
        @endif
    </x-panel>
@endsection
