from pydantic import BaseModel

from app.schemas.base import CamelModel


class PokemonResponse(CamelModel):
    id: int
    pokeapi_id: int
    national_dex: int
    name: str
    types: list[str]
    sprite_url: str | None


class PaginatedPokemonResponse(CamelModel):
    items: list[PokemonResponse]
    total: int
    limit: int
    offset: int


class EvolutionResponse(CamelModel):
    id: int
    from_pokemon_id: int
    to_pokemon: PokemonResponse
    trigger: str
    min_level: int | None
    item: str | None
    held_item: str | None
    condition: str | None
    region: str | None


class FamiliesResponse(CamelModel):
    families: list[list[int]]


class RouteEncounterResponse(CamelModel):
    id: int
    route_id: int
    pokemon_id: int
    game_id: int
    encounter_method: str
    encounter_rate: int
    min_level: int
    max_level: int


class RouteEncounterDetailResponse(RouteEncounterResponse):
    pokemon: PokemonResponse


# --- Admin schemas ---


class PokemonCreate(CamelModel):
    pokeapi_id: int
    national_dex: int
    name: str
    types: list[str]
    sprite_url: str | None = None


class PokemonUpdate(CamelModel):
    pokeapi_id: int | None = None
    national_dex: int | None = None
    name: str | None = None
    types: list[str] | None = None
    sprite_url: str | None = None


class RouteEncounterCreate(CamelModel):
    pokemon_id: int
    game_id: int
    encounter_method: str
    encounter_rate: int
    min_level: int
    max_level: int


class RouteEncounterUpdate(CamelModel):
    encounter_method: str | None = None
    encounter_rate: int | None = None
    min_level: int | None = None
    max_level: int | None = None


class BulkImportItem(BaseModel):
    pokeapi_id: int
    national_dex: int
    name: str
    types: list[str]
    sprite_url: str | None = None


class BulkImportResult(CamelModel):
    created: int
    updated: int
    errors: list[str]


# --- Evolution admin schemas ---


class EvolutionAdminResponse(CamelModel):
    id: int
    from_pokemon_id: int
    to_pokemon_id: int
    from_pokemon: PokemonResponse
    to_pokemon: PokemonResponse
    trigger: str
    min_level: int | None
    item: str | None
    held_item: str | None
    condition: str | None
    region: str | None


class PaginatedEvolutionResponse(CamelModel):
    items: list[EvolutionAdminResponse]
    total: int
    limit: int
    offset: int


class EvolutionCreate(CamelModel):
    from_pokemon_id: int
    to_pokemon_id: int
    trigger: str
    min_level: int | None = None
    item: str | None = None
    held_item: str | None = None
    condition: str | None = None
    region: str | None = None


class EvolutionUpdate(CamelModel):
    from_pokemon_id: int | None = None
    to_pokemon_id: int | None = None
    trigger: str | None = None
    min_level: int | None = None
    item: str | None = None
    held_item: str | None = None
    condition: str | None = None
    region: str | None = None
