<!DOCTYPE html>
<html lang="{{ app()->getLocale() }}">

<head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="icon" type="image/ico" href="{{ asset('/images/logo/') }}">

    {{-- <meta name="theme-color" content="#6777EF">
    <link rel="apple-touch-icon" href="{{ asset('images/logo/logo.png') }}">
    <link rel="manifest" href="{{ asset('/manifest.json') }}"> --}}
    <!--[if IE]>
    <link rel="shortcut icon" href="/favicon.ico" type="image/vnd.microsoft.icon">
    <![endif]-->

    <!-- CSRF Token -->
    <meta name="csrf-token" content="{{ csrf_token() }}">

    <title>Quiz</title>

    <!-- Styles -->
    <link rel="stylesheet" href="{{ asset('css/font-awesome.min.css') }}">
    <link rel="stylesheet" href="{{ asset('css/bootstrap.min.css') }}">
    @yield('head')
</head>

<body>
    <a href="#main-content" class="sr-only sr-only-focusable" style="position:absolute;top:0;left:0;z-index:99999;padding:10px;background:#fff;">Skip to main content</a>
    <div id="app">
        @yield('top_bar')
        <main id="main-content" role="main">
            @yield('content')
        </main>
    </div>

    <!-- Scripts -->
    <script src="{{ asset('js/app.js') }}"></script>
    @yield('scripts')
    <script src="{{ asset('/sw.js') }}"></script>
    <script>
        if (!navigator.serviceWorker.controller) {
            navigator.serviceWorker.register("/sw.js").then(function(reg) {
            });
        }

        // Toggle password visibility
        $(document).on('click', '.toggle-password', function() {
            var input = $(this).closest('.input-group').find('.password-field');
            var icon = $(this).find('i');
            if (input.attr('type') === 'password') {
                input.attr('type', 'text');
                icon.removeClass('fa-eye').addClass('fa-eye-slash');
            } else {
                input.attr('type', 'password');
                icon.removeClass('fa-eye-slash').addClass('fa-eye');
            }
        });

        // Mobile number input - only allow digits and +
        $(document).on('keypress', '.mobile-input', function(e) {
            var charCode = e.which || e.keyCode;
            var charStr = String.fromCharCode(charCode);
            if (!/[\d\+]/.test(charStr)) {
                e.preventDefault();
            }
        });
        $(document).on('paste', '.mobile-input', function(e) {
            var pastedData = (e.originalEvent.clipboardData || window.clipboardData).getData('text');
            if (!/^[\d\+]+$/.test(pastedData)) {
                e.preventDefault();
            }
        });
    </script>
</body>

</html>
