@model SceneEditViewModel
@{
    var status = Model.RevisionStatuses.FirstOrDefault(x => x.Value == Model.RevisionStatusID.ToString())?.Text ?? "Not set";
    var pov = Model.CharacterOptions.FirstOrDefault(x => x.Value == Model.POVCharacterID?.ToString())?.Text
        ?? Model.SceneCharacters.FirstOrDefault(x => x.RoleInSceneTypeName?.Contains("POV", StringComparison.OrdinalIgnoreCase) == true)?.CharacterName
        ?? "No POV character";
    var purposeLabels = Model.ScenePurposeTypes
        .Where(x => Model.SelectedPurposeTypeIds.Contains(x.ScenePurposeTypeID))
        .Select(x => x.PurposeName)
        .ToList();
    var sceneType = purposeLabels.FirstOrDefault() ?? "No scene type set";
    var primaryLocation = Model.LocationOptions.FirstOrDefault(x => x.Value == Model.PrimaryLocationID?.ToString())?.Text?.Trim() ?? "No primary location";
    var timeLabel = !string.IsNullOrWhiteSpace(Model.RelativeTimeText)
        ? Model.RelativeTimeText
        : Model.StartDateTime?.ToString("d MMM yyyy HH:mm")
            ?? "Time not set";
}

<article class="scene-inspector-v2-card scene-overview-v2-card" data-scene-summary-part="overview">
    <div class="scene-inspector-v2-card-header scene-overview-v2-header">
        <div>
            <p class="eyebrow">Overview</p>
            <div class="scene-inspector-v2-heading">
                <h3>@(string.IsNullOrWhiteSpace(Model.SceneTitle) ? "Untitled scene" : Model.SceneTitle)</h3>
                <help-icon key="sceneInspector.overview" mode="inline" />
            </div>
        </div>
        <div class="scene-overview-v2-controls">
            <span class="status-pill">@status</span>
            <button type="button" class="btn btn-sm btn-outline-primary" data-scene-editor="scene-details" data-scene-id="@Model.SceneID" data-scene-editor-url="@Url.Action("SceneDetailsEditor", "Scenes", new { sceneId = Model.SceneID })">Edit scene details</button>
        </div>
    </div>

    <dl class="scene-inspector-v2-facts scene-overview-v2-facts">
        <div>
            <dt>POV</dt>
            <dd>@pov</dd>
        </div>
        <div>
            <dt>Date/time</dt>
            <dd>@timeLabel</dd>
        </div>
        <div>
            <dt>Location</dt>
            <dd>@primaryLocation</dd>
        </div>
        <div>
            <dt>Scene type</dt>
            <dd>@sceneType</dd>
        </div>
        <div>
            <dt>Position</dt>
            <dd>Chapter @Model.Chapter?.ChapterNumber, Scene @Model.SceneNumber</dd>
        </div>
    </dl>

    <div class="scene-inspector-v2-summary scene-overview-v2-summary">
        <span>Synopsis</span>
        @if (string.IsNullOrWhiteSpace(Model.Summary))
        {
            <p class="muted">No synopsis has been added yet.</p>
        }
        else
        {
            <p>@Model.Summary</p>
        }
    </div>
</article>
