<!DOCTYPE html>
<html lang="en" data-bs-theme="dark">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>404 - Not Found</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css">
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
    <style>
        body {
            min-height: 100vh;
            display: flex;
            align-items: center;
            justify-content: center;
            background: radial-gradient(circle at top right, #1b2235 0%, #0d1117 55%, #090c12 100%);
            color: #e5e7eb;
        }
        .error-shell {
            width: min(760px, 92vw);
        }
        .error-card {
            background: rgba(23, 27, 40, 0.9);
            border: 1px solid #2a3249;
            border-radius: 16px;
            box-shadow: 0 20px 48px rgba(0, 0, 0, 0.35);
        }
        .path-chip {
            background: rgba(148, 163, 184, 0.14);
            border: 1px solid rgba(148, 163, 184, 0.35);
            border-radius: 10px;
            color: #cbd5e1;
            font-family: Consolas, 'Cascadia Code', monospace;
            font-size: 0.85rem;
            padding: 0.45rem 0.65rem;
            word-break: break-all;
        }
    </style>
</head>
<body>
<div class="error-shell">
    <div class="error-card p-4 p-md-5">
        <div class="d-flex align-items-center gap-3 mb-3">
            <i class="bi bi-signpost-split-fill text-warning" style="font-size: 2.2rem;"></i>
            <div>
                <h1 class="h3 mb-1">404 - Page not found</h1>
                <p class="text-secondary mb-0">The requested route does not exist or has been moved.</p>
            </div>
        </div>

        <div class="mb-3">
            <div class="small text-secondary mb-1">Request</div>
            <div class="path-chip">{{ request_method }} {{ requested_path }}</div>
        </div>

        <div class="mb-4">
            {% if not is_logged_in %}
            <p class="mb-0 text-secondary">You are currently not signed in. Start from the login page.</p>
            {% elif is_site_admin and not session.get('group_id') %}
            <p class="mb-0 text-secondary">You are signed in as Site Admin. You can manage groups and users from there.</p>
            {% elif role == 'admin' %}
            <p class="mb-0 text-secondary">You are a group admin. Use Panel or Group Admin to return to valid sections.</p>
            {% else %}
            <p class="mb-0 text-secondary">Use the dashboard to navigate back to known sections.</p>
            {% endif %}
        </div>

        <div class="d-flex flex-wrap gap-2">
            {% for link in links %}
            <a href="{{ link.href }}" class="btn {{ link.btn }}">{{ link.label }}</a>
            {% endfor %}
            <a href="javascript:history.back()" class="btn btn-outline-secondary">Go Back</a>
        </div>
    </div>
</div>
</body>
</html>
