# /opt/docker/dev/service_finder/backend/app/schemas/auth.py
from pydantic import BaseModel, EmailStr, Field, ConfigDict
from typing import Optional, Dict, List
from datetime import date, datetime

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

class ICEContact(BaseModel):
    name: str
    phone: str
    relationship: str

class UserLiteRegister(BaseModel):
    """ Step 1: Gyors regisztráció (Alap azonosítás). """
    email: EmailStr
    password: str = Field(..., min_length=8, description="Minimum 8 karakter hosszú jelszó")
    first_name: str
    last_name: str
    region_code: Optional[str] = "HU"
    lang: Optional[str] = "hu"
    timezone: Optional[str] = "Europe/Budapest"
    
    model_config = ConfigDict(from_attributes=True)

class UserKYCComplete(BaseModel):
    """ Step 2: Teljes körű személyazonosítás és címadatok. """
    phone_number: str = Field(..., pattern=r"^\+?[0-9]{7,15}$")
    birth_place: str
    birth_date: date
    mothers_last_name: str
    mothers_first_name: str
    
    # Atomizált címadatok a pontos GPS-hez és Robot-munkához
    address_zip: str
    address_city: str
    address_street_name: str
    address_street_type: str # utca, út, tér...
    address_house_number: str
    address_stairwell: Optional[str] = None
    address_floor: Optional[str] = None
    address_door: Optional[str] = None
    address_hrsz: Optional[str] = None # Külterület/Helyrajzi szám
    
    # Okmányok és Vészhelyzet
    identity_docs: Dict[str, DocumentDetail] # pl: {"ID_CARD": {...}, "LICENSE": {...}}
    ice_contact: ICEContact
    
    preferred_language: str = "hu"
    preferred_currency: str = "HUF"

class Token(BaseModel):
    access_token: str
    refresh_token: Optional[str] = None
    token_type: str = "bearer"
    is_active: bool