@extends('admin.layout')

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

@section('content')
    <div class="card">
        <div class="card-header" style="background-color:#6f42c1; color:#fff;">
            <h5 class="mb-0">Edit Penilaian Kokurikuler</h5>
        </div>
        <div class="card-body">
            <form method="POST" action="@if(request()->is('guru/*')){{ route('guru.penilaian.kokurikuler.update', $record->id) }}@else{{ route('admin.penilaian.kokurikuler.update', $record->id) }}@endif">
                @csrf
                @method('PUT')
                <div class="row g-3">
                    <div class="col-md-6">
                        <label class="form-label">Kelas</label>
                        <select name="kelas_id" class="form-select">
                            <option value="">-- Pilih Kelas --</option>
                            @foreach($kelasList as $k)
                                <option value="{{ $k->id }}" @if($record->kelas_id == $k->id) selected @endif>{{ $k->nama ?? $k->nama_kelas ?? $k->name }}</option>
                            @endforeach
                        </select>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Peserta Didik</label>
                        <select name="peserta_didik_id" class="form-select">
                            <option value="">-- Pilih Peserta --</option>
                            @foreach($pesertaList as $p)
                                <option value="{{ $p->id }}" @if($record->peserta_didik_id == $p->id) selected @endif>{{ $p->nama }}</option>
                            @endforeach
                        </select>
                    </div>

                    <div class="col-md-6">
                        <label class="form-label">Demensi</label>
                        <input type="text" name="demensi" class="form-control" value="{{ $record->demensi ?? '' }}" required>
                    </div>
                    <div class="col-md-6">
                        <label class="form-label">Sub Demensi</label>
                        <input type="text" name="sub_demensi" class="form-control" value="{{ $record->sub_demensi ?? '' }}">
                    </div>

                    <div class="col-md-4">
                        <label class="form-label">Nilai</label>
                        <div class="d-flex align-items-center">
                            <div class="btn-group" role="group" aria-label="Nilai pilihan">
                                <input type="radio" class="btn-check" name="nilai" id="nilaiBK" value="BK" autocomplete="off" {{ (isset($record) && ($record->nilai ?? '') === 'BK') ? 'checked' : '' }} required>
                                <label class="btn btn-outline-primary btn-sm" for="nilaiBK">BK</label>

                                <input type="radio" class="btn-check" name="nilai" id="nilaiCK" value="CK" autocomplete="off" {{ (isset($record) && ($record->nilai ?? '') === 'CK') ? 'checked' : '' }}>
                                <label class="btn btn-outline-primary btn-sm" for="nilaiCK">CK</label>

                                <input type="radio" class="btn-check" name="nilai" id="nilaiMH" value="MH" autocomplete="off" {{ (isset($record) && ($record->nilai ?? '') === 'MH') ? 'checked' : '' }}>
                                <label class="btn btn-outline-primary btn-sm" for="nilaiMH">MH</label>
                            </div>
                        </div>
                        <div class="form-text mt-1">BK = Berkembang, CK = Cakap, MH = Mahir</div>
                    </div>
                    <div class="col-12">
                        <label class="form-label">Deskripsi</label>
                        <textarea name="deskripsi" class="form-control" rows="3">{{ $record->deskripsi ?? '' }}</textarea>
                    </div>

                    <div class="col-12 mt-3">
                        <a href="@if(request()->is('guru/*')){{ url('guru/penilaian/kokurikuler') }}@else{{ url('admin/penilaian/kokurikuler') }}@endif" class="btn btn-secondary">Batal</a>
                        <button class="btn btn-primary">Simpan</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
@endsection
