<x-app-layout>
    <x-ui.page-header title="Modifier le compte" description="Filiale {{ $filiale->name }}" />
    <x-alert />

    <div class="card p-6 max-w-2xl">
        <form method="POST" action="{{ route('admin.filiales.users.update', [$filiale, $user]) }}" class="space-y-5">
            @csrf @method('PUT')
            <div class="grid grid-cols-1 md:grid-cols-2 gap-5">
                <div class="md:col-span-2">
                    <label class="block text-sm font-medium text-slate-700 mb-1">Nom *</label>
                    <input type="text" name="name" value="{{ old('name', $user->name) }}" class="input-modern" required>
                </div>
                <div class="md:col-span-2">
                    <label class="block text-sm font-medium text-slate-700 mb-1">Email *</label>
                    <input type="email" name="email" value="{{ old('email', $user->email) }}" class="input-modern" required>
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Nouveau mot de passe</label>
                    <input type="password" name="password" class="input-modern" placeholder="Laisser vide pour ne pas changer">
                </div>
                <div>
                    <label class="block text-sm font-medium text-slate-700 mb-1">Confirmer le mot de passe</label>
                    <input type="password" name="password_confirmation" class="input-modern">
                </div>
                <div class="md:col-span-2">
                    <label class="inline-flex items-center gap-2">
                        <input type="hidden" name="is_active" value="0">
                        <input type="checkbox" name="is_active" value="1" class="rounded border-slate-300 text-transtev-600 focus:ring-transtev-500" @checked(old('is_active', $user->is_active))>
                        <span class="text-sm font-medium text-slate-700">Compte actif</span>
                    </label>
                </div>
            </div>

            <div class="flex gap-3 pt-2">
                <button type="submit" class="btn-primary">Enregistrer</button>
                <a href="{{ route('admin.filiales.users.index', $filiale) }}" class="btn-secondary">Annuler</a>
            </div>
        </form>
    </div>
</x-app-layout>
