"""POST /scan-mobile-reachability — B1 Playwright Mobile-Verifikation.

Eigenes Modul-File damit main.py unter 500 LOC bleibt.
"""

from __future__ import annotations

import logging
from datetime import datetime, timezone

from fastapi import APIRouter
from pydantic import BaseModel

from services.mobile_reachability_scanner import scan_mobile_reachability

logger = logging.getLogger(__name__)
router = APIRouter()


class MobileReachReq(BaseModel):
    url: str


@router.post("/scan-mobile-reachability")
async def scan_mobile(req: MobileReachReq):
    logger.info("Mobile-reachability scan for %s", req.url)
    res = await scan_mobile_reachability(req.url)
    res["scanned_at"] = datetime.now(timezone.utc).isoformat()
    return res
