from pydantic import BaseModel, EmailStr, Field
from typing import Optional, Dict, Any
from datetime import date

# --- STEP 1: LITE REGISTRATION ---
class UserLiteRegister(BaseModel):
    email: EmailStr
    password: str = Field(..., min_length=8)
    first_name: str
    last_name: str
    region_code: str = "HU"
    lang: str = Field("hu", description="Választott nyelv kódja")
    timezone: str = Field("Europe/Budapest", description="Felhasználó időzónája")

class UserLogin(BaseModel):
    email: EmailStr
    password: str

# --- STEP 2: KYC & ONBOARDING ---
class ICEContact(BaseModel):
    name: str
    phone: str
    relationship: Optional[str] = None

class DocumentDetail(BaseModel):
    number: str
    expiry_date: date

class UserKYCComplete(BaseModel):
    phone_number: str
    birth_place: str
    birth_date: date
    mothers_last_name: str
    mothers_first_name: str
    address_zip: str
    address_city: str
    address_street_name: str
    address_street_type: str
    address_house_number: str
    address_hrsz: Optional[str] = None
    identity_docs: Dict[str, DocumentDetail]
    ice_contact: ICEContact
    preferred_currency: Optional[str] = Field("HUF", max_length=3)

# --- COMMON & SECURITY ---
class PasswordResetRequest(BaseModel):
    email: EmailStr

class PasswordResetConfirm(BaseModel):
    email: EmailStr
    token: str
    password: str = Field(..., min_length=8)
    password_confirm: str = Field(..., min_length=8)

class Token(BaseModel):
    access_token: str
    token_type: str
    is_active: bool

class TokenPayload(BaseModel):
    """JWT Token payload struktúrája validációhoz."""
    sub: Optional[str] = None
    role: Optional[str] = None
    rank: Optional[int] = 0
    scope_level: Optional[str] = None
    scope_id: Optional[str] = None
    region: Optional[str] = None