<!DOCTYPE html>
<html lang="it">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <meta name="robots" content="noindex, nofollow">
    <title>Token YouTube — Match Live TV</title>
    <style>
      body { font-family: system-ui, sans-serif; background: #0a0a0e; color: #f0f0f5; margin: 0; padding: 32px 20px; line-height: 1.5; }
      .wrap { max-width: 720px; margin: 0 auto; }
      h1 { font-size: 1.5rem; margin: 0 0 16px; }
      pre { background: #111; color: #eee; padding: 12px; overflow: auto; border-radius: 8px; word-break: break-all; }
      .muted { color: #999; }
      a { color: #ff6b6b; }
      .ok { color: #81c784; font-weight: 600; }
    </style>
  </head>
  <body>
    <div class="wrap">
      <h1>Token canale Match Live TV</h1>

      <% if @channel_title.present? %>
        <p>Canale: <strong><%= @channel_title %></strong></p>
      <% end %>

      <% if @refresh_token.present? %>
        <p class="ok">Collegamento riuscito. Copia subito questa riga:</p>
        <p>Aggiungi in <code>/opt/matchlivetv/infra/.env</code>:</p>
        <pre id="yt-token">YOUTUBE_PLATFORM_REFRESH_TOKEN=<%= @refresh_token %></pre>
        <p class="muted">Non verrà mostrato di nuovo. Poi: <code>docker compose -f docker-compose.prod.yml restart rails sidekiq</code></p>
      <% else %>
        <p class="muted">
          Google non ha restituito un refresh token. In
          <a href="https://myaccount.google.com/permissions" target="_blank" rel="noopener">account Google → accesso app</a>
          revoca «Match Live TV», poi ripeti da
          <a href="/admin/youtube/platform">/admin/youtube/platform</a>.
        </p>
      <% end %>

      <p><a href="/admin/">← Dashboard admin</a></p>
    </div>
  </body>
</html>
