from pydantic import BaseModel
from datetime import datetime
from typing import Optional, Dict, Any
from app.models.sport_event import SportType, EventStatus


class SportEventCreate(BaseModel):
    sport: SportType
    home_team: str
    away_team: str
    official_spread: float
    game_time: datetime
    venue: Optional[str] = None
    league: Optional[str] = None
    min_spread: float = -10.0
    max_spread: float = 10.0
    min_bet_amount: float = 10.0
    max_bet_amount: float = 1000.0


class SportEventUpdate(BaseModel):
    sport: Optional[SportType] = None
    home_team: Optional[str] = None
    away_team: Optional[str] = None
    official_spread: Optional[float] = None
    game_time: Optional[datetime] = None
    venue: Optional[str] = None
    league: Optional[str] = None
    status: Optional[EventStatus] = None
    final_score_home: Optional[int] = None
    final_score_away: Optional[int] = None


class SportEvent(BaseModel):
    id: int
    sport: SportType
    home_team: str
    away_team: str
    official_spread: float
    game_time: datetime
    venue: Optional[str] = None
    league: Optional[str] = None
    min_spread: float
    max_spread: float
    min_bet_amount: float
    max_bet_amount: float
    status: EventStatus
    final_score_home: Optional[int] = None
    final_score_away: Optional[int] = None
    created_by: int
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True


class SportEventWithBets(SportEvent):
    spread_grid: Dict[str, Any]
