.elementor-widget-heading .elementor-heading-title{font-family:var( --e-global-typography-primary-font-family ), Sans-serif;font-weight:var( --e-global-typography-primary-font-weight );color:var( --e-global-color-primary );}.elementor-3076 .elementor-element.elementor-element-225fb40{width:100%;max-width:100%;text-align:center;}.elementor-3076 .elementor-element.elementor-element-225fb40 .elementor-heading-title{font-family:"Roboto Serif", Sans-serif;font-weight:600;color:var( --e-global-color-secondary );}.elementor-3076 .elementor-element.elementor-element-6399d09 > .elementor-container{max-width:547px;}.elementor-3076 .elementor-element.elementor-element-a7b7f89 > .elementor-element-populated{margin:0px 0px 0px 0px;--e-column-margin-right:0px;--e-column-margin-left:0px;}.elementor-3076 .elementor-element.elementor-element-e4b693e{width:var( --container-widget-width, 88.372% );max-width:88.372%;--container-widget-width:88.372%;--container-widget-flex-grow:0;}/* Start custom CSS */<!-- Página: https://puntodeventanegocios.com/socios-forgot/ -->
<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="utf-8" />
  <meta name="viewport" content="width=device-width,initial-scale=1" />
  <title>Recuperar contraseña</title>
  <style>
    body{font-family:Arial,sans-serif;background:#f2f2f2;margin:0}
    .wrap{max-width:520px;margin:2.2rem auto;padding:0 1rem}
    .card{
      padding:2rem;background:linear-gradient(#dfe9f3,#5983a6);
      border:5px solid #001c48;border-radius:16px;box-shadow:0 0 25px rgba(0,0,0,.25);
      text-align:center
    }
    .logo{margin:0 auto 1rem auto;display:block}
    h1{color:#001c48;margin:.25rem 0 1rem;font-size:2rem}
    p.lead{color:#0e254a;margin:.25rem auto 1.25rem;max-width:36ch;line-height:1.35}
    .row{text-align:left;margin:.8rem 0}
    label{display:block;font-weight:600;color:#001c48;margin:.35rem 0}
    input[type="email"]{
      width:100%;height:44px;padding:8px 12px;border:1px solid #c6c6c6;border-radius:8px
    }
    .btn{
      display:inline-block;min-width:52%;height:46px;line-height:46px;
      border:0;border-radius:8px;background:#003366;color:#fff;
      font-weight:700;text-align:center
    }
    .btn:hover{background:#0051a3}
    .btn[disabled]{opacity:.65;cursor:not-allowed}
    .msg{margin-top:.9rem;font-size:.95rem;display:none}
    .msg.ok{color:#1b5e20}.msg.err{color:#b71c1c}
  </style>
</head>
<body>
  <div class="wrap">
    <div class="card">
      <img class="logo" src="https://puntodeventanegocios.com/assets/img/tech4biss-logo.jpg" alt="Tech4Biss" width="260" height="auto" />
      <h1>Recuperar contraseña</h1>
      <p class="lead">
        Escribe el <strong>correo con el que te registraste</strong>. Si existe en el sistema te enviaremos un enlace para restablecer tu contraseña.
      </p>

      <form id="forgotForm" method="post" autocomplete="off">
        <input type="hidden" id="csrfField" name="" value="">
        <div class="row">
          <label for="email">Correo electrónico</label>
          <input id="email" name="email" type="email" required />
        </div>
        <button id="btnSend" class="btn" type="submit">Enviar enlace</button>
        <div id="msg" class="msg" role="alert" aria-live="polite"></div>
      </form>
    </div>
  </div>

  <script>
  (function(){
    // Bases de tu CodeIgniter
    const CI_BASES = [
      'https://puntodeventanegocios.com/publicCI_html/index.php',
      'https://puntodeventanegocios.com/publicCI_html'
    ];
    // Endpoints posibles para CSRF (por si uno da 500)
    const CSRF_PATHS = ['login/csrf','clientes/csrf'];

    const form  = document.getElementById('forgotForm');
    const email = document.getElementById('email');
    const btn   = document.getElementById('btnSend');
    const msg   = document.getElementById('msg');
    const csrf  = document.getElementById('csrfField');

    let baseOk = null, csrfName = '', csrfToken = '';

    async function tryFetch(url){
      const r = await fetch(url, { credentials: 'include' });
      if(!r.ok) throw new Error('HTTP '+r.status);
      return r.json();
    }

    // Obtiene CSRF de forma tolerante a fallos.
    async function ensureCsrf(){
      if (csrfName && csrfToken && baseOk) return;
      let lastErr = '';
      for (const base of CI_BASES){
        for (const path of CSRF_PATHS){
          try{
            const j = await tryFetch(base.replace(/\/+$/,'') + '/' + path);
            csrfName  = j.tokenName || j.name || 'csrf_test_name';
            csrfToken = j.token || j.hash || '';
            baseOk    = base.replace(/\/+$/,'');
            csrf.name = csrfName;
            csrf.value= csrfToken;
            return;
          }catch(e){ lastErr = e.message; }
        }
      }
      // Fallback: seguimos sin bloquear el flujo
      csrfName = 'csrf_test_name'; csrfToken = '';
      csrf.name = csrfName; csrf.value = csrfToken;
      console.warn('CSRF no disponible. Continuando sin él. Último error:', lastErr);
    }

    function showOk(text){
      msg.className='msg ok'; msg.textContent=text; msg.style.display='block';
    }
    function showErr(text){
      msg.className='msg err'; msg.textContent=text; msg.style.display='block';
    }

    form.addEventListener('submit', async (e)=>{
      e.preventDefault();
      msg.style.display='none'; msg.textContent='';
      btn.disabled = true; btn.textContent = 'Enviando…';
      try{
        await ensureCsrf();

        const body = new URLSearchParams();
        body.set('email', (email.value||'').trim());
        if (csrfName) body.set(csrfName, csrfToken);

        const resp = await fetch(baseOk.replace(/\/+$/,'') + '/socios/forgot', {
          method:'POST',
          headers:{
            'Content-Type':'application/x-www-form-urlencoded; charset=UTF-8',
            'X-Requested-With':'XMLHttpRequest',
            'Accept':'application/json'
          },
          body, credentials:'include'
        });

        // Intentamos JSON; si no llega, mostramos mensaje amable igual
        let data = null;
        try { data = await resp.json(); } catch(_){}
        if (data && data.status === false && data.msg){
          showErr(data.msg);
        }else{
          showOk('Si el correo existe, te enviamos un enlace de restablecimiento (revisa también Spam).');
          form.reset();
        }
      }catch(e){
        showErr(e.message || 'No se pudo procesar la solicitud.');
      }finally{
        btn.disabled = false; btn.textContent = 'Enviar enlace';
      }
    });
  })();
  </script>
</body>
</html>/* End custom CSS */