@using BlazorBootstrap;
@using HerramientaCASA.Model
@using Microsoft.AspNetCore.Components.Web
@inherits LayoutComponentBase
@inject NavigationManager Navigation
@using Microsoft.AspNetCore.Components.Server.ProtectedBrowserStorage
@inject ProtectedSessionStorage ProtectedSessionStore

<head>
	<link href="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN" crossorigin="anonymous">
	<link href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css" rel="stylesheet" />
	<link href="_content/Blazor.Bootstrap/blazor.bootstrap.css" rel="stylesheet" />
	<link href="_content/Blazor.Bootstrap/Blazor.Bootstrap.bundle.scp.css" rel="stylesheet" />
	<link href="Content/Site.css?v=0.43" rel="stylesheet" />
	<link href="Content/all.min.css" rel="stylesheet" />
	<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.3/font/bootstrap-icons.min.css">
	<script src="Scripts/jquery.min.js"></script>
	<script src="https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js" integrity="sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL" crossorigin="anonymous"></script>
	<!-- Add chart.js reference if chart components are used in your application. -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/Chart.js/4.0.1/chart.umd.js" integrity="sha512-gQhCDsnnnUfaRzD8k1L5llCCV6O9HN09zClIzzeJ8OJ9MpGmIlCxm+pdCkqTwqJ4JcjbojFr79rl2F1mzcoLMQ==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
	<!-- Add chartjs-plugin-datalabels.min.js reference if chart components with data label feature is used in your application. -->
	<script src="https://cdnjs.cloudflare.com/ajax/libs/chartjs-plugin-datalabels/2.2.0/chartjs-plugin-datalabels.min.js" integrity="sha512-JPcRR8yFa8mmCsfrw4TNte1ZvF1e3+1SdGMslZvmrzDYxS69J7J49vkFL8u6u8PlPJK+H3voElBtUCzaXj+6ig==" crossorigin="anonymous" referrerpolicy="no-referrer"></script>
	<!-- Add sortable.js reference if SortableList component is used in your application. -->
	<script src="https://cdn.jsdelivr.net/npm/sortablejs@latest/Sortable.min.js"></script>
	<script src="_content/Blazor.Bootstrap/blazor.bootstrap.js"></script>
	<script src="Scripts/popper.min.js"></script>
	<script src="Scripts/all.min.js"></script>
	<script src="Scripts/Util.js"></script>
</head>

<div class="page">
	<main style="height: 100%;">
		<header class="d-none d-md-block">
			<div class="pa-header-t1">
				<div class="pa-header-row1">
					<nav class="navbar navbar-expand-lg navbar-light fixed-top bg-light navCACOA">
						<div class="container-fluid">
							<div>
								<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#topMenu" aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
									<span class="navbar-toggler-icon"></span>
								</button>
								<a class="navbar-brand" href="https://www.cacoa.es/">
									<img src="Content/Imagenes/logo_CACOA_alta.jpg" style="height: 40px" class="logoCacoa" />
								</a>
							</div>
							<div class="collapse navbar-collapse" id="topMenu">
								@if (!MostrarExtra)
								{
									<ul class="navbar-nav mr-auto ulMenu">
										<li id="liPC" class="nav-item">
											<NavLink class="nav-link headNav" href="PanelControl"><i class="fa-solid fa-house"></i> Menú</NavLink>
										</li>
										<li id="liCC" class="nav-item">
											<NavLink class="nav-link headNav" href="HerramientaCASASimulaciones">CASA – Edificación</NavLink>
										</li>
										<li id="liCS" class="nav-item">
											<NavLink class="nav-link headNav" href="LicitacionCASASimulaciones">Licitaciones Edificación</NavLink>
										</li>
										<li id="liCS" class="nav-item">
											<NavLink class="nav-link headNav" href="HerramientaURBANSimulaciones">CASA – Urbanismo</NavLink>
										</li>
										<li id="liCS" class="nav-item">
											<NavLink class="nav-link headNav" href="LicitacionUrbanSimulaciones">Licitaciones Urbanismo</NavLink>
										</li>
									@* 	<li id="liCB" class="nav-item">
											<NavLink class="nav-link headNav" href="BajasSimulaciones">Licitaciones Bajas</NavLink>
										</li> *@
										<li id="liMS" class="nav-item">
											<NavLink class="nav-link headNav" href="MisSimulaciones">Mis Simulaciones</NavLink>
										</li>
									</ul>
								}
								else
								{
									<div style="width:100%" class="d-flex justify-content-center">
										<label class="headNav" style="color: #078b98 !important; font-size: large; font-weight: bold;">Costes Asociados a los Servicios de Arquitectura - CASA</label>
									</div>
								}
							</div>
							<div class="ml-auto">
								<ul class="navbar-nav mr-auto ulMenu">
									<li class="nav-item">
										<NavLink class="nav-link headNav" href="/"> <i class="fas fa-user-slash"></i>Cerrar Sesión</NavLink>
									</li>
								</ul>
							</div>
						</div>
					</nav>
				</div>
			</div>
		</header>
		<div class="pagina">
			@Body
		</div>
	</main>
</div>


@code {
	private bool MostrarExtra => Navigation.Uri.Contains("PanelControl", StringComparison.OrdinalIgnoreCase);


		protected override async Task OnInitializedAsync()
		{
		var obtenerDatoAdmin = await ProtectedSessionStore.GetAsync<bool>("EsAdmin");
		var obtenerDatoId = await ProtectedSessionStore.GetAsync<int>("idUsuario");
		// Redirigir al home si no hay token y la ruta no es pública
		if (obtenerDatoId.Value == 0 || obtenerDatoAdmin.Value)
			{
				Navigation.NavigateTo("/", true);
			}
		}
}
