<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="Code of Conquest - An AI-powered Dungeons & Dragons adventure game">
    <title>{% block title %}Code of Conquest{% endblock %}</title>

    <!-- Google Fonts -->
    <link href="https://fonts.googleapis.com/css2?family=Cinzel:wght@400;600;700&family=Lato:wght@300;400;700&display=swap" rel="stylesheet">

    <!-- Main CSS -->
    <link rel="stylesheet" href="{{ url_for('static', filename='css/main.css') }}">

    <!-- HTMX for dynamic interactions -->
    <script src="https://unpkg.com/htmx.org@1.9.10"></script>
    <!-- HTMX JSON encoding extension -->
    <script src="https://unpkg.com/htmx.org@1.9.10/dist/ext/json-enc.js"></script>

    {% block extra_head %}{% endblock %}
</head>
<body>
    <!-- Header -->
    <header class="header">
        <div class="header-content">
            <a href="/" class="logo">⚔️ Code of Conquest</a>

            {% if current_user %}
            <nav class="header-nav">
                <span class="user-greeting">Welcome, {{ current_user.name or current_user.email }}!</span>
                <form method="POST" action="{{ url_for('auth_views.logout') }}" class="logout-form">
                    <button type="submit" class="btn-link">Logout</button>
                </form>
            </nav>
            {% endif %}
        </div>
    </header>

    <!-- Main Content -->
    <main>
        <!-- Flash Messages -->
        {% with messages = get_flashed_messages(with_categories=true) %}
            {% if messages %}
                <div class="flash-messages-container">
                    {% for category, message in messages %}
                        <div class="flash-message flash-{{ category }}">
                            {{ message }}
                            <button class="flash-close" onclick="this.parentElement.remove()">&times;</button>
                        </div>
                    {% endfor %}
                </div>
            {% endif %}
        {% endwith %}

        <!-- Page Content -->
        {% block content %}{% endblock %}
    </main>

    <!-- Footer -->
    <footer class="footer">
        <p class="footer-text">
            &copy; 2025 Code of Conquest. All rights reserved. | May your adventures be legendary.
        </p>
    </footer>

    <!-- JavaScript -->
    {% block scripts %}{% endblock %}
</body>
</html>
