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

    <div class="py-12">
        <div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
            <div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
                <div class="p-6">
                    <div class="flex justify-between items-center mb-4">
                        <h2 class="text-xl font-bold text-gray-900">Daftar Kelas</h2>
                        <a href="{{ route('kelas.create') }}" class="btn-primary">Tambah Kelas</a>
                    </div>
                    
                    @if(session('success'))
                        <div class="alert-success mb-4">{{ session('success') }}</div>
                    @endif
                    
                    <div class="overflow-x-auto">
                        <table class="table w-full border rounded-lg overflow-hidden">
                            <thead>
                                <tr class="table-header">
                                    <th class="px-3 py-2">No</th>
                                    <th class="px-3 py-2">Nama Kelas</th>
                                    <th class="px-3 py-2">Wali Kelas</th>
                                    <th class="px-3 py-2">Action</th>
                                </tr>
                            </thead>
                            <tbody>
                                @foreach($kelas as $i => $kela)
                                <tr class="table-row">
                                    <td class="px-3 py-2">{{ $i+1 }}</td>
                                    <td class="px-3 py-2">{{ $kela->nama_kelas }}</td>
                                    <td class="px-3 py-2">{{ $kela->waliKelas ? $kela->waliKelas->nama : '-' }}</td>
                                    <td class="px-3 py-2 space-x-1">
                                        <a href="{{ route('kelas.edit', $kela) }}" class="btn-accent btn-sm">Edit</a>
                                        <form action="{{ route('kelas.destroy', $kela) }}" method="POST" style="display:inline-block">
                                            @csrf
                                            @method('DELETE')
                                            <button type="submit" class="btn-primary btn-sm" onclick="return confirm('Yakin hapus?')">Delete</button>
                                        </form>
                                    </td>
                                </tr>
                                @endforeach
                            </tbody>
                        </table>
                    </div>
                </div>
            </div>
        </div>
    </div>
</x-app-layout> 