package com.hpay.hpay_mobile_api.utils;
import jakarta.mail.*;
import jakarta.mail.internet.*;

import java.time.LocalDate;
import java.util.*;


public class SendEmail {

    final static String HOST = "mail.hpaytest.cash"; // Sender's email address
    final static String FROM = "hpaytest@hpaytest.cash"; //"no-reply@hpaytest.cash"; ;
    final static String PASSWORD = "kOyWT(6NF#jg@"; //"onanajunior92@"; //;  //
    final static String PORT = "465";

    // Send email method
    public static void sendEmailValidationCode(String to, String code, String userName) throws MessagingException {

        // Setup the SMTP server properties
        Properties properties = System.getProperties();
        properties.put("mail.smtp.host", HOST);
        properties.put("mail.smtp.port", PORT);
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.ssl.enable", "true");



        // Create a session with authentication
        Session session = Session.getInstance(properties, new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(FROM, PASSWORD );  // Use App Password for Gmail if 2FA is enabled
            }
        });

        // Create a new email message
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(FROM));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject("Code de validation de votre Email");

        String htmlContent = "<!DOCTYPE html>" +
                "<html lang='en'>" +
                "<head>" +
                "<meta charset='UTF-8'>" +
                "<meta name='viewport' content='width=device-width, initial-scale=1.0'>" +
                "<title>Code de validation </title>" +
                "<style>" +
                "body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 0; }" +
                ".email-container { width: 100%; max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }" +
                ".email-header { background-color: #f4511e; color: white; padding: 20px; text-align: center; }" +
                ".email-body { padding: 30px; color: #333333; }" +
                ".validation-code { font-size: 24px; font-weight: bold; color: #f4511e; text-align: center; margin-top: 20px; }" +
                ".footer { padding: 20px; background-color: #f1f1f1; text-align: center; font-size: 12px; color: #777777; }" +
                "a { color: #4CAF50; text-decoration: none; }" +
                "</style>" +
                "</head>" +
                "<body>" +
                "<div class='email-container'>" +
                "<div class='email-header'>" +
                "<h1>Validation de votre adresse email</h1>" +
                "</div>" +
                "<div class='email-body'>" +
                "<p>Salut, [User's Name],</p>" +
                "<p>Merci d'avoir soumis votre adresse email comme deuxième facteur d'authentification! Pour valider votre addresse, veuillez utiliser votre code suivant:</p>" +
                "<div class='validation-code'>" +
                "[Validation Code]" +
                "</div>" +
                "<p>Entrez ce code dans l'application ou dans le site web pour valider votre adresse email</p>" +
                "<p>Si vous n'avez pas demandé ce code, veuillez ignorer cet e-mail ou nous contacter pour obtenir de l'aide.</p>" +
                "</div>" +
                "<div class='footer'>" +
                "<p>&copy; 2025 [Your Company Name]. All rights reserved.</p>" +
                "</div>" +
                "</div>" +
                "</body>" +
                "</html>";

        // Replace placeholders with actual values
        htmlContent = htmlContent.replace("[User's Name]", userName);
        htmlContent = htmlContent.replace("[Validation Code]", code);
        htmlContent = htmlContent.replace("[Your Company Name]", "HeySeller Pay");

        // Set the HTML content to the email
        message.setContent(htmlContent, "text/html");


        // Send the email
        Transport.send(message);
        System.out.println("Email sent successfully to " + to);
    }


    // Send email for add card
    public static void sendEmailAddCard(String to, String prenoms, String cardNum, String date, String time) throws MessagingException {

        // Setup the SMTP server properties
        Properties properties = System.getProperties();
        properties.put("mail.smtp.host", HOST);
        properties.put("mail.smtp.port", PORT);
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.ssl.enable", "true");


        // Create a session with authentication
        Session session = Session.getInstance(properties, new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(FROM, PASSWORD );  // Use App Password for Gmail if 2FA is enabled
            }
        });

        // Create a new email message
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(FROM));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject("Nouvelle carte HPay ajoutée à votre compte");

        String htmlContent = "<!DOCTYPE html>" +
                "<html lang='en'>" +
                "<head>" +
                "<meta charset='UTF-8'>" +
                "<meta name='viewport' content='width=device-width, initial-scale=1.0'>" +
                "<title> Nouvelle Carte ajouté </title>" +
                "<style>" +
                "body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 0; }" +
                ".email-container { width: 100%; max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }" +
                ".email-header { background-color: #f4511e; color: white; padding: 20px; text-align: center; }" +
                ".email-body { padding: 30px; color: #333333; }" +
                ".validation-code { font-size: 24px; font-weight: bold; color: #f4511e; text-align: center; margin-top: 20px; }" +
                ".footer { padding: 20px; background-color: #f1f1f1; text-align: center; font-size: 12px; color: #777777; }" +
                "a { color: #4CAF50; text-decoration: none; }" +
                "</style>" +
                "</head>" +
                "<body>" +
                "<div class='email-container'>" +
                "<div class='email-header'>" +
                "<h1>Nouvelle carte ajoutée</h1>" +
                "</div>" +
                "<div class='email-body'>" +
                "<p>Salut [User's Name],</p>" +
                "<p>Une nouvelle carte HPay portant le numéro [numcarte] a été liée avec succès à votre compte le [date] à [heure].</p>" +
                "<p>Si vous n'êtes pas à l'origine de cette opération, veuillez contacter notre support.</p>" +
                "<p>L'équipe HPay</p>" +
                "</div>" +
                "<div class='footer'>" +
                "<p>&copy; 2025 [Your Company Name]. All rights reserved.</p>" +
                "</div>" +
                "</div>" +
                "</body>" +
                "</html>";

        // Replace placeholders with actual values
        htmlContent = htmlContent.replace("[User's Name]", prenoms);
        htmlContent = htmlContent.replace("[numcarte]", cardNum);
        htmlContent = htmlContent.replace("[date]", date);
        htmlContent = htmlContent.replace("[heure]", time);
        htmlContent = htmlContent.replace("[Your Company Name]", "HeySeller Pay");

        // Set the HTML content to the email
        message.setContent(htmlContent, "text/html");


        // Send the email
        Transport.send(message);
        System.out.println("Email sent successfully to " + to);
    }



    // Send email for add card
    public static void sendEmailModifyPinCard(String to, String prenoms, String cardNum, String date, String time) throws MessagingException {

        // Setup the SMTP server properties
        Properties properties = System.getProperties();
        properties.put("mail.smtp.host", HOST);
        properties.put("mail.smtp.port", PORT);
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.ssl.enable", "true");


        // Create a session with authentication
        Session session = Session.getInstance(properties, new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(FROM, PASSWORD );  // Use App Password for Gmail if 2FA is enabled
            }
        });

        // Create a new email message
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(FROM));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject("Nouvelle carte HPay ajoutée à votre compte");

        String htmlContent = "<!DOCTYPE html>" +
                "<html lang='en'>" +
                "<head>" +
                "<meta charset='UTF-8'>" +
                "<meta name='viewport' content='width=device-width, initial-scale=1.0'>" +
                "<title>Changement du code PIN </title>" +
                "<style>" +
                "body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 0; }" +
                ".email-container { width: 100%; max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }" +
                ".email-header { background-color: #f4511e; color: white; padding: 20px; text-align: center; }" +
                ".email-body { padding: 30px; color: #333333; }" +
                ".validation-code { font-size: 24px; font-weight: bold; color: #f4511e; text-align: center; margin-top: 20px; }" +
                ".footer { padding: 20px; background-color: #f1f1f1; text-align: center; font-size: 12px; color: #777777; }" +
                "a { color: #4CAF50; text-decoration: none; }" +
                "</style>" +
                "</head>" +
                "<body>" +
                "<div class='email-container'>" +
                "<div class='email-header'>" +
                "<h1>Changement du code PIN</h1>" +
                "</div>" +
                "<div class='email-body'>" +
                "<p>Salut [User's Name],</p>" +
                "<p>Le code PIN de votre carte HPay [numcarte] a été modifié avec succès le [date] à [heure].</p>" +
                "<p>Si vous n'êtes pas à l'origine de cette action, contactez notre support rapidement.</p>" +
                "<p>L'équipe HPay</p>" +
                "</div>" +
                "<div class='footer'>" +
                "<p>&copy; 2025 [Your Company Name]. All rights reserved.</p>" +
                "</div>" +
                "</div>" +
                "</body>" +
                "</html>";

        // Replace placeholders with actual values
        htmlContent = htmlContent.replace("[User's Name]", prenoms);
        htmlContent = htmlContent.replace("[numcarte]", cardNum);
        htmlContent = htmlContent.replace("[date]", date);
        htmlContent = htmlContent.replace("[heure]", time);
        htmlContent = htmlContent.replace("[Your Company Name]", "HeySeller Pay");

        // Set the HTML content to the email
        message.setContent(htmlContent, "text/html");


        // Send the email
        Transport.send(message);
        System.out.println("Email sent successfully to " + to);
    }



    // Send email for add card
    public static void sendEmailRemoveCard(String to, String prenoms, String cardNum, String date, String time) throws MessagingException {

        // Setup the SMTP server properties
        Properties properties = System.getProperties();
        properties.put("mail.smtp.host", HOST);
        properties.put("mail.smtp.port", PORT);
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.ssl.enable", "true");


        // Create a session with authentication
        Session session = Session.getInstance(properties, new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(FROM, PASSWORD );  // Use App Password for Gmail if 2FA is enabled
            }
        });

        // Create a new email message
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(FROM));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject("Nouvelle carte HPay ajoutée à votre compte");

        String htmlContent = "<!DOCTYPE html>" +
                "<html lang='en'>" +
                "<head>" +
                "<meta charset='UTF-8'>" +
                "<meta name='viewport' content='width=device-width, initial-scale=1.0'>" +
                "<title> Carte HPay retirée de votre compte </title>" +
                "<style>" +
                "body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 0; }" +
                ".email-container { width: 100%; max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }" +
                ".email-header { background-color: #f4511e; color: white; padding: 20px; text-align: center; }" +
                ".email-body { padding: 30px; color: #333333; }" +
                ".validation-code { font-size: 24px; font-weight: bold; color: #f4511e; text-align: center; margin-top: 20px; }" +
                ".footer { padding: 20px; background-color: #f1f1f1; text-align: center; font-size: 12px; color: #777777; }" +
                "a { color: #4CAF50; text-decoration: none; }" +
                "</style>" +
                "</head>" +
                "<body>" +
                "<div class='email-container'>" +
                "<div class='email-header'>" +
                "<h1>Carte HPay retirée de votre compte</h1>" +
                "</div>" +
                "<div class='email-body'>" +
                "<p>Salut [User's Name],</p>" +
                "<p>La carte HPay numéro [numcarte] a été retirée de votre compte le [date] à [heure].</p>" +
                "<p>Si vous n'êtes pas à l'origine de cette action, contactez notre support rapidement.</p>" +
                "<p>L'équipe HPay</p>" +
                "</div>" +
                "<div class='footer'>" +
                "<p>&copy; 2025 [Your Company Name]. All rights reserved.</p>" +
                "</div>" +
                "</div>" +
                "</body>" +
                "</html>";

        // Replace placeholders with actual values
        htmlContent = htmlContent.replace("[User's Name]", prenoms);
        htmlContent = htmlContent.replace("[numcarte]", cardNum);
        htmlContent = htmlContent.replace("[date]", date);
        htmlContent = htmlContent.replace("[heure]", time);
        htmlContent = htmlContent.replace("[Your Company Name]", "HeySeller Pay");

        // Set the HTML content to the email
        message.setContent(htmlContent, "text/html");


        // Send the email
        Transport.send(message);
        System.out.println("Email sent successfully to " + to);
    }



    // Send email method
    public static void sendEmailValidationCode(String prenom, String nom, Long id) throws MessagingException {

        // Setup the SMTP server properties
        Properties properties = System.getProperties();
        properties.put("mail.smtp.host", HOST);
        properties.put("mail.smtp.port", PORT);
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.ssl.enable", "true");


        // Create a session with authentication
        Session session = Session.getInstance(properties, new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(FROM, PASSWORD);  // Use App Password for Gmail if 2FA is enabled
            }
        });

        // Create a new email message
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(FROM));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress("liaison-carte@hpay.cash"));
        message.setSubject("Valider le compte");

        String htmlContent = "<!DOCTYPE html>" +
                "<html lang='en'>" +
                "<head>" +
                "<meta charset='UTF-8'>" +
                "<meta name='viewport' content='width=device-width, initial-scale=1.0'>" +
                "<title>Code de validation </title>" +
                "<style>" +
                "body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 0; }" +
                ".email-container { width: 100%; max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }" +
                ".email-header { background-color: #f4511e; color: white; padding: 20px; text-align: center; }" +
                ".email-body { padding: 30px; color: #333333; }" +
                ".validation-code { font-size: 24px; font-weight: bold; color: #f4511e; text-align: center; margin-top: 20px; }" +
                ".footer { padding: 20px; background-color: #f1f1f1; text-align: center; font-size: 12px; color: #777777; }" +
                "a { color: #4CAF50; text-decoration: none; }" +
                "</style>" +
                "</head>" +
                "<body>" +
                "<div class='email-container'>" +
                "<div class='email-header'>" +
                "<h1>Examen du compte client</h1>" +
                "</div>" +
                "<div class='email-body'>" +
                "<p>Salut admin,</p>" +
                "<p>Le client [prenom] [nom] (idLoginClient: [id]) a completer la procedure KYC. Veuillez examiner son compte</p>" +

                "<div class='footer'>" +
                "<p>&copy; 2025 [Your Company Name]. All rights reserved.</p>" +
                "</div>" +
                "</div>" +
                "</body>" +
                "</html>";

        // Replace placeholders with actual values
        htmlContent = htmlContent.replace("[prenom]", prenom);
        htmlContent = htmlContent.replace("[nom]", nom);
        htmlContent = htmlContent.replace("[id]", String.valueOf(id));
        htmlContent = htmlContent.replace("[Your Company Name]", "HeySeller Pay");

        // Set the HTML content to the email
        message.setContent(htmlContent, "text/html");


        // Send the email
        Transport.send(message);

    }



    // Send email to clientFrom after transfert
    public static void sendEmailTransfertToClientFrom(String to, String nomClientTo, String nomClientFrom, String montant, String devise, LocalDate now, String code, String time) throws MessagingException {

        // Setup the SMTP server properties
        Properties properties = System.getProperties();
        properties.put("mail.smtp.host", HOST);
        properties.put("mail.smtp.port", PORT);
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.ssl.enable", "true");


        // Create a session with authentication
        Session session = Session.getInstance(properties, new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(FROM, PASSWORD);  // Use App Password for Gmail if 2FA is enabled
            }
        });

        // Create a new email message
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(FROM));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject("Transfert effectué");

        String htmlContent = "<!DOCTYPE html>" +
                "<html lang='en'>" +
                "<head>" +
                "<meta charset='UTF-8'>" +
                "<meta name='viewport' content='width=device-width, initial-scale=1.0'>" +
                "<title>Transfert effectué</title>" +
                "<style>" +
                "body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 0; }" +
                ".email-container { width: 100%; max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }" +
                ".email-header { background-color: #f4511e; color: white; padding: 20px; text-align: center; }" +
                ".email-body { padding: 30px; color: #333333; }" +
                ".validation-code { font-size: 24px; font-weight: bold; color: #f4511e; text-align: center; margin-top: 20px; }" +
                ".footer { padding: 20px; background-color: #f1f1f1; text-align: center; font-size: 12px; color: #777777; }" +
                "a { color: #4CAF50; text-decoration: none; }" +
                "</style>" +
                "</head>" +
                "<body>" +
                "<div class='email-container'>" +
                "<div class='email-header'>" +
                "<h1>Transfert effectué</h1>" +
                "</div>" +
                "<div class='email-body'>" +
                "<p>Salut [nomClientFrom] ,</p>" +
                "<p>Vous avez effectuer avec succès un transfert  d'un montant de  [montant] [devise] à [nomClientTo] le [now]  à [time] .</p>" +
                "<p style='display:block;font-weight: bold;'>Code de la transaction: [code]</p>"+
                "<p>Si vous n'êtes pas à l'origine de cette action, contactez notre support rapidement.</p>" +
                "<p>L'équipe HPay</p>" +

                "<div class='footer'>" +
                "<p>&copy; 2025 [Your Company Name]. All rights reserved.</p>" +
                "</div>" +
                "</div>" +
                "</body>" +
                "</html>";

        // Replace placeholders with actual values
        htmlContent = htmlContent.replace("[nomClientTo]", nomClientTo);
        htmlContent = htmlContent.replace("[nomClientFrom]", nomClientFrom);
        htmlContent = htmlContent.replace("[montant]", String.valueOf(montant));
        htmlContent = htmlContent.replace("[devise]", String.valueOf(devise));
        htmlContent = htmlContent.replace("[now]", now.toString());
        htmlContent = htmlContent.replace("[code]", code);
        htmlContent = htmlContent.replace("[time]", time);
        htmlContent = htmlContent.replace("[Your Company Name]", "HeySeller Pay");


        // Set the HTML content to the email
        message.setContent(htmlContent, "text/html");


        // Send the email
        Transport.send(message);

    }






    // Send email to clientTo after transfert
    public static void sendEmailTransfertToClientTo(String from, String nomClientTo, String nomClientFrom,  String montant, String devise, LocalDate now, String code,String time) throws MessagingException {

        // Setup the SMTP server properties
        Properties properties = System.getProperties();
        properties.put("mail.smtp.host", HOST);
        properties.put("mail.smtp.port", PORT);
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.ssl.enable", "true");


        // Create a session with authentication
        Session session = Session.getInstance(properties, new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(FROM, PASSWORD);  // Use App Password for Gmail if 2FA is enabled
            }
        });

        // Create a new email message
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(FROM));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(from));
        message.setSubject("Transfert effectué");

        String htmlContent = "<!DOCTYPE html>" +
                "<html lang='en'>" +
                "<head>" +
                "<meta charset='UTF-8'>" +
                "<meta name='viewport' content='width=device-width, initial-scale=1.0'>" +
                "<title>Transfert reçu</title>" +
                "<style>" +
                "body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 0; }" +
                ".email-container { width: 100%; max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }" +
                ".email-header { background-color: #f4511e; color: white; padding: 20px; text-align: center; }" +
                ".email-body { padding: 30px; color: #333333; }" +
                ".validation-code { font-size: 24px; font-weight: bold; color: #f4511e; text-align: center; margin-top: 20px; }" +
                ".footer { padding: 20px; background-color: #f1f1f1; text-align: center; font-size: 12px; color: #777777; }" +
                "a { color: #4CAF50; text-decoration: none; }" +
                "</style>" +
                "</head>" +
                "<body>" +
                "<div class='email-container'>" +
                "<div class='email-header'>" +
                "<h1>Transfert reçu</h1>" +
                "</div>" +
                "<div class='email-body'>" +
                "<p>Salut [nomClientTo] ,</p>" +
                "<p>Vous avez reçu  un transfert  d'un montant de  [montant] [devise] envoyé par  [nomClientFrom] le [now] à [time].</p>" +
                "<p style='display:block;font-weight: bold;'>Code de la transaction: [code]</p>"+
                "<p>L'équipe HPay</p>" +

                "<div class='footer'>" +
                "<p>&copy; 2025 [Your Company Name]. All rights reserved.</p>" +
                "</div>" +
                "</div>" +
                "</body>" +
                "</html>";

        // Replace placeholders with actual values
        htmlContent = htmlContent.replace("[nomClientTo]", nomClientTo);
        htmlContent = htmlContent.replace("[nomClientFrom]", nomClientFrom);
        htmlContent = htmlContent.replace("[montant]", String.valueOf(montant));
        htmlContent = htmlContent.replace("[devise]", String.valueOf(devise));
        htmlContent = htmlContent.replace("[now]", now.toString());
        htmlContent = htmlContent.replace("[code]", code);
        htmlContent = htmlContent.replace("[time]", time);
        htmlContent = htmlContent.replace("[Your Company Name]", "HeySeller Pay");


        // Set the HTML content to the email
        message.setContent(htmlContent, "text/html");

        // Send the email
        Transport.send(message);
    }


    // Send email method
    public static void sendAccountCreatedConfirmEmail(String to, String nomClient, String login) throws MessagingException {

        // Setup the SMTP server properties
        Properties properties = System.getProperties();
        properties.put("mail.smtp.host", HOST);
        properties.put("mail.smtp.port", PORT);
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.ssl.enable", "true");



        // Create a session with authentication
        Session session = Session.getInstance(properties, new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(FROM, PASSWORD );  // Use App Password for Gmail if 2FA is enabled
            }
        });

        // Create a new email message
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(FROM));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
        message.setSubject("Création de compte effectué");

        String htmlContent = "<!DOCTYPE html>" +
                "<html lang='en'>" +
                "<head>" +
                "<meta charset='UTF-8'>" +
                "<meta name='viewport' content='width=device-width, initial-scale=1.0'>" +
                "<title>Création de compte effectué</title>" +
                "<style>" +
                "body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 0; }" +
                ".email-container { width: 100%; max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }" +
                ".email-header { background-color: #f4511e; color: white; padding: 20px; text-align: center; }" +
                ".email-body { padding: 30px; color: #333333; }" +
                ".validation-code { font-size: 24px; font-weight: bold; color: #f4511e; text-align: center; margin-top: 20px; }" +
                ".footer { padding: 20px; background-color: #f1f1f1; text-align: center; font-size: 12px; color: #777777; }" +
                "a { color: #4CAF50; text-decoration: none; }" +
                ".account-info{  margin-top: 0; font-weight:'bold'}"+
                "</style>" +
                "</head>" +
                "<body>" +
                "<div class='email-container'>" +
                "<div class='email-header'>" +
                "<h1>Création de compte effectué</h1>" +
                "</div>" +
                "<div class='email-body'>" +
                "<p>Salut [nomClient] ,</p>" +
                "<p>Bienvenue chez HPay !</p>" +
                "<p>Nous vous confirmons la création de votre compte. " +
                "Vous pouvez désormais accéder à votre espace personnel via notre application ou notre site web " +
                " et profiter de tous nos services de paiement en ligne de manière simple, rapide et sécurisée.</p>" +

                "<div>"+
                "<span style='display:block;font-weight: bold;'>Login : [login]</span>" +
                "<span style='display:block;font-weight: bold;'>Mot de passe : votre mot de passe</span>" +
                "</div>"+



                "<p>N'oubliez pas de completer votre inscription en soumettant vous informations KYC(Know Your Costumer) " +
                "dans votre espace client afin de pouvoir profiter de toute les fonctionnalités de notre plateformes </p>" +

                "<p>Si vous n'êtes pas à l'origine de cette inscription, merci de nous le signaler immédiatement à : support@hpay.com "+

                "<div class='footer'>" +
                "<p>&copy; 2025 [Your Company Name]. All rights reserved.</p>" +
                "</div>" +
                "</div>" +
                "</body>" +
                "</html>";

            // Replace placeholders with actual values
            htmlContent = htmlContent.replace("[nomClient]", nomClient);
            htmlContent = htmlContent.replace("[login]", login);
            htmlContent = htmlContent.replace("[Your Company Name]", "HeySeller Pay");


        // Set the HTML content to the email
        message.setContent(htmlContent, "text/html");

        // Send the email
        Transport.send(message);
    }


    // Send email method
    public static void sendNewKycNotification(String nomClient, String idClient, String loginClient) throws MessagingException {

        // Setup the SMTP server properties
        Properties properties = System.getProperties();
        properties.put("mail.smtp.host", HOST);
        properties.put("mail.smtp.port", PORT);
        properties.put("mail.smtp.auth", "true");
        properties.put("mail.smtp.ssl.enable", "true");



        // Create a session with authentication
        Session session = Session.getInstance(properties, new Authenticator() {
            protected PasswordAuthentication getPasswordAuthentication() {
                return new PasswordAuthentication(FROM, PASSWORD );  // Use App Password for Gmail if 2FA is enabled
            }
        });

        // Create a new email message
        MimeMessage message = new MimeMessage(session);
        message.setFrom(new InternetAddress(FROM));
        message.addRecipient(Message.RecipientType.TO, new InternetAddress("kycvalidate@hpay.cash"));
        //message.addRecipient(Message.RecipientType.TO, new InternetAddress("onanajunior92@gmail.com"));
        message.setSubject("Nouvelle soumission KYC");

        String htmlContent = "<!DOCTYPE html>" +
                "<html lang='en'>" +
                "<head>" +
                "<meta charset='UTF-8'>" +
                "<meta name='viewport' content='width=device-width, initial-scale=1.0'>" +
                "<title>Nouvelle soumission KYC</title>" +
                "<style>" +
                "body { font-family: Arial, sans-serif; background-color: #f4f4f9; margin: 0; padding: 0; }" +
                ".email-container { width: 100%; max-width: 600px; margin: 0 auto; background-color: #ffffff; border-radius: 8px; overflow: hidden; box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1); }" +
                ".email-header { background-color: #f4511e; color: white; padding: 20px; text-align: center; }" +
                ".email-body { padding: 30px; color: #333333; }" +
                ".validation-code { font-size: 24px; font-weight: bold; color: #f4511e; text-align: center; margin-top: 20px; }" +
                ".footer { padding: 20px; background-color: #f1f1f1; text-align: center; font-size: 12px; color: #777777; }" +
                "a { color: #4CAF50; text-decoration: none; }" +
                ".account-info{  margin-top: 0; font-weight:'bold'}"+
                "</style>" +
                "</head>" +
                "<body>" +
                "<div class='email-container'>" +
                "<div class='email-header'>" +
                "<h1>Nouvelle soumission KYC</h1>" +
                "</div>" +
                "<div class='email-body'>" +
                "<p>Salut,</p>" +
                "<p>Un client vient de soumettre ses informations Kyc. </p>" +

                "<div>"+
                "<span style='display:block;font-weight: bold;'>Nom du client : [nomClient]</span>" +
                "<span style='display:block;font-weight: bold;'>Id  du client : [idClient]</span>" +
                "<span style='display:block;font-weight: bold;'>Login du client : [login]</span>" +
                "</div>"+

                "<p>Merci de procéder à la validation des ses informations. </p>" +

                "<div class='footer'>" +
                "<p>&copy; 2025 [Your Company Name]. All rights reserved.</p>" +
                "</div>" +
                "</div>" +
                "</body>" +
                "</html>";

        // Replace placeholders with actual values
        htmlContent = htmlContent.replace("[nomClient]", nomClient);
        htmlContent = htmlContent.replace("[login]", loginClient);
        htmlContent = htmlContent.replace("[idClient]", idClient);
        htmlContent = htmlContent.replace("[Your Company Name]", "HeySeller Pay");


        // Set the HTML content to the email
        message.setContent(htmlContent, "text/html");

        // Send the email
        Transport.send(message);
    }



}