@extends('layouts.app')

@section('content')
    <div class="space-y-6">
        <div class="flex flex-wrap items-center justify-between gap-4">
            <div>
                <h2 class="text-2xl font-semibold text-slate-900">Tambah User</h2>
                <p class="text-sm text-slate-500">Buat akun pengguna baru.</p>
            </div>
            <x-button href="{{ route('users.index') }}" variant="secondary">Kembali</x-button>
        </div>

        <x-card>
            <form method="post" action="{{ route('users.store') }}" class="grid gap-4 md:grid-cols-2">
                @csrf
                <x-input name="name" label="Nama" :value="old('name')" />
                <x-input name="username" label="Username" :value="old('username')" required />
                <x-input name="email" label="Email" type="email" :value="old('email')" required />
                <x-select name="roles_id" label="Role">
                    <option value="">Pilih Role</option>
                    @foreach($roles as $role)
                        <option value="{{ $role->id }}" {{ old('roles_id') == $role->id ? 'selected' : '' }}>{{ $role->nama_roles }}</option>
                    @endforeach
                </x-select>
                <x-input name="password" label="Password" type="password" required />
                <div class="md:col-span-2 flex justify-end gap-3">
                    <x-button type="submit">Simpan</x-button>
                </div>
            </form>
        </x-card>
    </div>
@endsection
