<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8" />
  <title>Payment</title>
  <meta name="viewport" content="width=device-width, initial-scale=1.0" />

  <script src="https://cdnjs.cloudflare.com/ajax/libs/qrcodejs/1.0.0/qrcode.min.js"></script>
  <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.5.0/css/all.min.css" />
  <link rel="stylesheet" href="../css/page5.css" />
</head>
<style>
    /* payment page */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Segoe UI", sans-serif;
}

/* Container */
.container {
  max-width: 390px;
  margin: auto;
  padding: 20px;
  opacity: 0;
  animation: fadeIn 0.7s ease forwards;
  animation-delay: 0.2s;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(16px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Back button */
.back {
  font-size: 20px;
  margin-bottom: 30px;
  cursor: pointer;
  opacity: 0;
  animation: slideLeft 0.5s ease forwards;
  animation-delay: 0.35s;
}

@keyframes slideLeft {
  from { opacity: 0; transform: translateX(-12px); }
  to { opacity: 1; transform: translateX(0); }
}

/* Title */
.title {
  font-size: 20px;
  margin-bottom: 20px;
  opacity: 0;
  animation: slideUp 0.5s ease forwards;
  animation-delay: 0.50s;
}

/* Headings */
h2 {
  margin-top: 20px;
  margin-bottom: 15px;
  opacity: 0;
  animation: slideUp 0.5s ease forwards;
  animation-delay: 0.65s;
}

h3 {
  margin-top: 30px;
  margin-bottom: 20px;
  opacity: 0;
  animation: slideUp 0.5s ease forwards;
  animation-delay: 0.80s;
}

/* Methods container */
.methods {
  margin-bottom: 20px;
}

.method {
  width: 100%; 
  display: flex;
  flex-direction: row; 
  justify-content: flex-start; 
  align-items: center;
  gap: 10px;
  padding: 14px;
  border: 1px solid #ddd;
  border-radius: 10px;
  margin-bottom: 10px;
  font-size: 14px;
  opacity: 0;
  animation: slideUp 0.45s ease forwards;
  box-sizing: border-box; 
}


.payment-methods .method:nth-child(1) { animation-delay: 0.95s; }
.payment-methods .method:nth-child(2) { animation-delay: 1.05s; }
.payment-methods .method:nth-child(3) { animation-delay: 1.15s; }
.payment-methods .method:nth-child(4) { animation-delay: 1.25s; }

.method input { accent-color: #1e6dfb; }

/* Scanner Box */
.scanner-box {
  margin: 25px 0;
  padding: 20px;
  border: 2px dashed #1e6dfb;
  border-radius: 12px;
  text-align: center;
  opacity: 0;
  animation: fadeIn 0.6s ease forwards;
  animation-delay: 1.35s;
}

.scanner-icon { font-size: 30px; }

.scanner-box p {
  margin-top: 8px;
  font-size: 14px;
  color: #333;
}

/* QR Box */
.qr-box {
  border: 2px dashed #1e6dfb;
  border-radius: 12px;
  padding: 10px;
  text-align: center;
  margin-bottom: 20px;
  opacity: 0;
  animation: fadeIn 0.6s ease forwards;
  animation-delay: 1.45s;
}

#qrcode {
  display: flex;
  justify-content: center;
  margin-top: 10px;
}

/* UPI Box */
.upi-box {
  display: none;
  margin-top: 10px;
  opacity: 0;
  animation: fadeIn 0.5s ease forwards;
  animation-delay: 0.0s;
}

.upi-box textarea {
  width: 100%;
  height: 45px;
  padding: 10px;
  font-size: 14px;
  border: 1px solid #ccc;
  border-radius: 8px;
  resize: none;
}

/* UPI Display Box */
.upi-display {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border: 1px solid #ccc;
  padding: 10px 12px;
  border-radius: 8px;
  background: #f9f9f9;
}

#adminUpi {
  font-size: 14px;
  font-weight: 600;
}

.copy-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  color: #1e6dfb;
}

.copy-btn:active {
  transform: scale(0.9);
}

.upi-hint {
  font-size: 12px;
  margin-top: 6px;
  color: #555;
}

.copy-msg {
  font-size: 12px;
  color: green;
  margin-top: 6px;
  display: none;
  animation: fadeIn 0.3s ease;
}


/* OR text */
.or {
  text-align: center;
  font-weight: bold;
  opacity: 0;
  animation: slideUp 0.5s ease forwards;
  animation-delay: 1.60s;
}

/* Pay Button */
.pay-btn {
  margin-top: 40px;
  width: 100%;
  padding: 15px;
  background: #1e6dfb;
  color: #fff;
  border: none;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 600;
  opacity: 0;
  animation: slideUp 0.6s ease forwards;
  animation-delay: 1.70s;
}

/* Keyframes */
@keyframes slideUp {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
</style>    
<body>
   <?php
    include('connection.php');
      $sql = "SELECT * FROM `payment`";
      $res = mysqli_query($con,$sql);
      $row = mysqli_fetch_assoc($res);
            
    ?>
  <div class="container">
    <div class="back">
      <i class="fa-solid fa-arrow-left"></i>
    </div>
    <h2>Select Payment Method</h2>

    <div class="payment-methods">

      <label class="method">
        <input type="radio" name="payment" />
        <span>📱 UPI Payment</span>
      </label>

      <div class="upi-box">
        <div class="upi-display">
          <span id="adminUpi"><?php echo $row['upi'];?></span>
          <button class="copy-btn" onclick="copyUpi()">
            <i class="fa-regular fa-copy"></i>
          </button>
        </div>

        <p class="upi-hint">Copy this UPI ID and pay via any UPI app</p>
        <p class="copy-msg" id="copyMsg">UPI ID copied to clipboard</p>
      </div>

      <!-- <label class="method">
          <input type="radio" name="payment" />
          <span>🏦 Net Banking</span>
        </label> -->
      <p class="or">OR</p>
    </div>
    <h3>Scan QR to Pay</h3>

    <div class="qr-box">
      <div id="qrcode"></div>
      <p style="font-size: 13px">Scan with any UPI app</p>
    </div>

   <a href="page6.html"> <button class="pay-btn">Pay Now</button></a>
  </div>
 <script>
//         const paymentData = "upi://pay?pa=demo@upi&pn=Demo%20Store&am=199&cu=INR";

// // Generate QR
// new QRCode(document.getElementById("qrcode"), {
//   text: paymentData,
//   width: 200,
//   height: 200,
// });

// const upiBox = document.querySelector(".upi-box");
// const upiInput = document.querySelector(".upi-box textarea");
// const paymentRadios = document.querySelectorAll('input[name="payment"]');
// const payBtn = document.querySelector(".pay-btn");

// let selectedMethod = "card";

// // Payment toggle
// paymentRadios.forEach((radio) => {
//   radio.addEventListener("change", () => {
//     const label = radio.nextElementSibling.innerText;

//     selectedMethod = label;

//     if (label.includes("UPI")) {
//       upiBox.style.display = "block";
//     } else {
//       upiBox.style.display = "none";
//       upiInput.value = "";
//     }
//   });
// });

// // Pay button validation
// payBtn.addEventListener("click", () => {
//   if (selectedMethod.includes("UPI")) {
//     if (upiInput.value.trim() === "") {
//       alert("Please enter your UPI ID");
//       upiInput.focus();
//       return;
//     }

//     if (!upiInput.value.includes("@")) {
//       alert("Please enter a valid UPI ID");
//       upiInput.focus();
//       return;
//     }
//   }

//   // Success animation
//   payBtn.innerText = "Processing...";
//   payBtn.disabled = true;

//   setTimeout(() => {
//     window.location.href = "page6.html";
//   }, 1200);
// });

// // Back button
// const backBtn = document.querySelector(".back");

// backBtn.addEventListener("click", () => {
//   window.location.href = "page4.html";
// });

//   </script>  
<script>
const paymentData = "upi://pay?pa=demo@upi&pn=Demo%20Store&am=199&cu=INR";

// Generate QR
new QRCode(document.getElementById("qrcode"), {
  text: paymentData,
  width: 200,
  height: 200,
});

const upiBox = document.querySelector(".upi-box");
const upiInput = document.querySelector(".upi-box textarea");
const paymentRadios = document.querySelectorAll('input[name="payment"]');
const payBtn = document.querySelector(".pay-btn");

let selectedMethod = "card";

// Payment toggle
paymentRadios.forEach((radio) => {
  radio.addEventListener("change", () => {
    const label = radio.nextElementSibling.innerText;

    selectedMethod = label;

    if (label.includes("UPI")) {
      upiBox.style.display = "block";
    } else {
      upiBox.style.display = "none";
      upiInput.value = "";
    }
  });
});

// Pay button validation
payBtn.addEventListener("click", () => {
  if (selectedMethod.includes("UPI")) {
    if (upiInput.value.trim() === "") {
      alert("Please enter your UPI ID");
      upiInput.focus();
      return;
    }

    if (!upiInput.value.includes("@")) {
      alert("Please enter a valid UPI ID");
      upiInput.focus();
      return;
    }
  }

  // Success animation
  payBtn.innerText = "Processing...";
  payBtn.disabled = true;

  setTimeout(() => {
    window.location.href = "../html/page6.html";
  }, 1200);
});

// Back button
const backBtn = document.querySelector(".back");

backBtn.addEventListener("click", () => {
  window.location.href = "../html/page4.html";
});

</script>

  <script src="../js/page5.js"></script>
</body>

</html>