<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>{% block title %}NetHang{% endblock %}</title>
    <!-- Favicon -->
    <link rel="icon" href="{{ url_for('static', filename='images/favicon.png') }}" type="image/png">
    <link rel="shortcut icon" href="{{ url_for('static', filename='images/favicon.png') }}" type="image/png">
    <link rel="apple-touch-icon" href="{{ url_for('static', filename='images/favicon.png') }}">
    <meta name="theme-color" content="#343a40">
    <!-- Bootstrap 5 CSS -->
    <link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.0/dist/css/bootstrap.min.css" rel="stylesheet">
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.0/font/bootstrap-icons.css" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/chart.js@3.9.1/dist/chart.min.js"></script>
    <script src="https://cdnjs.cloudflare.com/ajax/libs/socket.io/4.5.1/socket.io.min.js"></script>
    <!-- Custom CSS -->
    <style>
        .navbar-brand {
            font-weight: bold;
        }

        .card {
            box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
        }

        .table th {
            background-color: #f8f9fa;
        }

        .badge {
            font-size: 0.875rem;
        }
    </style>
    {% block extra_css %}{% endblock %}
</head>

<body>
    {% if g.privileges and (not g.privileges.tc_access or not g.privileges.iptables_access) %}
    <div class="alert alert-warning alert-dismissible fade show mb-0" role="alert">
        <div class="container">
            <strong>Warning:</strong> Insufficient privileges detected:
            <ul class="mb-0">
                {% if not g.privileges.tc_access %}
                <li>tc: {{ g.privileges.tc_error }}</li>
                {% endif %}
                {% if not g.privileges.iptables_access %}
                <li>iptables: {{ g.privileges.iptables_error }}</li>
                {% endif %}
            </ul>
            <button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
        </div>
    </div>
    {% endif %}

    <!-- Navigation -->
    <nav class="navbar navbar-expand-lg navbar-dark bg-dark mb-4">
        <div class="container-fluid">
            <a class="navbar-brand" href="/">
                <img src="{{ url_for('static', filename='images/icon-dark-trans.png') }}" alt="NetHang Logo" height="32"
                    class="d-inline-block align-text-center me-0">
                NetHang
            </a>
            <button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav"
                aria-controls="navbarNav" aria-expanded="false" aria-label="Toggle navigation">
                <span class="navbar-toggler-icon"></span>
            </button>
            <div class="collapse navbar-collapse" id="navbarNav">
                <ul class="navbar-nav gap-2">
                    <li class="nav-item">
                        <a class="nav-link" href="/">Simulation</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/config">Settings</a>
                    </li>
                    <li class="nav-item">
                        <a class="nav-link" href="/about">About</a>
                    </li>
                </ul>
                <ul class="navbar-nav ms-auto">
                    <li class="nav-item">
                        <a class="nav-link" href="{{ url_for('logout') }}">Logout</a>
                    </li>
                </ul>
            </div>
        </div>
    </nav>

    <!-- Main Content -->
    <div class="container-fluid">
        {% block content %}{% endblock %}
    </div>

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

</html>