<div class="flex min-h-screen bg-bg">
    <x-auth.brand
        :headline="__('auth.register_brand_headline')"
        :sub="__('auth.register_brand_sub')"
        :facts="[
            __('auth.fact_setup_term') => __('auth.fact_setup'),
            __('auth.fact_location_term') => __('auth.fact_location'),
            __('auth.fact_backup_term') => __('auth.fact_backup'),
            __('auth.fact_support_term') => __('auth.fact_support'),
        ]" />

    {{-- Form panel --}}
    <main class="flex flex-1 items-center justify-center px-6 py-12">
        <div class="w-full max-w-sm animate-rise">
            <x-ui.brand size="md" class="mb-9 lg:hidden" />

            <h1 class="text-3xl font-bold leading-tight tracking-tight text-ink">{{ __('auth.register_title') }}</h1>
            <p class="mt-2 text-sm text-muted">{{ __('auth.register_subtitle') }}</p>

            <form method="POST" action="{{ route('register.store') }}" class="mt-7 space-y-5">
                @csrf
                <x-ui.input name="name" type="text" :label="__('auth.name')" autocomplete="name" autofocus required value="{{ old('name') }}" />
                <x-ui.input name="email" type="email" :label="__('auth.email')" autocomplete="email" required value="{{ old('email') }}" />

                {{-- Asked here and nowhere else, because here is where the
                     customer record comes into being. It decides the
                     fourteen-day right of withdrawal, how the invoice is worded
                     and whether reverse charge can ever apply — none of which a
                     VAT field can answer, since most small businesses have no
                     number and no consumer has one. Two radios and no
                     preselection: a default would be an answer nobody gave. --}}
                <fieldset class="space-y-1.5">
                    <legend class="block text-sm font-medium text-body">{{ __('auth.customer_type') }}</legend>
                    <div class="grid grid-cols-2 gap-2">
                        @foreach ([\App\Models\Customer::TYPE_CONSUMER, \App\Models\Customer::TYPE_BUSINESS] as $type)
                            <label class="flex cursor-pointer items-center gap-2 rounded border border-line bg-surface px-3.5 py-2.5 text-sm text-ink transition has-[:checked]:border-ink">
                                <input type="radio" name="customer_type" value="{{ $type }}" required
                                       @checked(old('customer_type') === $type)
                                       class="size-4 shrink-0 border-line text-ink" />
                                {{ __('auth.customer_type_'.$type) }}
                            </label>
                        @endforeach
                    </div>
                    <p class="text-xs text-muted">{{ __('auth.customer_type_hint') }}</p>
                    @error('customer_type')<p class="text-xs text-danger">{{ $message }}</p>@enderror
                </fieldset>

                <x-ui.input name="password" type="password" :label="__('auth.password_label')" autocomplete="new-password" required />
                <x-ui.input name="password_confirmation" type="password" :label="__('auth.password_confirm')" autocomplete="new-password" required />
                <x-ui.button type="submit" variant="primary" size="md" class="w-full">{{ __('auth.create_account') }}</x-ui.button>
            </form>

            <p class="mt-8 text-center text-sm text-muted">
                {{ __('auth.have_account') }}
                <a href="{{ route('login') }}" wire:navigate class="font-semibold text-accent-text hover:underline">{{ __('auth.sign_in') }}</a>
            </p>
        </div>
    </main>
</div>
