<tr id="aff-{{ product.id }}">
  <td style="max-width:240px;overflow:hidden;text-overflow:ellipsis;white-space:nowrap" title="{{ product.name }}">
    <a href="{{ url_for('admin.affiliate_edit', product_id=product.id) }}" style="color:#0F172A;text-decoration:none;font-weight:500;">{{ product.name }}</a>
  </td>
  <td class="text-slate">{{ product.brand or '—' }}</td>
  <td class="text-slate">{{ product.retailer or '—' }}</td>
  <td class="text-slate">{{ product.category }}</td>
  <td class="mono">
    {% if product.price_cents %}{{ "%.0f" | format(product.price_cents / 100) }}€{% else %}—{% endif %}
  </td>
  <td>
    <button hx-post="{{ url_for('admin.affiliate_toggle', product_id=product.id) }}"
            hx-target="#aff-{{ product.id }}" hx-swap="outerHTML"
            hx-headers='{"X-CSRF-Token": "{{ csrf_token() }}"}'
            class="badge {% if product.status == 'active' %}badge-success{% elif product.status == 'draft' %}badge-warning{% else %}badge{% endif %}"
            style="cursor:pointer;border:none;">
      {{ product.status }}
    </button>
  </td>
  <td class="mono text-right">{{ product.click_count or 0 }}</td>
  <td class="text-right" style="white-space:nowrap">
    <a href="{{ url_for('admin.affiliate_edit', product_id=product.id) }}" class="btn-outline btn-sm">Edit</a>
    <form method="post" action="{{ url_for('admin.affiliate_delete', product_id=product.id) }}" style="display:inline" hx-boost="true">
      <input type="hidden" name="csrf_token" value="{{ csrf_token() }}">
      <button type="submit" class="btn-outline btn-sm"
              onclick="return confirm('Delete this product?')">Delete</button>
    </form>
  </td>
</tr>
