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

class LicenseActivationRequest(BaseModel):
    license_key: str
    machine_id: str
    hardware_hash: str
    os_info: Optional[Dict[str, Any]] = None
    app_version: Optional[str] = None

class LicenseActivationResponse(BaseModel):
    success: bool
    message: str
    activation_id: Optional[int] = None
    expires_at: Optional[datetime] = None
    features: Optional[Dict[str, Any]] = None

class LicenseVerificationRequest(BaseModel):
    license_key: str
    machine_id: str
    hardware_hash: str
    activation_id: int

class LicenseVerificationResponse(BaseModel):
    valid: bool
    message: str
    expires_at: Optional[datetime] = None
    features: Optional[Dict[str, Any]] = None
    requires_update: bool = False
    update_url: Optional[str] = None

class VersionCheckRequest(BaseModel):
    current_version: str
    license_key: str

class VersionCheckResponse(BaseModel):
    latest_version: str
    current_version: str
    update_available: bool
    is_mandatory: bool
    download_url: Optional[str] = None
    release_notes: Optional[str] = None

class SessionStartRequest(BaseModel):
    license_key: str
    machine_id: str
    hardware_id: str
    hardware_hash: str
    version: str
    ip_address: Optional[str] = None

class SessionStartResponse(BaseModel):
    success: bool
    message: str
    session_token: Optional[str] = None
    requires_update: bool = False
    update_url: Optional[str] = None
    whats_new: Optional[str] = None

class SessionHeartbeatRequest(BaseModel):
    session_token: str
    license_key: str

class SessionHeartbeatResponse(BaseModel):
    success: bool
    message: str

class SessionEndRequest(BaseModel):
    session_token: str

class SessionEndResponse(BaseModel):
    success: bool
    message: str