<x-teacher-layout>

    <x-slot name="header">

        <div>

            <span class="admin-section-label">Teacher</span>

            <h2 class="admin-page-title">Welcome, {{ $teacher->name }}!</h2>

            <p class="admin-page-subtitle">Subject-wise overview — chapters, questions, exams & homework</p>

        </div>

    </x-slot>



    <div class="admin-page space-y-6">

        <div class="grid sm:grid-cols-2 xl:grid-cols-4 gap-4">

            @include('admin.partials.stat-card', ['label' => 'Total Exams', 'value' => $examCount])

            @include('admin.partials.stat-card', ['label' => 'Published Exams', 'value' => $publishedExams])

            @include('admin.partials.stat-card', ['label' => 'Total Homework', 'value' => $homeworkCount])

            @include('admin.partials.stat-card', ['label' => 'Published Homework', 'value' => $publishedHomework])

        </div>



        @if ($standards->flatMap->activeSubjects->isEmpty())

            <div class="admin-card p-8 text-center text-sm text-slate-500">

                No subjects available yet. Admin needs to add standards and subjects first.

            </div>

        @else

            @include('teacher.partials.subject-overview-grid', ['standards' => $standards])

        @endif



        <div class="grid lg:grid-cols-2 gap-6">

            <div class="admin-card">

                <div class="admin-card-top"></div>

                <div class="admin-card-header flex items-center justify-between">

                    <h3 class="font-bold text-slate-900">Recent Exams</h3>

                    <a href="{{ route('teacher.exams.create') }}" class="text-xs font-semibold text-brand-green hover:underline">+ New Exam</a>

                </div>

                <div class="divide-y divide-slate-100">

                    @forelse ($recentExams as $exam)

                        <a href="{{ route('teacher.exams.show', $exam) }}" class="block p-4 hover:bg-slate-50 transition">

                            <p class="font-semibold text-slate-900">{{ $exam->title }}</p>

                            <p class="text-xs text-slate-500 mt-0.5">{{ ucfirst($exam->status) }} &middot; {{ $exam->created_at->diffForHumans() }}</p>

                        </a>

                    @empty

                        <p class="p-4 text-sm text-slate-500">No exams yet.</p>

                    @endforelse

                </div>

            </div>



            <div class="admin-card">

                <div class="admin-card-top"></div>

                <div class="admin-card-header flex items-center justify-between">

                    <h3 class="font-bold text-slate-900">Recent Homework</h3>

                    <a href="{{ route('teacher.homework.create') }}" class="text-xs font-semibold text-brand-green hover:underline">+ New Homework</a>

                </div>

                <div class="divide-y divide-slate-100">

                    @forelse ($recentHomework as $hw)

                        <a href="{{ route('teacher.homework.show', $hw) }}" class="block p-4 hover:bg-slate-50 transition">

                            <p class="font-semibold text-slate-900">{{ $hw->title }}</p>

                            <p class="text-xs text-slate-500 mt-0.5">{{ ucfirst($hw->status) }} &middot; {{ $hw->created_at->diffForHumans() }}</p>

                        </a>

                    @empty

                        <p class="p-4 text-sm text-slate-500">No homework yet.</p>

                    @endforelse

                </div>

            </div>

        </div>

    </div>

</x-teacher-layout>

