@using System
@using System.Collections.Generic
@using RolemasterDb.App.Features

<div class="critical-editor-compare-card">
    <div class="critical-editor-compare-card-header">
        <div>
            <strong>@Title</strong>
            @if (!string.IsNullOrWhiteSpace(Caption))
            {
                <p class="muted critical-editor-inline-copy">@Caption</p>
            }
        </div>
    </div>

    @if ((Effects?.Count ?? 0) == 0 && (Branches?.Count ?? 0) == 0 && string.IsNullOrWhiteSpace(Description))
    {
        <p class="muted">No visible result is available for this card.</p>
    }
    else
    {
        <CompactCriticalCell
            Description="@Description"
            Effects="Effects"
            Branches="Branches" />
    }

    @if ((Notes?.Count ?? 0) > 0)
    {
        <div class="critical-editor-validation-list">
            @foreach (var note in Notes!)
            {
                <p class="critical-editor-validation-item">@note</p>
            }
        </div>
    }
</div>

@code {
    [Parameter, EditorRequired]
    public string Title { get; set; } = string.Empty;

    [Parameter]
    public string? Caption { get; set; }

    [Parameter, EditorRequired]
    public string Description { get; set; } = string.Empty;

    [Parameter]
    public IReadOnlyList<CriticalEffectLookupResponse>? Effects { get; set; }

    [Parameter]
    public IReadOnlyList<CriticalBranchLookupResponse>? Branches { get; set; }

    [Parameter]
    public IReadOnlyList<string>? Notes { get; set; }
}
