@extends('layouts.app')

@section('title', 'Attendance')

@section('content')
    <x-page-head title="Attendance" subtitle="Daily tracker">
        <x-slot:actions>
            <a href="{{ route('school.attendance.create') }}" class="btn btn-primary">Mark Attendance</a>
            <a href="{{ route('school.attendance.term-report') }}" class="btn btn-outline">Term Report</a>
        </x-slot:actions>
    </x-page-head>
    <x-panel>
        @if ($sessions->isEmpty())
            <x-empty-state title="No attendance sessions" message="Mark daily class attendance to get started." />
        @else
            <div class="table-wrap">
                <table>
                    <thead><tr><th>Date</th><th>Class</th><th>Recorded By</th><th>Status</th></tr></thead>
                    <tbody>
                        @foreach ($sessions as $session)
                            <tr>
                                <td>{{ $session->date->format('d M Y') }}</td>
                                <td>{{ $session->schoolClass?->name }}</td>
                                <td>{{ $session->recordedBy?->full_name ?? '—' }}</td>
                                <td><x-badge variant="blue">{{ $session->status }}</x-badge></td>
                            </tr>
                        @endforeach
                    </tbody>
                </table>
            </div>
            <div style="margin-top:16px;">{{ $sessions->links() }}</div>
        @endif
    </x-panel>
@endsection
