<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{{title}} - {{site_name | default(value="My Blog")}}</title>
    <meta name="description" content="{{description | default(value=content | excerpt(length=160))}}">
    {% if author %}
    <meta name="author" content="{{author}}">
    {% endif %}
    {% if tags %}
    <meta name="keywords" content="{{tags | join(sep=', ')}}">
    {% endif %}
    <style>
        body {
            font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
            line-height: 1.6;
            color: #333;
            max-width: 800px;
            margin: 0 auto;
            padding: 20px;
            background-color: #f9f9f9;
        }
        .container {
            background: white;
            padding: 40px;
            border-radius: 8px;
            box-shadow: 0 2px 10px rgba(0,0,0,0.1);
        }
        h1 {
            color: #2c3e50;
            margin-bottom: 10px;
            font-size: 2.5em;
            line-height: 1.2;
        }
        .meta {
            color: #7f8c8d;
            margin-bottom: 30px;
            font-size: 0.9em;
        }
        .meta span {
            margin-right: 20px;
        }
        .content {
            font-size: 1.1em;
            line-height: 1.8;
            margin-bottom: 30px;
        }
        .tags {
            margin-top: 40px;
            padding-top: 20px;
            border-top: 1px solid #eee;
        }
        .tag {
            display: inline-block;
            background: #3498db;
            color: white;
            padding: 5px 12px;
            margin-right: 10px;
            margin-bottom: 10px;
            border-radius: 20px;
            font-size: 0.85em;
            text-decoration: none;
        }
        .tag:hover {
            background: #2980b9;
        }
        .reading-time {
            color: #95a5a6;
            font-style: italic;
        }
        .share-buttons {
            margin-top: 30px;
            padding-top: 20px;
            border-top: 1px solid #eee;
        }
        .share-button {
            display: inline-block;
            padding: 10px 20px;
            margin-right: 10px;
            margin-bottom: 10px;
            background: #34495e;
            color: white;
            text-decoration: none;
            border-radius: 5px;
            font-size: 0.9em;
        }
        .share-button:hover {
            background: #2c3e50;
        }
        .back-link {
            margin-top: 40px;
            text-align: center;
        }
        .back-link a {
            color: #3498db;
            text-decoration: none;
            font-weight: 500;
        }
        .back-link a:hover {
            text-decoration: underline;
        }
    </style>
</head>
<body>
    <div class="container">
        <article>
            <header>
                <h1>{{title}}</h1>
                <div class="meta">
                    {% if author %}
                    <span>By {{author}}</span>
                    {% endif %}
                    {% if published_date %}
                    <span>Published on {{published_date | date_format(format="%B %d, %Y")}}</span>
                    {% endif %}
                    {% if reading_time %}
                    <span class="reading-time">{{reading_time}} min read</span>
                    {% endif %}
                </div>
            </header>

            <div class="content">
                {% if featured_image %}
                <img src="{{featured_image}}" alt="{{title}}" style="width: 100%; height: auto; margin-bottom: 20px; border-radius: 5px;">
                {% endif %}

                {{content | markdown | safe}}
            </div>

            {% if tags %}
            <div class="tags">
                <strong>Tags:</strong>
                {% for tag in tags %}
                <a href="/tag/{{tag | slug}}" class="tag">{{tag}}</a>
                {% endfor %}
            </div>
            {% endif %}

            {% if enable_sharing %}
            <div class="share-buttons">
                <strong>Share this post:</strong><br>
                <a href="https://twitter.com/intent/tweet?text={{title | urlencode}}&url={{page_url | urlencode}}" class="share-button" target="_blank">Twitter</a>
                <a href="https://www.facebook.com/sharer/sharer.php?u={{page_url | urlencode}}" class="share-button" target="_blank">Facebook</a>
                <a href="https://www.linkedin.com/sharing/share-offsite/?url={{page_url | urlencode}}" class="share-button" target="_blank">LinkedIn</a>
                <a href="mailto:?subject={{title | urlencode}}&body={{page_url | urlencode}}" class="share-button">Email</a>
            </div>
            {% endif %}
        </article>

        <div class="back-link">
            <a href="{{back_url | default(value='/')}}">&larr; Back to {{back_text | default(value='Home')}}</a>
        </div>
    </div>

    {% if analytics_id %}
    <script>
        // Add analytics tracking here if needed
        console.log('Analytics ID: {{analytics_id}}');
    </script>
    {% endif %}
</body>
</html>
