@extends('layouts.app')
@section('title', 'Attendance')
@section('page-title', 'Attendance')
@section('sidebar-nav')
<div class="nav-item"><a href="{{ route('admin.dashboard') }}"><i class="bi bi-grid"></i> Dashboard</a></div>
<div class="nav-item"><a href="{{ route('admin.students.index') }}"><i class="bi bi-people"></i> Students</a></div>
<div class="nav-item"><a href="{{ route('admin.exams.index') }}"><i class="bi bi-journal-text"></i> Exams</a></div>
<div class="nav-item"><a href="{{ route('admin.attendance.index') }}"><i class="bi bi-calendar-check"></i> Attendance</a></div>
<div class="nav-item"><a href="{{ route('admin.fees.invoices') }}"><i class="bi bi-receipt"></i> Fees</a></div>
<div class="nav-item"><a href="{{ route('admin.users.index') }}"><i class="bi bi-person-gear"></i> Users</a></div>
@endsection

@section('content')
<div class="page-header">
    <div><h1>Attendance</h1><p>{{ \Carbon\Carbon::parse($date)->format('l, d F Y') }}</p></div>
    <form method="GET" style="display:flex;gap:8px;">
        <input type="date" name="date" value="{{ $date }}" style="width:160px;">
        <button type="submit" class="btn btn-secondary btn-sm">Go</button>
    </form>
</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="card-header"><h5>Take Attendance by Stream</h5></div>
    <div class="card-body">
        <div class="grid grid-3">
            @foreach($streams as $stream)
            <a href="{{ route('admin.attendance.take', [$stream, 'date' => $date]) }}" class="stat-card" style="text-decoration:none;cursor:pointer;transition:box-shadow .2s;" onmouseover="this.style.boxShadow='0 4px 20px rgba(0,0,0,.1)'" onmouseout="this.style.boxShadow='none'">
                <div class="stat-icon green"><i class="bi bi-people"></i></div>
                <div class="stat-info">
                    <h3 style="font-size:16px;">{{ $stream->schoolClass->name }} {{ $stream->name }}</h3>
                    <p>Take Attendance</p>
                </div>
                <i class="bi bi-chevron-right" style="color:var(--gray);margin-left:auto;"></i>
            </a>
            @endforeach
        </div>
    </div>
</div>
@endsection
