<!DOCTYPE html>
<html lang="es">
<head>
  <meta charset="UTF-8">
  <title>Reporte de Paciente</title>
  <style>
    body {
      font-family: "Segoe UI", Arial, sans-serif;
      margin: 25px;
      color: #333;
    }
    header {
      border-bottom: 2px solid #2196f3;
      text-align: center;
      margin-bottom: 20px;
    }
    h1 { color: #2196f3; margin: 0; }
    table { width: 100%; border-collapse: collapse; margin-top: 10px; }
    th, td { border: 1px solid #ddd; padding: 8px; text-align: left; }
    th { background: #f5f5f5; }
    footer {
      text-align: center;
      font-size: 12px;
      color: #777;
      margin-top: 40px;
      border-top: 1px solid #ccc;
      padding-top: 10px;
    }
  </style>
</head>
<body>
  <header>
    <h1>Ficha Hospitalaria</h1>
    <p>Generado el {{formatearFecha fecha}}</p>
  </header>

  <section>
    <h2>Datos del Paciente</h2>
    <p><strong>Nombre:</strong> {{upper nombre}}</p>
    <p><strong>Edad:</strong> {{edad}} años</p>
    {{#ifCond edad ">=" 18}}
      <p><strong>Condición:</strong> Adulto</p>
    {{else}}
      <p><strong>Condición:</strong> Menor de edad</p>
    {{/ifCond}}
  </section>

  <section>
    <h2>Constantes Vitales</h2>
    <table>
      <thead>
        <tr>
          <th>Tipo</th>
          <th>Valor</th>
          <th>Fecha</th>
        </tr>
      </thead>
      <tbody>
        {{#each constantes}}
        <tr>
          <td>{{this.tipo}}</td>
          <td>{{this.valor}}</td>
          <td>{{formatearFecha this.fecha}}</td>
        </tr>
        {{/each}}
      </tbody>
    </table>
  </section>

  <footer>
    Hospital Central © {{anioActual}}
  </footer>
</body>
</html>
