<x-admin-layout>
    <x-slot name="header">
        <div class="flex items-center gap-4">
            <a href="{{ route('admin.users.index') }}" class="p-2 text-gray-400 hover:text-indigo-600 dark:hover:text-indigo-400 dark:text-indigo-400 hover:bg-indigo-50 dark:hover:bg-indigo-900/30 dark:bg-indigo-900/30 rounded-full transition-colors">
                <x-heroicon-o-arrow-left class="w-6 h-6" />
            </a>
            <h2 class="font-bold text-2xl text-gray-900 dark:text-white leading-tight">
                {{ __('Tambah Pengguna Baru') }}
            </h2>
        </div>
    </x-slot>

    <div class="max-w-4xl">
        <div class="bg-white dark:bg-slate-800 rounded-2xl shadow-sm border border-gray-100 dark:border-slate-700 overflow-hidden">
            <form action="{{ route('admin.users.store') }}" method="POST">
                @csrf
                <div class="p-8 space-y-6">
                    <!-- Info Banner -->
                    <div class="flex items-start gap-3 p-4 rounded-xl bg-indigo-50 dark:bg-indigo-900/20 border border-indigo-100 dark:border-indigo-800/50">
                        <x-heroicon-o-information-circle class="w-5 h-5 text-indigo-500 flex-shrink-0 mt-0.5" />
                        <p class="text-sm text-indigo-700 dark:text-indigo-300">
                            Pengguna yang ditambahkan melalui admin panel akan <strong>langsung aktif</strong> tanpa perlu verifikasi email.
                        </p>
                    </div>

                    <!-- Name & Email -->
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <label for="name" class="block text-sm font-medium text-gray-700 dark:text-gray-200 mb-2">Nama Lengkap <span class="text-red-500">*</span></label>
                            <input type="text" name="name" id="name" value="{{ old('name') }}" required placeholder="Masukkan nama lengkap"
                                class="block w-full rounded-lg border-gray-300 dark:border-slate-600 dark:bg-slate-700 dark:text-gray-100 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2.5 px-3 border placeholder-gray-400 dark:placeholder-slate-500">
                            @error('name') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
                        </div>

                        <div>
                            <label for="email" class="block text-sm font-medium text-gray-700 dark:text-gray-200 mb-2">Email <span class="text-red-500">*</span></label>
                            <input type="email" name="email" id="email" value="{{ old('email') }}" required placeholder="contoh@email.com"
                                class="block w-full rounded-lg border-gray-300 dark:border-slate-600 dark:bg-slate-700 dark:text-gray-100 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2.5 px-3 border placeholder-gray-400 dark:placeholder-slate-500">
                            @error('email') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
                        </div>
                    </div>

                    <!-- Phone & Role -->
                    <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                        <div>
                            <label for="phone" class="block text-sm font-medium text-gray-700 dark:text-gray-200 mb-2">Nomor Telepon</label>
                            <input type="text" name="phone" id="phone" value="{{ old('phone') }}" placeholder="08xxxxxxxxxx"
                                class="block w-full rounded-lg border-gray-300 dark:border-slate-600 dark:bg-slate-700 dark:text-gray-100 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2.5 px-3 border placeholder-gray-400 dark:placeholder-slate-500">
                            @error('phone') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
                        </div>

                        <div>
                            <label for="role" class="block text-sm font-medium text-gray-700 dark:text-gray-200 mb-2">Role/Peran <span class="text-red-500">*</span></label>
                            <select id="role" name="role" required class="block w-full rounded-lg border-gray-300 dark:border-slate-600 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2.5 px-3 border bg-white dark:bg-slate-700 dark:text-gray-100">
                                @foreach($roles as $role)
                                    <option value="{{ $role->name }}" {{ old('role') === $role->name ? 'selected' : '' }}>
                                        {{ ucfirst($role->name) }}
                                    </option>
                                @endforeach
                            </select>
                            @error('role') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
                        </div>
                    </div>

                    <!-- Password Section -->
                    <div class="pt-2">
                        <div class="flex items-center gap-2 mb-4">
                            <x-heroicon-o-lock-closed class="w-4 h-4 text-gray-500 dark:text-gray-400" />
                            <h4 class="text-sm font-semibold text-gray-700 dark:text-gray-200 uppercase tracking-wide">Kata Sandi</h4>
                        </div>
                        <div class="grid grid-cols-1 md:grid-cols-2 gap-6">
                            <div>
                                <label for="password" class="block text-sm font-medium text-gray-700 dark:text-gray-200 mb-2">Password <span class="text-red-500">*</span></label>
                                <input type="password" name="password" id="password" required placeholder="Minimal 8 karakter"
                                    class="block w-full rounded-lg border-gray-300 dark:border-slate-600 dark:bg-slate-700 dark:text-gray-100 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2.5 px-3 border placeholder-gray-400 dark:placeholder-slate-500">
                                @error('password') <p class="mt-2 text-sm text-red-600">{{ $message }}</p> @enderror
                            </div>

                            <div>
                                <label for="password_confirmation" class="block text-sm font-medium text-gray-700 dark:text-gray-200 mb-2">Konfirmasi Password <span class="text-red-500">*</span></label>
                                <input type="password" name="password_confirmation" id="password_confirmation" required placeholder="Ulangi password"
                                    class="block w-full rounded-lg border-gray-300 dark:border-slate-600 dark:bg-slate-700 dark:text-gray-100 shadow-sm focus:border-indigo-500 focus:ring-indigo-500 py-2.5 px-3 border placeholder-gray-400 dark:placeholder-slate-500">
                            </div>
                        </div>
                    </div>
                </div>

                <!-- Form Actions -->
                <div class="px-8 py-4 bg-gray-50 dark:bg-slate-700/50 border-t border-gray-100 dark:border-slate-700 flex justify-end gap-3">
                    <a href="{{ route('admin.users.index') }}" class="px-4 py-2 border border-gray-300 dark:border-slate-600 rounded-lg shadow-sm font-medium text-gray-700 dark:text-gray-200 bg-white dark:bg-slate-800 hover:bg-gray-50 dark:hover:bg-slate-700/50">Batal</a>
                    <button type="submit" class="px-5 py-2 bg-indigo-600 border border-transparent rounded-lg shadow-sm font-medium text-white hover:bg-indigo-700 transition-colors flex items-center gap-2">
                        <x-heroicon-o-user-plus class="w-4 h-4" />
                        Tambah Pengguna
                    </button>
                </div>
            </form>
        </div>
    </div>
</x-admin-layout>
