@extends('guru.layouts.app')

@section('title', 'Daftar Guru')

@section('content')

<style>
    .page-title {
        font-size: 30px;
        font-weight: 800;
        margin-bottom: 10px;
        margin-top: -20px;
    }

    .custom-card {
        background: white;
        border-radius: 20px;
        border: 2px solid #e5e5e5;
        padding: 25px;
    }

    .table-header {
        background: #bae6fd;
    }

    .search-box {
        background: #bae6fd;
        border-radius: 30px;
        padding: 6px 15px;
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .search-box input {
        border: none;
        outline: none;
        background: transparent;
        width: 150px;
    }

    .per-page-select {
        border-radius: 10px;
        padding: 5px;
        border: 1px solid #ccc;
    }

    .badge-info {
        background: #e0f2fe;
        color: #0369a1;
        padding: 5px 12px;
        border-radius: 8px;
        font-size: 12px;
        font-weight: 600;
    }
</style>

<h3 class="page-title">DAFTAR GURU</h3>

<div class="custom-card">

    <div class="d-flex justify-content-between align-items-center mb-3">

        <div class="badge-info">
            📖 Mode Hanya Lihat (Read Only)
        </div>

        <form method="GET">
            <div class="search-box">
                <input type="text" name="search" placeholder="Cari" value="{{ request('search') }}">
                <button style="border:none;background:none">
                    <img src="{{ asset('images/icon/main/search.png') }}" width="18">
                </button>
            </div>
        </form>

    </div>

    <form method="GET" class="mb-2">
        <span>Tampilkan</span>

        <select name="perPage" onchange="this.form.submit()" class="per-page-select">
            <option value="10" {{ request('perPage') == 10 ? 'selected' : '' }}>10</option>
            <option value="25" {{ request('perPage') == 25 ? 'selected' : '' }}>25</option>
            <option value="50" {{ request('perPage') == 50 ? 'selected' : '' }}>50</option>
        </select>

        <span>data</span>

        <input type="hidden" name="search" value="{{ request('search') }}">
    </form>

    <table class="table text-center align-middle">
        <thead class="table-header">
            <tr>
                <th>No</th>
                <th>NIP</th>
                <th>Nama Guru</th>
            </tr>
        </thead>

        <tbody>
            @forelse($gurus as $index => $guru)
            <tr>
                <td>{{ $gurus->firstItem() + $index }}</td>
                <td>{{ $guru->nip }}</td>
                <td>{{ $guru->nama }}</td>
            </tr>

            @empty
            <tr>
                <td colspan="3">Belum ada data guru</td>
            </tr>
            @endforelse
        </tbody>
    </table>

    <div class="d-flex justify-content-end">
        {{ $gurus->links() }}
    </div>

</div>

@endsection

