@using Duende.IdentityServer.Extensions
@using Microsoft.AspNetCore.Mvc.Localization
@using LiteCharmsSecurity.STS.Identity.Configuration.Interfaces
@inject IViewLocalizer Localizer
@inject IRootConfiguration RootConfiguration

<div class="py-4">
  <div class="text-center mb-6">
    <img class="mx-auto h-20 w-auto mb-4 opacity-90 dark:invert" alt="Logo"
         src="@UrlHelper.Content(RootConfiguration.AdminConfiguration.HomePageLogoUri)">
    <h1 class="text-5xl font-bold mb-2 tracking-tight">@RootConfiguration.AdminConfiguration.PageTitle</h1>
    <p class="text-lg text-muted-foreground mt-3">
      @Localizer["SubTitle", RootConfiguration.AdminConfiguration.PageTitle]
    </p>
  </div>

  @if (!User.IsAuthenticated())
  {
    <section class="flex min-h-[40vh] items-center justify-center py-12">
      <div class="flex flex-wrap justify-center gap-6 max-w-5xl">
        <a asp-controller="Account" asp-action="Login"
           class="card w-80 hover:border-primary/40 transition-all hover:shadow-xl duration-300 group block">
          <div class="card-content text-center py-10 px-6">
            <div
              class="mx-auto mb-6 inline-flex h-24 w-24 items-center justify-center rounded-2xl bg-gradient-to-br from-primary/15 to-primary/5 group-hover:from-primary/25 group-hover:to-primary/10 transition-all duration-300">
              <lucideicon name="log-in" class="h-12 w-12 text-primary" />
            </div>
            <h2 class="text-2xl font-bold mb-3">@Localizer["Login"]</h2>
            <p class="text-sm text-muted-foreground mb-8">@Localizer["LoginDescription"]</p>
          </div>
        </a>

        @if (RootConfiguration.RegisterConfiguration.Enabled)
        {
          <a asp-controller="Account" asp-action="Register"
             class="card w-80 hover:border-primary/40 transition-all hover:shadow-xl duration-300 group block">
            <div class="card-content text-center py-10 px-6">
              <div
                class="mx-auto mb-6 inline-flex h-24 w-24 items-center justify-center rounded-2xl bg-gradient-to-br from-primary/15 to-primary/5 group-hover:from-primary/25 group-hover:to-primary/10 transition-all duration-300">
                <lucideicon name="user-plus" class="h-12 w-12 text-primary" />
              </div>
              <h2 class="text-2xl font-bold mb-3">@Localizer["Register"]</h2>
              <p class="text-sm text-muted-foreground mb-8">@Localizer["RegisterDescription"]</p>
            </div>
          </a>
        }

        <a href="~/.well-known/openid-configuration"
           class="card w-80 hover:border-primary/40 transition-all hover:shadow-xl duration-300 group block">
          <div class="card-content text-center py-10 px-6">
            <div
              class="mx-auto mb-6 inline-flex h-24 w-24 items-center justify-center rounded-2xl bg-gradient-to-br from-primary/15 to-primary/5 group-hover:from-primary/25 group-hover:to-primary/10 transition-all duration-300">
              <lucideicon name="globe" class="h-12 w-12 text-primary" />
            </div>
            <h2 class="text-2xl font-bold mb-3">@Localizer["Discovery"]</h2>
            <p class="text-sm text-muted-foreground mb-8">@Localizer["DiscoveryDescription"]</p>
          </div>
        </a>
      </div>
    </section>
  }
  else
  {
    <div class="grid gap-8 md:grid-cols-2 lg:grid-cols-3 mb-10">
      @{
        var menuItems = new[] {
        new { Title = Localizer["Grants"], Icon = "badge-check", Controller = "Grants", Action = "Index", Description =
        Localizer["GrantsDescription"], Url = "" },
        new { Title = Localizer["Discovery"], Icon = "globe", Controller = "", Action = "", Description =
        Localizer["DiscoveryDescription"], Url = Url.Content("~/.well-known/openid-configuration") },
        new { Title = Localizer["ManageProfile"], Icon = "user", Controller = "Manage", Action = "Index", Description =
        Localizer["ManageProfileDescription"], Url = "" },
        new { Title = Localizer["ManagePersonalData"], Icon = "cloud-download", Controller = "Manage", Action =
        "PersonalData", Description = Localizer["ManagePersonalDataDescription"], Url = "" },
        new { Title = Localizer["2FA"], Icon = "shield-check", Controller = "Manage", Action = "TwoFactorAuthentication",
        Description = Localizer["2FADescription"], Url = "" },
        new { Title = Localizer["ChangePassword"], Icon = "key-round", Controller = "Manage", Action = "ChangePassword",
        Description = Localizer["ChangePasswordDescription"], Url = "" }
        };
      }
      @foreach (var item in menuItems)
      {
        @if (!string.IsNullOrEmpty(item.Url))
        {
          <a href="@item.Url" class="card hover:border-primary/40 transition-all hover:shadow-xl duration-300 group block">
            <div class="card-content text-center py-10 px-6">
              <div
                class="mx-auto mb-6 inline-flex h-24 w-24 items-center justify-center rounded-2xl bg-gradient-to-br from-primary/15 to-primary/5 group-hover:from-primary/25 group-hover:to-primary/10 transition-all duration-300">
                <lucideicon name="@item.Icon" class="h-12 w-12 text-primary" />
              </div>
              <h2 class="text-2xl font-bold mb-3">@item.Title</h2>
              <p class="text-sm text-muted-foreground mb-8">@item.Description</p>
            </div>
          </a>
        }
        else
        {
          <a asp-controller="@item.Controller" asp-action="@item.Action"
             class="card hover:border-primary/40 transition-all hover:shadow-xl duration-300 group block">
            <div class="card-content text-center py-10 px-6">
              <div
                class="mx-auto mb-6 inline-flex h-24 w-24 items-center justify-center rounded-2xl bg-gradient-to-br from-primary/15 to-primary/5 group-hover:from-primary/25 group-hover:to-primary/10 transition-all duration-300">
                <lucideicon name="@item.Icon" class="h-12 w-12 text-primary" />
              </div>
              <h2 class="text-2xl font-bold mb-3">@item.Title</h2>
              <p class="text-sm text-muted-foreground mb-8">@item.Description</p>
            </div>
          </a>
        }
      }
    </div>
  }
</div>