<!-- OTP Verification Modal -->
<div id="otpModal" class="fixed inset-0 bg-gray-600 bg-opacity-50 overflow-y-auto h-full w-full z-50 hidden">
    <div class="relative top-20 mx-auto p-5 border w-96 shadow-lg rounded-md bg-white">
        <!-- Modal Header -->
        <div class="flex justify-between items-center pb-3">
            <h3 class="text-lg font-semibold text-gray-900">ফোন যাচাই করুন</h3>
            <button type="button" class="text-gray-400 hover:text-gray-600" onclick="closeOtpModal()">
                <svg class="w-6 h-6" fill="none" stroke="currentColor" viewBox="0 0 24 24">
                    <path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M6 18L18 6M6 6l12 12"></path>
                </svg>
            </button>
        </div>

        <!-- Modal Content -->
        <div class="mt-3">
            <div class="mb-4 text-sm text-gray-600">
                আমরা <strong id="otpPhoneNumber"></strong> নম্বরে একটি <strong>৪-সংখ্যার</strong> যাচাইকরণ কোড পাঠিয়েছি। 
                অনুগ্রহ করে নিচে কোডটি লিখুন অথবা SMS থেকে অটো-ফিল করুন।
            </div>

            <!-- Error Messages -->
            <div id="otpErrors" class="mb-4 p-4 bg-red-100 border border-red-400 text-red-700 rounded-lg hidden">
                <ul id="otpErrorsList" class="list-disc list-inside"></ul>
            </div>

            <!-- Success Messages -->
            <div id="otpSuccess" class="mb-4 p-4 bg-green-100 border border-green-400 text-green-700 rounded-lg hidden">
                <span id="otpSuccessMessage"></span>
            </div>

            <!-- OTP Form -->
            <form id="otpForm" method="POST">
                @csrf
                <input type="hidden" id="otp_phone" name="phone" value="">
                <input type="hidden" id="otp_type" name="type" value="auth_verification">
                
                <!-- OTP Code -->
                <div class="mb-4">
                    <label for="modal_otp_code" class="block text-sm font-medium text-gray-700 mb-2">যাচাইকরণ কোড</label>
                    <input type="text" id="modal_otp_code" name="otp"
                           inputmode="numeric" autocomplete="one-time-code"
                           class="w-full px-3 py-2 border border-gray-300 rounded-md focus:outline-none focus:ring-2 focus:ring-blue-500 focus:border-transparent text-center text-2xl tracking-widest"
                           placeholder="0000" maxlength="4" required>
                </div>

                <!-- Submit Button -->
                <div class="mb-4">
                    <button type="submit" id="otpSubmitBtn"
                            class="w-full bg-blue-600 text-white px-4 py-2 rounded-md hover:bg-blue-700 focus:outline-none focus:ring-2 focus:ring-blue-500 focus:ring-offset-2 transition-colors">
                        <span id="otpBtnText">কোড যাচাই করুন</span>
                        <span id="otpBtnLoading" class="hidden">
                            <svg class="animate-spin -ml-1 mr-3 h-5 w-5 text-white inline" xmlns="http://www.w3.org/2000/svg" fill="none" viewBox="0 0 24 24">
                                <circle class="opacity-25" cx="12" cy="12" r="10" stroke="currentColor" stroke-width="4"></circle>
                                <path class="opacity-75" fill="currentColor" d="M4 12a8 8 0 018-8V0C5.373 0 0 5.373 0 12h4zm2 5.291A7.962 7.962 0 014 12H0c0 3.042 1.135 5.824 3 7.938l3-2.647z"></path>
                            </svg>
                            যাচাই হচ্ছে...
                        </span>
                    </button>
                </div>
            </form>

            <!-- Resend OTP -->
            <div class="text-center">
                <button type="button" id="resendOtpBtn" onclick="resendOtp()"
                        class="text-blue-600 hover:text-blue-500 text-sm font-medium">
                    কোড আবার পাঠান
                </button>
                <p id="resendTimer" class="text-sm text-gray-500 hidden">
                    <span id="timerCount">60</span> সেকেন্ডের মধ্যে আবার পাঠানো যাবে
                </p>
            </div>
        </div>
    </div>
</div>