<x-layouts.app title="Protect Your Account" activePage="security">
<div class="max-w-3xl mx-auto">
    <h2 class="text-2xl font-bold text-gray-800 mb-2">Protect Your Account</h2>
    <p class="text-sm text-gray-500 mb-6">Freeze your accounts instantly if you suspect unauthorized access. Unfreezing is just as easy.</p>

    {{-- Security Tips --}}
    <div class="bg-blue-50 border border-blue-200 rounded-lg p-4 mb-6">
        <h3 class="text-sm font-bold text-blue-800 mb-2">Security Best Practices</h3>
        <ul class="text-xs text-blue-700 list-disc list-inside space-y-1">
            <li>Never share your password, PIN, or OTP with anyone</li>
            <li>Enable two-factor authentication in your <a href="{{ route('profile') }}" class="underline">profile settings</a></li>
            <li>Regularly review your transaction history for unauthorized activity</li>
            <li>Use a strong, unique password for your banking account</li>
            <li>Contact us immediately if you notice anything suspicious</li>
        </ul>
    </div>

    {{-- Account Freeze/Unfreeze --}}
    <div class="space-y-4">
        @foreach($accounts as $account)
        <div class="bg-white rounded-lg shadow p-5 flex flex-col sm:flex-row items-start sm:items-center justify-between gap-4">
            <div>
                <p class="font-semibold text-gray-800">{{ ucfirst($account->account_type?->value ?? 'Unknown') }} Account</p>
                <p class="text-xs text-gray-500 font-mono">{{ $account->account_number }}</p>
                <p class="text-sm mt-1">
                    Balance: <span class="font-semibold">${{ number_format($account->balance, 2) }}</span>
                </p>
            </div>
            <div class="flex items-center gap-3 w-full sm:w-auto">
                <span class="text-xs px-2 py-0.5 rounded {{ $account->status === \App\Enums\AccountStatus::Frozen ? 'bg-blue-100 text-blue-700' : 'bg-green-100 text-green-700' }}">
                    {{ ucfirst($account->status?->value ?? 'Unknown') }}
                </span>
                <form method="POST" action="{{ route('security.freeze-account') }}">
                    @csrf
                    <input type="hidden" name="account_id" value="{{ $account->id }}">
                    @if($account->status === \App\Enums\AccountStatus::Frozen)
                        <button type="submit" class="text-sm bg-green-600 text-white px-4 py-2 rounded hover:bg-green-700 transition" onclick="return confirm('Unfreeze this account?')">Unfreeze</button>
                    @else
                        <button type="submit" class="text-sm bg-red-600 text-white px-4 py-2 rounded hover:bg-red-700 transition" onclick="return confirm('Freeze this account? All transactions will be blocked.')">Freeze Account</button>
                    @endif
                </form>
            </div>
        </div>
        @endforeach
    </div>
</div>
</x-layouts.app>
