<?php header('Content-Type: text/html; charset=utf-8'); ?>
<!DOCTYPE html>
<html lang="th">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?= isset($title) ? Security::e($title) . ' | ' : '' ?><?= APP_NAME ?></title>

    <!-- ⚡ Preconnect: ลดเวลา DNS + TCP สำหรับ CDN ทุกตัว -->
    <link rel="preconnect" href="https://cdn.jsdelivr.net" crossorigin>
    <link rel="preconnect" href="https://fonts.googleapis.com" crossorigin>
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>

    <!-- Google Fonts: Kanit (ใช้ link แทน @import ใน CSS — เร็วกว่ามาก) -->
    <link href="https://fonts.googleapis.com/css2?family=Kanit:wght@300;400;500;600&display=swap" rel="stylesheet">

    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">

    <!-- Bootstrap Icons -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">

    <!-- Leaflet CSS -->
    <link rel="stylesheet" href="https://unpkg.com/leaflet@1.9.4/dist/leaflet.css">

    <!-- Custom CSS (critical — load normally) -->
    <link rel="stylesheet" href="<?= APP_URL ?>/public/css/style.css">

    <!-- SweetAlert2 — defer: ไม่บล็อก render -->
    <script src="https://cdn.jsdelivr.net/npm/sweetalert2@11/dist/sweetalert2.all.min.js" defer></script>
</head>
<body class="bg-light d-flex flex-column min-vh-100">
<!-- Global JS Config — available to main.js and all inline scripts -->
<script>
window.SHOP39 = {
    baseUrl:    '<?= rtrim(APP_URL, '/') ?>',
    csrfToken:  '<?= Session::getCsrfToken() ?>',
    isLoggedIn: <?= Auth::check() ? 'true' : 'false' ?>
};
</script>
