<?php
/**
 * Name: Nxz官网系统
 * URI: https://www.nxzlm.com/
 * Description: 逆行者官网系统源码，简单好用带后台
 * Version: 1.0.0
 * Author: 逆行者联盟
 */
require_once 'includes/common.php';

// 获取轮播图
$stmt_sliders = $pdo->query("SELECT * FROM nxz_sliders WHERE status = 1 ORDER BY sort ASC, id DESC");
$sliders = $stmt_sliders->fetchAll();

// 获取服务列表
$stmt_services = $pdo->query("SELECT * FROM nxz_services WHERE status = 1 ORDER BY sort ASC, id DESC");
$services = $stmt_services->fetchAll();

// 获取项目列表
$stmt_projects = $pdo->query("SELECT * FROM nxz_projects WHERE status = 1 ORDER BY sort ASC, id DESC");
$projects = $stmt_projects->fetchAll();

// 获取团队成员
$stmt_members = $pdo->query("SELECT * FROM nxz_members WHERE status = 1 ORDER BY sort ASC, id DESC");
$members = $stmt_members->fetchAll();

// 获取友情链接
$stmt_links = $pdo->query("SELECT * FROM nxz_links WHERE status = 1 ORDER BY sort ASC, id DESC");
$links = $stmt_links->fetchAll();

// 增加访问量
$pdo->exec("UPDATE nxz_config SET v = v + 1 WHERE k = 'site_visits'");
?>
<!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 htmlspecialchars(get_config('site_title') ?: get_config('site_name')); ?></title>
    <meta name="keywords" content="<?php echo htmlspecialchars(get_config('site_keywords')); ?>">
    <meta name="description" content="<?php echo htmlspecialchars(get_config('site_description')); ?>">
    <?php if(get_config('site_favicon')): ?>
    <link rel="icon" href="<?php echo htmlspecialchars(get_config('site_favicon')); ?>" type="image/x-icon">
    <?php endif; ?>
    <link rel="stylesheet" href="assets/layui/css/layui.css">
    <style>
        /* 基础重置与排版 */
        body { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; color: #333; line-height: 1.6; background-color: #fafafa; }
        a { text-decoration: none; transition: all 0.3s; }
        
        /* 顶部导航 */
        .nxz-header { background-color: rgba(255, 255, 255, 0.95); backdrop-filter: blur(10px); position: fixed; top: 0; left: 0; right: 0; z-index: 1000; box-shadow: 0 1px 10px rgba(0,0,0,0.05); }
        .nxz-header .layui-container { display: flex; justify-content: space-between; align-items: center; height: 70px; }
        .nxz-logo { font-size: 24px; font-weight: bold; color: #16b777; letter-spacing: 1px; }
        .nxz-nav { display: flex; gap: 30px; }
        .nxz-nav a { color: #333; font-size: 16px; font-weight: 500; }
        .nxz-nav a:hover { color: #16b777; }
        
        /* 轮播图区域 */
        .nxz-carousel { margin-top: 70px; }
        .nxz-carousel img { width: 100%; height: 100%; object-fit: cover; }
        .carousel-caption { position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); text-align: center; color: #fff; text-shadow: 0 2px 4px rgba(0,0,0,0.5); width: 80%; }
        .carousel-caption h2 { font-size: 48px; font-weight: 700; margin-bottom: 20px; }
        .carousel-caption p { font-size: 20px; }
        
        /* 模块标题 */
        .section-title { text-align: center; margin-bottom: 60px; }
        .section-title h2 { font-size: 32px; font-weight: 600; color: #333; margin-bottom: 15px; position: relative; display: inline-block; }
        .section-title h2::after { content: ''; position: absolute; bottom: -10px; left: 50%; transform: translateX(-50%); width: 50px; height: 3px; background-color: #16b777; border-radius: 3px; }
        .section-title p { color: #999; font-size: 15px; }

        /* 服务模块 */
        .nxz-services { padding: 80px 0; background-color: #fff; }
        .service-card { text-align: center; padding: 40px 20px; background: #fff; border-radius: 12px; transition: all 0.3s; border: 1px solid #f0f0f0; height: 100%; box-sizing: border-box; }
        .service-card:hover { transform: translateY(-10px); box-shadow: 0 15px 30px rgba(0,0,0,0.08); border-color: transparent; }
        .service-icon { width: 80px; height: 80px; line-height: 80px; background: rgba(22, 183, 119, 0.1); color: #16b777; border-radius: 50%; font-size: 36px; margin: 0 auto 20px; }
        .service-card h3 { font-size: 20px; font-weight: 600; margin-bottom: 15px; }
        .service-card p { color: #666; font-size: 14px; }

        /* 项目模块 */
        .nxz-projects { padding: 80px 0; background-color: #fafafa; }
        .project-card { background: #fff; border-radius: 12px; overflow: hidden; transition: all 0.3s; height: 100%; display: flex; flex-direction: column; }
        .project-card:hover { transform: translateY(-5px); box-shadow: 0 10px 20px rgba(0,0,0,0.06); }
        .project-img { height: 220px; width: 100%; overflow: hidden; }
        .project-img img { width: 100%; height: 100%; object-fit: cover; transition: transform 0.5s; }
        .project-card:hover .project-img img { transform: scale(1.05); }
        .project-info { padding: 25px; flex: 1; display: flex; flex-direction: column; }
        .project-info h3 { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
        .project-info p { color: #777; font-size: 14px; margin-bottom: 20px; flex: 1; }
        
        /* 团队成员模块 */
        .nxz-team { padding: 80px 0; background-color: #fff; }
        .team-card { text-align: center; padding: 30px 20px; background: #fafafa; border-radius: 12px; transition: all 0.3s; }
        .team-card:hover { transform: translateY(-10px); box-shadow: 0 15px 30px rgba(0,0,0,0.08); background: #fff; }
        .team-avatar { width: 120px; height: 120px; border-radius: 50%; margin: 0 auto 20px; overflow: hidden; border: 4px solid #fff; box-shadow: 0 4px 10px rgba(0,0,0,0.1); }
        .team-avatar img { width: 100%; height: 100%; object-fit: cover; }
        .team-card h3 { font-size: 20px; font-weight: 600; margin-bottom: 5px; color: #333; }
        .team-card h4 { font-size: 14px; color: #16b777; margin-bottom: 15px; font-weight: 500; }
        .team-card p { color: #666; font-size: 14px; line-height: 1.8; }

        /* 底部版权 */
        .nxz-footer { background-color: #1a1c23; color: #8a8e99; padding: 80px 0 40px; position: relative; }
        .footer-top { display: flex; flex-direction: column; align-items: center; text-align: center; margin-bottom: 50px; }
        .footer-top h3 { color: #fff; font-size: 28px; font-weight: 500; margin-bottom: 25px; letter-spacing: 1px; }
        .contact-info { display: flex; gap: 30px; justify-content: center; flex-wrap: wrap; }
        .contact-item { display: flex; align-items: center; gap: 10px; font-size: 16px; background: rgba(255,255,255,0.05); padding: 12px 25px; border-radius: 30px; transition: all 0.3s; }
        .contact-item:hover { background: rgba(22, 183, 119, 0.2); color: #fff; transform: translateY(-3px); }
        .contact-item i { font-size: 20px; color: #16b777; }
        .footer-divider { height: 1px; background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent); border: none; margin: 0 0 40px 0; }
        .footer-bottom { text-align: center; line-height: 2; }
        .footer-bottom p { margin-bottom: 8px; font-size: 14px; }
        .footer-bottom b { color: #fff; font-weight: 500; }
        .footer-tips { font-size: 13px; color: #666; margin-top: 15px !important; display: inline-block; padding: 4px 15px; background: rgba(0,0,0,0.2); border-radius: 20px; }
        .footer-links { margin-bottom: 20px; }
        .footer-links span { color: #fff; font-weight: 500; margin-right: 10px; }
        .footer-links a { color: #8a8e99; margin: 0 10px; font-size: 14px; }
        .footer-links a:hover { color: #16b777; }
    </style>
</head>
<body>

<!-- 导航栏 -->
<div class="nxz-header">
    <div class="layui-container">
        <a href="/" class="nxz-logo">
            <?php if(get_config('site_logo')): ?>
            <img src="<?php echo htmlspecialchars(get_config('site_logo')); ?>" alt="<?php echo htmlspecialchars(get_config('site_name')); ?>" style="max-height: 40px;">
            <?php else: ?>
            <?php echo htmlspecialchars(get_config('site_name')); ?>
            <?php endif; ?>
        </a>
        <div class="nxz-nav layui-hide-xs">
            <a href="#home">首页</a>
            <a href="#services">我们的服务</a>
            <a href="#projects">项目展示</a>
            <a href="#team">核心团队</a>
            <a href="#contact">联系我们</a>
        </div>
    </div>
</div>

<!-- 轮播图区域 -->
<div class="nxz-carousel" id="home">
    <div class="layui-carousel" id="mainCarousel">
        <div carousel-item>
            <?php if(empty($sliders)): ?>
            <div>
                <img src="https://via.placeholder.com/1920x600/16b777/ffffff?text=<?php echo urlencode(get_config('site_name')); ?>">
                <div class="carousel-caption">
                    <h2><?php echo htmlspecialchars(get_config('site_title') ?: '全栈开发定制解决方案'); ?></h2>
                    <p><?php echo htmlspecialchars(get_config('site_description') ?: '专注程序开发与全栈解决方案。代码 / 架构 / 运维 / SEO'); ?></p>
                </div>
            </div>
            <?php else: ?>
                <?php foreach($sliders as $slider): ?>
                <div>
                    <a href="<?php echo htmlspecialchars($slider['link']); ?>">
                        <img src="<?php echo htmlspecialchars($slider['image']); ?>" alt="<?php echo htmlspecialchars($slider['title']); ?>">
                        <div class="carousel-caption">
                            <h2><?php echo htmlspecialchars($slider['title']); ?></h2>
                        </div>
                    </a>
                </div>
                <?php endforeach; ?>
            <?php endif; ?>
        </div>
    </div>
</div>

<!-- 服务介绍 -->
<div class="nxz-services" id="services">
    <div class="layui-container">
        <div class="section-title">
            <h2>我们的服务</h2>
            <p>专业的技术团队，为您提供全方位的技术支持</p>
        </div>
        <div class="layui-row layui-col-space30">
            <?php foreach($services as $service): ?>
            <div class="layui-col-md3 layui-col-sm6">
                <div class="service-card">
                    <div class="service-icon">
                        <i class="layui-icon <?php echo htmlspecialchars($service['icon']); ?>"></i>
                    </div>
                    <h3><?php echo htmlspecialchars($service['title']); ?></h3>
                    <p><?php echo htmlspecialchars($service['description']); ?></p>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</div>

<!-- 项目展示 (带演示图) -->
<div class="nxz-projects" id="projects">
    <div class="layui-container">
        <div class="section-title">
            <h2>项目展示</h2>
            <p>精心打磨的每一个产品，都是我们实力的证明</p>
        </div>
        <div class="layui-row layui-col-space30">
            <?php foreach($projects as $project): ?>
            <div class="layui-col-md4 layui-col-sm6">
                <div class="project-card">
                    <div class="project-img">
                        <?php if($project['image']): ?>
                        <img src="<?php echo htmlspecialchars($project['image']); ?>" alt="<?php echo htmlspecialchars($project['title']); ?>">
                        <?php else: ?>
                        <!-- 默认渐变背景作为占位 -->
                        <div style="width:100%;height:100%;background: linear-gradient(120deg, #84fab0 0%, #8fd3f4 100%);display:flex;align-items:center;justify-content:center;color:#fff;font-size:24px;font-weight:bold;">
                            <?php echo htmlspecialchars($project['title']); ?>
                        </div>
                        <?php endif; ?>
                    </div>
                    <div class="project-info">
                        <h3><?php echo htmlspecialchars($project['title']); ?></h3>
                        <p><?php echo htmlspecialchars($project['description']); ?></p>
                        <a href="<?php echo htmlspecialchars($project['link']); ?>" class="layui-btn layui-btn-sm layui-btn-radius layui-btn-normal layui-btn-fluid">查看详情</a>
                    </div>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</div>

<!-- 核心团队 -->
<div class="nxz-team" id="team">
    <div class="layui-container">
        <div class="section-title">
            <h2>核心团队</h2>
            <p>汇聚行业精英，打造卓越品质</p>
        </div>
        <div class="layui-row layui-col-space30">
            <?php foreach($members as $member): ?>
            <div class="layui-col-md4 layui-col-sm6">
                <div class="team-card">
                    <div class="team-avatar">
                        <img src="<?php echo htmlspecialchars($member['avatar']); ?>" alt="<?php echo htmlspecialchars($member['name']); ?>">
                    </div>
                    <h3><?php echo htmlspecialchars($member['name']); ?></h3>
                    <h4><?php echo htmlspecialchars($member['role']); ?></h4>
                    <p><?php echo htmlspecialchars($member['description']); ?></p>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</div>

<!-- 底部联系与版权 -->
<div class="nxz-footer" id="contact">
    <div class="layui-container">
        <div class="footer-top">
            <h3>准备好开始您的项目了吗？</h3>
            <div class="contact-info">
                <a href="https://t.me/<?php echo ltrim(htmlspecialchars(get_config('contact_tg')), '@'); ?>" target="_blank" class="contact-item">
                    <i class="layui-icon layui-icon-release" style="transform: rotate(45deg); display: inline-block;"></i>
                    <span>Telegram: <?php echo htmlspecialchars(get_config('contact_tg')); ?></span>
                </a>
                <a href="mailto:<?php echo htmlspecialchars(get_config('contact_email')); ?>" class="contact-item">
                    <i class="layui-icon layui-icon-email"></i>
                    <span>邮箱: <?php echo htmlspecialchars(get_config('contact_email')); ?></span>
                </a>
            </div>
        </div>
        
        <hr class="footer-divider">
        
        <div class="footer-bottom">
            <?php if(!empty($links)): ?>
            <div class="footer-links">
                <span>友情链接:</span>
                <?php foreach($links as $link): ?>
                <a href="<?php echo htmlspecialchars($link['url']); ?>" target="_blank"><?php echo htmlspecialchars($link['name']); ?></a>
                <?php endforeach; ?>
            </div>
            <?php endif; ?>
            
            <p><?php echo htmlspecialchars(get_config('footer_copyright')); ?></p>
        </div>
    </div>
</div>

<script src="assets/layui/layui.js"></script>
<script>
layui.use(['jquery', 'carousel'], function(){
    var $ = layui.jquery;
    var carousel = layui.carousel;
    
    // 初始化轮播图
    carousel.render({
        elem: '#mainCarousel',
        width: '100%',
        height: '600px',
        arrow: 'hover',
        anim: 'fade',
        interval: 5000
    });

    // 平滑滚动
    $('a[href^="#"]').on('click', function(e) {
        e.preventDefault();
        var target = this.hash;
        var $target = $(target);
        if ($target.length) {
            $('html, body').stop().animate({
                'scrollTop': $target.offset().top - 70
            }, 500, 'swing');
        }
    });
});
</script>
</body>
</html>