<?php include dirname(__DIR__) . '/header.php'; ?>

<article class="py-5">
    <div class="container">
        <div class="row justify-content-center">
            <div class="col-lg-8">
                <nav aria-label="breadcrumb" class="mb-4">
                    <ol class="breadcrumb">
                        <li class="breadcrumb-item"><a href="/">Home</a></li>
                        <li class="breadcrumb-item"><a href="/blog">Blog</a></li>
                        <li class="breadcrumb-item active" aria-current="page"><?php echo htmlspecialchars($post['title']); ?></li>
                    </ol>
                </nav>

                <header class="mb-5 text-center">
                    <h1 class="display-4 fw-bold mb-3"><?php echo htmlspecialchars($post['title']); ?></h1>
                    <div class="text-muted d-flex align-items-center justify-content-center">
                        <span class="me-3"><i class="far fa-calendar-alt me-1"></i> <?php echo date('F d, Y', strtotime($post['created_at'])); ?></span>
                        <span><i class="far fa-user me-1"></i> Admin</span>
                    </div>
                </header>

                <?php if ($post['image_path']): ?>
                    <div class="mb-5 shadow-sm rounded-4 overflow-hidden">
                        <img src="/<?php echo $post['image_path']; ?>" class="img-fluid w-100" alt="<?php echo htmlspecialchars($post['title']); ?>">
                    </div>
                <?php endif; ?>

                <div class="blog-content fs-5 lh-lg text-secondary">
                    <?php echo nl2br($post['content']); ?>
                </div>

                <hr class="my-5">

                <div class="d-flex justify-content-between align-items-center bg-light p-4 rounded-4">
                    <div class="fw-bold">Share this article:</div>
                    <div class="d-flex gap-2">
                        <a href="https://facebook.com/sharer/sharer.php?u=<?php echo urlencode("https://" . $_SERVER['HTTP_HOST'] . "/blog/" . $post['slug']); ?>" target="_blank" class="btn btn-outline-primary btn-sm rounded-circle">
                            <i class="fab fa-facebook-f"></i>
                        </a>
                        <a href="https://twitter.com/intent/tweet?url=<?php echo urlencode("https://" . $_SERVER['HTTP_HOST'] . "/blog/" . $post['slug']); ?>&text=<?php echo urlencode($post['title']); ?>" target="_blank" class="btn btn-outline-info btn-sm rounded-circle">
                            <i class="fab fa-twitter"></i>
                        </a>
                        <a href="https://api.whatsapp.com/send?text=<?php echo urlencode($post['title'] . " - https://" . $_SERVER['HTTP_HOST'] . "/blog/" . $post['slug']); ?>" target="_blank" class="btn btn-outline-success btn-sm rounded-circle">
                            <i class="fab fa-whatsapp"></i>
                        </a>
                    </div>
                </div>
            </div>
        </div>
    </div>
</article>

<style>
.blog-content {
    white-space: pre-wrap;
    word-break: break-word;
}
.blog-content h2, .blog-content h3 {
    color: #333;
    margin-top: 2rem;
    margin-bottom: 1rem;
    font-weight: bold;
}
</style>

<?php include dirname(__DIR__) . '/footer.php'; ?>
