{% 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 %}Grassroots Campaign Manager{% endblock %}</title>
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css">
    <link rel="stylesheet" href="{% static 'css/custom.css' %}?v={{ deployment_timestamp }}">
    {% if project_description %}
    <meta name="description" content="{{ project_description }}">
    {% endif %}
    {% if project_image_url %}
    <meta property="og:image" content="{{ project_image_url }}">
    {% endif %}
    {% block extra_css %}{% endblock %}
</head>
<body class="bg-light">
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark">
        <div class="container">
            <a class="navbar-brand" href="/">Grassroots CM</a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav me-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="/">Home</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/voters/">Voters</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/call-queue/">Call Queue</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/door-visits/">Door Visits</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/events/">Events</a>
                    </li>
                    {% if can_view_volunteers %}
                    <li class="nav-item">
                        <a class="nav-link" href="/volunteers/">Volunteers</a>
                    </li>
                    {% endif %}
                </ul>
                <div class="d-flex align-items-center">
                    <a href="/admin/" class="btn btn-outline-primary btn-sm me-3">Admin Panel</a>
                    {% if user.is_authenticated %}
                        <div class="dropdown">
                            <button class="btn btn-link nav-link dropdown-toggle text-white d-flex align-items-center p-0" type="button" id="userDropdown" data-bs-toggle="dropdown" aria-expanded="false" style="text-decoration: none;">
                                <i class="bi bi-person-circle me-1"></i>
                                <span class="small">{{ user.username }}</span>
                            </button>
                            <ul class="dropdown-menu dropdown-menu-end shadow border-0" aria-labelledby="userDropdown">
                                <li><a class="dropdown-item small" href="{% url 'profile' %}"><i class="bi bi-person me-2"></i>My Profile</a></li>
                                <li><a class="dropdown-item small" href="{% url 'password_change' %}"><i class="bi bi-shield-lock me-2"></i>Change Password</a></li>
                                <li><hr class="dropdown-divider"></li>
                                <li>
                                    <form method="post" action="{% url 'logout' %}" class="px-3">
                                        {% csrf_token %}
                                        <button type="submit" class="btn btn-link dropdown-item small p-0 m-0"><i class="bi bi-box-arrow-right me-2"></i>Logout</button>
                                    </form>
                                </li>
                            </ul>
                        </div>
                    {% else %}
                        <a href="{% url 'login' %}" class="btn btn-link nav-link text-white">Login</a>
                    {% endif %}
                </div>
            </div>
        </div>
    </nav>

    <div class="container py-4">
        {% if messages %}
            {% for message in messages %}
                <div class="alert alert-{{ message.tags }} alert-dismissible fade show">
                    {{ message }}
                    <button type="button" class="btn-close" data-bs-dismiss="alert"></button>
                </div>
            {% endfor %}
        {% endif %}

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

    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    <script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
    {% block extra_js %}{% endblock %}
</body>
</html>