@extends('layouts.app')

@section('content')
<div class="page-header d-flex justify-content-between align-items-center">
    <div>
        <h4><i class="bi bi-people-fill me-2" style="color:#1565c0;"></i>Data Siswa</h4>
        <p>Manajemen data siswa SMAN 1 Makassar</p>
    </div>
    <a href="{{ route('siswa.create') }}" class="btn btn-primary d-flex align-items-center gap-2">
        <i class="bi bi-plus-circle"></i> Tambah Siswa
    </a>
</div>

@if(session('success'))
<div class="alert alert-success alert-dismissible fade show" role="alert">
    <i class="bi bi-check-circle-fill me-2"></i> {{ session('success') }}
    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
</div>
@endif

<div class="card-table">
    <div class="table-responsive">
        <table class="table table-hover align-middle mb-0">
            <thead>
                <tr>
                    <th>NISN</th>
                    <th>Nama</th>
                    <th>L/P</th>
                    <th>Aksi</th>
                </tr>
            </thead>
            <tbody>
                @forelse($siswas as $siswa)
                <tr>
                    <td>{{ $siswa->nisn }}</td>
                    <td>{{ $siswa->nama }}</td>
                    <td>{{ $siswa->jenis_kelamin }}</td>
                    <td>
                        <div class="d-flex gap-2">
                            <a href="{{ route('siswa.show', $siswa->id) }}" class="btn btn-sm btn-light text-primary"><i
                                    class="bi bi-eye"></i></a>

                            <a href="{{ route('siswa.edit', $siswa->id) }}" class="btn btn-sm btn-light text-warning"><i
                                    class="bi bi-pencil"></i></a>

                            <form action="{{ route('siswa.destroy', $siswa->id) }}" method="POST"
                                onsubmit="return confirm('Yakin ingin menghapus data siswa ini?')">
                                @csrf
                                @method('DELETE')
                                <button type="submit" class="btn btn-sm btn-light text-danger"><i
                                        class="bi bi-trash"></i></button>
                            </form>
                        </div>
                    </td>
                </tr>
                @empty
                <tr>
                    <td colspan="4" class="text-center py-4 text-muted">Belum ada data siswa.</td>
                </tr>
                @endforelse
            </tbody>
        </table>
    </div>
</div>
@endsection