<x-app-layout>
    <x-slot name="header">
        <div class="flex flex-col gap-2">
            <p class="text-xs font-semibold uppercase tracking-[0.3em] text-cyan-300/80">Admin Only</p>
            <h2 class="text-2xl font-semibold text-white">{{ __('Tambah Akun Client') }}</h2>
            <p class="max-w-2xl text-sm text-slate-300">Halaman ini hanya untuk admin agar pembuatan akun client tetap private dan terkontrol.</p>
        </div>
    </x-slot>

    <div class="py-10">
        <div class="mx-auto grid max-w-7xl gap-6 px-4 sm:px-6 lg:grid-cols-[0.95fr_1.05fr] lg:px-8">
            <section class="rounded-3xl border border-white/10 bg-white/10 p-6 shadow-2xl shadow-slate-950/30 backdrop-blur">
                @if (session('success'))
                    <div class="mb-5 rounded-2xl border border-emerald-400/30 bg-emerald-500/10 px-4 py-3 text-sm text-emerald-100">
                        {{ session('success') }}
                    </div>
                @endif

                <div class="mb-6">
                    <p class="text-sm font-medium text-cyan-200">Form Client</p>
                    <h3 class="mt-2 text-2xl font-semibold text-white">Buat akun client baru</h3>
                    <p class="mt-2 text-sm text-slate-300">Akun yang dibuat akan langsung terverifikasi sehingga client bisa login dan melihat katalog produk.</p>
                </div>

                <form method="POST" action="{{ route('admin.clients.store') }}" class="space-y-5">
                    @csrf

                    <div>
                        <label for="name" class="text-sm font-medium text-slate-200">Nama Client</label>
                        <input id="name" name="name" type="text" value="{{ old('name') }}" required autofocus class="mt-2 w-full rounded-2xl border border-white/10 bg-slate-950/60 px-4 py-3 text-white placeholder:text-slate-500 focus:border-cyan-400 focus:outline-none focus:ring-0">
                        <x-input-error :messages="$errors->get('name')" class="mt-2" />
                    </div>

                    <div>
                        <label for="email" class="text-sm font-medium text-slate-200">Email Client</label>
                        <input id="email" name="email" type="email" value="{{ old('email') }}" required class="mt-2 w-full rounded-2xl border border-white/10 bg-slate-950/60 px-4 py-3 text-white placeholder:text-slate-500 focus:border-cyan-400 focus:outline-none focus:ring-0">
                        <x-input-error :messages="$errors->get('email')" class="mt-2" />
                    </div>

                    <div>
                        <label for="phone" class="text-sm font-medium text-slate-200">No Telp Client</label>
                        <input id="phone" name="phone" type="text" value="{{ old('phone') }}" required class="mt-2 w-full rounded-2xl border border-white/10 bg-slate-950/60 px-4 py-3 text-white placeholder:text-slate-500 focus:border-cyan-400 focus:outline-none focus:ring-0">
                        <x-input-error :messages="$errors->get('phone')" class="mt-2" />
                    </div>

                    <div>
                        <label for="password" class="text-sm font-medium text-slate-200">Password Sementara</label>
                        <input id="password" name="password" type="password" required class="mt-2 w-full rounded-2xl border border-white/10 bg-slate-950/60 px-4 py-3 text-white placeholder:text-slate-500 focus:border-cyan-400 focus:outline-none focus:ring-0">
                        <x-input-error :messages="$errors->get('password')" class="mt-2" />
                    </div>

                    <button type="submit" class="inline-flex w-full items-center justify-center rounded-full bg-cyan-400 px-5 py-3 text-sm font-semibold text-slate-950 transition hover:bg-cyan-300">
                        Simpan Akun Client
                    </button>
                </form>
            </section>

            <section class="rounded-3xl border border-white/10 bg-slate-950/70 p-6 shadow-2xl shadow-slate-950/30">
                <div class="flex items-center justify-between gap-4">
                    <div>
                        <p class="text-sm font-medium text-cyan-200">Client Terdaftar</p>
                        <h3 class="mt-2 text-2xl font-semibold text-white">Daftar akun client aktif</h3>
                    </div>
                    <span class="rounded-full border border-white/10 bg-white/5 px-4 py-2 text-sm font-medium text-slate-200">{{ $clients->count() }} client</span>
                </div>

                <div class="mt-6 space-y-3">
                    @forelse ($clients as $client)
                        <div class="rounded-2xl border border-white/10 bg-white/5 px-4 py-4">
                            <div class="flex items-start justify-between gap-4">
                                <div>
                                    <h4 class="text-base font-semibold text-white">{{ $client->name }}</h4>
                                    <p class="mt-1 text-sm text-slate-400">{{ $client->email }}</p>
                                    <p class="mt-1 text-sm text-slate-500">{{ $client->phone ?? 'No telp belum diisi' }}</p>
                                </div>
                                <div class="flex flex-col items-end gap-2">
                                    <span class="rounded-full border border-emerald-400/20 bg-emerald-400/10 px-3 py-1 text-xs font-semibold text-emerald-100">
                                        {{ $client->email_verified_at ? 'Siap Login' : 'Belum Verifikasi' }}
                                    </span>
                                    <a href="{{ route('admin.clients.edit', $client) }}" class="inline-flex items-center rounded-full border border-white/10 bg-white/5 px-3 py-1.5 text-xs font-semibold text-slate-200 transition hover:bg-white/10">
                                        Edit Client
                                    </a>
                                </div>
                            </div>
                        </div>
                    @empty
                        <div class="rounded-2xl border border-dashed border-white/15 bg-white/5 px-4 py-8 text-center text-sm text-slate-400">
                            Belum ada client yang dibuat oleh admin.
                        </div>
                    @endforelse
                </div>
            </section>
        </div>
    </div>
</x-app-layout>
