{% extends 'base.html' %}
{% block content %}
<div class="row g-4">
  <div class="col-lg-4">
    <div class="card shadow-sm">
      <div class="card-body">
        <h2 class="h5">Bloqueos de {{ profile.display_name }}</h2>
        <form method="post" class="row g-3">
          <div class="col-12"><label class="form-label">Desde</label><input class="form-control" type="date" name="start_date" required></div>
          <div class="col-12"><label class="form-label">Hasta</label><input class="form-control" type="date" name="end_date" required></div>
          <div class="col-12"><label class="form-label">Motivo</label><input class="form-control" name="reason" required></div>
          <div class="col-12 d-grid"><button class="btn btn-primary">Guardar bloqueo</button></div>
        </form>
      </div>
    </div>
  </div>
  <div class="col-lg-8">
    <div class="card shadow-sm">
      <div class="card-header fw-bold">Licencias y bloqueos</div>
      <div class="table-responsive">
        <table class="table align-middle mb-0">
          <thead><tr><th>Desde</th><th>Hasta</th><th>Motivo</th><th></th></tr></thead>
          <tbody>
          {% for item in leaves %}
            <tr>
              <td>{{ item.start_date.strftime('%d/%m/%Y') }}</td>
              <td>{{ item.end_date.strftime('%d/%m/%Y') }}</td>
              <td>{{ item.reason }}</td>
              <td class="text-end">
                <form method="post" action="{{ url_for('admin_leave_delete', leave_id=item.id) }}" onsubmit="return confirm('¿Eliminar?')">
                  <button class="btn btn-sm btn-outline-danger">Eliminar</button>
                </form>
              </td>
            </tr>
          {% else %}
            <tr><td colspan="4" class="text-center text-muted py-4">No hay bloqueos cargados.</td></tr>
          {% endfor %}
          </tbody>
        </table>
      </div>
    </div>
  </div>
</div>
{% endblock %}
