@extends('layouts.admin')
@section('title', 'Edit ' . $user->full_name . ' — JAM Admin')
@section('page-title', 'Edit Member')

@section('content')
<div class="max-w-2xl">
    <div class="flex items-center gap-3 mb-6">
        <a href="{{ route('admin.members.show', $user) }}" class="text-white/30 hover:text-white transition-colors">
            <svg class="w-4 h-4" fill="none" stroke="currentColor" viewBox="0 0 24 24"><path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7"/></svg>
        </a>
        <h2 class="text-2xl font-semibold" style="font-family: 'Playfair Display', serif;">Edit {{ $user->full_name }}</h2>
    </div>

    @if($errors->any())
    <div class="bg-red-900/20 border border-red-800/50 rounded-xl p-4 mb-6">
        @foreach($errors->all() as $error)
        <p class="text-red-400 text-sm">{{ $error }}</p>
        @endforeach
    </div>
    @endif

    <form method="POST" action="{{ route('admin.members.update', $user) }}" class="bg-[#111111] border border-[#1e1e1e] rounded-xl p-8 space-y-6">
        @csrf
        @method('PUT')
        <div class="grid grid-cols-2 gap-6">
            <div>
                <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">First Name</label>
                <input type="text" name="first_name" value="{{ old('first_name', $user->first_name) }}" required
                       class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-[#D4B84A] rounded-lg px-4 py-3 text-sm text-white outline-none transition-colors">
            </div>
            <div>
                <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Last Name</label>
                <input type="text" name="last_name" value="{{ old('last_name', $user->last_name) }}" required
                       class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-[#D4B84A] rounded-lg px-4 py-3 text-sm text-white outline-none transition-colors">
            </div>
        </div>
        <div>
            <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Date of Birth</label>
            <input type="date" name="dob" value="{{ old('dob', $user->dob?->format('Y-m-d')) }}" required
                   class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-[#D4B84A] rounded-lg px-4 py-3 text-sm text-white outline-none transition-colors"
                   style="color-scheme: dark;">
        </div>
        <div>
            <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Email Address</label>
            <input type="email" name="email" value="{{ old('email', $user->email) }}" required
                   class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-[#D4B84A] rounded-lg px-4 py-3 text-sm text-white outline-none transition-colors">
        </div>
        <div>
            <label class="block text-xs tracking-widest uppercase text-white/40 mb-2">Phone (optional)</label>
            <input type="tel" name="phone" value="{{ old('phone', $user->phone) }}"
                   class="w-full bg-[#1a1a1a] border border-[#2a2a2a] focus:border-[#D4B84A] rounded-lg px-4 py-3 text-sm text-white outline-none transition-colors">
        </div>
        <div class="flex justify-end gap-3 pt-2 border-t border-[#1e1e1e]">
            <a href="{{ route('admin.members.show', $user) }}"
               class="px-6 py-3 rounded-full border border-[#2a2a2a] text-white/50 hover:text-white text-sm transition-colors">
                Cancel
            </a>
            <button type="submit"
                    class="px-6 py-3 rounded-full bg-[#D4B84A] hover:bg-[#E8D080] text-black font-semibold text-sm transition-colors">
                Save Changes
            </button>
        </div>
    </form>
</div>
@endsection
