"""Schemas für das öffentliche QR-Stempeln (statischer firmenweiter QR-Code).

Flow: Handy scannt QR (/stamp?t=<token>) → Seite zeigt Firmennamen →
Personalnummer + PIN → Kurz-Session (120s) → Ein-/Ausstempeln.
"""
from __future__ import annotations

from typing import Literal

from pydantic import BaseModel, Field

from app.schemas.time_entry import TimeEntryOut


class PublicStampCompanyInfo(BaseModel):
    """Header-Info für die Stempel-Seite (Token-Auflösung)."""
    company_name: str
    enabled: bool


class PublicStampAuthRequest(BaseModel):
    token: str = Field(..., min_length=8)
    personnel_number: str = Field(..., min_length=1, max_length=50)
    pin: str = Field(..., min_length=4, max_length=6, pattern=r"^\d+$")


class PublicStampStatus(BaseModel):
    """Aktueller Stempel-Status des Mitarbeiters."""
    open: bool
    on_break: bool
    today: list[TimeEntryOut] = []


class PublicStampAuthResponse(PublicStampStatus):
    session_token: str
    user_name: str
    expires_in_seconds: int


class PublicStampActionRequest(BaseModel):
    session_token: str
    action: Literal["in", "out", "break_start", "break_end"]
    note: str | None = None


class PublicStampActionResponse(PublicStampStatus):
    warnings: list[str] = []
