@extends('layouts.app')

@section('content')
<!-- Background seluruh halaman -->
<div style="background-color: #e0e0e0; width: 100%; min-height: 100vh; border-radius: 15px; padding: 1rem;">

    <!-- Header -->
    <div style="background-color: #000; color: #fff; padding: 0.1rem; border-radius: 0.5rem;">
        <h1 class="m-0">Akun Admin</h1>
    </div>

    <!-- Konten utama -->
    <div class="container mt-4">
        @if(session('success'))
            <div class="alert alert-success">{{ session('success') }}</div>
        @endif

        <div class="card p-4 border border-secondary" style="border-radius: 15px; background-color: #fff;">
            <div class="d-flex justify-content-between mb-3">
                <a href="{{ route('dashboard') }}" class="btn btn-secondary">Kembali</a>
                <a href="{{ route('admin.create') }}" class="btn btn-primary">Tambah Admin</a>
            </div>

            <div class="table-responsive">
                <table class="table table-bordered table-hover mb-0">
                    <thead class="table-dark text-center">
                        <tr>
                            <th>No</th>
                            <th>Nama</th>
                            <th>Email</th>
                            <th>Aksi</th>
                        </tr>
                    </thead>
                    <tbody>
                        @forelse($admins as $i => $admin)
                            <tr>
                                <td class="text-center">{{ $i + 1 }}</td>
                                <td>{{ $admin->name }}</td>
                                <td>{{ $admin->email }}</td>
                                <td class="text-center">
                                    <a href="{{ route('admin.edit', $admin->id) }}" class="btn btn-warning btn-sm">Edit</a>
                                    <form action="{{ route('admin.destroy', $admin->id) }}" method="POST" style="display:inline" onsubmit="return confirm('Yakin hapus admin ini?')">
                                        @csrf
                                        @method('DELETE')
                                        <button class="btn btn-danger btn-sm" type="submit">Hapus</button>
                                    </form>
                                </td>
                            </tr>
                        @empty
                            <tr><td colspan="4" class="text-center">Belum ada data admin</td></tr>
                        @endforelse
                    </tbody>
                </table>
            </div>
        </div>
    </div>
</div>
@endsection
