from pydantic import BaseModel, EmailStr, Field, field_validator
from typing import Optional, List
from datetime import date

class UserRegister(BaseModel):
    # --- AUTH ---
    email: EmailStr = Field(..., example="teszt.user@profibot.hu")
    password: Optional[str] = Field(None, min_length=8, description="Social login esetén üres maradhat")
    
    # --- IDENTITY (KYC Step 2) ---
    last_name: str = Field(..., min_length=2)
    first_name: str = Field(..., min_length=2)
    mothers_name: str = Field(..., description="Anyja születési neve")
    birth_place: Optional[str] = None
    birth_date: Optional[date] = None
    
    # --- OKMÁNYOK (Banki szint) ---
    id_card_number: Optional[str] = None
    id_card_expiry: Optional[date] = None
    
    driver_license_number: Optional[str] = None
    driver_license_expiry: Optional[date] = None
    driver_license_categories: List[str] = Field(default_factory=list, example=["B", "A"])
    
    # --- SPECIÁLIS ENGEDÉLYEK ---
    boat_license_number: Optional[str] = None
    pilot_license_number: Optional[str] = None

    # --- SYSTEM ---
    region_code: str = Field(default="HU")
    invite_token: Optional[str] = None
    social_provider: Optional[str] = None 
    social_id: Optional[str] = None

    @field_validator('region_code')
    @classmethod
    def validate_region(cls, v: str) -> str:
        return v.upper() if v else "HU"

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

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