@using ZB.MOM.WW.ScadaBridge.CentralUI.Services
@using ZB.MOM.WW.ScadaBridge.Commons.Types.Enums

@* Audit Log drilldown drawer (#23 M7 Bundle C / M7-T4..T8).
   Right-side Bootstrap offcanvas-style drawer hosted by the Audit Log page.
   The drawer owns only the offcanvas chrome (backdrop, header, Close buttons);
   the single-AuditEvent detail body is delegated to <AuditEventDetail>, which
   is shared with the execution-tree node-detail modal. *@

@if (IsOpen && Event is not null)
{
    <div class="offcanvas-backdrop fade show" data-test="drawer-backdrop"
         @onclick="HandleClose"></div>
    <div class="offcanvas offcanvas-end show audit-drilldown-drawer"
         tabindex="-1"
         style="visibility: visible;"
         data-test="audit-drilldown-drawer">
        <div class="offcanvas-header border-bottom">
            <div>
                <div class="text-muted small text-uppercase">Audit event</div>
                <h5 class="offcanvas-title mb-0">Audit Event @ShortEventId(Event.EventId)</h5>
            </div>
            <button type="button" class="btn-close" aria-label="Close"
                    data-test="drawer-close"
                    @onclick="HandleClose"></button>
        </div>

        <div class="offcanvas-body small">
            @* Single-row detail body + action buttons — shared component. *@
            <AuditEventDetail Event="Event" />
        </div>

        @* Close button kept at the bottom per form-layout memory. *@
        <div class="border-top p-3 d-flex gap-2 flex-wrap drawer-footer">
            <button class="btn btn-primary btn-sm ms-auto"
                    data-test="drawer-close-footer"
                    @onclick="HandleClose">
                Close
            </button>
        </div>
    </div>
}
