{% 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 %}Support Center{% endblock %}</title>
    <meta name="description" content="{% block description %}A lightweight support center to triage and resolve tickets.{% endblock %}">
    
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <!-- Custom CSS -->
    <link rel="stylesheet" href="{% static 'css/custom.css' %}?v={% now 'U' %}">
    
    {% block extra_head %}{% endblock %}
</head>
<body class="app-body">
    <div class="ambient-bg" aria-hidden="true"></div>
    <nav class="navbar navbar-expand-lg sticky-top mb-4 site-nav">
        <div class="container">
            <a class="navbar-brand fw-bold d-flex align-items-center gap-2" href="{% url 'dashboard' %}">
                <span class="brand-mark">SC</span>
                <span class="brand-text">Support Center</span>
            </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 ms-auto align-items-center">
                    {% if user.is_authenticated %}
                        <li class="nav-item me-3">
                            <span class="text-muted small">Welcome, {{ user.username }}</span>
                        </li>
                        <li class="nav-item">
                            <a class="btn btn-primary btn-sm" href="{% url 'ticket_create' %}">+ New Ticket</a>
                        </li>
                        <li class="nav-item ms-2">
                            <form action="{% url 'logout' %}" method="post" style="display: inline;">
                                {% csrf_token %}
                                <button type="submit" class="nav-link btn btn-link text-muted" style="text-decoration: none;">Logout</button>
                            </form>
                        </li>
                        {% if user.is_staff %}
                        <li class="nav-item ms-2">
                            <a class="nav-link text-muted" href="/admin/">Admin</a>
                        </li>
                        {% endif %}
                    {% else %}
                        <li class="nav-item">
                            <a class="nav-link" href="{% url 'login' %}">Login</a>
                        </li>
                    {% endif %}
                </ul>
            </div>
        </div>
    </nav>

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

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

    <footer class="py-5 mt-5 text-center text-muted small site-footer">
        <div class="container">
            <p>&copy; {% now 'Y' %} Support Center. Built with Django.</p>
        </div>
    </footer>

    <!-- Bootstrap 5 JS -->
    <script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/js/bootstrap.bundle.min.js"></script>
    {% block extra_js %}{% endblock %}
</body>
</html>
