@using Microsoft.AspNetCore.Authentication
@using Microsoft.AspNetCore.Authorization
@using Microsoft.AspNetCore.Http
@inject IHttpContextAccessor HttpContextAccessor

@{
    var pictureUrl = User.FindFirst("picture")?.Value;
    var preferredUsername = User.FindFirst("preferred_username")?.Value ?? "User";
}

<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8" />
    <title>@ViewData["Title"] - Watcher</title>
    <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.3/dist/css/bootstrap.min.css" />
    <link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.10.5/font/bootstrap-icons.css" rel="stylesheet">

    <style>
        body {
            overflow: hidden;
        }

        .sidebar {
            width: 240px;
            height: 100vh;
            position: fixed;
            left: 0;
            top: 0;
            background-color: #343a40;
            color: white;
            display: flex;
            flex-direction: column;
            justify-content: space-between;
            padding: 1rem;
        }

        .main {
            margin-left: 240px;
            padding: 2rem;
        }

        .nav-link {
            color: #adb5bd;
        }

        .nav-link:hover {
            color: white;
        }

        .account-box {
            font-size: 0.9rem;
            color: #ced4da;
        }
    </style>
</head>

<body>
    <div class="sidebar">
        <div>
            <h4>Watcher</h4>
            <ul class="nav flex-column">
                <li class="nav-item">
                    <a class="nav-link" href="/">Dashboard</a>
                </li>
                <li class="nav-item"></li>
                <a class="nav-link" href="/Uptime">Uptime</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/Monitoring/Servers">Servers</a>
                </li>
                <li class="nav-item">
                    <a class="nav-link" href="/Container">Container</a>
                </li>
            </ul>
        </div>

        <div class="account-box mt-auto">
            @if (User.Identity?.IsAuthenticated ?? false)
            {
                <a href="/Auth/Info" class="d-block text-decoration-none text-light">
                    <div class="d-flex align-items-center gap-2">
                        <div class="rounded-circle bg-secondary text-white px-2 py-1">
                            <i class="bi bi-person"></i>
                        </div>
                        <div>
                            <strong>@User.Claims.FirstOrDefault(c => c.Type == "name")?.Value</strong><br />
                            <small class="text-muted">Profil ansehen</small>
                        </div>
                    </div>
                </a>
            }
            else
            {
                <a class="nav-link p-0 text-primary" href="/Account/Login">Login</a>
            }
        </div>
    </div>

    <main class="main">
        @RenderBody()
    </main>

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

</html>
