<!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">
    
    <!-- 优化后的 CSS -->
    <link rel="stylesheet" href="/templates/<?php echo htmlspecialchars($theme, ENT_QUOTES, 'UTF-8'); ?>/style.css?v=<?php echo time(); ?>">
    
    <!-- Robots -->
    <meta name="robots" content="index, follow">
    
    <?php echo get_setting('stat_code', ''); ?>
</head>
<body>
    <!-- 顶部信息栏（优化：语义化 + 无障碍）-->
    <div class="top-bar" role="banner">
        <div class="container">
            <div class="top-left">
                <span>欢迎来到<?php echo htmlspecialchars(SITE_NAME, ENT_QUOTES, 'UTF-8'); ?>！</span>
            </div>
            <div class="top-right">
                <span>电话：<?php echo htmlspecialchars(get_setting('contact_phone', '13874944449'), ENT_QUOTES, 'UTF-8'); ?></span>
                <span>邮箱：<?php echo htmlspecialchars(get_setting('contact_email', '284795@qq.com'), ENT_QUOTES, 'UTF-8'); ?></span>
            </div>
        </div>
    </div>
    
    <!-- 导航栏（优化：毛玻璃效果 + 无障碍）-->
    <header class="header" role="navigation" aria-label="主导航">
        <div class="container">
            <div class="logo">
                <a href="/" aria-label="<?php echo htmlspecialchars(SITE_NAME, ENT_QUOTES, 'UTF-8'); ?> 首页">
                    <?php $logo = get_setting('site_logo', ''); ?>
                    <?php if ($logo): ?>
                        <img src="<?php echo htmlspecialchars($logo, ENT_QUOTES, 'UTF-8'); ?>" alt="<?php echo htmlspecialchars(SITE_NAME, ENT_QUOTES, 'UTF-8'); ?> Logo">
                    <?php else: ?>
                        <h1><?php echo htmlspecialchars(SITE_NAME, ENT_QUOTES, 'UTF-8'); ?></h1>
                    <?php endif; ?>
                    <p class="slogan"><?php echo htmlspecialchars(SITE_SLOGAN, ENT_QUOTES, 'UTF-8'); ?></p>
                </a>
            </div>
            
            <nav class="nav">
                <ul class="main-menu" role="menubar">
                    <li role="none" class="<?php echo ($_GET['p'] ?? 'home') == 'home' ? 'active' : ''; ?>">
                        <a href="/" role="menuitem">首页</a>
                    </li>
                    <li role="none" class="<?php echo ($_GET['p'] ?? '') == 'about' ? 'active' : ''; ?>">
                        <a href="<?php echo cms_url('about'); ?>" role="menuitem">关于我们</a>
                    </li>
                    <li role="none" class="<?php echo in_array($_GET['p'] ?? '', ['services']) ? 'active' : ''; ?>">
                        <a href="<?php echo cms_url('services'); ?>" role="menuitem">服务内容</a>
                    </li>
                    <li role="none" class="<?php echo in_array($_GET['p'] ?? '', ['products']) ? 'active' : ''; ?>">
                        <a href="<?php echo cms_url('products'); ?>" role="menuitem">产品中心</a>
                    </li>
                    <li role="none" class="menu-item-has-children <?php echo in_array($_GET['p'] ?? '', ['news']) ? 'active' : ''; ?>">
                        <a href="<?php echo cms_url('news'); ?>" role="menuitem" aria-haspopup="true" aria-expanded="false">新闻资讯</a>
                        <!-- 文章分类下拉菜单（优化：无障碍）-->
                        <ul class="sub-menu" role="menu" aria-label="新闻分类">
                            <?php
                            $categories = db_query("SELECT id, name, slug FROM categories WHERE type = 'news' AND status = 1 ORDER BY sort_order LIMIT 10");
                            foreach ($categories as $cat):
                            ?>
                            <li role="menuitem">
                                <a href="/category/<?php echo htmlspecialchars($cat['slug'], ENT_QUOTES, 'UTF-8'); ?>.html">
                                    <?php echo htmlspecialchars($cat['name'], ENT_QUOTES, 'UTF-8'); ?>
                                </a>
                            </li>
                            <?php endforeach; ?>
                        </ul>
                    </li>
                    <li role="none" class="<?php echo in_array($_GET['p'] ?? '', ['cases']) ? 'active' : ''; ?>">
                        <a href="<?php echo cms_url('cases'); ?>" role="menuitem">成功案例</a>
                    </li>
                    <li role="none" class="<?php echo in_array($_GET['p'] ?? '', ['contact']) ? 'active' : ''; ?>">
                        <a href="<?php echo cms_url('contact'); ?>" role="menuitem">联系我们</a>
                    </li>
                </ul>
            </nav>
            
            <!-- 移动端菜单按钮（优化：无障碍）-->
            <button class="menu-toggle" aria-label="打开菜单" aria-expanded="false" aria-controls="main-menu" onclick="
                document.querySelector('.nav .main-menu').classList.toggle('show');
                this.setAttribute('aria-expanded', document.querySelector('.nav .main-menu').classList.contains('show'));
            ">
                <span></span><span></span><span></span>
                <span class="sr-only">菜单</span>
            </button>
        </div>
    </header>
    
    <!-- 主内容区开始 -->
    <?php if ($_GET['p'] ?? 'home' == 'home'): ?>
    <!-- 首页 Hero 区（新增：优化后的视觉焦点）-->
    <section class="hero" aria-label="网站主视觉">
        <div class="container">
            <h1>引领未来科技<br>助力企业数字化转型</h1>
            <p>新一代智能建站系统，基于 PHP + MySQL 开发，提供企业官网、产品展示、新闻资讯、在线留言等全套功能。</p>
            <div class="cta-group">
                <a href="<?php echo cms_url('products'); ?>" class="btn btn-white btn-lg">查看产品</a>
                <a href="<?php echo cms_url('contact'); ?>" class="btn btn-secondary btn-lg">联系我们</a>
            </div>
        </div>
    </section>
    <?php endif; ?>
    
    <!-- 页脚在 footer.php 中 -->
