<!-- backend/templates/vista_leads.html -->
<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Leads del Usuario</title>
  <style>
    body {
      font-family: Arial, sans-serif;
      padding: 2rem;
      background: #f2f2f2;
    }
    h2 {
      color: #333;
    }
    table {
      width: 100%;
      border-collapse: collapse;
      margin-top: 1rem;
    }
    th, td {
      border: 1px solid #ccc;
      padding: 0.75rem;
      text-align: left;
    }
    th {
      background-color: #007bff;
      color: white;
    }
    tr:nth-child(even) {
      background-color: #f9f9f9;
    }
    .boton {
      background: #28a745;
      color: white;
      padding: 0.4rem 0.8rem;
      text-decoration: none;
      border-radius: 4px;
      font-size: 0.9rem;
    }
  </style>
</head>
<body>
  <h2>Leads creados por ti</h2>
  <table>
    <thead>
      <tr>
        <th>Código</th>
        <th>Nombre</th>
        <th>Comuna</th>
        <th>Teléfono</th>
        <th>Conversar</th>
        <th>Email</th>
        <th>Fecha Ingreso</th>
        <th>Fecha Evento</th>
        <th>Plataforma</th>
        <th>Monto</th>
        <th>Segmentación</th>
        <th>Estado</th>
        <th>Creado Por</th>
      </tr>
    </thead>
    <tbody>
      {% for lead in leads %}
      <tr>
        <td>{{ lead.codigo_cliente }}</td>
        <td>{{ lead.nombre }}</td>
        <td>{{ lead.comuna }}</td>
        <td>{{ lead.telefono }}</td>
        <td><a class="boton" href="https://wa.me/56{{ lead.telefono }}" target="_blank">Ir a WhatsApp</a></td>
        <td>{{ lead.email }}</td>
        <td>{{ lead.fecha_ingreso.strftime('%d/%m/%Y') }}</td>
        <td>{{ lead.fecha_evento.strftime('%d/%m/%Y') }}</td>
        <td>{{ lead.plataforma }}</td>
        <td>${{ '{:,.0f}'.format(lead.monto_cotizado) }}</td>
        <td>{{ lead.segmentacion }}</td>
        <td>{{ lead.estado }}</td>
        <td>{{ lead.creado_por }}</td>
      </tr>
      {% endfor %}
    </tbody>
  </table>
</body>
</html>
