from datetime import datetime
from typing import Optional
from uuid import UUID
from pydantic import BaseModel, Field


class TargetEntry(BaseModel):
    label: str = Field(..., min_length=1, max_length=255)
    notes: Optional[str] = Field(None, max_length=500)


class TargetListCreate(BaseModel):
    name: str = Field(..., min_length=1, max_length=255)
    description: Optional[str] = None
    targets: list[TargetEntry] = Field(..., min_length=1)


class TargetListUpdate(BaseModel):
    name: Optional[str] = Field(None, min_length=1, max_length=255)
    description: Optional[str] = None
    targets: Optional[list[TargetEntry]] = Field(None, min_length=1)


class TargetListResponse(BaseModel):
    id: UUID
    team_id: UUID
    created_by: Optional[UUID]
    name: str
    description: Optional[str]
    targets: list[TargetEntry]
    created_at: datetime
    updated_at: datetime

    model_config = {"from_attributes": True}
