@php($slot = $slot ?? null)

<div style="display:grid; grid-template-columns: repeat(2, 1fr); gap:16px;">
    <div class="form-group">
        <label class="form-label" for="class_id">Class</label>
        <select class="input" id="class_id" name="class_id" required>
            @foreach ($classes as $class)
                <option value="{{ $class->id }}" @selected(old('class_id', $slot?->class_id) == $class->id)>{{ $class->name }}</option>
            @endforeach
        </select>
    </div>
    <div class="form-group">
        <label class="form-label" for="subject_id">Subject</label>
        <select class="input" id="subject_id" name="subject_id" required>
            @foreach ($subjects as $subject)
                <option value="{{ $subject->id }}" @selected(old('subject_id', $slot?->subject_id) == $subject->id)>{{ $subject->name }}</option>
            @endforeach
        </select>
    </div>
    <div class="form-group">
        <label class="form-label" for="staff_id">Teacher</label>
        <select class="input" id="staff_id" name="staff_id">
            <option value="">—</option>
            @foreach ($staffMembers as $member)
                <option value="{{ $member->id }}" @selected(old('staff_id', $slot?->staff_id) == $member->id)>{{ $member->full_name }}</option>
            @endforeach
        </select>
    </div>
    <div class="form-group">
        <label class="form-label" for="day_of_week">Day</label>
        <select class="input" id="day_of_week" name="day_of_week" required>
            @foreach ($days as $value => $label)
                <option value="{{ $value }}" @selected(old('day_of_week', $slot?->day_of_week) == $value)>{{ $label }}</option>
            @endforeach
        </select>
    </div>
    <div class="form-group">
        <label class="form-label" for="starts_at">Starts</label>
        <input class="input" type="time" id="starts_at" name="starts_at" value="{{ old('starts_at', $slot ? substr($slot->starts_at, 0, 5) : '') }}" required>
    </div>
    <div class="form-group">
        <label class="form-label" for="ends_at">Ends</label>
        <input class="input" type="time" id="ends_at" name="ends_at" value="{{ old('ends_at', $slot ? substr($slot->ends_at, 0, 5) : '') }}" required>
    </div>
    <div class="form-group">
        <label class="form-label" for="room">Room</label>
        <input class="input" type="text" id="room" name="room" value="{{ old('room', $slot?->room) }}">
    </div>
    <div class="form-group">
        <label class="form-label" for="term_id">Term</label>
        <select class="input" id="term_id" name="term_id">
            <option value="">—</option>
            @foreach ($terms as $term)
                <option value="{{ $term->id }}" @selected(old('term_id', $slot?->term_id) == $term->id)>{{ $term->name }}</option>
            @endforeach
        </select>
    </div>
</div>
