from pydantic import BaseModel, EmailStr
from typing import Optional, Literal


class RegisterRequest(BaseModel):
    name: str
    email: Optional[str] = None
    phone: Optional[str] = None
    password: str
    role: Literal["citizen", "driver", "admin"] = "citizen"
    # Dirección inicial (opcional, se guarda en el mismo request para evitar un segundo HTTP call)
    address_label: Optional[str] = None
    addressLabel: Optional[str] = None
    address_calle: Optional[str] = None
    addressCalle: Optional[str] = None
    address_colonia: Optional[str] = None
    addressColonia: Optional[str] = None
    address_lat: Optional[float] = None
    addressLat: Optional[float] = None
    address_lng: Optional[float] = None
    addressLng: Optional[float] = None


class LoginRequest(BaseModel):
    email: Optional[str] = None
    phone: Optional[str] = None
    password: str


class TokenResponse(BaseModel):
    access_token: str
    token_type: str = "bearer"
    user_id: str
    role: str
    # route_id se incluye opcionalmente para ciudadanos; permite al cliente
    # suscribirse al topic correcto inmediatamente después del login.
    route_id: Optional[str] = None
