<?php
/**
 * 医疗健康行业模板 - 首页
 */
$pageTitle = '首页 - ' . SITE_NAME;
$pageDescription = '专业医疗服务，守护您的健康';
?>
<?php echo load_template('header.php'); ?>

<!-- 医疗行业特色横幅 -->
<section class="medical-hero" style="background:linear-gradient(135deg, #2ecc71 0%, #27ae60 100%); color:white; padding:80px 0; text-align:center;">
    <div class="container">
        <h1 style="font-size:48px; margin-bottom:20px;">专业医疗，守护健康</h1>
        <p style="font-size:20px; margin-bottom:40px; opacity:0.9;">24小时在线预约，专业医生团队</p>
        <div style="display:flex; gap:20px; justify-content:center;">
            <a href="/appointment.html" style="padding:15px 40px; background:white; color:#2ecc71; border-radius:50px; font-weight:bold; text-decoration:none;">在线预约</a>
            <a href="/doctors.html" style="padding:15px 40px; border:2px solid white; color:white; border-radius:50px; font-weight:bold; text-decoration:none;">医生团队</a>
        </div>
    </div>
</section>

<!-- 科室介绍 -->
<section style="padding:80px 0; background:#f8f9fa;">
    <div class="container">
        <h2 style="text-align:center; font-size:36px; margin-bottom:50px;">专业科室</h2>
        <div style="display:grid; grid-template-columns:repeat(auto-fit, minmax(250px, 1fr)); gap:30px;">
            <div style="background:white; padding:30px; border-radius:12px; text-align:center; box-shadow:0 5px 20px rgba(0,0,0,0.1);">
                <div style="font-size:48px; margin-bottom:20px;">🏥</div>
                <h3>内科</h3>
                <p style="color:#666;">常见病、多发病的诊断和治疗</p>
            </div>
            <div style="background:white; padding:30px; border-radius:12px; text-align:center; box-shadow:0 5px 20px rgba(0,0,0,0.1);">
                <div style="font-size:48px; margin-bottom:20px;">🔪</div>
                <h3>外科</h3>
                <p style="color:#666;">手术治疗、创伤修复</p>
            </div>
            <div style="background:white; padding:30px; border-radius:12px; text-align:center; box-shadow:0 5px 20px rgba(0,0,0,0.1);">
                <div style="font-size:48px; margin-bottom:20px;">👶</div>
                <h3>妇产科</h3>
                <p style="color:#666;">孕产期保健、妇科疾病</p>
            </div>
            <div style="background:white; padding:30px; border-radius:12px; text-align:center; box-shadow:0 5px 20px rgba(0,0,0,0.1);">
                <div style="font-size:48px; margin-bottom:20px;">🦷</div>
                <h3>口腔科</h3>
                <p style="color:#666;">口腔疾病治疗、牙齿美容</p>
            </div>
        </div>
    </div>
</section>

<!-- 医生团队 -->
<section style="padding:80px 0;">
    <div class="container">
        <h2 style="text-align:center; font-size:36px; margin-bottom:50px;">资深医生团队</h2>
        <div style="display:grid; grid-template-columns:repeat(auto-fit, minmax(200px, 1fr)); gap:30px;">
            <?php
            // 获取医生团队（从团队管理中调用）
            $doctors = db_query("SELECT * FROM `team` WHERE `status`=1 LIMIT 4");
            if (empty($doctors)) {
                // 示例数据
                $doctors = [
                    ['name' => '张医生', 'position' => '主任医师', 'avatar' => ''],
                    ['name' => '李医生', 'position' => '副主任医师', 'avatar' => ''],
                    ['name' => '王医生', 'position' => '主治医师', 'avatar' => ''],
                    ['name' => '刘医生', 'position' => '住院医师', 'avatar' => ''],
                ];
            }
            
            foreach ($doctors as $index => $doctor):
            ?>
            <div style="text-align:center;">
                <div style="width:150px; height:150px; border-radius:50%; background:#f0f0f0; margin:0 auto 20px; display:flex; align-items:center; justify-content:center; font-size:48px; color:#ccc;">
                    <?php echo $doctor['avatar'] ? '<img src="' . $doctor['avatar'] . '" style="width:100%; height:100%; border-radius:50%; object-fit:cover;">' : '👨⚕️'; ?>
                </div>
                <h4 style="margin-bottom:5px;"><?php echo htmlspecialchars($doctor['name'] ?? '医生'); ?></h4>
                <p style="color:#666; font-size:14px;"><?php echo htmlspecialchars($doctor['position'] ?? '医师'); ?></p>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</section>

<!-- 预约挂号 -->
<section style="padding:80px 0; background:#f8f9fa;">
    <div class="container">
        <div style="max-width:600px; margin:0 auto; background:white; padding:40px; border-radius:12px; box-shadow:0 5px 30px rgba(0,0,0,0.1);">
            <h2 style="text-align:center; margin-bottom:30px;">在线预约挂号</h2>
            <form method="post" action="/form-submit.php">
                <input type="hidden" name="form_id" value="3"> <!-- 假设预约表单ID为3 -->
                <div style="margin-bottom:20px;">
                    <label style="display:block; margin-bottom:5px; font-weight:500;">就诊科室</label>
                    <select style="width:100%; padding:10px; border:1px solid #ddd; border-radius:4px;">
                        <option>请选择科室</option>
                        <option>内科</option>
                        <option>外科</option>
                        <option>妇产科</option>
                        <option>口腔科</option>
                    </select>
                </div>
                <div style="margin-bottom:20px;">
                    <label style="display:block; margin-bottom:5px; font-weight:500;">预约医生</label>
                    <select style="width:100%; padding:10px; border:1px solid #ddd; border-radius:4px;">
                        <option>请选择医生</option>
                        <option>张医生（主任医师）</option>
                        <option>李医生（副主任医师）</option>
                    </select>
                </div>
                <div style="margin-bottom:20px;">
                    <label style="display:block; margin-bottom:5px; font-weight:500;">预约时间</label>
                    <input type="date" style="width:100%; padding:10px; border:1px solid #ddd; border-radius:4px;">
                </div>
                <div style="margin-bottom:20px;">
                    <label style="display:block; margin-bottom:5px; font-weight:500;">联系电话</label>
                    <input type="tel" style="width:100%; padding:10px; border:1px solid #ddd; border-radius:4px;" placeholder="请输入联系电话">
                </div>
                <button type="submit" style="width:100%; padding:15px; background:#2ecc71; color:white; border:none; border-radius:4px; font-size:16px; cursor:pointer;">提交预约</button>
            </form>
        </div>
    </div>
</section>

<!-- 健康资讯 -->
<section style="padding:80px 0;">
    <div class="container">
        <h2 style="text-align:center; font-size:36px; margin-bottom:50px;">健康资讯</h2>
        <div style="display:grid; grid-template-columns:repeat(auto-fit, minmax(300px, 1fr)); gap:30px;">
            <?php
            // 获取健康资讯文章
            $health_articles = db_query("SELECT * FROM `articles` WHERE `status`=1 AND (`category_id` IN (SELECT `id` FROM `categories` WHERE `name` LIKE '%健康%' OR `name` LIKE '%医疗%') OR `title` LIKE '%健康%' OR `title` LIKE '%医疗%') ORDER BY `published_at` DESC LIMIT 3");
            
            if (empty($health_articles)) {
                // 示例数据
                $health_articles = [
                    ['title' => '夏季养生小贴士', 'summary' => '夏季养生需要注意的事项...', 'created_at' => '2026-06-15'],
                    ['title' => '常见疾病预防措施', 'summary' => '如何预防常见疾病...', 'created_at' => '2026-06-10'],
                    ['title' => '健康饮食指南', 'summary' => '科学饮食，健康生活...', 'created_at' => '2026-06-05'],
                ];
            }
            
            foreach ($health_articles as $article):
            ?>
            <div style="background:white; border-radius:12px; overflow:hidden; box-shadow:0 5px 20px rgba(0,0,0,0.1);">
                <div style="height:200px; background:#f0f0f0; display:flex; align-items:center; justify-content:center; font-size:48px; color:#ccc;">
                    📰
                </div>
                <div style="padding:20px;">
                    <h4 style="margin-bottom:10px; font-size:18px;"><?php echo htmlspecialchars($article['title']); ?></h4>
                    <p style="color:#666; font-size:14px; margin-bottom:15px;"><?php echo htmlspecialchars($article['summary']); ?></p>
                    <div style="display:flex; justify-content:space-between; align-items:center; font-size:13px; color:#999;">
                        <span><?php echo date('Y-m-d', strtotime($article['created_at'] ?? 'now')); ?></span>
                        <a href="#" style="color:#2ecc71; text-decoration:none;">阅读详情 →</a>
                    </div>
                </div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>
</section>

<?php echo load_template('footer.php'); ?>
