{{define "admin.html"}}
{{template "shell-start" .}}
<header class="page-head">
  <div><p class="eyebrow">ADMIN</p><h1>Team approvals</h1><p>Review time-off and remote-day requests.</p></div>
  <div class="filter-tabs"><a href="/admin/requests" class="active">All</a><a href="/admin/requests?status=pending">Pending</a><a href="/admin/requests?status=approved">Approved</a></div>
</header>
{{template "notice" .}}
<section class="card approval-card">
  {{if .Requests}}
  <div class="request-list">
    {{range .Requests}}
    <article class="approval-row">
      <span class="avatar small">{{initial .UserName}}</span>
      <div class="approval-main">
        <div class="approval-title"><strong>{{.UserName}}</strong><span class="badge kind">{{kindLabel .Kind}}</span><span class="badge {{.Status}}">{{statusLabel .Status}}</span></div>
        <p>{{dateFA .StartDate}}{{if ne .StartDate .EndDate}} — {{dateFA .EndDate}}{{end}} · {{.DayCount}} day(s)</p>
        {{if .Reason}}<blockquote>“{{.Reason}}”</blockquote>{{end}}
        {{if eq .Status "pending"}}
        <form method="post" action="/admin/requests/{{.ID}}/review" class="review-form">
          <input type="hidden" name="csrf" value="{{$.CSRF}}">
          <input name="note" maxlength="500" placeholder="Optional note to teammate">
          <button class="button approve" name="decision" value="approved">Approve</button>
          <button class="button reject" name="decision" value="rejected">Reject</button>
        </form>
        {{else if .AdminNote}}<p class="admin-note">Review note: {{.AdminNote}}</p>{{end}}
      </div>
    </article>
    {{end}}
  </div>
  {{else}}<div class="empty roomy"><span>✓</span><h3>All clear</h3><p>No requests match this view.</p></div>{{end}}
</section>
{{template "shell-end" .}}
{{end}}
