@extends('admin.layout')

@section('title', 'Edit Penilaian Intrakulikuler')

@section('content')
<div class="card">
    <div class="card-header" style="background-color:#6f42c1; color:#fff;">
        <h5 class="mb-0">Edit Penilaian Intrakulikuler</h5>
    </div>
    <div class="card-body">
        <form method="POST" action="@if(request()->is('guru/*')){{ route('guru.penilaian.intrakulikuler.update', $record->id) }}@else{{ route('admin.penilaian.intrakulikuler.update', $record->id) }}@endif">
            @csrf
            @method('PUT')
            <div class="row g-3">
                <div class="col-md-4">
                    <label class="form-label">Kelas</label>
                    <select name="kelas_id" class="form-select">
                        <option value="">-- Pilih Kelas --</option>
                        @foreach($kelases as $kelas)
                            <option value="{{ $kelas->id }}" {{ ($record->kelas_id == $kelas->id) ? 'selected' : '' }}>{{ $kelas->nama ?? $kelas->name }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="col-md-4">
                    <label class="form-label">Peserta Didik</label>
                    <select name="peserta_didik_id" class="form-select">
                        <option value="">-- Pilih Peserta --</option>
                        @foreach($siswas as $s)
                            <option value="{{ $s->id }}" {{ ($record->peserta_didik_id == $s->id) ? 'selected' : '' }}>{{ $s->nama }}</option>
                        @endforeach
                    </select>
                </div>
                <div class="col-md-4">
                    <label class="form-label">Mata Pelajaran</label>
                    <select name="mata_pelajaran_id" class="form-select">
                        <option value="">-- Pilih Mapel --</option>
                        @foreach($mapels as $m)
                            <option value="{{ $m->id }}" {{ ($record->mata_pelajaran_id == $m->id) ? 'selected' : '' }}>{{ $m->nama }}</option>
                        @endforeach
                    </select>
                </div>

                @for ($i = 1; $i <= 6; $i++)
                <div class="col-4 col-md-2">
                    <label class="form-label small">Nilai {{ $i }}</label>
                    <input type="number" name="nilai{{ $i }}" class="form-control" min="0" max="100" value="{{ $record->{'nilai'.$i} ?? '' }}">
                </div>
                @endfor

                <div class="col-md-4">
                    <label class="form-label">N-Sumatif</label>
                    <input type="number" name="n_sumatif" class="form-control" value="{{ $record->n_sumatif ?? '' }}">
                </div>
                <div class="col-md-4">
                    <label class="form-label">N-Akhir Semester</label>
                    <input type="number" name="n_akhir_semester" class="form-control" value="{{ $record->n_akhir_semester ?? '' }}">
                </div>
                <div class="col-md-4">
                    <label class="form-label">Nilai Akhir</label>
                    <input type="number" name="nilai_akhir" class="form-control" value="{{ $record->nilai_akhir ?? '' }}">
                </div>

                <div class="col-12">
                    <label class="form-label">Deskripsi</label>
                    <textarea name="deskripsi" class="form-control" rows="3">{{ $record->deskripsi ?? '' }}</textarea>
                </div>
            </div>
            <div class="mt-3">
                <a href="@if(request()->is('guru/*')){{ route('guru.penilaian.intrakulikuler') }}@else{{ route('admin.penilaian.intrakulikuler') }}@endif" class="btn btn-secondary">Batal</a>
                <button type="submit" class="btn btn-primary">Simpan</button>
            </div>
        </form>
    </div>
</div>
@endsection
