<x-app-layout>
    <x-slot name="header">
        {{ __('Add Department') }}
    </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 Department</h1>
                    <p class="mt-1 text-sm text-gray-600">
                        Create a new department for the current dealer.
                    </p>
                </div>

                <form method="POST" action="{{ route('settings.departments.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">
                        Department code will be generated automatically from the name (e.g. <code>DEPT-SYSTEM-ADMINISTRATION</code>).
                    </div>

                    <div class="flex items-center justify-end gap-3 pt-4">
                        <a
                            href="{{ route('settings.departments.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 Department
                        </button>
                    </div>
                </form>
            </div>
        </div>
    </div>
</x-app-layout>

