<?php
    error_reporting(1);
session_start();
    define('BASEPATH', __DIR__);
    define("SCRIPT_VERSION", "SCRIPT_VERSION");
    include_once 'helper.php';
    include_once 'version.php';
    $base_url = base_path();
    $SCRIPT_VERSION = SCRIPT_VERSION;
    $root_url = root_url();
    
    if(checkIsInstall() && ___construct()){
        header("location:../index.php");die;
    }
?>
<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="author" content="">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Installation Process</title>
    
    <link rel="icon" type="image/x-icon" href="<?= $base_url ?>/assets/favicon.ico">

    <!-- Bootstrap 5 Css -->
    <link rel="stylesheet" href="<?= $base_url ?>/assets/bootstrap.min.css">
    <link rel="stylesheet" href="<?= $base_url ?>/assets/bootstrap-icons.css">

</head>

<body class="bg-light">
    <div class="container-fluid">
        <div class="row justify-content-center">
            <div class="col-12 col-lg-10 col-xl-8">
                <div class="bg-white rounded shadow my-4">
                    <div class="text-center py-4">
                        <h2 class="text-secondary fw-bold">
                            <i class="bi bi-gear-fill text-primary me-2"></i>
                            Affiliate Management System Installation
                        </h2>
                    </div>
                    
                    <div id="main" class="p-4">
                        <div class="text-center py-5">
                            <div class="spinner-border text-primary" role="status">
                                <span class="visually-hidden">Loading...</span>
                            </div>
                            <p class="mt-3 text-muted">Initializing installation wizard...</p>
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

    <!-- Scripts -->
    <script src="<?= $base_url ?>/assets/jquery.min.js"></script>
    <script src="<?= $base_url ?>/assets/popper.min.js"></script>
    <script src="<?= $base_url ?>/assets/bootstrap.min.js"></script>
    
    <script type="text/javascript">
        $.ajax({
            url:'proccess.php',
            type:'POST',
            dataType:'json',
            data:{page:'step1'},
            success:function(json){
                $("#main").html(json['html']);
            },
            error: function(xhr, status, error) {
                $("#main").html('<div class="alert alert-danger"><h5>Error Loading Installation</h5><p>Unable to load installation step. Please check your server configuration.</p></div>');
                console.error('Installation loading error:', error);
            }
        })
    </script>
</body>

</html>