@php
    $fieldText = 'h-12 w-full rounded-md border border-line bg-inset px-3 text-center font-mono text-sm text-ink placeholder:text-ink-4 focus:border-accent/40 focus:outline-none';
    $label = 'mb-1.5 block font-mono text-[11px] uppercase tracking-wider text-ink-3';
    $err = 'mt-1.5 flex items-center gap-1.5 font-mono text-[11px] text-offline';
@endphp

<div class="space-y-7">
    <div class="space-y-1.5">
        <p class="font-mono text-[10px] font-semibold uppercase tracking-[0.18em] text-accent-text">{{ __('auth.two_factor') }}</p>
        <h1 class="font-display text-2xl font-bold tracking-tight text-ink">{{ __('auth.backup_heading') }}</h1>
        <p class="font-mono text-xs text-ink-3">{{ __('auth.backup_subtitle') }}</p>
    </div>

    <form wire:submit="verify" class="space-y-4">
        <div>
            <label for="code" class="{{ $label }}">{{ __('auth.challenge_backup_label') }}</label>
            <input wire:model="code" id="code" inputmode="text" autocomplete="one-time-code" autofocus
                   class="{{ $fieldText }}" placeholder="{{ __('auth.challenge_backup_placeholder') }}" />
            @error('code') <p class="{{ $err }}"><x-icon name="alert" class="h-3.5 w-3.5 shrink-0" />{{ $message }}</p> @enderror
        </div>

        <x-btn variant="primary" size="lg" type="submit" class="w-full" wire:loading.attr="disabled" wire:target="verify">
            <svg wire:loading wire:target="verify" class="h-4 w-4 animate-spin" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" aria-hidden="true"><path d="M21 12a9 9 0 1 1-6.219-8.56" stroke-linecap="round" /></svg>
            <span wire:loading.remove wire:target="verify">{{ __('common.confirm') }}</span>
            <span wire:loading wire:target="verify">{{ __('auth.checking') }}</span>
        </x-btn>
    </form>

    <div class="flex flex-col items-center gap-2.5">
        @if ($this->pendingHasTotp || $this->webauthnAvailable())
            <a href="{{ route('two-factor.challenge') }}" wire:navigate class="inline-flex items-center gap-1.5 font-mono text-[11px] text-ink-4 transition-colors hover:text-ink-2">
                <x-icon name="chevron-left" class="h-3.5 w-3.5" /> {{ __('auth.back_to_options') }}
            </a>
        @endif
        <a href="{{ route('login') }}" wire:navigate class="inline-flex items-center gap-1.5 font-mono text-[11px] text-ink-4 transition-colors hover:text-ink-2">
            <x-icon name="chevron-left" class="h-3.5 w-3.5" /> {{ __('auth.back_to_login') }}
        </a>
    </div>
</div>
