<section class="dash">
  <div class="dash-greeting">
    <h1><%= greeting %><% if (typeof currentUser !== 'undefined' && currentUser && currentUser.name) { %>, <%= currentUser.name %><% } %>!</h1>
    <p>Here's a summary of your site activity.</p>
  </div>

  <div class="dash-stats-row">
    <a class="dash-stat-card" href="/admin/pages">
      <span class="dash-stat-icon">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"></path>
          <polyline points="14 2 14 8 20 8"></polyline>
        </svg>
      </span>
      <span class="dash-stat-count"><%= stats.pages %></span>
      <span class="dash-stat-label">Pages</span>
    </a>

    <a class="dash-stat-card" href="/admin/posts">
      <span class="dash-stat-icon">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <path d="M12 20h9"></path>
          <path d="M16.5 3.5a2.12 2.12 0 0 1 3 3L7 19l-4 1 1-4Z"></path>
        </svg>
      </span>
      <span class="dash-stat-count"><%= stats.posts %></span>
      <span class="dash-stat-label">Blog posts</span>
    </a>

    <a class="dash-stat-card" href="/admin/work">
      <span class="dash-stat-icon">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <rect x="2" y="7" width="20" height="14" rx="2"></rect>
          <path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"></path>
        </svg>
      </span>
      <span class="dash-stat-count"><%= stats.projects %></span>
      <span class="dash-stat-label">Case studies</span>
    </a>

    <a class="dash-stat-card" href="/admin/categories">
      <span class="dash-stat-icon">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <path d="M20.59 13.41 13.41 20.59a2 2 0 0 1-2.82 0L2 12V2h10l8.59 8.59a2 2 0 0 1 0 2.82Z"></path>
          <line x1="7" y1="7" x2="7.01" y2="7"></line>
        </svg>
      </span>
      <span class="dash-stat-count"><%= stats.categories %></span>
      <span class="dash-stat-label">Categories</span>
    </a>

    <a class="dash-stat-card" href="/admin/comments">
      <span class="dash-stat-icon">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <path d="M21 11.5a8.38 8.38 0 0 1-.9 3.8 8.5 8.5 0 0 1-7.6 4.7 8.38 8.38 0 0 1-3.8-.9L3 21l1.9-5.7a8.38 8.38 0 0 1-.9-3.8 8.5 8.5 0 0 1 4.7-7.6 8.38 8.38 0 0 1 3.8-.9h.5a8.48 8.48 0 0 1 8 8v.5Z"></path>
        </svg>
      </span>
      <span class="dash-stat-count"><%= stats.pendingComments %></span>
      <span class="dash-stat-label"><%= stats.pendingComments === 1 ? 'Comment to review' : 'Comments to review' %></span>
    </a>
  </div>

  <div class="dash-panel">
    <div class="dash-panel-header">
      <h2>Recent case studies</h2>
      <a href="/admin/work">View all &rarr;</a>
    </div>

    <% if (recentProjects && recentProjects.length) { %>
      <div class="dash-recent-list">
        <% recentProjects.forEach(function(p) { %>
          <a class="dash-recent-row" href="/admin/work/<%= p.id %>/edit">
            <span class="dash-recent-main">
              <span class="dash-recent-title"><%= p.title %></span>
              <span class="dash-recent-meta"><%= p.client || 'No client set' %></span>
            </span>
            <span class="dash-recent-status dash-recent-status-<%= p.status %>"><%= p.status %></span>
          </a>
        <% }) %>
      </div>
    <% } else { %>
      <div class="dash-empty-state">
        <svg viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
          <rect x="2" y="7" width="20" height="14" rx="2"></rect>
          <path d="M16 21V5a2 2 0 0 0-2-2h-4a2 2 0 0 0-2 2v16"></path>
        </svg>
        <p>No case studies yet.</p>
        <a href="/admin/work/new">Add your first case study &rarr;</a>
      </div>
    <% } %>
  </div>

  <div class="dash-panel-header" style="margin-top: 0.5rem;">
    <h2>Manage site pages</h2>
  </div>
  <div class="dash-actions-row" style="margin-bottom: 1.75rem;">
    <a class="dash-action-card" href="/admin/countries">
      <span class="dash-action-text">
        <span class="dash-action-title">Countries<%= typeof stats !== 'undefined' && stats.countries !== undefined ? ' (' + stats.countries + ')' : '' %></span>
        <span class="dash-action-desc">Edit each country page's text, photos, and details.</span>
      </span>
      <svg class="dash-action-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>
    </a>

    <a class="dash-action-card" href="/admin/divisions">
      <span class="dash-action-text">
        <span class="dash-action-title">Services<%= typeof stats !== 'undefined' && stats.services !== undefined ? ' (' + stats.services + ')' : '' %></span>
        <span class="dash-action-desc">Edit the Events, PR &amp; Media, and Digital &amp; Media pages.</span>
      </span>
      <svg class="dash-action-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>
    </a>

    <a class="dash-action-card" href="/admin/hero-slides">
      <span class="dash-action-text">
        <span class="dash-action-title">Hero slides</span>
        <span class="dash-action-desc">Manage the homepage hero carousel.</span>
      </span>
      <svg class="dash-action-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>
    </a>
  </div>

  <div class="dash-actions-row">
    <a class="dash-action-card" href="/admin/work/new">
      <span class="dash-action-text">
        <span class="dash-action-title">Add a case study</span>
        <span class="dash-action-desc">Publish a new project to Our Work.</span>
      </span>
      <svg class="dash-action-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>
    </a>

    <a class="dash-action-card" href="/admin/posts/new">
      <span class="dash-action-text">
        <span class="dash-action-title">Write a blog post</span>
        <span class="dash-action-desc">Share an update on the Insights blog.</span>
      </span>
      <svg class="dash-action-chevron" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"></polyline></svg>
    </a>
  </div>
</section>
