[Back]
@extends('layouts.public')

@section('content')
<div class="flex items-center justify-between mb-6">
    <h1 class="text-2xl font-bold">Edit Customer</h1>
    <a href="{{ route('admin.customers.index') }}" class="underline">Back</a>
</div>

<div class="bg-white rounded-xl shadow p-6 space-y-6">
    <div class="text-sm">
        <div><span class="text-gray-500">Name:</span> {{ $user->name }}</div>
        <div><span class="text-gray-500">Email:</span> {{ $user->email }}</div>
    </div>

    <form method="POST" action="{{ route('admin.customers.update', $user) }}" class="space-y-4">
        @csrf
        @method('PATCH')

        <div>
            <label class="text-sm font-medium">Phone</label>
            <input name="phone" class="mt-1 w-full rounded border-gray-300"
                   value="{{ old('phone', $profile->phone) }}" />
        </div>

        <div>
            <label class="text-sm font-medium">Address Line 1</label>
            <input name="address_line1" class="mt-1 w-full rounded border-gray-300"
                   value="{{ old('address_line1', $profile->address_line1) }}" />
        </div>

        <div>
            <label class="text-sm font-medium">Address Line 2</label>
            <input name="address_line2" class="mt-1 w-full rounded border-gray-300"
                   value="{{ old('address_line2', $profile->address_line2) }}" />
        </div>

        <div class="grid grid-cols-2 gap-3">
            <div>
                <label class="text-sm font-medium">City</label>
                <input name="city" class="mt-1 w-full rounded border-gray-300"
                       value="{{ old('city', $profile->city) }}" />
            </div>
            <div>
                <label class="text-sm font-medium">State</label>
                <input name="state" class="mt-1 w-full rounded border-gray-300"
                       value="{{ old('state', $profile->state) }}" />
            </div>
        </div>

        <div class="grid grid-cols-2 gap-3">
            <div>
                <label class="text-sm font-medium">Postcode</label>
                <input name="postcode" class="mt-1 w-full rounded border-gray-300"
                       value="{{ old('postcode', $profile->postcode) }}" />
            </div>
            <div>
                <label class="text-sm font-medium">Country</label>
                <input name="country" class="mt-1 w-full rounded border-gray-300"
                       value="{{ old('country', $profile->country ?? 'MY') }}" />
            </div>
        </div>

        <button class="px-5 py-3 rounded bg-black text-white">Save</button>
    </form>
</div>
@endsection