@inherits LayoutComponentBase
@using AliasVault.Client.Auth.Components
@using AliasVault.Client.Shared.Components
@inject NavigationManager NavigationManager

<div class="flex flex-col items-center justify-center px-6 pt-8 pb-8 mx-auto md:h-screen pt:mt-0 dark:bg-gray-900 relative">
    @if (ShowLanguageSwitcher)
    {
        <div class="absolute top-4 right-4 z-10">
            <LanguageSwitcher />
        </div>
    }
    <Logo />
    <div class="w-full max-w-xl p-6 sm:p-8 bg-white rounded-lg shadow dark:bg-gray-800">
        <GlobalNotificationDisplay />
        @Body
    </div>
</div>

@code {
    private bool ShowLanguageSwitcher => ShouldShowLanguageSwitcher();

    private bool ShouldShowLanguageSwitcher()
    {
        var currentPath = NavigationManager.Uri;

        // Show on login, forgot password, and register pages, not during setup or unlock
        return currentPath.Contains("/user/login", StringComparison.OrdinalIgnoreCase) ||
               currentPath.Contains("/user/forgot-password", StringComparison.OrdinalIgnoreCase) ||
               currentPath.Contains("/user/register", StringComparison.OrdinalIgnoreCase) ||
               currentPath.EndsWith('/');
    }
}
