<x-app-layout>
    <x-slot name="header">
        <h2 class="font-semibold text-xl text-gray-800 leading-tight">
            {{ __('Edit Nilai Santri') }}
        </h2>
    </x-slot>

    <div class="py-12">
        <div class="max-w-2xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6">
                    <h2 class="text-xl font-bold text-primary mb-4">Edit Nilai Santri</h2>
                    <form action="{{ route('nilai_santris.update', $nilaiSantri) }}" method="POST">
                        @csrf
                        @method('PUT')
                        <div class="mb-3">
                            <label class="font-semibold">Nama Santri</label>
                            <input type="text" class="form-control rounded" value="{{ $santri->nama }}" readonly>
                        </div>
                        <div class="mb-3">
                            <label class="font-semibold">Nilai</label>
                            <input type="number" name="nilai" class="form-control rounded" min="0" max="100" value="{{ old('nilai', $nilaiSantri->nilai) }}" required>
                            @error('nilai')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
                        </div>
                        <div class="mb-3">
                            <label class="font-semibold">Keterangan</label>
                            <input type="text" name="keterangan" class="form-control rounded" value="{{ old('keterangan', $nilaiSantri->keterangan) }}">
                            @error('keterangan')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
                        </div>
                        <div class="mb-3">
                            <label class="font-semibold">Semester</label>
                            <select name="semester_id" class="form-control rounded" required>
                                <option value="">Pilih Semester</option>
                                @foreach($semesters as $s)
                                    <option value="{{ $s->id }}" {{ old('semester_id', $nilaiSantri->semester_id) == $s->id ? 'selected' : '' }}>{{ $s->semester }} - {{ $s->tahun_ajaran }}</option>
                                @endforeach
                            </select>
                            @error('semester_id')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
                        </div>
                        <div class="mb-3">
                            <label class="font-semibold">Jenis Nilai</label>
                            <select name="jenis_nilai" class="form-control rounded" required>
                                <option value="">Pilih Jenis Nilai</option>
                                <option value="Tugas" {{ old('jenis_nilai', $nilaiSantri->jenis_nilai) == 'Tugas' ? 'selected' : '' }}>Tugas</option>
                                <option value="UTS" {{ old('jenis_nilai', $nilaiSantri->jenis_nilai) == 'UTS' ? 'selected' : '' }}>UTS</option>
                                <option value="UAS" {{ old('jenis_nilai', $nilaiSantri->jenis_nilai) == 'UAS' ? 'selected' : '' }}>UAS</option>
                                <option value="Quiz" {{ old('jenis_nilai', $nilaiSantri->jenis_nilai) == 'Quiz' ? 'selected' : '' }}>Quiz</option>
                                <option value="Praktikum" {{ old('jenis_nilai', $nilaiSantri->jenis_nilai) == 'Praktikum' ? 'selected' : '' }}>Praktikum</option>
                                <option value="Nilai Akhir" {{ old('jenis_nilai', $nilaiSantri->jenis_nilai) == 'Nilai Akhir' ? 'selected' : '' }}>Nilai Akhir</option>
                            </select>
                            @error('jenis_nilai')<div class="text-red-600 text-sm mt-1">{{ $message }}</div>@enderror
                        </div>
                        <div class="flex gap-2 mt-4">
                            <button type="submit" class="btn-primary">Update</button>
                            <a href="{{ route('nilai_santris.index', ['kelas_id'=>$nilaiSantri->kelas_id, 'mapel_id'=>$nilaiSantri->mapel_id, 'tanggal'=>$nilaiSantri->tanggal]) }}" class="btn-accent">Kembali</a>
                        </div>
                    </form>
                </div>
            </div>
        </div>
    </div>
</x-app-layout> 