@extends('layouts.app')
@section('title', 'Timetable')
@section('page-title', 'My Timetable')
@section('sidebar-nav')
<div class="nav-item"><a href="{{ route('teacher.dashboard') }}"><i class="bi bi-grid"></i> Dashboard</a></div>
<div class="nav-item"><a href="{{ route('teacher.timetable') }}"><i class="bi bi-calendar3"></i> Timetable</a></div>
<div class="nav-item"><a href="{{ route('teacher.marks') }}"><i class="bi bi-pencil-square"></i> Enter Marks</a></div>
<div class="nav-item"><a href="{{ route('teacher.attendance') }}"><i class="bi bi-calendar-check"></i> Attendance</a></div>
@endsection

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

@php $days = [1=>'Monday',2=>'Tuesday',3=>'Wednesday',4=>'Thursday',5=>'Friday']; @endphp

<div class="card">
    <div class="table-wrap">
        <table>
            <thead>
                <tr><th>Day</th><th>Time</th><th>Subject</th><th>Stream</th><th>Room</th></tr>
            </thead>
            <tbody>
                @forelse($timetable as $day => $slots)
                    @foreach($slots as $i => $slot)
                    <tr>
                        @if($i === 0)
                        <td rowspan="{{ $slots->count() }}" style="font-weight:700;background:var(--primary-light);color:var(--primary);">
                            {{ $days[$day] ?? $day }}
                        </td>
                        @endif
                        <td>{{ \Carbon\Carbon::parse($slot->start_time)->format('H:i') }} - {{ \Carbon\Carbon::parse($slot->end_time)->format('H:i') }}</td>
                        <td><strong>{{ $slot->subject->name }}</strong></td>
                        <td>{{ $slot->stream->schoolClass->name }} {{ $slot->stream->name }}</td>
                        <td>{{ $slot->room ?? '-' }}</td>
                    </tr>
                    @endforeach
                @empty
                <tr><td colspan="5" style="text-align:center;padding:40px;color:var(--gray);">No timetable assigned yet</td></tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>
@endsection
