@using Microsoft.AspNetCore.Mvc.Localization
@inject IViewLocalizer Localizer
@model LiteCharmsSecurity.STS.Identity.ViewModels.Consent.ConsentViewModel

<div class="py-8">
	<div class="mb-8">
		@if (Model.ClientLogoUrl != null)
		{
			<div class="mb-4"><img src="@Model.ClientLogoUrl" alt="Client Logo" class="h-16"></div>
		}
		<h1 class="text-4xl font-bold mb-2">@Model.ClientName</h1>
		<p class="text-lg text-muted-foreground">@Localizer["SubTitle"]</p>
	</div>

	@await Html.PartialAsync("_ValidationSummary")

	<form asp-action="Index" class="space-y-6">
		<input type="hidden" asp-for="ReturnUrl" />

		<div class="text-lg mb-6">@Localizer["UnCheckPermission"]</div>

		@if (Model.IdentityScopes.Any())
		{
			<div class="card">
			<div class="card-header">
				<h2 class="card-title flex items-center gap-2">
					<lucideicon name="user" class="h-5 w-5" />
					@Localizer["PersonalInformation"]
				</h2>
			</div>
			<div class="card-content py-4">
				<ul class="space-y-4">
						@foreach (var scope in Model.IdentityScopes)
						{
							@await Html.PartialAsync("_ScopeListItem", scope)
						}
					</ul>
				</div>
			</div>
		}

		@if (Model.ApiScopes.Any())
		{
			<div class="card">
			<div class="card-header">
				<h2 class="card-title flex items-center gap-2">
					<lucideicon name="lock" class="h-5 w-5" />
					@Localizer["ApplicationAccess"]
				</h2>
			</div>
			<div class="card-content py-4">
				<ul class="space-y-4">
						@foreach (var scope in Model.ApiScopes)
						{
							@await Html.PartialAsync("_ScopeListItem", scope)
						}
					</ul>
				</div>
			</div>
		}

		<div class="card">
			<div class="card-header">
				<h2 class="card-title flex items-center gap-2">
					<lucideicon name="pencil" class="h-5 w-5" />
					@Localizer["DescriptionTitle"]
				</h2>
			</div>
			<div class="card-content py-4">
				<input asp-for="Description" class="input w-full" placeholder="@Localizer["DescriptionPlaceholder"]" />
			</div>
		</div>

		@if (Model.AllowRememberConsent)
		{
			<div class="card">
				<div class="card-content py-4">
					<div class="flex items-center justify-between">
						<label for="RememberConsent" class="font-semibold cursor-pointer">
							@Localizer["Remember"]
						</label>
						<label class="switch">
							<input asp-for="RememberConsent" type="checkbox" id="RememberConsent" />
							<span class="switch-slider"></span>
						</label>
					</div>
				</div>
			</div>
		}
		<div class="flex flex-wrap gap-4 items-center justify-between">
			<div class="flex gap-3">
				<button name="button" value="yes" class="btn-default" autofocus>
					<lucideicon name="check" class="inline-block h-4 w-4 mr-2" />
					@Localizer["Yes"]
				</button>
				<button name="button" value="no" class="btn-outline">
					<lucideicon name="x" class="inline-block h-4 w-4 mr-2" />
					@Localizer["No"]
				</button>
			</div>

			@if (Model.ClientUrl != null)
			{
				<a class="btn-outline" target="_blank" href="@Model.ClientUrl">
					<lucideicon name="info" class="h-4 w-4 mr-1" />
					<strong>@Model.ClientName</strong>
				</a>
			}
		</div>
	</form>
</div>
