# /opt/docker/dev/service_finder/backend/app/schemas/user.py
from pydantic import BaseModel, EmailStr, field_validator, ConfigDict
from typing import Optional
from datetime import date

class UserBase(BaseModel):
    email: EmailStr
    first_name: Optional[str] = None
    last_name: Optional[str] = None
    is_active: bool = True
    region_code: str = "HU"

class UserResponse(UserBase):
    id: int
    person_id: Optional[int] = None
    role: str
    subscription_plan: str
    scope_level: str
    scope_id: Optional[str] = None
    ui_mode: str = "personal"
    active_organization_id: Optional[int] = None
    model_config = ConfigDict(from_attributes=True)

class UserUpdate(BaseModel):
    first_name: Optional[str] = None
    last_name: Optional[str] = None
    preferred_language: Optional[str] = None
    ui_mode: Optional[str] = None

class ActiveOrganizationUpdate(BaseModel):
    organization_id: Optional[str] = None  # UUID/string or None to revert to personal mode

class UserWithTokenResponse(BaseModel):
    """User response with new JWT token for organization switching"""
    user: UserResponse
    access_token: str
    token_type: str = "bearer"