@* Shared shell for driver edit/new pages — panel layout + Save/Cancel/Delete bar + error banner.
   The parent page owns the <EditForm> — this shell only renders the button bar. *@

<div>
    @ChildContent

    @if (!string.IsNullOrWhiteSpace(Error))
    {
        <div class="panel notice mt-3" style="border-color:var(--alert)">@Error</div>
    }

    <div class="mt-3 d-flex gap-2">
        <button type="submit" class="btn btn-primary" disabled="@Busy">
            @if (Busy) { <span class="spinner-border spinner-border-sm me-1"></span> }
            @(IsNew ? "Create" : "Save changes")
        </button>
        <a href="@CancelHref" class="btn btn-outline-secondary">Cancel</a>
        @if (OnDelete.HasValue)
        {
            <button type="button" class="btn btn-outline-danger ms-auto" @onclick="OnDelete.Value" disabled="@Busy">
                Delete
            </button>
        }
    </div>
</div>

@code {
    [Parameter] public bool IsNew { get; set; }
    [Parameter] public bool Busy { get; set; }
    [Parameter] public string? Error { get; set; }
    [Parameter, EditorRequired] public string CancelHref { get; set; } = "";
    [Parameter] public EventCallback? OnDelete { get; set; }
    [Parameter] public RenderFragment? ChildContent { get; set; }
}
