@page "/pokemonsleep/add-new-pokemon"

@inject IPokemonService PokemonService
@inject NavigationManager Navigation

@attribute [StreamRendering]
@rendermode InteractiveServer


<PageTitle>Add New Pokémon</PageTitle>
<PokemonHeader />


@if (isSubmitting)
{
    <p><em>Submitting...</em></p>
}
else
{
    <div class="w-50 mt-5 m-auto create-container bg-info">

        <div class="card-header bg-secondary bg-gradient ml-0 py-3">
            <div class="row">
                <div class="col-12 text-center">
                    <h2 class="text-info">Add New Pokémon</h2>
                </div>
            </div>
        </div>


        <div class="container m-lg-1" >
            <EditForm class=" col mb-3" Model="NewPokemon" OnValidSubmit="HandleSubmit">
                <DataAnnotationsValidator />

                <!-- Section 1 -->
                <div class="row mt-3">
                    <div class="col-sm-3 input-group mb-3 ">
                        <!-- Pokemon #-->
                        <span for="PokemonId" class="input-group-text">#</span>
                        <InputNumber min="0" placeholder="Pokedex #" id="PokemonId" @bind-Value="NewPokemon.PokemonId" class="form-control " required />
                        <!-- Pokemon Name-->
                        <InputText placeholder="Pokemon Name" id="PokemonName" @bind-Value="NewPokemon.PokemonName" class="form-control w-75" required />
                    </div>
                </div>

                <!-- Pokemon Type, Sleep Type, and Speciality -->
                <div class="row">
                    <!-- Pokemon Type -->
                    <div class="col mb-3 m-auto">
                        <label for="PokemonType" class="form-label">Pokemon Type</label>
                        <InputSelect id="PokemonType" @bind-Value="NewPokemon.PokemonType" class="form-select">
                            <option dsabled value="">Select Type</option>
                            <option value="Grass">Grass</option>
                            <option value="Fire">Fire</option>
                            <option value="Water">Water</option>
                            <option value="Normal">Normal</option>
                            <option value="Flying">Flying</option>
                            <option value="Bug">Bug</option>
                            <option value="Poison">Poison</option>
                            <option value="Electric">Electric</option>
                            <option value="Ground">Ground</option>
                            <option value="Rock">Rock</option>
                            <option value="Ice">Ice</option>
                            <option value="Steel">Steel</option>
                            <option value="Fighting">Fighting</option>
                            <option value="Psychic">Psychic</option>
                            <option value="Dark">Dark</option>
                            <option value="Fairy">Fairy</option>
                            <option value="Ghost">Ghost</option>
                            <option value="Dragon">Dragon</option>
                        </InputSelect>
                    </div>
                    <!-- Sleep Type -->
                    <div class="col mb-3 m-auto">
                        <label for="SleepType" class="form-label">Sleep Type</label>
                        <InputSelect id="SleepType" @bind-Value="NewPokemon.SleepType" class="form-select">
                            <option value="Dozing">Dozing</option>
                            <option value="Snoozing">Snoozing</option>
                            <option value="Slumbering">Slumbering</option>
                        </InputSelect>
                    </div>
                    <!-- Speciality-->
                    <div class="col mb-3 m-auto">
                        <label for="Speciality" class="form-label">Specialty</label>
                        <InputSelect id="Speciality" @bind-Value="NewPokemon.Speciality" class="form-select">
                            <option value="Berries">Berries</option>
                            <option value="Ingredients">Ingredients</option>
                            <option value="Skills">Skills</option>
                            <option value="All">All</option>
                        </InputSelect>
                    </div>
                </div>

                <!-- Section 2 -->
                <div class="row">
                    <div class="input-group mb-3">
                        <!-- Variation Check -->
                        <div class=" d-inline-flex">
                            <InputCheckbox id="IsVariation" @bind-Value="NewPokemon.IsVariation" @onclick="@Toggle" class="form-check-input checkbox-styling p-3 mt-1" />
                            <span for="IsVariation" class="input-group-text m-1">Variation?</span>
                        </div>
                        
                        <!-- Variation Region Input -->
                        <div class="w-75 mx-2 mt-1">

                            <InputText placeholder="What Variant? (Alolan, Paldean)" hidden="@HideLabel" id="VariationName" @bind-Value="NewPokemon.VariationName" class="form-control" />
                        </div>
                    </div>
                </div>
                <!-- New Image URL Field -->
                <div class="row mb-3 m-auto">
                    <label for="ImageUrl" class="form-label">Base Image URL</label>
                    <InputText id="ImageUrl" @bind-Value="NewPokemon.PokemonImageUrl" class="form-control" />
                </div>
                <!-- Shiny Image URL Input -->
                <div class="row mb-3 m-auto">
                    <label for="ImageUrl" class="form-label">Shiny Image URL</label>
                    <InputText id="ImageUrl" @bind-Value="NewPokemon.PokemonShinyImageUrl" class="form-control" />
                </div>

                <!-- Flavor Text Input -->
                <div class="row mb-3 m-auto">
                    <label for="FlavorText" class="form-label">Flavor Text</label>
                    <InputText id="FlavorText" @bind-Value="NewPokemon.FlavorText" class="form-control" />
                </div>

                <!-- Form Buttons -->
                <div class="d-flex justify-content-between">
                    <button type="button" class="btn btn-secondary mb-3" @onclick="Cancel">Cancel</button>
                    <button type="submit" class="btn btn-primary mb-3">Add Pokemon</button>
                </div>
            </EditForm>
        </div>
    </div>
}

