<section class="section">
  <p class="eyebrow">Festival Control Center</p>
  <h1><%= event.title %></h1>
  <div class="festival-stats">
    <div class="city-tile"><strong><%= settings?.enabled ? 'Activ' : 'Inactiv' %></strong><span>festival mode</span></div>
    <div class="city-tile"><strong><%= settings?.max_entries_per_day || 3 %></strong><span>intrari maxime/zi</span></div>
    <div class="city-tile"><strong><%= occupancy.totalInside %></strong><span>participanti inside</span></div>
    <div class="city-tile"><strong><%= occupancy.entriesToday + occupancy.exitsToday %></strong><span>scanari azi</span></div>
  </div>
  <p><a class="button" href="/organizer/events/<%= event.id %>/scanner">Deschide scanner festival</a></p>
</section>

<section class="section split-sections">
  <form class="checkout-form" method="post" action="/organizer/events/<%= event.id %>/festival/zones">
    <%- include('../partials/csrf-field') %>
    <h2>Zones</h2>
    <label>Nume <input name="name" placeholder="General" required></label>
    <label>Cod <input name="code" placeholder="GENERAL" required></label>
    <label>Capacitate <input type="number" name="capacity_limit" min="0"></label>
    <label>Culoare <input name="color" value="#4f46e5"></label>
    <button type="submit">Creeaza/editeaza zona</button>
  </form>

  <form class="checkout-form" method="post" action="/organizer/events/<%= event.id %>/festival/gates">
    <%- include('../partials/csrf-field') %>
    <h2>Gates</h2>
    <label>Nume <input name="name" placeholder="Poarta 1" required></label>
    <label>Cod <input name="code" placeholder="GATE-1" required></label>
    <label>Tip <select name="type"><option value="entry">entry</option><option value="exit">exit</option><option value="mixed">mixed</option></select></label>
    <label>Zona <select name="zone_id"><option value="">Fara zona</option><% zones.forEach((z) => { %><option value="<%= z.id %>"><%= z.name %></option><% }) %></select></label>
    <button type="submit">Creeaza/editeaza poarta</button>
  </form>
</section>

<section class="section">
  <h2>Ticket Access</h2>
  <div class="event-grid">
    <% ticketTypes.forEach((ticketType) => { const active = mappings.filter((m) => Number(m.ticket_type_id) === Number(ticketType.id)).map((m) => Number(m.zone_id)); %>
      <form class="checkout-form" method="post" action="/organizer/events/<%= event.id %>/festival/entitlements">
        <%- include('../partials/csrf-field') %>
        <input type="hidden" name="ticket_type_id" value="<%= ticketType.id %>">
        <h3><%= ticketType.name %></h3>
        <% zones.forEach((zone) => { %>
          <label><input type="checkbox" name="zone_ids" value="<%= zone.id %>" <%= active.includes(Number(zone.id)) ? 'checked' : '' %>> <%= zone.name %></label>
        <% }) %>
        <button type="submit">Salveaza zone</button>
      </form>
    <% }) %>
  </div>
</section>

<section class="section split-sections">
  <div class="checkout-form"><h2>Live Stats</h2><p>Total inside: <strong><%= occupancy.totalInside %></strong></p><p>Intrari azi: <strong><%= occupancy.entriesToday %></strong></p><p>Iesiri azi: <strong><%= occupancy.exitsToday %></strong></p></div>
  <div class="checkout-form"><h2>Zones</h2><% occupancy.byZone.forEach((z) => { %><p><strong><%= z.name %></strong>: <%= z.inside %> inside</p><% }) %></div>
</section>
