"""Authentication schemas for request/response models."""

from uuid import UUID

from pydantic import BaseModel, EmailStr, Field


class LoginRequest(BaseModel):
    """Login request with email and password."""

    email: EmailStr = Field(..., description="User email address")
    password: str = Field(..., min_length=1, description="User password")


class TokenResponse(BaseModel):
    """Authentication token response."""

    access_token: str = Field(..., description="JWT access token")
    refresh_token: str = Field(..., description="JWT refresh token")
    token_type: str = Field(default="bearer", description="Token type")
    expires_in: int = Field(..., description="Access token TTL in seconds")


class RefreshRequest(BaseModel):
    """Token refresh request."""

    refresh_token: str = Field(..., description="JWT refresh token")


class AccessTokenResponse(BaseModel):
    """Response containing only a new access token."""

    access_token: str = Field(..., description="JWT access token")
    token_type: str = Field(default="bearer", description="Token type")
    expires_in: int = Field(..., description="Access token TTL in seconds")


class UserResponse(BaseModel):
    """Current user information from token."""

    id: UUID = Field(..., description="User ID")
    tenant_id: UUID = Field(..., description="Tenant ID")
    email: str = Field(..., description="User email address")
    name: str | None = Field(default=None, description="User display name")
    permissions: list[str] = Field(default_factory=list, description="User permissions")
    roles: list[str] = Field(default_factory=list, description="User roles")


class LogoutResponse(BaseModel):
    """Logout response."""

    message: str = Field(default="Successfully logged out", description="Logout message")
