"""
routes/interview.py — Interview Stage HTML Page Router
GET /interview/assessment   → people_hub_assessment.html
GET /interview/roleplay     → people_hub_assessment.html (role-play variant)
GET /interview/coding       → people_hub_coding_assessment.html
GET /interview/technical    → technical_interview.html
GET /interview/human        → human_interview.html
GET /interview/hr           → hr_round.html
"""
from __future__ import annotations
from fastapi import APIRouter, Depends
from fastapi.responses import HTMLResponse, RedirectResponse
from fastapi.requests import Request
from middleware.auth_middleware import get_current_candidate
from services.auth_service import get_redirect_url
from pathlib import Path

router = APIRouter(prefix="/interview", tags=["interview"])
STATIC = Path(__file__).parent.parent / "static" / "html"


def _serve(filename: str) -> HTMLResponse:
    path = STATIC / filename
    if not path.exists():
        return HTMLResponse(
            f"<h2>Page not available: {filename}</h2>"
            f"<p>Place the HTML file in <code>static/html/{filename}</code></p>",
            status_code=404,
        )
    return HTMLResponse(path.read_text(encoding="utf-8"))


@router.get("/assessment")
def assessment_page():
    return _serve("people_hub_assessment.html")


@router.get("/roleplay")
def roleplay_page():
    # Role play uses the session HTML (served from static)
    return _serve("people_hub_session.html")


@router.get("/coding")
def coding_page():
    return _serve("people_hub_coding_assessment.html")


@router.get("/technical")
def technical_page():
    return _serve("people_hub_technical.html")


@router.get("/human")
def human_page():
    return _serve("people_hub_human.html")


@router.get("/hr")
def hr_page():
    return _serve("people_hub_hr.html")
