from pydantic import BaseModel, computed_field


class Recipient(BaseModel):
    name: str
    company: str
    street: str
    city: str


class LetterMeta(BaseModel):
    recipient: Recipient
    subject: str
    date: str
    greeting: str
    closing: str
    appended: str


class ContactInfo(BaseModel):
    address: str
    address_full: str
    phone: str
    phone_url: str
    email: str
    github: str
    github_url: str
    linkedin: str
    linkedin_url: str


class Skill(BaseModel):
    name: str
    level: int
    specification: str | None = None

    @computed_field
    @property
    def css_class(self) -> str:
        return f"skilllevel_{self.level}"


class Certificate(BaseModel):
    name: str
    url: str


class OtherSkill(BaseModel):
    text: str


class Language(BaseModel):
    name: str
    level: int
    specification: str | None = None

    @computed_field
    @property
    def css_class(self) -> str:
        return f"skilllevel_{self.level}"


class SubExperience(BaseModel):
    time: str
    title: str
    bullets: list[str] = []


class Experience(BaseModel):
    time: str
    title: str
    institution: str | None = None
    description: str | None = None
    grades: str | None = None
    sub_experiences: list[SubExperience] = []


class OtherActivity(BaseModel):
    time: str
    title: str
    institution: str | None = None
    description: str | None = None


class CVData(BaseModel):
    first_name: str
    last_name: str
    description: str
    photo: str
    signature: str
    contact: ContactInfo
    letter: LetterMeta
    skills: list[Skill]
    certificates: list[Certificate]
    other_skills: list[OtherSkill] = []
    languages: list[Language]
    work_experience: list[Experience]
    education: list[Experience]
    other_activities: list[OtherActivity]
