<?php
/**
 * 关于我们页面 — 展示后台配置的团队信息
 */
$pageTitle = '关于我们';
$pageCss = '/css/about.css';
require_once '../includes/header.php';

// 获取团队信息
$db = getDB();
$teamInfo = [];
$stmt = $db->query("SELECT key_name, value FROM settings WHERE group_name = 'team'");
foreach ($stmt->fetchAll() as $row) {
    $teamInfo[$row['key_name']] = $row['value'];
}

// 获取站点信息（logo）
$siteInfo = [];
$stmt = $db->query("SELECT key_name, value FROM settings WHERE group_name = 'site' AND key_name IN ('site_logo', 'site_title', 'site_footer')");
foreach ($stmt->fetchAll() as $row) {
    $siteInfo[$row['key_name']] = $row['value'];
}
?>

<div class="about-container">
    <!-- 团队头部 -->
    <div class="about-header">
        <?php if ($siteInfo['site_logo']): ?>
        <div class="about-logo">
            <img src="<?php echo htmlspecialchars($siteInfo['site_logo']); ?>" alt="Logo">
        </div>
        <?php else: ?>
        <div class="about-logo-placeholder">
            <i class="fas fa-shield-alt"></i>
        </div>
        <?php endif; ?>
        <div class="about-title"><?php echo htmlspecialchars($teamInfo['team_title'] ?? $siteInfo['site_title'] ?? '一课'); ?></div>
        <div class="about-subtitle">校园生活服务平台</div>
    </div>

    <!-- 团队简介 -->
    <div class="about-card">
        <div class="about-card-title"><i class="fas fa-info-circle"></i> 团队简介</div>
        <div class="about-card-content">
            我们致力于为在校大学生提供便捷的校园服务，包括课表查询、成绩查看、空教室查询等功能，让校园生活更加智能化。
        </div>
    </div>

    <!-- 联系方式 -->
    <div class="about-card">
        <div class="about-card-title"><i class="fas fa-phone-alt"></i> 联系方式</div>
        <div class="about-contact-list">
            <?php
            $contactLines = explode('\n', $teamInfo['team_contact'] ?? '');
            if (empty($contactLines) || $contactLines[0] === '') {
                $contactLines = ['微信：example_team', '邮箱：team@example.com'];
            }
            foreach ($contactLines as $line):
                $line = trim($line);
                if (empty($line)) continue;
                // 判断类型
                $icon = 'fa-comment';
                if (stripos($line, '微信') !== false) $icon = 'fa-comment-dots';
                elseif (stripos($line, '邮箱') !== false || stripos($line, '@') !== false) $icon = 'fa-envelope';
                elseif (stripos($line, 'QQ') !== false) $icon = 'fa-qq';
                elseif (stripos($line, '电话') !== false || stripos($line, 'tel') !== false) $icon = 'fa-phone-alt';
            ?>
            <div class="about-contact-item">
                <div class="contact-icon"><i class="fas <?php echo $icon; ?>"></i></div>
                <div class="contact-text"><?php echo htmlspecialchars($line); ?></div>
            </div>
            <?php endforeach; ?>
        </div>
    </div>

    <!-- 版本信息 -->
    <div class="about-card">
        <div class="about-card-title"><i class="fas fa-code-branch"></i> 版本信息</div>
        <div class="about-version">
            <div class="version-item">
                <span class="version-label">版本</span>
                <span class="version-value">v1.0.0</span>
            </div>
            <div class="version-item">
                <span class="version-label">更新日期</span>
                <span class="version-value"><?php echo date('Y-m-d'); ?></span>
            </div>
        </div>
    </div>

    <!-- 版权信息 -->
    <div class="about-footer">
        <?php echo htmlspecialchars($siteInfo['site_footer'] ?? '易网SaaS'); ?>
    </div>
</div>

<div class="bottom-nav">
    <div class="nav-item" onclick="location.href='../index.php'">
        <div class="nav-icon"><i class="fas fa-home"></i></div>
        <div class="nav-name">大厅</div>
    </div>
    <div class="nav-item" onclick="location.href='schedule.php'">
        <div class="nav-icon"><i class="fas fa-calendar-alt"></i></div>
        <div class="nav-name">课表</div>
    </div>
    <div class="nav-item" onclick="location.href='profile.php'">
        <div class="nav-icon"><i class="fas fa-user"></i></div>
        <div class="nav-name">我的</div>
    </div>
</div>

<?php require_once '../includes/footer.php'; ?>
