<div class="mb-6 sm:mb-8">
  <h1 class="text-2xl sm:text-3xl font-display font-semibold">Rekomendasi Broker</h1>
  <p class="text-muted text-sm mt-1">Broker yang sudah kami uji & rekomendasikan untuk Anda. Daftar lewat link ini untuk dapat benefit IB.</p>
</div>

<% if (!brokers || brokers.length === 0) { %>
  <div class="card empty-state">
    <div class="empty-icon">🏦</div>
    <h2>Belum ada rekomendasi broker</h2>
    <p>Tim kami sedang menyiapkan daftar broker rekomendasi. Cek kembali nanti.</p>
  </div>
<% } else { %>
  <div class="space-y-5">
    <% brokers.forEach(function(b){ %>
      <div class="card p-5 sm:p-6">
        <div class="flex items-start gap-4 mb-4">
          <% if (b.logo_path) { %>
            <img src="<%= b.logo_path %>" alt="<%= b.name %>" class="h-16 w-16 sm:h-20 sm:w-20 object-cover rounded-2xl border border-white/10 bg-white/5 shrink-0">
          <% } else { %>
            <div class="h-16 w-16 sm:h-20 sm:w-20 rounded-2xl border border-white/10 bg-gradient-to-br from-gold-300/15 to-transparent grid place-items-center text-gold-300 text-2xl shrink-0">🏦</div>
          <% } %>
          <div class="flex-1 min-w-0">
            <h2 class="text-xl font-display font-semibold truncate"><%= b.name %></h2>
            <% if (b.tagline) { %>
              <p class="text-sm text-gold-200 mt-1"><%= b.tagline %></p>
            <% } %>
            <% if (b.description) { %>
              <p class="text-sm text-muted mt-2 leading-relaxed"><%= b.description %></p>
            <% } %>
          </div>
        </div>

        <% if (b.register_url) { %>
          <a href="<%= b.register_url %>" target="_blank" rel="noopener"
             class="btn btn-gold w-full sm:w-auto h-11 rounded-full px-6 text-sm mb-4">
            <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="h-4 w-4"><path d="M18 13v6a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2V8a2 2 0 0 1 2-2h6"/><polyline points="15 3 21 3 21 9"/><line x1="10" y1="14" x2="21" y2="3"/></svg>
            Daftar Sekarang via Link Kami
          </a>
        <% } %>

        <% if (b.register_instructions || b.change_ib_instructions) { %>
          <div class="grid md:grid-cols-2 gap-4 mt-2">
            <% if (b.register_instructions) { %>
              <details class="card-soft p-4">
                <summary class="cursor-pointer font-medium text-sm flex items-center gap-2">
                  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="h-4 w-4 text-emerald-300"><path d="M16 21v-2a4 4 0 0 0-4-4H6a4 4 0 0 0-4 4v2"/><circle cx="9" cy="7" r="4"/><line x1="20" y1="8" x2="20" y2="14"/><line x1="23" y1="11" x2="17" y2="11"/></svg>
                  Cara Daftar
                </summary>
                <div class="text-sm text-muted mt-3 leading-relaxed whitespace-pre-line"><%= b.register_instructions %></div>
              </details>
            <% } %>
            <% if (b.change_ib_instructions) { %>
              <details class="card-soft p-4">
                <summary class="cursor-pointer font-medium text-sm flex items-center gap-2">
                  <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" class="h-4 w-4 text-gold-300"><polyline points="17 1 21 5 17 9"/><path d="M3 11V9a4 4 0 0 1 4-4h14"/><polyline points="7 23 3 19 7 15"/><path d="M21 13v2a4 4 0 0 1-4 4H3"/></svg>
                  Cara Pindah IB
                </summary>
                <div class="text-sm text-muted mt-3 leading-relaxed whitespace-pre-line"><%= b.change_ib_instructions %></div>
              </details>
            <% } %>
          </div>
        <% } %>
      </div>
    <% }); %>
  </div>

  <div class="card-soft p-4 mt-6 text-xs text-muted leading-relaxed">
    💡 <b>Tips:</b> Pakai link daftar dari kami supaya Anda otomatis tercatat di bawah IB Trader Rebahan. Setelah daftar, jangan lupa <a href="/member/ib-request" class="text-gold-300 hover:text-gold-200 underline">request kode aktivasi IB</a> untuk benefit tambahan.
  </div>
<% } %>
