<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title><?php echo seo_title($pageTitle ?? ''); ?></title>
    <meta name="description" content="<?php echo seo_description($pageDescription ?? ''); ?>">
    <meta name="keywords" content="<?php echo seo_keywords($pageKeywords ?? ''); ?>">
    <meta name="author" content="<?php echo SITE_NAME; ?>">
    <link rel="canonical" href="<?php echo 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>">

    <!-- Open Graph -->
    <meta property="og:title" content="<?php echo seo_title($pageTitle ?? ''); ?>">
    <meta property="og:description" content="<?php echo seo_description($pageDescription ?? ''); ?>">
    <meta property="og:type" content="website">
    <meta property="og:url" content="<?php echo 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>">

    <!-- Favicon -->
    <link rel="icon" href="<?php echo get_setting('site_favicon', '/favicon.ico'); ?>" type="image/x-icon">

    <!-- Fonts -->
    <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=Bricolage+Grotesque:opsz,wght@12..96,400;12..96,600;12..96,700;12..96,800&family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap" rel="stylesheet">

    <!-- CSS -->
    <link rel="stylesheet" href="/templates/<?php echo htmlspecialchars($theme, ENT_QUOTES, "UTF-8"); ?>/style.css?v=<?php echo time(); ?>">

    <!-- Robots -->
    <link rel="canonical" href="<?php echo 'https://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI']; ?>">
    <meta name="robots" content="index, follow">

    <!-- Schema.org SoftwareApplication -->
    <script type="application/ld+json">
    {
      "@context": "https://schema.org",
      "@type": "SoftwareApplication",
      "name": "云创CMS",
      "applicationCategory": "WebApplication",
      "operatingSystem": "Linux, Windows",
      "description": "免费开源的企业CMS内容管理系统，支持域名自助授权，纯PHP开发",
      "offers": { "@type": "Offer", "price": "0", "priceCurrency": "CNY" },
      "author": { "@type": "Organization", "name": "长沙吧聚网络科技有限公司" }
    }
    </script>

    <?php echo get_setting('stat_code', ''); ?>
</head>
<body>
    <!-- 顶部信息栏 -->
    <div class="top-bar">
        <div class="container">
            <div class="top-left">
                <span><?php echo SITE_NAME; ?> / <?php echo SITE_SLOGAN; ?></span>
            </div>
            <div class="top-right">
                <span><?php echo get_setting('contact_phone', '13874944449'); ?></span>
                <span><?php echo get_setting('contact_email', '284795@qq.com'); ?></span>
            </div>
        </div>
    </div>

    <!-- 导航栏 -->
    <header class="header">
        <div class="container">
            <div class="logo">
                <a href="/">
                    <span class="logo-mark">C</span>
                    <h1><?php echo SITE_NAME; ?></h1>
                </a>
                <p class="slogan"><?php echo SITE_SLOGAN; ?></p>
            </div>
            <nav class="nav" id="mainNav">
                <ul class="main-menu">
                    <li class="<?php echo ($_GET['p'] ?? 'home') == 'home' ? 'active' : ''; ?>"><a href="/">首页</a></li>
                    <li class="<?php echo ($_GET['p'] ?? '') == 'barjucms' ? 'active' : ''; ?>"><a href="<?php echo cms_url('barjucms'); ?>">系统介绍</a></li>
                    <li class="<?php echo ($_GET['p'] ?? '') == 'templates' ? 'active' : ''; ?>"><a href="<?php echo cms_url('templates'); ?>">模板中心</a></li>
                    <li class="<?php echo ($_GET['p'] ?? '') == 'download' ? 'active' : ''; ?>"><a href="<?php echo cms_url('download'); ?>">下载中心</a></li>
                    <li class="<?php echo ($_GET['p'] ?? '') == 'apply' ? 'active' : ''; ?>"><a href="<?php echo cms_url('apply'); ?>">申请授权</a></li>
                    <li class="menu-item-has-children <?php echo in_array($_GET['p'] ?? '', ['news', 'article', 'category']) ? 'active' : ''; ?>">
                        <a href="<?php echo cms_url('news'); ?>">资源</a>
                        <ul class="sub-menu">
                            <?php echo display_category_menu(0, $_GET['slug'] ?? ''); ?>
                        </ul>
                    </li>
                    <li class="<?php echo ($_GET['p'] ?? '') == 'cases' ? 'active' : ''; ?>"><a href="<?php echo cms_url('cases'); ?>">成功案例</a></li>
                    <li class="<?php echo ($_GET['p'] ?? '') == 'about' ? 'active' : ''; ?>"><a href="<?php echo cms_url('about'); ?>">关于我们</a></li>
                </ul>
            </nav>
            <div class="menu-toggle" onclick="document.getElementById('mainNav').classList.toggle('show')">
                <span></span><span></span><span></span>
            </div>
        </div>
    </header>

    <!-- 搜索框 -->
    <div class="search-bar">
        <div class="container">
            <form action="<?php echo cms_url('search'); ?>" method="get">
                <input type="text" name="q" placeholder="搜索文章、产品、案例..." value="<?php echo xss_clean($_GET['q'] ?? ''); ?>">
                <button type="submit">搜索</button>
            </form>
        </div>
    </div>

    <!-- 主内容区开始 -->
