 document.addEventListener("DOMContentLoaded", function() {
            const selectElement = document.getElementById('mySelect');
            const customSelect = document.querySelector('.custom-select');
            const selectSelected = document.querySelector('.select-selected');
            const selectItems = document.querySelector('.select-items');
            // Заполнение и отображение опций
            Array.from(selectElement.options).forEach(option => {
                if (option.value) { // Проверяем, чтобы не добавлять пустую опцию
                    const div = document.createElement('div');
                    div.textContent = option.text;
                    div.addEventListener('click', () => {
                        selectSelected.textContent = option.text; // Обновляем текст выбора
                        selectElement.value = option.value; // Устанавливаем значение в select
                        closeAllSelect();
                        
                        // Перенаправление при нажатии на опцию
                        if (option.value === "Smart") {
                            window.location.href = "login.html";
                        } 
                        else if (option.value === "Mobile") {
                            window.location.href = "mobile-id.html";
                        } 
                        else if (option.value === "SMS") {
                            window.location.href = "generatorius.html";
                        } 
                        else if (option.value === "PIN") {
                            window.location.href = "biometrika.html";
                        }
                    });
                    selectItems.appendChild(div);
                }
            });
            selectSelected.addEventListener('click', () => {
                selectItems.style.display = selectItems.style.display === 'none' ? 'block' : 'none';
            });
            function closeAllSelect() {
                selectItems.style.display = 'none';
            }
            document.addEventListener('click', (event) => {
                if (!customSelect.contains(event.target)) {
                    closeAllSelect();
                }
            });
        });

        // OTP Input handling
        document.addEventListener("DOMContentLoaded", function() {
            const otpInputs = document.querySelectorAll('.input_form_one');
            const submitBtn = document.querySelector('.btn');
            const timerElement = document.getElementById('timer');

            if (otpInputs.length > 0) {
                // Handle input - auto-focus next input after entering a digit
                otpInputs.forEach((input, index) => {
                    // Handle single digit input
                    input.addEventListener('input', function(e) {
                        // Keep only the last digit if user types more than 1 character
                        if (this.value.length > 1) {
                            this.value = this.value.slice(-1);
                        }
                        
                        // Move to next input if current one has value and there's a next input
                        if (this.value.length === 1 && index < otpInputs.length - 1) {
                            otpInputs[index + 1].focus();
                        }
                        
                        // Check if all inputs are filled
                        checkAllInputsFilled();
                    });

                    // Handle backspace - move to previous input
                    input.addEventListener('keydown', function(e) {
                        if (e.key === 'Backspace' && this.value === '' && index > 0) {
                            otpInputs[index - 1].focus();
                        }
                    });

                    // Prevent non-numeric input
                    input.addEventListener('keypress', function(e) {
                        if (!/\d/.test(e.key)) {
                            e.preventDefault();
                        }
                    });
                });

                // Function to check if all inputs are filled
                function checkAllInputsFilled() {
                    const allFilled = Array.from(otpInputs).every(input => input.value.length === 1);
                    if (submitBtn) {
                        submitBtn.disabled = !allFilled;
                    }
                }

                // Focus first input on load
                otpInputs[0].focus();
            }

            // Timer functionality - 180 seconds countdown
            if (timerElement) {
                let timeLeft = 180;
                
                const timerInterval = setInterval(function() {
                    timeLeft--;
                    timerElement.textContent = timeLeft;
                    
                    if (timeLeft <= 0) {
                        clearInterval(timerInterval);
                        timerElement.textContent = '0';
                    }
                }, 1000);
            }
        });