<?php
/**
 * 2026企业CMS - 默认模板案例详情页
 */
$pageDescription = $case['summary'] ?: strip_tags(mb_substr($case['content'],0,200,'UTF-8'));
$pageKeywords = $case['seo_keywords'];
$breadcrumbItems = [
    ['title' => '成功案例', cms_url('cases')],
    ['title' => $case['title']]
];
?>
<?php echo breadcrumb($breadcrumbItems); ?>

<div class="main-content">
    <div class="container" style="display:flex;gap:30px;">
        <div style="flex:1;">
            <div class="article-detail">
                <h1 class="title"><?php echo xss_clean($case['title']); ?></h1>
                <div class="meta">
                    <?php if ($case['client_name']): ?><span>客户：<?php echo xss_clean($case['client_name']); ?></span><?php endif; ?>
                    <?php if ($case['project_time']): ?><span style="margin-left:20px;">项目时间：<?php echo date('Y-m-d', strtotime($case['project_time'])); ?></span><?php endif; ?>
                    <span style="margin-left:20px;">浏览量：<?php echo $case['views']; ?></span>
                </div>
                
                <!-- 案例图片 -->
                <?php if ($case['cover_image']): ?>
                <div style="margin-bottom:30px;">
                    <img src="<?php echo $case['cover_image']; ?>" alt="<?php echo xss_clean($case['title']); ?>" style="width:100%;border-radius:8px;">
                </div>
                <?php endif; ?>
                
                <!-- 案例图集 -->
                <?php if ($case['gallery']): ?>
                <?php $gallery = json_decode($case['gallery'], true); ?>
                <div style="display:grid;grid-template-columns:repeat(3,1fr);gap:15px;margin-bottom:30px;">
                    <?php foreach ($gallery as $img): ?>
                    <div style="border-radius:8px;overflow:hidden;height:150px;">
                        <img src="<?php echo $img; ?>" style="width:100%;height:100%;object-fit:cover;">
                    </div>
                    <?php endforeach; ?>
                </div>
                <?php endif; ?>
                
                <!-- 案例详情 -->
                <div class="content">
                    <?php echo $case['content']; ?>
                </div>
                
                <?php if ($case['project_url']): ?>
                <div style="margin-top:30px;padding:20px;background:#f5f5f5;border-radius:8px;">
                    <a href="<?php echo $case['project_url']; ?>" target="_blank" style="color:#2c82e0;font-size:16px;">访问项目 →</a>
                </div>
                <?php endif; ?>
            </div>
        </div>
        
        <!-- 侧边栏 -->
        <div class="sidebar">
            <div class="widget">
                <h3 class="widget-title">更多案例</h3>
                <ul style="list-style:none;">
                    <?php $moreCases = db_query("SELECT `title`,`slug` FROM `cases` WHERE `status`=1 AND `id`!=? ORDER BY `sort_order` ASC LIMIT 8", [$case['id']]); ?>
                    <?php foreach ($moreCases as $mc): ?>
                    <li style="padding:8px 0;border-bottom:1px solid #eee;">
                        <a href="<?php echo cms_url('case', ['slug' => $mc['slug']]); ?>"><?php echo xss_clean($mc['title']); ?></a>
                    </li>
                    <?php endforeach; ?>
                </ul>
            </div>
        </div>
    </div>
</div>
