@extends('admin.layout')

@section('title', '')

@section('content')
    <div class="card">
        <div class="card-header bg-success text-white">
            <h5 class="mb-0"><i class="bi bi-award me-1"></i> Demensi Kokurikuler</h5>
            <p class="mb-0 small text-white-50">Halaman manajemen demensi kokurikuler untuk penilaian profil lulusan</p>
        </div>
            @php
                $activePeriode = \App\Models\Periode::where('status', \App\Models\Periode::STATUS_AKTIF)->first();
                $tahunPel = $activePeriode->tahun_pelajaran ?? '-';
                $semester = $activePeriode->semester ?? '-';
            @endphp
        <div class="card-body">
            <div class="mb-3 d-flex align-items-start justify-content-between">
                <div>
                    <h5 class="mb-1">Capaian Perkembangan Profil Lulusan</h5>
                    <div class="small text-muted">Tahun Pelajaran: <strong>{{ $tahunPel }}</strong> &nbsp;|&nbsp; Semester: <strong>{{ $semester }}</strong></div>
                </div>
                <div>
                    <button type="button" class="btn btn-primary" data-bs-toggle="modal" data-bs-target="#addCapaianModal">
                        <i class="bi bi-plus-lg me-1"></i> Tambah Capaian
                    </button>
                </div>
            </div>
            <div class="table-responsive">
                    <table class="table table-bordered table-striped">
                        <thead class="table-light">
                            <tr>
                                <th>Demensi</th>
                                <th style="width:200px;">Sub-demensi</th>
                                <th class="text-start">Berkembang</th>
                                <th class="text-start">Cakap</th>
                                <th class="text-start">Mahir</th>
                                <th style="width:90px;">Aksi</th>
                            </tr>
                        </thead>
                        <tbody>
                            @forelse($demensis ?? [] as $demensi)
                                <tr>
                                    <td>{{ $demensi->nama_demensi ?? $demensi['nama_demensi'] ?? '-' }}</td>
                                    <td>{{ $demensi->sub_demensi ?? $demensi['sub_demensi'] ?? '-' }}</td>
                                    <td class="text-start">{{ $demensi->berkembang ?? ($demensi['berkembang'] ?? '-') }}</td>
                                    <td class="text-start">{{ $demensi->cakap ?? ($demensi['cakap'] ?? '-') }}</td>
                                    <td class="text-start">{{ $demensi->mahir ?? ($demensi['mahir'] ?? '-') }}</td>
                                    <td class="text-center">
                                        <a href="{{ route('admin.data-umum.demensi-kokurikuler.edit', $demensi->id ?? ($demensi['id'] ?? '')) }}" class="btn btn-sm btn-primary me-1" title="Edit">
                                            <i class="bi bi-pencil"></i>
                                        </a>
                                        <form action="{{ route('admin.data-umum.demensi-kokurikuler.destroy', $demensi->id ?? ($demensi['id'] ?? '')) }}" method="POST" style="display:inline-block;" onsubmit="return confirm('Yakin ingin menghapus capaian ini?');">
                                            @csrf
                                            @method('DELETE')
                                            <button type="submit" class="btn btn-sm btn-danger" title="Hapus">
                                                <i class="bi bi-trash"></i>
                                            </button>
                                        </form>
                                    </td>
                                </tr>
                            @empty
                                <tr>
                                    <td colspan="6" class="text-center text-muted">Belum ada data demensi kokurikuler.</td>
                                </tr>
                            @endforelse
                        </tbody>
                    </table>
                </div>
        </div>
    </div>
@include('admin.data-umum.demensi-kokurikuler.create')
@endsection
