<?php $__env->startSection("title", env("APP_NAME") . " :: Área Restrita"); ?>
<?php $__env->startSection('content'); ?>
    <form autocomplete="on" class="formLogin" id="formLogin" action="<?php echo e(route("admin.loginAuthentication")); ?>" method="post">
        <section class="d-flex align-items-center min-vh-100">
            <div class="container">
                <div class="row justify-content-center">
                    <div class="col-12">
                        <div class="card-admin-login p-5">
                            <?php echo $__env->make("errors.messageFlash", array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>
                            <div class="text-center">
                                <img src="<?php echo e(asset("pmar/assets/img/logo-angra-branco.svg")); ?>" class="card-img-top" title="<?php echo e(__("Prefeitura Municipal de Angra dos Reis")); ?>" alt="<?php echo e(__("Prefeitura Municipal de Angra dos Reis")); ?>" class="img-fluid text-center" style="width: 100%; height: 5rem;" />
                            </div>
                            <style>
                                .form-label{ color: #FFF !important}
                            </style>
                            <div class="card-body">
                                <h5 class="text-white card-title text-center">Conta Angra</h5>
                                <br>
                                <?php echo csrf_field(); ?>
                                
                                <?php if(!empty($redirect) || request('redirect')): ?>
                                    <input type="hidden" name="redirect" value="<?php echo e(request('redirect', $redirect)); ?>">
                                <?php endif; ?>
                                <div class="mb-3">
                                    <input type="hidden" class="form-control" name="recaptcha" id="recaptcha">

                                    <!-- Matrícula, CPF ou E-mail -->
                                    <?php echo $__env->make('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Matrícula, CPF ou E-mail",
                                        "name" => "login",
                                        "id" => "matriculation",
                                        "required" => true,
                                        "type" => null,
                                        "old" => old('login'),
                                        "oninput" => "",
                                        "readonly" => false,
                                        "small" => null,
                                        "autocomplete" => "username",
                                    ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

                                </div>
                                <div class="mb-3">

                                    <!-- Campo Senha -->
                                    <?php echo $__env->make('components.inputs._inputType',[
                                        "for" => null,
                                        "label" => "Senha",
                                        "name" => "password",
                                        "id" => null,
                                        "required" => true,
                                        "type" => 'password',
                                        "old" => old('password'),
                                        "oninput" => null,
                                        "readonly" => false,
                                        "small" => null,
                                        "autocomplete" => "current-password",
                                    ], array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?>

                                    <small class="text-danger text-bold small-password"></small>
                                    <?php $__errorArgs = ['password'];
$__bag = $errors->getBag($__errorArgs[1] ?? 'default');
if ($__bag->has($__errorArgs[0])) :
if (isset($message)) { $__messageOriginal = $message; }
$message = $__bag->first($__errorArgs[0]); ?>
                                        <small class="text-danger text-bold"><?php echo e($message); ?></small>
                                    <?php unset($message);
if (isset($__messageOriginal)) { $message = $__messageOriginal; }
endif;
unset($__errorArgs, $__bag); ?>
                                    <a href="<?php echo e(route("admin.esqueceuSenha")); ?>" class="text-white">Esqueceu senha?</a>
                                </div>

                                <?php
                                    $recallerName = auth()->getRecallerName();
                                    $hasRecallerCookie = request()->cookie($recallerName) ? true : false;
                                ?>

                                <div class="form-check form-switch mb-3 fs-5 d-flex justify-content-center">
                                    <input class="form-check-input shadow" type="checkbox" id="remember" name="remember"  <?php echo e((old('remember') === 'on' || $hasRecallerCookie) ? 'checked' : ''); ?> >
                                    <label class="form-check-label text-white px-2" for="remember"> <small><?php echo e(__("Lembrar acesso")); ?></small> </label>
                                </div>

                                <div class="my-3">
                                    <button class="fs-5 rounded-4 btn m-auto btn-primary  w-100" type="submit" id="submitLogin"><?php echo e(__('Entrar')); ?></button>
                                </div>
                                <div class="my-3 text-center">
                                    <a class="my-auto fw-bold fs-5 rounded-4 btn m-auto bg-white text-primary w-100" href="<?php echo e(route("admin.login.govbr")); ?>">
                                        <i class="me-1 fa-solid fa-user-shield"></i> <span style="font-size: 14px !important;"><?php echo e(__(' Entrar com')); ?></span> <strong style="font-weight: 900 !important;">
                                            <span class="text-blue">g</span><span class="text-yellow">o</span><span class="text-green">v</span><span class="text-blue">.</span><span class="text-blue">b</span><span class="text-yellow">r</span>
                                        </strong>
                                    </a>
                                </div>
                                <hr/>
                                <div class="my-3 text-center">
                                    <a href="<?php echo e(route("admin.contas.publicas.create")); ?>" class="text-white">Ainda não possui cadastro? <strong class="fw-bolder text-yellow fs-5">Crie sua conta</strong></a>
                                </div>

                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div id='recaptchaLogin' data-size="invisible"></div>
        </section>
    </form>

    <script>
        // Logs para debug do GOV.BR
        console.log('🔍 GOV.BR Debug - Página de login carregada');
        console.log('🔍 URL atual:', window.location.href);
        console.log('🔍 Parâmetros da URL:', new URLSearchParams(window.location.search).toString());

        // Verifica se há mensagens de erro/sucesso
        <?php if(session('error')): ?>
            console.error('❌ GOV.BR Erro:', '<?php echo e(session('error')); ?>');
        <?php endif; ?>

        <?php if(session('success')): ?>
            console.log('✅ GOV.BR Sucesso:', '<?php echo e(session('success')); ?>');
        <?php endif; ?>

        // Monitora cliques no botão GOV.BR
        document.addEventListener('DOMContentLoaded', function() {
            const govBrLink = document.querySelector('a[href*="login.govbr"]');
            if (govBrLink) {
                govBrLink.addEventListener('click', function(e) {
                    console.log('🔍 GOV.BR: Link clicado, redirecionando...');
                    console.log('🔍 GOV.BR: URL destino:', this.href);
                });
            }

            // Verifica se voltou do callback
            const urlParams = new URLSearchParams(window.location.search);
            if (urlParams.has('code') || urlParams.has('error')) {
                console.log('🔍 GOV.BR: Callback detectado');
                console.log('🔍 GOV.BR: Code:', urlParams.get('code'));
                console.log('🔍 GOV.BR: Error:', urlParams.get('error'));
            }
        });
    </script>
<?php $__env->stopSection(); ?>

<?php echo $__env->make('layouts.login.theme', array_diff_key(get_defined_vars(), ['__data' => 1, '__path' => 1]))->render(); ?><?php /**PATH /var/www/html/portal/resources/views/admin/login.blade.php ENDPATH**/ ?>