@model PlotThreadEditViewModel
@{
    ViewData["Title"] = Model.PlotThreadID == 0 ? "New Plot Thread" : "Edit Plot Thread";
}

<div class="page-heading compact">
    <div>
        <p class="eyebrow">@Model.Project?.ProjectName</p>
        <h1>@ViewData["Title"] <help-icon key="plotThreads.edit" /></h1>
    </div>
    <div class="button-row">
        <a class="btn btn-outline-secondary" asp-action="Index" asp-route-projectId="@Model.ProjectID">Back to plot threads</a>
        @if (Model.PlotThreadID > 0)
        {
            <form asp-action="Archive" method="post" class="archive-button-form" data-confirm-message="Archive this plot thread?&#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.PlotThreadID" />
                <input type="hidden" name="projectId" value="@Model.ProjectID" />
                <button class="btn btn-outline-danger" type="submit">Archive Plot Thread</button>
            </form>
        }
    </div>
</div>

<form asp-action="Save" method="post" class="edit-panel">
    <input asp-for="PlotThreadID" type="hidden" />
    <input asp-for="ProjectID" type="hidden" />
    <div asp-validation-summary="ModelOnly" class="text-danger"></div>
    <div class="row g-3">
        <div class="col-md-6">
            <label asp-for="PlotLineID" class="form-label">Plot line <help-icon key="plotThreads.fields.parentPlotLine" mode="inline" /></label>
            <select asp-for="PlotLineID" asp-items="Model.PlotLineOptions" class="form-select"></select>
        </div>
        <div class="col-md-6">
            <label asp-for="ThreadTitle" class="form-label"></label>
            <input asp-for="ThreadTitle" class="form-control" />
            <span asp-validation-for="ThreadTitle" class="text-danger"></span>
        </div>
        <div class="col-md-4">
            <label asp-for="ThreadTypeID" class="form-label">Type <help-icon key="plotThreads.fields.type" mode="inline" /></label>
            <select asp-for="ThreadTypeID" asp-items="Model.ThreadTypeOptions" class="form-select"></select>
        </div>
        <div class="col-md-4">
            <label asp-for="ThreadStatusID" class="form-label">Status <help-icon key="plotThreads.fields.status" mode="inline" /></label>
            <select asp-for="ThreadStatusID" asp-items="Model.ThreadStatusOptions" class="form-select"></select>
        </div>
        <div class="col-md-4">
            <label asp-for="Importance" class="form-label">Importance <help-icon key="plotThreads.fields.importance" mode="inline" /></label>
            <input asp-for="Importance" type="number" min="1" max="10" class="form-control" />
        </div>
        <div class="col-12">
            <label asp-for="Summary" class="form-label"></label>
            <textarea asp-for="Summary" class="form-control" rows="4"></textarea>
        </div>
        <div class="col-md-4">
            <label asp-for="IntroducedSceneID" class="form-label">Introduced scene <help-icon key="plotThreads.fields.introducedScene" mode="inline" /></label>
            <select asp-for="IntroducedSceneID" asp-items="Model.SceneOptions" class="form-select">
                <option value="">Not set</option>
            </select>
        </div>
        <div class="col-md-4">
            <label asp-for="PlannedResolutionSceneID" class="form-label">Planned resolution scene <help-icon key="plotThreads.fields.resolution" mode="inline" /></label>
            <select asp-for="PlannedResolutionSceneID" asp-items="Model.SceneOptions" class="form-select">
                <option value="">Not set</option>
            </select>
        </div>
        <div class="col-md-4">
            <label asp-for="ActualResolutionSceneID" class="form-label">Actual resolution scene <help-icon key="plotThreads.fields.resolution" mode="inline" /></label>
            <select asp-for="ActualResolutionSceneID" asp-items="Model.SceneOptions" class="form-select">
                <option value="">Not set</option>
            </select>
        </div>
    </div>
    <button class="btn btn-primary mt-3" type="submit">Save thread</button>
</form>

@section Scripts {
    <partial name="_ValidationScriptsPartial" />
}
