<?php
/**
 * Order Success Page
 * Digital Product Store
 */

require_once __DIR__ . '/config/database.php';

$page_title = 'Order Successful';

if (!isset($_SESSION['order_success'])) {
    header('Location: ' . BASE_URL . '/');
    exit;
}

$order_number = $_SESSION['order_success'];
unset($_SESSION['order_success']);

include __DIR__ . '/includes/header.php';
?>

<div class="container py-5">
    <div class="row justify-content-center">
        <div class="col-lg-8 text-center">
            <div class="card p-5">
                <div class="mb-4">
                    <div class="bg-success rounded-circle d-inline-flex align-items-center justify-content-center" style="width: 100px; height: 100px;">
                        <i class="fas fa-check fa-3x text-white"></i>
                    </div>
                </div>
                
                <h1 class="mb-3">Thank You!</h1>
                <p class="lead text-muted mb-4">Your order has been placed successfully.</p>
                
                <div class="bg-light rounded-3 p-4 mb-4">
                    <p class="mb-1">Order Number:</p>
                    <h3 class="text-primary mb-0"><?php echo htmlspecialchars($order_number); ?></h3>
                </div>
                
                <p class="text-muted mb-4">
                    A confirmation email has been sent to your email address.<br>
                    You can download your products from your account dashboard.
                </p>
                
                <div class="d-flex gap-3 justify-content-center flex-wrap">
                    <?php if (is_user_logged_in()): ?>
                    <a href="<?php echo BASE_URL; ?>/account/orders.php" class="btn btn-primary btn-lg">
                        <i class="fas fa-list me-2"></i>View My Orders
                    </a>
                    <a href="<?php echo BASE_URL; ?>/account/downloads.php" class="btn btn-success btn-lg">
                        <i class="fas fa-download me-2"></i>My Downloads
                    </a>
                    <?php else: ?>
                    <a href="<?php echo BASE_URL; ?>/register.php" class="btn btn-primary btn-lg">
                        <i class="fas fa-user-plus me-2"></i>Create Account
                    </a>
                    <?php endif; ?>
                    <a href="<?php echo BASE_URL; ?>/products.php" class="btn btn-outline-primary btn-lg">
                        <i class="fas fa-shopping-bag me-2"></i>Continue Shopping
                    </a>
                </div>
            </div>
        </div>
    </div>
</div>

<?php include __DIR__ . '/includes/footer.php'; ?>
