<?php
    if(isset($_COOKIE["ordered"])) {
        header("Location: thank2.html");
        die();
    }
    if(isset($_POST['Phone']))
    {
        $sheetUrl = 'https://script.google.com/macros/s/AKfycbyDVaFrRxTzmbC5CfxdHItcu50uggktNF1w9m1OatLjgaqe7DY0uAOHYeUefqWx0-3s/exec';
        $encodedData = http_build_query($_POST);
        $options = [
            CURLOPT_URL => $sheetUrl,
            CURLOPT_POST => true,
            CURLOPT_POSTFIELDS => $encodedData,
            CURLOPT_RETURNTRANSFER => true,
        ];
        $curl = curl_init();
        curl_setopt_array($curl, $options);
        $response = curl_exec($curl);
        curl_close($curl);
        if ($response !== false) {
            setcookie("ordered", "yep", time() + (86400));
            echo 'Success';die();
        } else {
            echo 'Error';die();
        }
    }

?>

<!DOCTYPE html>
<html lang="fr">
<head>
<meta charset="utf-8">
<title>Montre Élégante + Bracelet Offert – 19 900 FCFA | Livraison gratuite & Paiement à la livraison</title>
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="Montre dorée avec cadran bleu saphir + bracelet en cadeau. Livraison gratuite à Abidjan et paiement à la livraison. Offre limitée.">
<link rel="icon" href="img/favicon.png" type="image/png">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link href="https://fonts.googleapis.com/css2?family=Montserrat:wght@700;800&family=Poppins:wght@400;500;600;700;800&display=swap" rel="stylesheet">
<link rel="stylesheet" href="css/bootstrap.min.css">
<link rel="stylesheet" href="css/style.css"><!-- existing -->
<link rel="stylesheet" href="css/pro.css"><!-- new minimal layer -->

<meta property="og:title" content="Montre Élégante + Bracelet Offert – 19 900 FCFA">
<meta property="og:description" content="Livraison gratuite & Paiement à la livraison à Abidjan.">
<meta property="og:image" content="img/1.webp">
<meta property="og:type" content="product">
<script>
  /* Product identifier used by main.js during order append */
  var product_id = "montre bra cote divoire";
</script>
<style>
/* Small tweak to ensure the sticky bar doesn't overlap the form submit area */
@media (max-width: 576px){
  .mb-8-for-sticky{ margin-bottom: 80px; }
}
</style>

<script type="application/ld+json">
{
  "@context": "https://schema.org/",
  "@type": "Product",
  "name": "Montre Élégante + Bracelet Offert",
  "image": ["img/1.webp","img/w1.webp","img/w2.webp","img/w3.webp","img/bracelet.webp"],
  "description": "Montre dorée avec cadran bleu saphir, bracelet en cadeau. Livraison gratuite & Paiement à la livraison à Abidjan.",
  "brand": {"@type":"Brand","name":"Votre Boutique"},
  "offers": {
    "@type": "Offer",
    "priceCurrency": "XOF",
    "price": "19900",
    "availability": "https://schema.org/InStock",
    "url": ""
  }
}
</script>

</head>
<body>

<!-- Top info bar -->
<div class="top-bar-pro text-center">
  Livraison gratuite &nbsp;•&nbsp; Paiement à la livraison &nbsp;•&nbsp; Support WhatsApp
</div>

<!-- Header -->
<header class="header-pro py-2">
  <div class="container">
    <div class="d-flex align-items-center justify-content-between">
      <div class="badges-pro d-none d-md-block">
        <span class="badge">Satisfait ou remboursé</span>
        <span class="badge">Retour 7 jours</span>
      </div>
      <a href="#" class="mx-auto"><img src="img/logo.png" alt="Logo" class="brand"></a>
      <div class="d-none d-md-block" style="min-width:140px;text-align:right;">
        <small class="text-muted">Abidjan, Côte d’Ivoire</small>
      </div>
    </div>
  </div>
</header>

<!-- Main -->
<main class="py-4">
  <div class="container">
    <div class="row g-4">
      <!-- Gallery -->
      <div class="col-lg-6">
        <div class="gallery-main p-2">
          <img id="big-img" src="img/1.webp" class="img-fluid w-100 rounded-3" alt="Montre Élégante">
        </div>
        <div class="mt-3 d-flex gap-2 flex-wrap" id="small-img-roll">
          <img class="show-small-img thumb active" src="img/1.webp" alt="now" width="90" height="90">
          <img class="show-small-img thumb" src="img/w1.webp" alt="1" width="90" height="90">
          <img class="show-small-img thumb" src="img/w2.webp" alt="2" width="90" height="90">
          <img class="show-small-img thumb" src="img/w3.webp" alt="3" width="90" height="90">
          <img class="show-small-img thumb" src="img/bracelet.webp" alt="bracelet" width="90" height="90">
        </div>
        <section class="section mt-4">
          <h5 class="mb-3">Pourquoi vous allez l’adorer</h5>
          <ul class="feature-list list-unstyled">
            <li><svg width="18" height="18" viewBox="0 0 24 24"><path d="M9 12l2 2 4-4" stroke="currentColor" fill="none" stroke-width="2"/></svg>Design raffiné cadran bleu saphir</li>
            <li><svg width="18" height="18" viewBox="0 0 24 24"><path d="M9 12l2 2 4-4" stroke="currentColor" fill="none" stroke-width="2"/></svg>Bracelet doré offert avec chaque commande</li>
            <li><svg width="18" height="18" viewBox="0 0 24 24"><path d="M9 12l2 2 4-4" stroke="currentColor" fill="none" stroke-width="2"/></svg>Livraison gratuite à Abidjan</li>
            <li><svg width="18" height="18" viewBox="0 0 24 24"><path d="M9 12l2 2 4-4" stroke="currentColor" fill="none" stroke-width="2"/></svg>Paiement à la livraison (Cash)</li>
          </ul>
        </section>
      </div>

      <!-- Details + Checkout -->
      <div class="col-lg-6">
        <h1 class="h3 fw-bold">Montre Élégante + Bracelet Offert</h1>
        <div class="mb-2">
          <span class="text-warning">★★★★★</span> <small class="text-muted">(124 avis)</small>
        </div>

        <div class="price-box mb-3">
          <div class="d-flex align-items-baseline gap-2">
            <div class="old h5 mb-0">39 900 FCFA</div>
            <div class="new">19 900 FCFA</div>
            <div class="save ms-auto">–50%</div>
          </div>
          <small class="text-muted">Livraison gratuite & Paiement à la livraison</small>
        </div>

        <!-- Offer variants -->
        <div class="mb-3">
          <div class="row g-2">
            <div class="col-12">
              <label class="variant-card w-100" id="card_1">
                <input old-price="39900" new-price="19900" type="radio" name="offer" id="1_unit" value="1" class="form-input" checked>
                <div class="d-flex align-items-center justify-content-between">
                  <div>
                    <h6>1 Montre + 1 Bracelet</h6>
                    <small>Idéal pour offrir 🎁</small>
                  </div>
                  <div class="text-end">
                    <div class="fw-bold">19 900 FCFA</div>
                    <small class="text-muted"><s>39 900 FCFA</s></small>
                  </div>
                </div>
              </label>
            </div>
            <div class="col-12">
              <label class="variant-card w-100" id="card_2">
                <input old-price="49900" new-price="29900" type="radio" name="offer" id="2_unit" value="2" class="form-input">
                <div class="d-flex align-items-center justify-content-between">
                  <div>
                    <h6>2 Montres + 2 Bracelets</h6>
                    <small>Couple Pack – économisez +</small>
                  </div>
                  <div class="text-end">
                    <div class="fw-bold">29 900 FCFA</div>
                    <small class="text-muted"><s>49 900 FCFA</s></small>
                  </div>
                </div>
              </label>
            </div>
            <div class="col-12">
              <label class="variant-card w-100" id="card_3">
                <input old-price="59900" new-price="39900" type="radio" name="offer" id="3_unit" value="3" class="form-input">
                <div class="d-flex align-items-center justify-content-between">
                  <div>
                    <h6>3 Montres + 3 Bracelets</h6>
                    <small>Famille & Cadeaux</small>
                  </div>
                  <div class="text-end">
                    <div class="fw-bold">39 900 FCFA</div>
                    <small class="text-muted"><s>59 900 FCFA</s></small>
                  </div>
                </div>
              </label>
            </div>
          </div>
        </div>

        <!-- Checkout form -->
        <section class="section form-elegant dv_checkout mb-8-for-sticky">
          <h5 class="mb-3">Complétez votre commande</h5>
          <form id="frm_post" method="POST" onsubmit="setOrder(event)" novalidate>
            <div class="mb-3">
              <label for="name">Nom complet</label>
              <input name="Name" id="name" class="form-control" placeholder="Ex: Koffi Yao" required>
            </div>
            <div class="mb-3">
              <label for="phone">Téléphone</label>
              <input name="Phone" id="phone" type="tel" class="form-control" placeholder="Ex: 07 12 34 56 78" required>
            </div>
            <div class="mb-3">
              <label for="address">Adresse / Ville</label>
              <input name="Address" id="address" class="form-control" placeholder="Ex: Cocody, Abidjan" required>
            </div>
            <input type="hidden" id="selected-color" name="Color" value="Noire,">
            <button id="btn-buy" class="btn btn-success btn-buy w-100">Commander maintenant</button>
            <p class="text-center text-muted mt-2" style="font-size:12px;">En cliquant, vous confirmez votre commande. Aucun paiement en ligne – vous payez à la livraison.</p>
          </form>
          <div class="d-flex justify-content-center gap-3 mt-3">
            <div><small>🔒 Paiement à la livraison</small></div>
            <div><small>🚚 Livraison gratuite</small></div>
            <div><small>💬 Support WhatsApp</small></div>
          </div>
        </section>

        <!-- FAQ -->
        <section class="section">
          <h6 class="fw-bold mb-2">FAQ</h6>
          <div class="accordion" id="faq">
            <div class="accordion-item">
              <h2 class="accordion-header" id="q1"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#a1">Comment payer&nbsp;?</button></h2>
              <div id="a1" class="accordion-collapse collapse" data-bs-parent="#faq"><div class="accordion-body">Vous payez en espèces à la livraison. Pas de paiement en ligne.</div></div>
            </div>
            <div class="accordion-item">
              <h2 class="accordion-header" id="q2"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#a2">Délais de livraison</button></h2>
              <div id="a2" class="accordion-collapse collapse" data-bs-parent="#faq"><div class="accordion-body">Livraison rapide à Abidjan. Nous vous appelons pour confirmer l’adresse.</div></div>
            </div>
            <div class="accordion-item">
              <h2 class="accordion-header" id="q3"><button class="accordion-button collapsed" type="button" data-bs-toggle="collapse" data-bs-target="#a3">Retours</button></h2>
              <div id="a3" class="accordion-collapse collapse" data-bs-parent="#faq"><div class="accordion-body">Retours acceptés sous 7 jours pour produit non utilisé et emballage intact.</div></div>
            </div>
          </div>
        </section>
      </div>
    </div>
  </div>
</main>

<!-- Sticky mobile bar -->
<div id="div-sticky" class="sticky-pro py-2 d-md-none" style="display:none;">
  <div class="container d-flex align-items-center justify-content-between">
    <div>
      <div class="small text-muted">Total</div>
      <div class="new" id="sticky-price">19 900 FCFA</div>
    </div>
    <a href="#frm_post" onclick="scrollToForm()" class="btn btn-success btn-buy">Commander</a>
  </div>
</div>

<footer class="py-4 mt-4">
  <div class="container d-flex flex-wrap justify-content-between align-items-center">
    <div class="links">
      <a href="#">Politique de confidentialité</a>
      <a href="#">Conditions d’utilisation</a>
      <a href="#">Contact</a>
    </div>
    <small class="text-muted">© 2025 – Votre Boutique</small>
  </div>
</footer>

<script src="js/jquery.min.js"></script>
<script src="js/main.js"></script>
<script>
  // Activate active style on variant cards
  function updateVariantCards(){
    document.querySelectorAll('.variant-card').forEach(function(card){
      const input = card.querySelector('input[name=offer]');
      if(input.checked){ card.classList.add('active'); } else { card.classList.remove('active'); }
    });
  }
  document.querySelectorAll('input[name=offer]').forEach(function(radio){
    radio.addEventListener('change', function(){
      updateVariantCards();
      // Update sticky price
      var price = this.getAttribute('new-price');
      document.getElementById('sticky-price').innerText = new Intl.NumberFormat('fr-FR').format(price) + " FCFA";
    });
  });
  updateVariantCards();

  // Simple gallery: click thumb -> swap big image + active style (keeps existing classes for main.js compatibility)
  document.querySelectorAll('.show-small-img').forEach(function(img){
    img.addEventListener('click', function(){
      document.getElementById('big-img').src = this.getAttribute('src');
      document.querySelectorAll('.show-small-img').forEach(t=>t.classList.remove('active'));
      this.classList.add('active');
    });
  });
</script>
</body>
</html>
