@model IReadOnlyList<Project>
@{
    ViewData["Title"] = "Projects";
}

<div class="page-heading">
    <div>
        <p class="eyebrow">Series planning</p>
        <h1>Projects <help-icon key="projects.overview" /></h1>
    </div>
    <div class="button-row">
        <a class="btn btn-outline-primary" asp-controller="Imports" asp-action="Index">Import JSON</a>
        <a class="btn btn-primary" asp-action="Create">New project</a>
    </div>
</div>

@if (!Model.Any())
{
    <section class="empty-panel">
        <h2>Start with a series or standalone novel</h2>
        <p>Create a project, then add books, chapters and scenes in narrative order.</p>
        <a class="btn btn-primary" asp-action="Create">Create your first project</a>
    </section>
}
else
{
    <div class="content-grid">
        @foreach (var project in Model)
        {
            <article class="plain-card">
                <h2>@project.ProjectName</h2>
                <p>@(string.IsNullOrWhiteSpace(project.Description) ? "No description yet." : project.Description)</p>
                <div class="button-row">
                    <a class="btn btn-outline-primary btn-sm" asp-action="Details" asp-route-id="@project.ProjectID">Open</a>
                    <a class="btn btn-outline-secondary btn-sm" asp-action="Edit" asp-route-id="@project.ProjectID">Edit</a>
                    <form asp-action="Archive" method="post" class="archive-button-form" data-confirm-message="Archive this project?&#10;&#10;This will hide it from active lists and timelines, but the data will be kept and can be restored later.">
                        <input type="hidden" name="id" value="@project.ProjectID" />
                        <button class="btn btn-outline-danger btn-sm" type="submit">Archive</button>
                    </form>
                </div>
            </article>
        }
    </div>
}
