<?php
require('connection.inc.php');
require('security.php');

$order_id = $_GET['order_id'] ?? '';

// Validate and fetch order
if ($order_id) {
    $stmt = $conn->prepare("SELECT * FROM orders WHERE order_id = ? AND payment_status = 'Paid'");
    $stmt->bind_param("s", $order_id);
    $stmt->execute();
    $result = $stmt->get_result();

    if ($result->num_rows === 0) {
        // Invalid or unpaid order
        header("Location: index.php");
        exit;
    }

    $order = $result->fetch_assoc();
    $stmt->close();
} else {
    // No order ID passed
    header("Location: index.php");
    exit;
}
?>


<!doctype html>
<html class="no-js" lang="zxx">
<head>
      <meta charset="utf-8">
      <meta http-equiv="x-ua-compatible" content="ie=edge">
      <title>LoveBeri</title>
      <meta name="description" content="">
      <meta name="viewport" content="width=device-width, initial-scale=1">

      <!-- Place favicon.ico in the root directory -->
      <link rel="shortcut icon" type="image/x-icon" href="assets/img/logo/favicon.png">

      <!-- CSS here -->
      <link rel="stylesheet" href="assets/css/bootstrap.min.css">
      <link rel="stylesheet" href="assets/css/animate.css">
      <link rel="stylesheet" href="assets/css/swiper-bundle.css">
      <link rel="stylesheet" href="assets/css/slick.css">
      <link rel="stylesheet" href="assets/css/magnific-popup.css">
      <link rel="stylesheet" href="assets/css/spacing.css">
      <link rel="stylesheet" href="assets/css/meanmenu.css">
      <link rel="stylesheet" href="assets/css/nice-select.css">
      <link rel="stylesheet" href="assets/css/fontawesome.min.css">
      <link rel="stylesheet" href="assets/css/icon-dukamarket.css">
      <link rel="stylesheet" href="assets/css/jquery-ui.css">
      <link rel="stylesheet" href="assets/css/main.css">
   </head>
   <body>


      <!-- Scroll-top -->
      <button class="scroll-top scroll-to-target" data-target="html">
         <i class="icon-chevrons-up"></i>
      </button>
      <!-- Scroll-top-end-->


      <!-- header-area-start -->
     <?php 
     include 'header.php'
     ?>
      <!-- header-area-end -->

      <main>

         <!-- breadcrumb-area-start -->
         <div class="breadcrumb__area pt-5 pb-5">
            <div class="container">
               <div class="row">
                  <div class="col-lg-12">
                     <div class="tp-breadcrumb__content">
                        <div class="tp-breadcrumb__list">
                           <span class="tp-breadcrumb__active"><a href="index.php">Home</a></span>
                           <span class="dvdr">/</span>
                           <span>Wishlist</span>
                        </div>
                     </div>
                  </div>
               </div>
            </div>
         </div>
         <!-- breadcrumb-area-end -->

         <style>
    .confirmation-container {
      background-color: white;
      padding: 40px;
      border-radius: 12px;
      box-shadow: 0 8px 24px rgba(0, 0, 0, 0.1);
      text-align: center;
      max-width: 500px;
      width: 90%;
      margin: 50px auto;
      font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    }

    .confirmation-container h3 {
      color: #2D2A6E;
      margin-bottom: 20px;
    }

    .confirmation-container p {
      font-size: 16px;
      margin-bottom: 20px;
      color: #333;
    }

    .order-id {
      font-weight: bold;
      color: #2D2A6E;
      margin-bottom: 30px;
    }

    .btn-group {
      display: flex;
      gap: 15px;
      justify-content: center;
      flex-wrap: wrap;
    }

    .btn-group a {
      text-decoration: none;
      background-color: #2D2A6E;
      color: white;
      padding: 12px 20px;
      border-radius: 8px;
      transition: background-color 0.3s ease;
      display: inline-block;
    }

    .btn-group a:hover {
      background-color: #2D2A6E;
    }
  </style>

        <main>
    

    <div class="confirmation-container text-center py-5">
        <h3 class="mb-3"> Yay! Your Order is Confirmed</h3>
        <p class="mb-2">Thank you for shopping with Love Beri. We're preparing your order with care.</p>
        <div class="order-id mb-4">Your Order ID is: <strong><?= htmlspecialchars($order['order_id']) ?></strong></div>
        <div class="btn-group d-flex justify-content-center gap-3">
            <a class="btn btn-primary" href="index.php">Continue Shopping</a>
            <a class="btn btn-outline-secondary" href="orderdetail.php?order_id=<?= urlencode($order['order_id']) ?>">View Order Details</a>
        </div>
    </div>
</main>

         <!-- feature-area-end -->

      </main>

      <!-- footer-area-start -->
     <?php 
     include "footer.php"
     ?>
      <!-- footer-area-end -->
      

      <!-- JS here -->
      <script src="assets/js/jquery.js"></script>
      <script src="assets/js/waypoints.js"></script>
      <script src="assets/js/bootstrap.bundle.min.js"></script>
      <script src="assets/js/swiper-bundle.js"></script>
      <script src="assets/js/nice-select.js"></script>
      <script src="assets/js/slick.js"></script>
      <script src="assets/js/magnific-popup.js"></script>
      <script src="assets/js/counterup.js"></script>
      <script src="assets/js/wow.js"></script>
      <script src="assets/js/isotope-pkgd.js"></script>
      <script src="assets/js/imagesloaded-pkgd.js"></script>
      <script src="assets/js/countdown.js"></script>
      <script src="assets/js/ajax-form.js"></script>
      <script src="assets/js/jquery-ui.js"></script>
      <script src="assets/js/meanmenu.js"></script>
      <script src="assets/js/main.js"></script>
   </body>

</html>
