from pydantic import BaseModel
from typing import Optional, List
from datetime import datetime


class TranslationCreate(BaseModel):
    source_text: str
    category: str
    text_en: Optional[str] = None
    text_mn: Optional[str] = None
    text_ru: Optional[str] = None


class TranslationUpdate(BaseModel):
    source_text: Optional[str] = None
    category: Optional[str] = None
    text_en: Optional[str] = None
    text_mn: Optional[str] = None
    text_ru: Optional[str] = None


class TranslationResponse(BaseModel):
    id: int
    source_text: str
    category: str
    text_en: Optional[str] = None
    text_mn: Optional[str] = None
    text_ru: Optional[str] = None
    created_at: datetime
    updated_at: datetime

    class Config:
        from_attributes = True


class TranslationListResponse(BaseModel):
    total: int
    page: int
    page_size: int
    translations: List[TranslationResponse]


class TranslationBulkRequest(BaseModel):
    """Bulk translation lookup request"""
    texts: List[str]
    category: Optional[str] = None
    lang: str = "en"


class TranslationBulkResponse(BaseModel):
    """Returns a dictionary mapping source text to translated text"""
    translations: dict  # {source_text: translated_text}
