<?php
require_once 'config/config.php';

session_start();

// حماية الصفحة
if (!isset($_SESSION['user_id'])) {
    header("Location: auth/login.php");
    exit;
}

// اللغة
$lang_code = $_SESSION['language'] ?? 'english';
require_once "languages/$lang_code.php";
?>

<?php include 'header.php'; ?>

<div class="main-content p-4" style="flex:1;">

    <h2 class="mb-4"><?= $lang['insurance_title']; ?></h2>

    <div class="card p-4">

        <h5><?= $lang['choose_car_type']; ?></h5>

        <div class="mt-3">
            <button class="btn btn-primary" onclick="loadForm('fuel')">
                <?= $lang['fuel_hybrid']; ?>
            </button>

            <button class="btn btn-success" onclick="loadForm('electric')">
                <?= $lang['electric']; ?>
            </button>
        </div>

        <div id="formArea" class="mt-4"></div>

    </div>

</div>

<script>
function loadForm(type){
    $.ajax({
        url: 'insurance_form.php',
        method: 'POST',
        data: {type:type},
        success: function(res){
            $("#formArea").html(res);
        }
    });
}
</script>

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