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

session_start();

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

// نوع السيارة
$type = $_POST['type'] ?? 'fuel';
?>

<form id="calcForm">

    <input type="hidden" name="type" value="<?= $type ?>">

    <div class="mb-3">
        <label class="form-label"><?= $lang['car_value']; ?></label>
        <input type="number" name="car_value" class="form-control" required>
    </div>

    <button type="submit" class="btn btn-primary">
        <?= $lang['calculate']; ?>
    </button>

</form>

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

<script>
$("#calcForm").submit(function(e){
    e.preventDefault();

    $.ajax({
        url: 'calculate_insurance.php',
        method: 'POST',
        data: $(this).serialize(),
        success: function(res){
            $("#resultArea").html(res);
        }
    });
});
</script>