@extends('layouts.app')
@section('title', 'Assignments')
@section('page-title', 'Assignments')
@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>Assignments</h1></div></div>

<div class="card">
    <div class="table-wrap">
        <table>
            <thead><tr><th>Title</th><th>Subject</th><th>Teacher</th><th>Due Date</th><th>Marks</th><th>File</th></tr></thead>
            <tbody>
                @forelse($assignments as $a)
                <tr>
                    <td>
                        <div style="font-weight:500;">{{ $a->title }}</div>
                        @if($a->description)<div style="font-size:12px;color:var(--gray);">{{ Str::limit($a->description, 60) }}</div>@endif
                    </td>
                    <td>{{ $a->subject->name }}</td>
                    <td>{{ $a->teacher->user->name }}</td>
                    <td>
                        {{ $a->due_date->format('d M Y') }}
                        @if($a->due_date->isPast())
                            <span class="badge badge-danger">Overdue</span>
                        @elseif($a->due_date->isToday())
                            <span class="badge badge-warning">Today</span>
                        @endif
                    </td>
                    <td>{{ $a->total_marks }}</td>
                    <td>
                        @if($a->file_path)
                            <a href="{{ Storage::url($a->file_path) }}" target="_blank" class="btn btn-sm btn-secondary">
                                <i class="bi bi-download"></i>
                            </a>
                        @else
                            <span style="color:var(--gray);">-</span>
                        @endif
                    </td>
                </tr>
                @empty
                <tr><td colspan="6" style="text-align:center;padding:40px;color:var(--gray);">No assignments yet</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
    <div style="padding:16px;">{{ $assignments->links() }}</div>
</div>
@endsection
