<?php
// ============================================
// AJOUAMAI IMMO-BUSINESS — Configuration
// ============================================

session_start();

// --- Database ---
// TODO: Update these credentials with your yelazz.com hosting DB details
define('DB_HOST', 'localhost');
define('DB_NAME', 'yelatgrz_aib');
define('DB_USER', 'yelatgrz_aib');
define('DB_PASS', 'aibDATABASE123');

// --- Site Constants ---
define('SITE_NAME', 'AJOUAMAI IMMO-BUSINESS');
define('SITE_URL', '');
define('ASSETS_URL', SITE_URL . '/assets');
define('IMG_URL', SITE_URL . '/assets/img');
define('UPLOADS_DIR', dirname(__DIR__) . '/assets/uploads/');
define('UPLOADS_URL', SITE_URL . '/assets/uploads/');
define('MAX_LOGIN_ATTEMPTS', 5);
define('LOCKOUT_MINUTES', 15);

// Security Headers
if (!headers_sent()) {
    header("X-Content-Type-Options: nosniff");
    header("X-Frame-Options: SAMEORIGIN");
    header("X-XSS-Protection: 1; mode=block");
    header("Referrer-Policy: strict-origin-when-cross-origin");
}

// Form Submission Rate Limiting
function checkFormRateLimit(string $formType = 'general', int $maxPerInterval = 5, int $intervalSeconds = 3600): bool {
    $ip = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1';
    $key = 'rate_limit_' . $formType . '_' . md5($ip);
    if (!isset($_SESSION[$key])) {
        $_SESSION[$key] = ['count' => 1, 'start_time' => time()];
        return true;
    }
    if (time() - $_SESSION[$key]['start_time'] > $intervalSeconds) {
        $_SESSION[$key] = ['count' => 1, 'start_time' => time()];
        return true;
    }
    if ($_SESSION[$key]['count'] >= $maxPerInterval) {
        return false;
    }
    $_SESSION[$key]['count']++;
    return true;
}

function getDB(): PDO {
    static $pdo = null;
    if ($pdo === null) {
        $credentials = [
            ['host' => DB_HOST, 'user' => DB_USER, 'pass' => DB_PASS],
            ['host' => 'localhost', 'user' => 'root', 'pass' => 'root'],
            ['host' => 'localhost', 'user' => 'root', 'pass' => ''],
            ['host' => '127.0.0.1', 'user' => 'root', 'pass' => 'root'],
            ['host' => '127.0.0.1', 'user' => 'root', 'pass' => '']
        ];
        foreach ($credentials as $cred) {
            try {
                $pdo = new PDO(
                    "mysql:host=" . $cred['host'] . ";dbname=" . DB_NAME . ";charset=utf8mb4",
                    $cred['user'],
                    $cred['pass'],
                    [
                        PDO::ATTR_ERRMODE => PDO::ERRMODE_EXCEPTION,
                        PDO::ATTR_DEFAULT_FETCH_MODE => PDO::FETCH_ASSOC,
                        PDO::ATTR_EMULATE_PREPARES => false,
                    ]
                );
                if ($pdo) break;
            } catch (PDOException $e) {
                // Try next credential set
            }
        }
        if (!$pdo) {
            die("Erreur de connexion à la base de données. Veuillez vérifier vos identifiants dans includes/config.php.");
        }
    }
    return $pdo;
}

// --- Helpers ---
function sanitize(string $str): string {
    return htmlspecialchars(trim($str), ENT_QUOTES, 'UTF-8');
}

function redirect(string $url): void {
    header("Location: $url");
    exit;
}

function isLoggedIn(): bool {
    return isset($_SESSION['admin_id']);
}

function requireLogin(): void {
    if (!isLoggedIn()) {
        redirect(SITE_URL . '/admin/login');
    }
}

function getAdminRole(): ?string {
    if (!isLoggedIn()) return null;
    return $_SESSION['admin_role'] ?? 'agent';
}

function isSuperAdmin(): bool {
    return getAdminRole() === 'super_admin';
}

function setFlash(string $type, string $message): void {
    $_SESSION['flash'] = ['type' => $type, 'message' => $message];
}

function getFlash(): ?array {
    if (isset($_SESSION['flash'])) {
        $flash = $_SESSION['flash'];
        unset($_SESSION['flash']);
        return $flash;
    }
    return null;
}

function generateCSRF(): string {
    if (empty($_SESSION['csrf_token'])) {
        $_SESSION['csrf_token'] = bin2hex(random_bytes(32));
    }
    return $_SESSION['csrf_token'];
}

function verifyCSRF(string $token): bool {
    return isset($_SESSION['csrf_token']) && hash_equals($_SESSION['csrf_token'], $token);
}

function slugify(string $text): string {
    $text = preg_replace('~[^\pL\d]+~u', '-', $text);
    $text = iconv('utf-8', 'us-ascii//TRANSLIT', $text);
    $text = preg_replace('~[^-\w]+~', '', $text);
    $text = trim($text, '-');
    $text = preg_replace('~-+~', '-', $text);
    $text = strtolower($text);
    if (empty($text)) {
        return 'n-a';
    }
    return $text;
}

function formatPrice(?float $price): string {
    if ($price === null || $price == 0) return 'Prix sur demande';
    return number_format($price, 0, ',', ' ') . ' MAD';
}

// --- Property Helpers ---
function getPropertyTypes(): array {
    try {
        $db = getDB();
        $stmt = $db->query("SELECT slug, name FROM property_types ORDER BY ordre ASC");
        $types = [];
        while ($row = $stmt->fetch()) {
            $types[$row['slug']] = $row['name'];
        }
        if (!empty($types)) return $types;
    } catch (Exception $e) {}
    return [
        'villa' => 'Villa',
        'appartement' => 'Appartement',
        'terrain' => 'Terrain',
        'commercial' => 'Local commercial',
        'duplex' => 'Duplex',
        'triplex' => 'Triplex',
    ];
}

function getPropertyStatuses(): array {
    return [
        'vente' => 'À vendre',
        'location' => 'À louer',
    ];
}

function getZones(): array {
    try {
        $db = getDB();
        $stmt = $db->query("SELECT name FROM zones ORDER BY ordre ASC");
        return $stmt->fetchAll(PDO::FETCH_COLUMN);
    } catch (Exception $e) {}
    return ['Dar Bouazza', 'Casablanca', 'Sidi Rahal'];
}

function getCities(): array {
    $zones = getZones();
    try {
        $db = getDB();
        $stmt = $db->query("SELECT DISTINCT city FROM properties ORDER BY city");
        $cities = $stmt->fetchAll(PDO::FETCH_COLUMN);
        return array_unique(array_merge($zones, $cities));
    } catch (Exception $e) {}
    return $zones;
}

function resolveAssetUrl(?string $path, string $default = 'assets/img/property-1.jpg'): string {
    if (empty($path)) {
        $path = $default;
    }
    if (strpos($path, 'http://') === 0 || strpos($path, 'https://') === 0 || strpos($path, '//') === 0) {
        return $path;
    }
    if (strpos($path, 'assets/') === 0 && strpos($path, 'assets/img/') !== 0 && strpos($path, 'assets/uploads/') !== 0) {
        $path = str_replace('assets/', 'assets/img/', $path);
    }
    // Strip any leading /hind/ or hind/ legacy paths
    $path = preg_replace('#^/?hind/#', '', $path);
    $clean = ltrim($path, '/');
    return '/' . $clean;
}

function getPrimaryImage(int $propertyId): string {
    $db = getDB();
    $stmt = $db->prepare("SELECT image_path FROM property_images WHERE property_id = ? ORDER BY is_primary DESC, sort_order ASC LIMIT 1");
    $stmt->execute([$propertyId]);
    $result = $stmt->fetchColumn();
    return resolveAssetUrl($result ?: 'assets/img/property-1.jpg');
}

function getPropertyImages(int $propertyId): array {
    $db = getDB();
    $stmt = $db->prepare("SELECT * FROM property_images WHERE property_id = ? ORDER BY is_primary DESC, sort_order ASC");
    $stmt->execute([$propertyId]);
    $images = $stmt->fetchAll();
    foreach ($images as &$img) {
        $img['url'] = resolveAssetUrl($img['image_path']);
        if (strpos($img['image_path'], 'assets/') === 0 && strpos($img['image_path'], 'assets/img/') !== 0 && strpos($img['image_path'], 'assets/uploads/') !== 0) {
            $img['image_path'] = str_replace('assets/', 'assets/img/', $img['image_path']);
        }
    }
    return $images;
}

// --- CMS Content Helpers ---
function getPageContent(string $pageKey, string $sectionKey, string $contentKey, string $default = ''): string {
    try {
        $db = getDB();
        $stmt = $db->prepare("SELECT content_value FROM page_contents WHERE page_key = ? AND section_key = ? AND content_key = ?");
        $stmt->execute([$pageKey, $sectionKey, $contentKey]);
        $result = $stmt->fetchColumn();
        return $result !== false ? $result : $default;
    } catch (Exception $e) {
        return $default;
    }
}

function setPageContent(string $pageKey, string $sectionKey, string $contentKey, string $value, string $type = 'text'): bool {
    $db = getDB();
    $stmt = $db->prepare("INSERT INTO page_contents (page_key, section_key, content_key, content_value, content_type) VALUES (?,?,?,?,?) ON DUPLICATE KEY UPDATE content_value = VALUES(content_value), content_type = VALUES(content_type)");
    return $stmt->execute([$pageKey, $sectionKey, $contentKey, $value, $type]);
}

// --- Site Settings Helpers ---
function getSetting(string $key, string $default = ''): string {
    try {
        $db = getDB();
        $stmt = $db->prepare("SELECT setting_value FROM site_settings WHERE setting_key = ?");
        $stmt->execute([$key]);
        $result = $stmt->fetchColumn();
        return $result !== false ? $result : $default;
    } catch (Exception $e) {
        return $default;
    }
}

function setSetting(string $key, string $value, string $type = 'text'): bool {
    $db = getDB();
    $stmt = $db->prepare("INSERT INTO site_settings (setting_key, setting_value, setting_type) VALUES (?,?,?) ON DUPLICATE KEY UPDATE setting_value = VALUES(setting_value)");
    return $stmt->execute([$key, $value, $type]);
}

// --- Email Notification ---
function sendNotificationEmail(string $templateKey, array $variables = [], ?string $recipientEmail = null): bool {
    try {
        $db = getDB();
        $stmt = $db->prepare("SELECT subject, body_html FROM email_templates WHERE template_key = ?");
        $stmt->execute([$templateKey]);
        $template = $stmt->fetch();
        if (!$template) return false;

        $subject = $template['subject'];
        $body = $template['body_html'];

        foreach ($variables as $key => $val) {
            $subject = str_replace('{{' . $key . '}}', htmlspecialchars($val), $subject);
            $body = str_replace('{{' . $key . '}}', htmlspecialchars($val), $body);
        }

        $to = $recipientEmail ?? getSetting('notification_email', 'contact@aib-immobilier.ma');
        $cc = getSetting('notification_email_cc');

        $headers = "MIME-Version: 1.0\r\n";
        $headers .= "Content-type: text/html; charset=UTF-8\r\n";
        $headers .= "From: AJOUAMAI IMMO-BUSINESS <noreply@aib-immobilier.ma>\r\n";
        if ($cc) {
            $headers .= "Cc: $cc\r\n";
        }

        return @mail($to, $subject, $body, $headers);
    } catch (Exception $e) {
        return false;
    }
}

// --- WhatsApp Notification ---
function sendWhatsAppNotification(string $phone, string $message): bool {
    $enabled = getSetting('whatsapp_enabled', '0');
    if ($enabled !== '1') return false;

    $apiKey = getSetting('whatsapp_api_key');
    $sender = getSetting('whatsapp_sender_number');

    if (!$apiKey || !$sender) return false;
    return false;
}

// --- File Upload Helper ---
function handleUpload(string $inputName, string $subDir = ''): ?string {
    if (!isset($_FILES[$inputName]) || $_FILES[$inputName]['error'] !== UPLOAD_ERR_OK) {
        return null;
    }

    $file = $_FILES[$inputName];
    $ext = strtolower(pathinfo($file['name'], PATHINFO_EXTENSION));
    $allowed = ['jpg', 'jpeg', 'png', 'gif', 'webp', 'svg'];

    if (!in_array($ext, $allowed)) return null;

    $targetDir = UPLOADS_DIR . ($subDir ? $subDir . '/' : '');
    if (!is_dir($targetDir)) {
        mkdir($targetDir, 0755, true);
    }

    $filename = uniqid('img_') . '.' . $ext;
    $targetPath = $targetDir . $filename;

    if (move_uploaded_file($file['tmp_name'], $targetPath)) {
        return 'assets/uploads/' . ($subDir ? $subDir . '/' : '') . $filename;
    }

    return null;
}

// --- Login Rate Limiting ---
function checkLoginAttempts(string $username): bool {
    $db = getDB();
    $stmt = $db->prepare("SELECT login_attempts, locked_until FROM admins WHERE username = ?");
    $stmt->execute([$username]);
    $admin = $stmt->fetch();
    if (!$admin) return true;

    if ($admin['locked_until'] && strtotime($admin['locked_until']) > time()) {
        return false;
    }

    if ($admin['login_attempts'] >= MAX_LOGIN_ATTEMPTS) {
        $lockUntil = date('Y-m-d H:i:s', time() + (LOCKOUT_MINUTES * 60));
        $stmt = $db->prepare("UPDATE admins SET locked_until = ?, login_attempts = 0 WHERE username = ?");
        $stmt->execute([$lockUntil, $username]);
        return false;
    }

    return true;
}

function incrementLoginAttempts(string $username): void {
    $db = getDB();
    $stmt = $db->prepare("UPDATE admins SET login_attempts = login_attempts + 1 WHERE username = ?");
    $stmt->execute([$username]);
}

function resetLoginAttempts(string $username): void {
    $db = getDB();
    $stmt = $db->prepare("UPDATE admins SET login_attempts = 0, locked_until = NULL WHERE username = ?");
    $stmt->execute([$username]);
}

// --- RDV Helpers ---
function getAvailableSlots(string $creneau): array {
    $defaults = [
        'matin' => ['09:00', '09:30', '10:00', '10:30', '11:00', '11:30'],
        'apres_midi' => ['14:00', '14:30', '15:00', '15:30', '16:00', '16:30', '17:00', '17:30'],
        'soir' => ['18:00', '18:30', '19:00', '19:30']
    ];
    try {
        $db = getDB();
        $stmt = $db->prepare("SELECT heure_debut, heure_fin, intervalle_minutes FROM rdv_settings WHERE creneau = ? AND actif = 1");
        $stmt->execute([$creneau]);
        $setting = $stmt->fetch();
        if (!$setting) return $defaults[$creneau] ?? [];

        $slots = [];
        $start = strtotime($setting['heure_debut']);
        $end = strtotime($setting['heure_fin']);
        $interval = max(15, (int)$setting['intervalle_minutes']) * 60;

        while ($start < $end) {
            $slots[] = date('H:i', $start);
            $start += $interval;
        }
        return !empty($slots) ? $slots : ($defaults[$creneau] ?? []);
    } catch (Exception $e) {
        return $defaults[$creneau] ?? [];
    }
}

function isDateBlocked(string $date): bool {
    try {
        $db = getDB();
        $stmt = $db->prepare("SELECT COUNT(*) FROM rdv_blackouts WHERE ? BETWEEN date_debut AND date_fin");
        $stmt->execute([$date]);
        return $stmt->fetchColumn() > 0;
    } catch (Exception $e) {
        return false;
    }
}

function isSlotTaken(string $date, string $heure): bool {
    try {
        $db = getDB();
        $stmt = $db->prepare("SELECT COUNT(*) FROM rdv_requests WHERE date_rdv = ? AND heure = ? AND status != 'annule'");
        $stmt->execute([$date, $heure]);
        return $stmt->fetchColumn() > 0;
    } catch (Exception $e) {
        return false;
    }
}

// --- Visitor Analytics Tracking ---
function trackVisitor(): void {
    if (php_sapi_name() === 'cli' || (defined('IS_ADMIN_AREA') && IS_ADMIN_AREA)) return;
    $uri = $_SERVER['REQUEST_URI'] ?? '/';
    if (preg_match('/\.(css|js|jpg|jpeg|png|webp|svg|gif|ico|woff|woff2|ttf|eot)$/i', $uri)) return;
    if (strpos($uri, '/admin') !== false) return;
    
    $path = parse_url($uri, PHP_URL_PATH);
    if (empty($path)) $path = '/';
    
    try {
        $db = getDB();
        $db->exec("CREATE TABLE IF NOT EXISTS `visitor_logs` (
            `id` INT AUTO_INCREMENT PRIMARY KEY,
            `ip_address` VARCHAR(45) NOT NULL,
            `page_url` VARCHAR(255) NOT NULL,
            `user_agent` VARCHAR(255) NULL,
            `visited_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
            INDEX(`visited_at`),
            INDEX(`ip_address`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");

        $ip = $_SERVER['REMOTE_ADDR'] ?? '127.0.0.1';
        $ua = substr($_SERVER['HTTP_USER_AGENT'] ?? '', 0, 255);

        $stmt = $db->prepare("SELECT id FROM visitor_logs WHERE ip_address = ? AND page_url = ? AND visited_at >= DATE_SUB(NOW(), INTERVAL 1 MINUTE) LIMIT 1");
        $stmt->execute([$ip, $path]);
        if (!$stmt->fetch()) {
            $insert = $db->prepare("INSERT INTO visitor_logs (ip_address, page_url, user_agent) VALUES (?,?,?)");
            $insert->execute([$ip, $path, $ua]);
        }
    } catch (Exception $e) {
        // Silently skip
    }
}

function getVisitorStats(): array {
    try {
        $db = getDB();
        $db->exec("CREATE TABLE IF NOT EXISTS `visitor_logs` (
            `id` INT AUTO_INCREMENT PRIMARY KEY,
            `ip_address` VARCHAR(45) NOT NULL,
            `page_url` VARCHAR(255) NOT NULL,
            `user_agent` VARCHAR(255) NULL,
            `visited_at` TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
            INDEX(`visited_at`),
            INDEX(`ip_address`)
        ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4");

        $totalViews = (int)$db->query("SELECT COUNT(*) FROM visitor_logs")->fetchColumn();
        $uniqueVisitors = (int)$db->query("SELECT COUNT(DISTINCT ip_address) FROM visitor_logs")->fetchColumn();
        $viewsToday = (int)$db->query("SELECT COUNT(*) FROM visitor_logs WHERE DATE(visited_at) = CURDATE()")->fetchColumn();
        $visitorsToday = (int)$db->query("SELECT COUNT(DISTINCT ip_address) FROM visitor_logs WHERE DATE(visited_at) = CURDATE()")->fetchColumn();
        $viewsMonth = (int)$db->query("SELECT COUNT(*) FROM visitor_logs WHERE MONTH(visited_at) = MONTH(CURRENT_DATE()) AND YEAR(visited_at) = YEAR(CURRENT_DATE())")->fetchColumn();
        $visitorsMonth = (int)$db->query("SELECT COUNT(DISTINCT ip_address) FROM visitor_logs WHERE MONTH(visited_at) = MONTH(CURRENT_DATE()) AND YEAR(visited_at) = YEAR(CURRENT_DATE())")->fetchColumn();

        $topPages = $db->query("SELECT page_url, COUNT(*) as views FROM visitor_logs GROUP BY page_url ORDER BY views DESC LIMIT 5")->fetchAll();
        $recent = $db->query("SELECT page_url, ip_address, visited_at FROM visitor_logs ORDER BY visited_at DESC LIMIT 5")->fetchAll();

        $chartData = [];
        for ($i = 6; $i >= 0; $i--) {
            $date = date('Y-m-d', strtotime("-$i days"));
            $dayLabel = date('d/m', strtotime("-$i days"));
            $stmtV = $db->prepare("SELECT COUNT(*) FROM visitor_logs WHERE DATE(visited_at) = ?");
            $stmtV->execute([$date]);
            $vCount = (int)$stmtV->fetchColumn();

            $stmtU = $db->prepare("SELECT COUNT(DISTINCT ip_address) FROM visitor_logs WHERE DATE(visited_at) = ?");
            $stmtU->execute([$date]);
            $uCount = (int)$stmtU->fetchColumn();

            $chartData[] = [
                'date' => $dayLabel,
                'views' => $vCount,
                'visitors' => $uCount
            ];
        }

        return [
            'total_views' => $totalViews,
            'unique_visitors' => $uniqueVisitors,
            'views_today' => $viewsToday,
            'visitors_today' => $visitorsToday,
            'views_month' => $viewsMonth,
            'visitors_month' => $visitorsMonth,
            'top_pages' => $topPages,
            'recent' => $recent,
            'chart_data' => $chartData
        ];
    } catch (Exception $e) {
        return [
            'total_views' => 0, 'unique_visitors' => 0,
            'views_today' => 0, 'visitors_today' => 0,
            'views_month' => 0, 'visitors_month' => 0,
            'top_pages' => [], 'recent' => [], 'chart_data' => []
        ];
    }
}

// --- Common HTML Head ---
function renderHead(string $title, string $description = '', string $ogImage = ''): string {
    trackVisitor();
    $desc = $description ?: 'AJOUAMAI IMMO-BUSINESS — Agence immobilière de luxe à Dar Bouazza, Casablanca. Conseil, estimation, achat, vente & gestion locative de prestige.';
    $siteName = 'AJOUAMAI IMMO-BUSINESS';
    $fullTitle = htmlspecialchars($title) . ' | ' . $siteName;
    $imgUrl = $ogImage ?: (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on' ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost') . SITE_URL . '/assets/img/home.jpeg';
    
    $jsonLd = json_encode([
        "@context" => "https://schema.org",
        "@type" => "RealEstateAgent",
        "name" => "AJOUAMAI IMMO-BUSINESS",
        "image" => $imgUrl,
        "description" => $desc,
        "address" => [
            "@type" => "PostalAddress",
            "addressLocality" => "Dar Bouazza",
            "addressRegion" => "Casablanca-Settat",
            "addressCountry" => "MA"
        ],
        "url" => (isset($_SERVER['HTTPS']) && $_SERVER['HTTPS']==='on' ? 'https' : 'http') . '://' . ($_SERVER['HTTP_HOST'] ?? 'localhost') . SITE_URL,
        "telephone" => "+212 6 XX XX XX XX",
        "priceRange" => "$$$$"
    ], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);

    return '
    <meta charset="UTF-8"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>
    <title>' . $fullTitle . '</title>
    <meta name="description" content="' . htmlspecialchars($desc) . '"/>
    <meta name="author" content="AJOUAMAI IMMO-BUSINESS — Hind Ajouamai"/>
    <meta name="robots" content="index, follow"/>
    <meta name="theme-color" content="#0a0a0a"/>
    <meta name="format-detection" content="telephone=no"/>
    
    <!-- Favicon & Icons -->
    <link rel="icon" type="image/png" href="' . SITE_URL . '/assets/img/logo.png"/>
    <link rel="shortcut icon" type="image/png" href="' . SITE_URL . '/assets/img/logo.png"/>
    <link rel="apple-touch-icon" href="' . SITE_URL . '/assets/img/logo.png"/>
    
    <!-- Open Graph / Facebook -->
    <meta property="og:type" content="website"/>
    <meta property="og:title" content="' . $fullTitle . '"/>
    <meta property="og:description" content="' . htmlspecialchars($desc) . '"/>
    <meta property="og:image" content="' . htmlspecialchars($imgUrl) . '"/>
    <meta property="og:site_name" content="' . $siteName . '"/>
    
    <!-- Twitter -->
    <meta name="twitter:card" content="summary_large_image"/>
    <meta name="twitter:title" content="' . $fullTitle . '"/>
    <meta name="twitter:description" content="' . htmlspecialchars($desc) . '"/>
    <meta name="twitter:image" content="' . htmlspecialchars($imgUrl) . '"/>
    
    <!-- Google Fonts: Sansation (titles/headers) + McLaren (body text) -->
    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link href="https://fonts.googleapis.com/css2?family=Sansation:ital,wght@0,300;0,400;0,700;1,300;1,400&family=McLaren&display=swap" rel="stylesheet">
    
    <!-- Swiper CSS -->
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/swiper@11/swiper-bundle.min.css"/>
    
    <!-- Tailwind CSS CDN -->
    <script src="https://cdn.tailwindcss.com"></script>
    <script>
      tailwind.config = {
        theme: {
          extend: {
            fontFamily: {
              serif: [\'Sansation\', \'sans-serif\'],
              display: [\'Sansation\', \'sans-serif\'],
              sans: [\'McLaren\', \'cursive\', \'sans-serif\']
            },
            colors: {
              gold: {
                DEFAULT: \'#B8A882\',
                light: \'#D4C7A3\',
                dark: \'#8E7E5A\'
              }
            }
          }
        }
      }
    </script>
    
    <link rel="stylesheet" href="' . SITE_URL . '/assets/css/app.css"/>
    
    <!-- JSON-LD Structured Data -->
    <script type="application/ld+json">
    ' . $jsonLd . '
    </script>
    ';
}

