{% load static %}
<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}AI Code Reviewer System{% endblock %}</title>

    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">

    <link rel="preconnect" href="https://fonts.googleapis.com">
    <link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
    <link
        href="https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800&family=Fira+Code:wght@400;500&display=swap"
        rel="stylesheet">

    <link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.4.0/css/all.min.css">

    <link rel="stylesheet" href="{% static 'css/theme.css' %}">

    <script>
        localStorage.setItem('theme', 'light');
    </script>

    {% block extra_head %}{% endblock %}
</head>

<body class="light-theme">

    <div class="app-container">
        <aside class="sidebar">
            <div class="brand">
                <i class="fa-solid fa-brain-circuit"></i>
                <span>Antigravity Reviewer</span>
            </div>

            <ul class="nav-menu">
                {% if user.is_authenticated %}
                <li class="nav-item {% if request.resolver_match.url_name == 'review' %}active{% endif %}">
                    <a href="{% url 'review' %}">
                        <i class="fa-solid fa-code"></i>
                        <span>Workspace</span>
                    </a>
                </li>
                <li
                    class="nav-item {% if request.resolver_match.url_name == 'review_history' or request.resolver_match.url_name == 'review_detail' %}active{% endif %}">
                    <a href="{% url 'review_history' %}">
                        <i class="fa-solid fa-history"></i>
                        <span>My History</span>
                    </a>
                </li>
                <li class="nav-item {% if request.resolver_match.url_name == 'dashboard' %}active{% endif %}">
                    <a href="{% url 'dashboard' %}">
                        <i class="fa-solid fa-chart-pie"></i>
                        <span>Analytics</span>
                    </a>
                </li>
                <li class="nav-item {% if request.resolver_match.url_name == 'profile' %}active{% endif %}">
                    <a href="{% url 'profile' %}">
                        <i class="fa-solid fa-user-astronaut"></i>
                        <span>Profile</span>
                    </a>
                </li>
                {% else %}
                <li class="nav-item {% if request.resolver_match.url_name == 'login' %}active{% endif %}">
                    <a href="{% url 'login' %}">
                        <i class="fa-solid fa-right-to-bracket"></i>
                        <span>Sign In</span>
                    </a>
                </li>
                <li class="nav-item {% if request.resolver_match.url_name == 'signup' %}active{% endif %}">
                    <a href="{% url 'signup' %}">
                        <i class="fa-solid fa-user-plus"></i>
                        <span>Sign Up</span>
                    </a>
                </li>
                {% endif %}
            </ul>

            <div class="sidebar-footer">


                {% if user.is_authenticated %}
                <div class="d-flex align-items-center gap-3 mb-3">
                    <div class="user-avatar">
                        {{ user.username|slice:":1"|upper }}
                    </div>
                    <div>
                        <div class="fw-semibold text-truncate" style="max-width: 140px;">
                            {{ user.username }}
                        </div>
                        <small class="text-muted d-block" style="font-size: 0.75rem;">
                            {% if user.is_staff %}<span class="badge bg-primary">Admin</span>{% else %}Coder{% endif %}
                        </small>
                    </div>
                </div>
                <a href="{% url 'logout' %}"
                    class="btn btn-secondary-premium btn-sm w-100 d-flex justify-content-center align-items-center gap-2">
                    <i class="fa-solid fa-power-off text-danger"></i> Sign Out
                </a>
                {% else %}
                <small class="text-muted text-center d-block">Please sign in to review code.</small>
                {% endif %}
            </div>
        </aside>

        <main class="main-content">
            {% if messages %}
            <div class="messages mb-4">
                {% for message in messages %}
                <div class="alert {% if message.tags == 'error' %}alert-danger{% else %}alert-success{% endif %} alert-dismissible fade show glass-card"
                    role="alert" style="color: inherit;">
                    {{ message }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
                </div>
                {% endfor %}
            </div>
            {% endif %}

            {% block content %}{% endblock %}
        </main>
    </div>

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>

    {% block extra_js %}{% endblock %}
</body>

</html>