<% content_for :title, "Abbonamento — #{@team.name}" %>

<div class="wrap" style="padding-top:20px">
  <h1>Abbonamento</h1>
  <p>Squadra: <strong><%= @team.name %></strong> · Piano attuale: <strong><%= @entitlements.plan.name %></strong></p>

  <div class="plans">
    <% @plans.each do |plan| %>
      <div class="plan-card <%= 'featured' if plan.slug == @entitlements.plan.slug %>">
        <h3><%= plan.name %></h3>
        <% if plan.slug == "free" %>
          <div class="plan-price">€0</div>
        <% elsif plan.slug == "premium_light" %>
          <div class="plan-price" style="color:#e53935">€40/anno</div>
          <p style="color:#888;font-size:0.85rem">oppure €5/mese</p>
        <% else %>
          <div class="plan-price">€200/anno</div>
          <p style="color:#888;font-size:0.85rem">oppure €20/mese</p>
        <% end %>
        <ul>
          <li>Staff trasmissione: <%= plan.max_staff_transmission || "illimitato" %> / anno</li>
          <li>Staff regia: <%= plan.max_staff_regia || "illimitato" %> / anno</li>
          <li>Partite: <%= plan.concurrent_streams_limit || "illimitate" %> in contemporanea</li>
          <li>Replay: <%= plan.recordings_enabled? ? "#{plan.recording_days} giorni" : "no" %></li>
          <li>YouTube: <% if plan.slug == "premium_light" %>Match TV Light<% elsif plan.youtube_enabled? %>canale società<% else %>no<% end %></li>
        </ul>
        <% if plan.slug == @entitlements.plan.slug %>
          <span class="btn btn-secondary" style="opacity:0.7">Piano attuale</span>
        <% elsif plan.slug == "free" %>
          <p style="color:#888;font-size:0.85rem">Contatta il supporto per downgrade.</p>
        <% elsif MatchLiveTv.stripe_enabled? %>
          <%= link_to "Attiva #{plan.name}", public_team_checkout_path(@team, plan: plan.slug), class: "btn btn-primary" %>
        <% else %>
          <p style="color:#888">Stripe non configurato</p>
        <% end %>
      </div>
    <% end %>
  </div>

  <div class="card" style="margin-top:24px;text-align:center">
    <p style="color:#aaa">Esigenze diverse? <%= mail_to "info@matchlivetv.eminux.it", "Contattaci" %> per un'offerta su misura.</p>
  </div>

  <% if @entitlements.premium_active? && MatchLiveTv.stripe_enabled? %>
    <p style="margin-top:20px"><%= button_to "Gestisci su Stripe", public_team_portal_path(@team), class: "btn btn-secondary" %></p>
  <% end %>

  <p><%= link_to "← Dashboard", public_team_dashboard_path(@team) %></p>
</div>
