@extends('layouts.dashboard')

@section('title', 'Smart School | Siswa')

@section('content')

<div class="bg-white shadow-md rounded-lg p-6">
    <div class="flex justify-between items-center mb-4">
        <h1 class="text-2xl font-semibold">Data Siswa</h1>
        <a href="{{ route('siswa.create') }}" class="bg-blue-500 hover:bg-blue-600 text-white px-4 py-2 rounded-lg">
            + Tambah Siswa
        </a>
    </div>

    <div class="overflow-x-auto">
        <table class="w-full border-collapse border border-gray-200">
            <thead class="bg-gray-100">
                <tr class="text-left text-gray-700">
                    <th class="border px-4 py-2">No</th>
                    <th class="border px-4 py-2">Nama Siswa</th>
                    <th class="border px-4 py-2">NISN</th>
                    <th class="border px-4 py-2">Jenis Kelamin</th>
                    <th class="border px-4 py-2">No HP</th>
                    <th class="border px-4 py-2">Nama Jurusan</th>
                    <th class="border px-4 py-2">Nama Kelas</th>
                    <th class="border px-4 py-2 text-center">Aksi</th>
                </tr>
            </thead>
            <tbody>
                @foreach ($siswa as $index => $item)
                <tr class="border hover:bg-gray-50">
                    <td class="border px-4 py-2">{{ $index + 1 }}</td>
                    <td class="border px-4 py-2">{{ $item->nama_siswa }}</td>
                    <td class="border px-4 py-2">{{ $item->nisn }}</td>
                    <td class="border px-4 py-2">{{ $item->jenis_kelamin }}</td>
                    <td class="border px-4 py-2">{{ $item->no_hp }}</td>
                    <td class="border px-4 py-2">{{ $item->nama_jurusan }}</td>
                    <td class="border px-4 py-2">{{ $item->nama_kelas }}</td>
                    <td class="border px-4 py-2 text-center">
                        <a href="{{ route('siswa.edit', $item->id) }}" class="bg-yellow-400 hover:bg-yellow-500 text-white px-3 py-1 rounded">Edit</a>
                        <form action="{{ route('siswa.destroy', $item->id) }}" method="POST" class="inline-block">
                            @csrf
                            @method('DELETE')
                            <button type="submit" onclick="return confirm('Yakin ingin menghapus?')" class="bg-red-500 hover:bg-red-600 text-white px-3 py-1 rounded">
                                Hapus
                            </button>
                        </form>
                    </td>
                </tr>
                @endforeach
            </tbody>
        </table>
    </div>
</div>

@endsection
