@extends('layouts.app')

@section('content')
<div class="card">
    <h2 style="margin-top:0">Halo Admin, {{ auth()->user()->name }}</h2>
    <p>Ini adalah dashboard khusus admin. Akses cepat:</p>
    <ul>
        <li><a href="{{ route('admin.absensi.index') }}">Lihat Data Absensi</a></li>
        <li><a href="{{ route('pegawai.dashboard') }}">Beralih ke Dashboard Pegawai</a></li>
        <li><a href="{{ route('admin.notifications.create') }}" style="color:#38bdf8; font-weight:600;">Kirim Pemberitahuan</a></li>
    </ul>
    <p>Kedepan, kita dapat menambahkan: manajemen user, master shift, ekspor laporan.</p>
    <p style="margin:0; color:#cbd5e1;">Tanggal: {{ now()->format('d M Y H:i') }}</p>
    <hr style="margin: 18px 0; border-color: rgba(148,163,184,0.2);">
    <div>
        <div style="display:flex; align-items:center; justify-content: space-between; margin-bottom:10px;">
            <h3 style="margin:0;">Daftar Akun</h3>
            <a href="{{ route('register') }}" class="btn">+ Daftar Akun</a>
        </div>
        <div class="table-responsive">
        <table style="width:100%; border-collapse: collapse;">
            <thead>
                <tr style="text-align:left; border-bottom:1px solid rgba(148,163,184,0.2);">
                    <th style="padding:8px;">Nama</th>
                    <th style="padding:8px;">Username</th>
                    <th style="padding:8px;">Email</th>
                    <th style="padding:8px;">Role</th>
                    <th style="padding:8px;">Dibuat</th>
                </tr>
            </thead>
            <tbody>
                @forelse($users as $u)
                <tr style="border-bottom:1px solid rgba(148,163,184,0.08);">
                    <td style="padding:8px;">{{ $u->name }}</td>
                    <td style="padding:8px;">{{ $u->username ?? '-' }}</td>
                    <td style="padding:8px;">{{ $u->email }}</td>
                    <td style="padding:8px; text-transform:capitalize;">{{ $u->role }}</td>
                    <td style="padding:8px;">{{ $u->created_at?->format('d M Y') }}</td>
                </tr>
                @empty
                <tr>
                    <td colspan="5" style="padding:10px; color:#9ca3af;">Belum ada akun.</td>
                </tr>
                @endforelse
            </tbody>
        </table>
        </div>
    </div>
    </div>
@endsection
