@extends('layouts.parent')
@section('title', 'Assignments')
@section('content')
    <x-page-head title="Assignments" :subtitle="$activeChild?->full_name" />
    <x-child-switcher :students="$students" :active-child="$activeChild" />
    <x-panel>@if($assignments->isEmpty())<x-empty-state title="No assignments" />@else<div class="table-wrap"><table><thead><tr><th>Title</th><th>Subject</th><th>Due</th><th>Status</th><th>Marks</th></tr></thead><tbody>
        @foreach($assignments as $a)
            @php $sub = $submissions->get($a->id); @endphp
            <tr><td>{{ $a->title }}</td><td>{{ $a->subject?->name }}</td><td>{{ optional($a->due_at)->format('d M Y') ?? '—' }}</td>
            <td>@if($sub)<x-badge variant="{{ in_array($sub->status, ['submitted','late_submitted','marked']) ? 'green' : 'amber' }}">{{ ucfirst(str_replace('_',' ', $sub->status)) }}</x-badge>@else<x-badge variant="amber">Not submitted</x-badge>@endif</td>
            <td>@if($sub && $a->results_released && $sub->marks_awarded !== null){{ $sub->marks_awarded }}/{{ $a->total_marks }}@else — @endif</td></tr>
        @endforeach
    </tbody></table></div>{{ $assignments->links() }}@endif</x-panel>
@endsection
