<form action="{{ route('settings.security.update') }}" method="POST" class="max-w-xl space-y-5">
    @csrf
    @method('PUT')
    <div>
        <label for="two_factor_policy" class="block text-xs font-medium text-slate-500">Two-factor policy</label>
        <select name="two_factor_policy" id="two_factor_policy" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2 text-sm focus:border-slate-500 focus:outline-none focus:ring-1 focus:ring-slate-500 js-select2">
            <option value="off" {{ ($twoFactorPolicy ?? 'optional') === 'off' ? 'selected' : '' }}>Off — hidden from employee profiles</option>
            <option value="optional" {{ ($twoFactorPolicy ?? 'optional') === 'optional' ? 'selected' : '' }}>Optional — employee chooses</option>
            <option value="required" {{ ($twoFactorPolicy ?? '') === 'required' ? 'selected' : '' }}>Required — all employees must use 2FA</option>
        </select>
        @error('two_factor_policy')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
    </div>
    <div>
        <label for="two_factor_default_method" class="block text-xs font-medium text-slate-500">Default method (when required)</label>
        <select name="two_factor_default_method" id="two_factor_default_method" class="mt-1 block w-full rounded-lg border border-slate-300 px-3 py-2 text-sm focus:border-slate-500 focus:outline-none focus:ring-1 focus:ring-slate-500 js-select2">
            <option value="email" {{ ($twoFactorDefaultMethod ?? 'email') === 'email' ? 'selected' : '' }}>Email OTP — auto-enabled on first login</option>
            <option value="totp" {{ ($twoFactorDefaultMethod ?? '') === 'totp' ? 'selected' : '' }}>Authenticator app — setup at login</option>
        </select>
        <p class="mt-1 text-xs text-slate-500">Used when policy is Required and the employee has not enrolled yet.</p>
        <p class="mt-2 text-xs text-amber-700">Switching policy to <strong>Off</strong> clears 2FA for all employees in your company.</p>
        @error('two_factor_default_method')<p class="mt-1 text-sm text-red-600">{{ $message }}</p>@enderror
    </div>
    <div class="flex justify-end border-t border-slate-100 pt-4">
        <button type="submit" class="rounded-lg bg-slate-800 px-4 py-2 text-sm font-medium text-white hover:bg-slate-700">Save security</button>
    </div>
</form>
