"""Simple root and API index views."""
from django.http import HttpResponse


def root(request):
    """Home page with links to API and admin."""
    html = """
    <!DOCTYPE html>
    <html>
    <head><title>Voice Agent Backend</title></head>
    <body style="font-family: sans-serif; max-width: 600px; margin: 2rem auto; padding: 0 1rem;">
        <h1>Voice Agent Backend</h1>
        <p>Django backend is running.</p>
        <ul>
            <li><a href="/api/">API index</a></li>
            <li><a href="/api/agents/">List agents</a></li>
            <li><a href="/admin/">Django admin</a></li>
        </ul>
        <p>Start a session: <code>POST /api/sessions/start/</code></p>
        <p>Get token: <code>GET /api/token/?room=...&identity=...</code></p>
    </body>
    </html>
    """
    return HttpResponse(html.strip(), content_type="text/html")


def api_index(request):
    """API root with endpoint list."""
    html = """
    <!DOCTYPE html>
    <html>
    <head><title>Voice Agent API</title></head>
    <body style="font-family: sans-serif; max-width: 640px; margin: 2rem auto; padding: 0 1rem;">
        <h1>Voice Agent API</h1>
        <ul>
            <li><a href="/api/agents/">GET /api/agents/</a> — List agents</li>
            <li>POST /api/sessions/start/ — Start session (returns token, room_name, conversation_id)</li>
            <li>GET /api/token/?room=...&identity=... — Get LiveKit token</li>
            <li>GET /api/conversations/&lt;id&gt;/transcript/ — Get transcript</li>
            <li>GET /api/agents/&lt;name&gt;/config/ — Agent config</li>
        </ul>
        <p><a href="/">Back to home</a></p>
    </body>
    </html>
    """
    return HttpResponse(html.strip(), content_type="text/html")
