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

<div style="display:grid; grid-template-columns: repeat(2, 1fr); gap:16px;">
    <div class="form-group">
        <label class="form-label" for="student_id">Student</label>
        <select class="input" id="student_id" name="student_id" required>
            @foreach ($students as $student)
                <option value="{{ $student->id }}" @selected(old('student_id', $record?->student_id) == $student->id)>{{ $student->full_name }}</option>
            @endforeach
        </select>
    </div>
    <div class="form-group">
        <label class="form-label" for="incident_date">Incident Date</label>
        <input class="input" type="date" id="incident_date" name="incident_date" value="{{ old('incident_date', optional($record?->incident_date)->format('Y-m-d') ?? today()->format('Y-m-d')) }}" required>
    </div>
    <div class="form-group">
        <label class="form-label" for="category">Category</label>
        <input class="input" type="text" id="category" name="category" value="{{ old('category', $record?->category) }}" placeholder="e.g. Bullying, Lateness">
    </div>
    <div class="form-group">
        <label class="form-label" for="status">Status</label>
        <select class="input" id="status" name="status">
            @foreach (['open', 'resolved', 'escalated'] as $status)
                <option value="{{ $status }}" @selected(old('status', $record?->status ?? 'open') === $status)>{{ ucfirst($status) }}</option>
            @endforeach
        </select>
    </div>
    <div class="form-group" style="grid-column: span 2;">
        <label class="form-label" for="description">Description</label>
        <textarea class="input" id="description" name="description" rows="4" required>{{ old('description', $record?->description) }}</textarea>
    </div>
    <div class="form-group" style="grid-column: span 2;">
        <label class="form-label" for="action_taken">Action Taken</label>
        <input class="input" type="text" id="action_taken" name="action_taken" value="{{ old('action_taken', $record?->action_taken) }}">
    </div>
</div>
