<%- include('partials/header', { title, flash, session, csrf }) %>
<div class="grid cards">
  <section class="card"><span>حالة واتساب</span><strong class="status status-<%= whatsappStatus.state %>"><%= whatsappStatus.state %></strong><small><%= whatsappStatus.phone || 'لم يتم الربط' %></small></section>
  <section class="card"><span>جروبات العملاء</span><strong><%= groupCounts.clients || 0 %></strong></section>
  <section class="card"><span>جروبات المزودين</span><strong><%= groupCounts.providers || 0 %></strong></section>
  <section class="card"><span>طلبات اليوم</span><strong><%= requestCounts.total_today || 0 %></strong><small>تحتاج مراجعة: <%= requestCounts.attention_today || 0 %></small></section>
  <section class="card"><span>متابعة Partial النشطة</span><strong><%= partialCounts.active || 0 %></strong><small>تم الحل: <%= partialCounts.resolved || 0 %></small></section>
  <section class="card"><span>متابعة الإلغاء النشطة</span><strong><%= cancelCounts.active || 0 %></strong><small>تم الحل: <%= cancelCounts.resolved || 0 %></small></section>
</div>
<section class="card">
  <div class="section-head"><h2>آخر الطلبات</h2><a class="button" href="/logs">عرض السجلات</a></div>
  <div class="table-wrap"><table><thead><tr><th>#</th><th>النوع</th><th>العميل</th><th>الحالة</th><th>التاريخ</th></tr></thead><tbody>
  <% recentRequests.forEach(row => { %><tr><td><%= row.id %></td><td><%= row.request_type %></td><td><%= row.linked_username || '-' %></td><td><%= row.status %></td><td><%= row.created_at %></td></tr><% }) %>
  <% if (!recentRequests.length) { %><tr><td colspan="5">لا توجد طلبات حتى الآن.</td></tr><% } %>
  </tbody></table></div>
</section>
<%- include('partials/footer') %>
