@model SceneEditViewModel
@{
    ViewData["Title"] = Model.SceneID == 0 ? "New Scene" : "Edit Scene";
    ViewData["ProjectSection"] = "Overview";
    ViewData["ShellClass"] = "plotline-shell-wide";
}

<nav class="breadcrumb-trail" aria-label="Breadcrumb">
    <a asp-controller="Projects" asp-action="Index">Projects</a>
    @if (Model.Project is not null)
    {
        <a asp-controller="Projects" asp-action="Details" asp-route-id="@Model.Project.ProjectID">@Model.Project.ProjectName</a>
    }
    @if (Model.Book is not null)
    {
        <a asp-controller="Books" asp-action="Details" asp-route-id="@Model.Book.BookID">@Model.Book.BookTitle</a>
    }
    @if (Model.Chapter is not null)
    {
        <a asp-controller="Chapters" asp-action="Details" asp-route-id="@Model.ChapterID">Chapter @Model.Chapter.ChapterNumber</a>
    }
    <span>@(Model.SceneID == 0 ? "New scene" : $"Scene {Model.SceneNumber}")</span>
</nav>

@if (Model.Project is not null)
{
    <partial name="_ProjectSectionNav" model="Model.Project" />
}

<div class="page-heading scene-edit-heading">
    <div>
        <p class="eyebrow">@Model.Book?.BookTitle / Chapter @Model.Chapter?.ChapterNumber</p>
        <h1>@ViewData["Title"] <help-icon key="scenes.edit" /></h1>
        <span class="status-pill">@(Model.IsLinkedToManuscript ? "🔗 Linked" : "📝 Planned")</span>
    </div>
    <div class="button-row">
        @if (Model.SceneID > 0)
        {
            <a class="btn btn-outline-primary" asp-controller="Exports" asp-action="SceneBrief" asp-route-id="@Model.SceneID">Scene brief</a>
            <a class="btn btn-outline-secondary" asp-controller="Exports" asp-action="SceneBrief" asp-route-id="@Model.SceneID" asp-route-format="markdown">Markdown</a>
            <a class="btn btn-outline-primary" asp-controller="Exports" asp-action="WritingSession" asp-route-sceneId="@Model.SceneID">Prepare Writing Session</a>
            <div class="dropdown pw-actions">
                <button class="btn pw-actions__toggle dropdown-toggle" type="button" data-bs-toggle="dropdown" aria-expanded="false">
                    Actions
                </button>
                <div class="dropdown-menu dropdown-menu-end">
                    <form asp-action="Archive" method="post" class="archive-button-form" data-confirm-message="Archive this scene?&#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="@Model.SceneID" />
                        <input type="hidden" name="chapterId" value="@Model.ChapterID" />
                        <button class="dropdown-item text-danger" type="submit">Archive Scene</button>
                    </form>
                </div>
            </div>
        }
    </div>
</div>

<section class="edit-panel scene-editor scene-editor-v2-workspace">
    <partial name="~/Views/Shared/SceneInspectorV2/_SceneInspectorEditPage.cshtml" model="Model" />
</section>

@section Scripts {
    <partial name="_ValidationScriptsPartial" />
    <script src="~/js/scene-inspector-v2.js" asp-append-version="true"></script>
}
