<x-app-layout>
    <x-slot name="header">
        {{ __('Add Dealer') }}
    </x-slot>

    <div class="p-6">
        <div class="max-w-xl">
            <div class="bg-white border border-gray-200 rounded-xl shadow-sm p-6 space-y-6">
                <div>
                    <h1 class="text-xl font-semibold text-gray-900">Add Dealer</h1>
                    <p class="mt-1 text-sm text-gray-600">
                        Create a new dealer (tenant). Codes must be unique.
                    </p>
                </div>

                <form method="POST" action="{{ route('settings.dealers.store') }}" class="space-y-4">
                    @csrf

                    <div>
                        <label for="name" class="block text-sm font-medium text-gray-700">Name</label>
                        <input
                            id="name"
                            name="name"
                            type="text"
                            value="{{ old('name') }}"
                            required
                            class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-red-500 focus:ring-red-500 text-sm"
                        >
                        @error('name')
                            <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                        @enderror
                    </div>

                    <div class="text-xs text-gray-500">
                        Dealer code will be generated automatically from the name (e.g. <code>DLR-MEGA-THERON-TRADERS</code>).
                    </div>

                    <div>
                        <label for="domain" class="block text-sm font-medium text-gray-700">Email / Login Domain</label>
                        <input
                            id="domain"
                            name="domain"
                            type="text"
                            placeholder="example: dealerb.co.za"
                            value="{{ old('domain') }}"
                            required
                            class="mt-1 block w-full rounded-md border-gray-300 shadow-sm focus:border-red-500 focus:ring-red-500 text-sm"
                        >
                        <p class="mt-1 text-xs text-gray-500">
                            Used to generate built-in user emails (e.g. <code>admin@dealerb.co.za</code>).
                        </p>
                        @error('domain')
                            <p class="mt-1 text-xs text-red-600">{{ $message }}</p>
                        @enderror
                    </div>

                    <div class="flex items-center justify-end gap-3 pt-4">
                        <a
                            href="{{ route('settings.dealers.index') }}"
                            class="inline-flex items-center rounded-md border border-gray-200 px-4 py-2 text-sm text-gray-700 hover:bg-gray-50"
                        >
                            Cancel
                        </a>
                        <button
                            type="submit"
                            class="inline-flex items-center rounded-md bg-red-600 px-4 py-2 text-sm font-semibold text-white shadow-sm hover:bg-red-700"
                        >
                            Save Dealer
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</x-app-layout>

