@extends('layouts.app')
@section('title', 'Attendance')
@section('page-title', 'My Attendance')
@section('sidebar-nav')
<div class="nav-item"><a href="{{ route('student.dashboard') }}"><i class="bi bi-grid"></i> Dashboard</a></div>
<div class="nav-item"><a href="{{ route('student.results') }}"><i class="bi bi-bar-chart"></i> My Results</a></div>
<div class="nav-item"><a href="{{ route('student.fees') }}"><i class="bi bi-cash"></i> Fee Balance</a></div>
<div class="nav-item"><a href="{{ route('student.attendance') }}"><i class="bi bi-calendar-check"></i> Attendance</a></div>
<div class="nav-item"><a href="{{ route('student.assignments') }}"><i class="bi bi-file-earmark-text"></i> Assignments</a></div>
@endsection

@section('content')
<div class="page-header"><div><h1>My Attendance</h1></div></div>

<div class="grid grid-4" style="margin-bottom:24px;">
    <div class="stat-card"><div class="stat-icon green"><i class="bi bi-check-circle"></i></div><div class="stat-info"><h3>{{ $summary['present'] ?? 0 }}</h3><p>Present</p></div></div>
    <div class="stat-card"><div class="stat-icon red"><i class="bi bi-x-circle"></i></div><div class="stat-info"><h3>{{ $summary['absent'] ?? 0 }}</h3><p>Absent</p></div></div>
    <div class="stat-card"><div class="stat-icon amber"><i class="bi bi-clock"></i></div><div class="stat-info"><h3>{{ $summary['late'] ?? 0 }}</h3><p>Late</p></div></div>
    <div class="stat-card"><div class="stat-icon blue"><i class="bi bi-shield-check"></i></div><div class="stat-info"><h3>{{ $summary['excused'] ?? 0 }}</h3><p>Excused</p></div></div>
</div>

<div class="card">
    <div class="table-wrap">
        <table>
            <thead><tr><th>Date</th><th>Status</th><th>Reason</th></tr></thead>
            <tbody>
                @forelse($records as $record)
                <tr>
                    <td>{{ $record->date->format('D, d M Y') }}</td>
                    <td>
                        <span class="badge {{ $record->status === 'present' ? 'badge-success' : ($record->status === 'absent' ? 'badge-danger' : ($record->status === 'late' ? 'badge-warning' : 'badge-info')) }}">
                            {{ ucfirst($record->status) }}
                        </span>
                    </td>
                    <td style="color:var(--gray);">{{ $record->reason ?? '-' }}</td>
                </tr>
                @empty
                <tr><td colspan="3" style="text-align:center;padding:40px;color:var(--gray);">No attendance records</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
    <div style="padding:16px;">{{ $records->links() }}</div>
</div>
@endsection
