from pydantic import BaseModel, Field
from typing import Optional
from datetime import datetime
from enum import Enum

from models.episode import EpisodeStatus


class EpisodeBase(BaseModel):
    name: str = Field(..., min_length=1, max_length=255)
    description: Optional[str] = None
    episode_number: int = Field(..., ge=1)
    status: EpisodeStatus = EpisodeStatus.PLANNING


class EpisodeCreate(EpisodeBase):
    pass


class EpisodeUpdate(BaseModel):
    name: Optional[str] = Field(None, min_length=1, max_length=255)
    description: Optional[str] = None
    episode_number: Optional[int] = Field(None, ge=1)
    status: Optional[EpisodeStatus] = None


class EpisodeResponse(EpisodeBase):
    id: int
    project_id: int
    created_at: datetime
    updated_at: datetime
    
    # Summary information
    shot_count: int = 0

    class Config:
        from_attributes = True


class EpisodeListResponse(BaseModel):
    id: int
    name: str
    description: Optional[str] = None
    episode_number: int
    status: EpisodeStatus
    project_id: int
    created_at: datetime
    updated_at: datetime
    
    # Summary information
    shot_count: int = 0

    class Config:
        from_attributes = True