from pydantic import BaseModel, Field
from typing import Optional
from datetime import date


class SignupRequest(BaseModel):
    username: str = Field(min_length=3, max_length=32, pattern=r"^[a-zA-Z0-9_-]+$")
    email: str = Field(min_length=5, max_length=255)
    password: str = Field(min_length=6, max_length=128)
    confirm_password: str = Field(min_length=6, max_length=128)


class LoginRequest(BaseModel):
    email: str = Field(min_length=5, max_length=255)
    password: str = Field(min_length=6, max_length=128)
    remember_me: bool = False


class PostCreate(BaseModel):
    content: str = Field(min_length=1, max_length=2000)
    title: Optional[str] = Field(default=None, max_length=500)
    topic: str = Field(pattern=r"^(devlog|showcase|question|rant|fun|random)$")
    project_uid: Optional[str] = None


class CommentCreate(BaseModel):
    content: str = Field(min_length=1, max_length=1000)
    parent_uid: Optional[str] = None


class ProjectCreate(BaseModel):
    title: str = Field(min_length=1, max_length=200)
    description: str = Field(min_length=1, max_length=5000)
    release_date: Optional[date] = None
    demo_date: Optional[date] = None
    project_type: str = Field(pattern=r"^(game|game_asset|software|mobile_app|website)$")
    platforms: str = Field(default="", max_length=500)


class MessageCreate(BaseModel):
    content: str = Field(min_length=1, max_length=2000)
    receiver_uid: str


class ProfileUpdate(BaseModel):
    bio: Optional[str] = Field(default=None, max_length=500)
    location: Optional[str] = Field(default=None, max_length=200)
    git_link: Optional[str] = Field(default=None, max_length=500)
    website: Optional[str] = Field(default=None, max_length=500)
