<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Verify Code - Immia Finance</title>
    <script src="https://cdn.tailwindcss.com"></script>
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">
</head>
<body class="bg-gray-50 min-h-screen flex items-center justify-center">
    <div class="max-w-md w-full mx-4 py-10">
        <div class="bg-white rounded-2xl shadow-lg p-8">
            <div class="text-center mb-8">
                <div class="flex items-center justify-center space-x-3 mb-4">
                    <div class="w-12 h-12 bg-blue-600 rounded-lg flex items-center justify-center">
                        <i class="fas fa-shield-alt text-white text-xl"></i>
                    </div>
                    <div>
                        <h1 class="text-2xl font-bold text-gray-900">IMMIA FINANCE</h1>
                        <p class="text-blue-600 text-sm font-semibold uppercase tracking-wider">Step 2 of 3</p>
                    </div>
                </div>
                <h2 class="text-3xl font-bold text-gray-900">Verify OTP</h2>
                <p class="text-gray-600 mt-2">Enter the 6-digit code sent to your devices</p>
            </div>

            @if (session('success'))
                <div class="bg-green-50 border border-green-200 text-green-700 px-4 py-3 rounded-lg mb-6 text-sm flex items-center">
                    <i class="fas fa-check-circle mr-2"></i> {{ session('success') }}
                </div>
            @endif

            @if (session('error'))
                <div class="bg-red-50 border border-red-200 text-red-700 px-4 py-3 rounded-lg mb-6 text-sm flex items-center">
                    <i class="fas fa-exclamation-circle mr-2"></i> {{ session('error') }}
                </div>
            @endif

            <form method="POST" action="{{ route('customer.password.verify.submit') }}">
                @csrf
                <div class="mb-8">
                    <label class="block text-center text-sm font-semibold text-gray-600 mb-4 uppercase tracking-wider font-mono">6-Digit Code</label>
                    <input 
                        type="text" 
                        name="otp" 
                        maxlength="6" 
                        placeholder="000000"
                        required 
                        autofocus
                        class="w-full text-center text-3xl tracking-[0.5em] font-bold py-4 border-2 border-blue-100 rounded-xl focus:border-blue-500 focus:ring-0 transition-all bg-blue-50/30"
                    >
                    @error('otp')
                        <p class="text-red-500 text-xs mt-2 text-center font-medium">{{ $message }}</p>
                    @enderror
                </div>

                <button type="submit" class="w-full bg-blue-600 hover:bg-blue-700 text-white py-3 px-6 rounded-lg font-semibold shadow-md transition-all flex items-center justify-center">
                    Verify Code <i class="fas fa-arrow-right ml-2"></i>
                </button>
            </form>

            <div class="mt-8 pt-6 border-t border-gray-100 text-center">
                <p class="text-sm text-gray-600 mb-2">Didn't receive the code?</p>
                <form id="resendForm" method="POST" action="{{ route('customer.password.resend') }}">
                    @csrf
                    <button type="submit" id="resendBtn" class="text-blue-600 font-bold hover:text-blue-700 disabled:text-gray-400 disabled:cursor-not-allowed transition-colors inline-flex items-center">
                        Resend Code <span id="timer" class="ml-1"></span>
                    </button>
                </form>
            </div>
        </div>

        <div class="mt-6 text-center">
            <a href="{{ route('customer.password.request') }}" class="text-gray-500 hover:text-blue-600 text-sm font-medium">
                <i class="fas fa-arrow-left mr-1"></i> Changed my mind
            </a>
        </div>
    </div>

    <script>
        document.addEventListener('DOMContentLoaded', function() {
            let seconds = 60;
            const timerDisplay = document.getElementById('timer');
            const resendBtn = document.getElementById('resendBtn');
            function startTimer() {
                resendBtn.disabled = true;
                const countdown = setInterval(() => {
                    seconds--;
                    timerDisplay.textContent = `(${seconds}s)`;
                    if (seconds <= 0) {
                        clearInterval(countdown);
                        timerDisplay.textContent = "";
                        resendBtn.disabled = false;
                        seconds = 60;
                    }
                }, 1000);
            }
            startTimer();
        });
    </script>
</body>
</html>