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

@section('content')
<div class="flex items-center justify-between mb-6">
    <h1 class="text-2xl font-bold">Customers</h1>

    <form class="flex gap-2" method="GET" action="{{ route('admin.customers.index') }}">
        <input name="search" class="rounded border-gray-300" placeholder="Search name/email"
               value="{{ request('search') }}" />
        <button class="px-3 py-2 rounded bg-black text-white text-sm">Search</button>
    </form>
</div>

<div class="bg-white rounded-xl shadow overflow-hidden">
    <table class="w-full text-sm">
        <thead class="bg-gray-50">
            <tr>
                <th class="p-4 text-left">Name</th>
                <th class="p-4 text-left">Email</th>
                <th class="p-4 text-left">Phone</th>
                <th class="p-4 text-right">Action</th>
            </tr>
        </thead>
        <tbody>
        @forelse($customers as $c)
            <tr class="border-t">
                <td class="p-4 font-medium">{{ $c->name }}</td>
                <td class="p-4">{{ $c->email }}</td>
                <td class="p-4">{{ $c->customerProfile->phone ?? '-' }}</td>
                <td class="p-4 text-right">
                    <a class="underline" href="{{ route('admin.customers.edit', $c) }}">Edit</a>
                </td>
            </tr>
        @empty
            <tr><td class="p-6 text-gray-600" colspan="4">No customers found.</td></tr>
        @endforelse
        </tbody>
    </table>
</div>

<div class="mt-6">{{ $customers->links() }}</div>
@endsection