@page "/pokemon/{id:int}"
@inject IPokemonService PokemonService
@inject NavigationManager Navigation

@attribute [StreamRendering]
@rendermode InteractiveServer


<PokemonHeader />

<head>
    <link rel="stylesheet" href="bootstrap/bootstrap-lumen.css" /> <!-- app.css -->
</head>

@if (_pokemon == null)
{
   <Loading />
}
else
{
    <PageTitle>@_pokemon.PokemonName</PageTitle>
    <!-- Total Componenet-->

    <div class="container">
        <div class="w-75 row mt-4 m-auto">

            <!-- Previous Pokemon Button -->
            <div class="col-auto">
                <button class="mt-1 p-2 btn btn-danger rounded-5 align-self-start text-white" disabled="@(!_previousPokemonId.HasValue)" @onclick="NavigateToPrevious">
                    <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" class="bi bi-arrow-left-circle-fill" viewBox="0 0 16 16">
                        <path d="M8 0a8 8 0 1 0 0 16A8 8 0 0 0 8 0m3.5 7.5a.5.5 0 0 1 0 1H5.707l2.147 2.146a.5.5 0 0 1-.708.708l-3-3a.5.5 0 0 1 0-.708l3-3a.5.5 0 1 1 .708.708L5.707 7.5z" />
                    </svg>
                </button>
            </div>

            <!-- Pokemon Presentation -->
            <div class="mt-5 mx-5 col justify-content-center">
                @if (_variationPokemonId != null)
                {
                    @if (_variationPokemonId != null && _pokemonVariant == null){
                        <Loading />
                    }
                    else
                    {
                        <!-- If Variation Pokemon have same PokemonId -->
                        @if(_pokemon.Id != _pokemonVariant.Id)
                        {
                            <div class="d-flex justify-content-center">
                                    <div class="pokemoncard m-1">
                                        <PokemonCard Pokemon="_pokemon" />
                                    </div>

                                    <div class="pokemoncard m-1">
                                        <PokemonCard Pokemon="_pokemonVariant" />
                                    </div>

                            </div>
                            
                        }
                        <!-- If Variation Pokemon has diff PokemonId -->
                        else
                        {
                            <div class="d-flex justify-content-center align-items-center h-100">
                                <div class="pokemoncard">
                                    <PokemonCard Pokemon="_pokemonVariant" />
                                </div>

                            </div>
                            
                        }
                    }
                }
                else{
                <!-- Standard Pokemon Display -->
                    <div class="d-flex justify-content-center align-items-center h-100">
                        <div class="pokemoncard m-1">
                            <PokemonCard Pokemon="_pokemon" />
                        </div>

                    </div>
                }
            </div>

            <!-- Next Pokemon Button -->
            <div class="col-auto">
            <button class="mt-1 p-2 btn btn-danger rounded rounded-5 align-self-start text-white" disabled="@(!_nextPokemonId.HasValue)" @onclick="NavigateToNext">
                <svg xmlns="http://www.w3.org/2000/svg" width="32" height="32" fill="currentColor" class="bi bi-arrow-right-circle-fill" viewBox="0 0 16 16">
                    <path d="M8 0a8 8 0 1 1 0 16A8 8 0 0 1 8 0M4.5 7.5a.5.5 0 0 0 0 1h5.793l-2.147 2.146a.5.5 0 0 0 .708.708l3-3a.5.5 0 0 0 0-.708l-3-3a.5.5 0 1 0-.708.708L10.293 7.5z" />
                </svg>
                </button>
            </div>
        </div>
        
    </div>
}
