<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Bonus Promo Code Reward</title>
  <meta name="csrf-token" content="<?php echo e(csrf_token()); ?>">
  <style>
    body {
      font-family: Arial, sans-serif;
      background: #0f0f17;
      color: #eee;
      margin: 0;
      padding: 0;
    }

    .nav {
      display: flex;
      align-items: center;
      background: #1d1d27;
      padding: 12px;
    }
    .nav i {
      cursor: pointer;
      margin-right: 12px;
    }
    .nav h1 {
      flex: 1;
      font-size: 18px;
      text-align: center;
      margin: 0;
      color: #f5d293;
    }

    .container {
      padding: 20px;
      text-align: center;
    }

    .promo-box {
      background: #16161f;
      border-radius: 12px;
      padding: 20px;
      box-shadow: 0 4px 12px rgba(0,0,0,.4);
      margin-bottom: 20px;
    }
    .promo-box label {
      display: block;
      margin-bottom: 8px;
      font-size: 14px;
      color: #aaa;
    }
    .promo-box input {
      width: 100%;
      padding: 12px;
      border-radius: 8px;
      border: none;
      margin-bottom: 15px;
      font-size: 14px;
      background: #1f1f2b;
      color: #fff;
    }
    .promo-box button {
      width: 100%;
      padding: 12px;
      border: none;
      border-radius: 8px;
      background: linear-gradient(90deg, #d9b872, #f5d293);
      font-weight: 600;
      cursor: pointer;
      font-size: 15px;
      color: #1c1c1c;
    }

    .promotion-text {
      font-size: 13px;
      color: #bbb;
      margin: 20px 0;
    }

    .invite-button {
      background: #f9436b;
      color: #fff;
      padding: 12px;
      border: none;
      border-radius: 10px;
      width: 100%;
      cursor: pointer;
      font-weight: 600;
    }

    /* Popup overlay */
    .overlay {
      display:none;
      position:fixed;
      top:0;left:0;right:0;bottom:0;
      background:rgba(0,0,0,.7);
      z-index:9999;
    }
    .ex {
      display:none;
      position:fixed;
      top:50%;left:50%;
      transform:translate(-50%,-50%);
      z-index:10000;
      background:#16161f;
      padding:20px;
      border-radius:14px;
      width: 90%;
      max-width: 400px;
      text-align: center;
      color:#fff;
    }
    .ex h3 {
      margin:10px 0;
    }
    .takeIt {
      display:block;
      margin-top:15px;
      padding:12px;
      background:linear-gradient(90deg, #d9b872, #f5d293);
      border-radius:10px;
      color:#1c1c1c;
      text-decoration:none;
      font-weight:600;
    }
  </style>
</head>
<body>

  <!-- Header -->
  <div class="nav">
    <i onclick="window.history.back()">←</i>
    <h1>Bonus Promo Code</h1>
    <div style="width:24px"></div>
  </div>

  <!-- Main Container -->
  <div class="container">
    <div class="promo-box">
      <label for="fname">Enter Lucky Code</label>
      <input type="text" id="fname" name="client" placeholder="Bonus Code">
      <button onclick="toClient()">Check Code</button>
    </div>

  

  </div>

  <!-- Success Popup -->
  <?php $bonus = \App\Models\Bonus::where('status', 'active')->first(); ?>
  <div class="overlay" onclick="closePop()"></div>
  <div class="ex">
    <img style="width: 100%;" src="<?php echo e(asset('public/ex.png')); ?>" alt="">
    <h3 class="ccon">🎉 Congratulations!</h3>
    <h3 class="ttik"><?php echo e(price(1) .' - '. price($bonus ? $bonus->amount : 1)); ?></h3>
    <a href="javascript:void(0)" class="takeIt" onclick="getClaiemCode()">Happy to Take It</a>
  </div>

  <input type="hidden" name="csrf-token" value="<?php echo e(csrf_token()); ?>">

  <script src="//ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>
  <script>
    function message(msg) {
      alert(msg); // you can replace with custom toast
    }

    function closePop(){
      document.querySelector('.overlay').style.display = 'none';
      document.querySelector('.ex').style.display = 'none';
    }

    function toClient(){
      let cliem = document.querySelector('input[name="client"]').value;
      if (cliem == ''){
        message('Please enter bonus code');
        return 0;
      }

      $.ajaxSetup({
        headers: {
          'X-CSRF-TOKEN': document.querySelector('meta[name="csrf-token"]').getAttribute('content')
        }
      });

      $.ajax({
        type:'GET',
        url:'<?php echo e(url('submit-bonus-check')); ?>/'+cliem,
        success:function(data){
          if (data.status == true){
            document.querySelector('.overlay').style.display = 'block';
            document.querySelector('.ex').style.display = 'block';
          } else {
            message(data.message);
            document.querySelector('input[name="client"]').value = '';
          }
        }
      });
    }

    function getClaiemCode(){
      let cliem = document.querySelector('input[name="client"]').value;
      document.querySelector('.takeIt').innerHTML = 'Loading...';

      $.ajax({
        type:'GET',
        url:'<?php echo e(url('submit-bonus-amount')); ?>/'+cliem,
        success:function(data){
          message(data.message);
          document.querySelector('.takeIt').innerHTML = 'Happy to Take It';
          closePop();
          document.querySelector('input[name="client"]').value = '';
        }
      });
    }
  </script>
</body>
</html>
<?php /**PATH /home/ddmkeqvc/public_html/resources/views/app/main/exchange.blade.php ENDPATH**/ ?>