/* Capability Procedure drawer — header/body helpers (width rules live in app.css after full-drawer overrides) */

.capability-procedure-drawer-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    flex: 1 1 auto;
    min-width: 0;
}

.capability-procedure-drawer-header__main {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1 1 auto;
}

.capability-procedure-drawer-header__title {
    font-weight: 650;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.capability-procedure-drawer-header__actions {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

/*
  View mode: body fills the drawer content slot.
  Outer view is the scrollport (scrollbar at drawer/screen right).
  TOC pins left; document centres in the remaining width.
*/
.entity-action-drawer .drawer-content-full-height > .capability-procedure-drawer-body:not(.capability-procedure-drawer-body--configure),
.capability-procedure-drawer-body:not(.capability-procedure-drawer-body--configure) {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    width: 100%;
    overflow: hidden !important;
    background: var(--mud-palette-background);
}

.capability-procedure-drawer-view {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    align-content: start;
    align-items: start;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    width: 100%;
    overflow-x: hidden !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch;
    background: var(--mud-palette-background);
}

.capability-procedure-drawer-view--with-toc {
    grid-template-columns: 220px minmax(0, 1fr);
}

.capability-procedure-drawer-view__toc {
    grid-column: 1;
    position: sticky;
    top: 0;
    align-self: start;
    width: 220px;
    max-width: 100%;
    box-sizing: border-box;
    padding: 1rem 0.75rem 1.5rem 1rem;
    border-right: 1px solid var(--mud-palette-divider);
    background: var(--mud-palette-surface, #fff);
    z-index: 1;
}

.capability-procedure-drawer-view__toc-label {
    display: block;
    margin-bottom: 0.5rem;
    letter-spacing: 0.04em;
}

.capability-procedure-drawer-view__toc-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
}

.capability-procedure-drawer-view__toc-link {
    display: block;
    width: 100%;
    text-align: left;
    border: none;
    background: transparent;
    border-radius: 4px;
    padding: 0.4rem 0.55rem;
    font-size: 0.8125rem;
    line-height: 1.35;
    color: var(--mud-palette-text-secondary);
    cursor: pointer;
}

.capability-procedure-drawer-view__toc-link:hover {
    color: var(--mud-palette-text-primary);
    background: var(--mud-palette-action-hover, rgba(0, 0, 0, 0.04));
}

.capability-procedure-drawer-view__toc-link--active {
    color: var(--mud-palette-primary);
    font-weight: 600;
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, transparent);
}

/* Reading column: centred in available width so large screens get gutters either side */
.capability-procedure-drawer-view__document {
    grid-column: 1;
    width: 100%;
    max-width: 48rem;
    justify-self: center;
    box-sizing: border-box;
    min-width: 0;
    padding: 1.25rem 1.5rem 2.5rem;
    background: var(--mud-palette-background);
}

.capability-procedure-drawer-view--with-toc .capability-procedure-drawer-view__document {
    grid-column: 2;
}

.capability-procedure-drawer-view .procedure-doc-view {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: none;
    min-height: min-content;
}

.capability-procedure-drawer-view .procedure-doc-view__section {
    scroll-margin-top: 0.75rem;
}

@media (max-width: 900px) {
    .capability-procedure-drawer-view--with-toc {
        grid-template-columns: 160px minmax(0, 1fr);
    }

    .capability-procedure-drawer-view__toc {
        width: 160px;
        padding-left: 0.65rem;
        padding-right: 0.5rem;
    }

    .capability-procedure-drawer-view__document {
        padding: 1rem 1rem 2rem;
    }
}

/*
  Configure mode: DOM was present but flex+min-height:0 collapsed the builder to 0px
  (white blank panel). Pin the configure body to the drawer content slot, then fill it.
*/
.entity-action-drawer .drawer-content-full-height:has(> .capability-procedure-drawer-body--configure) {
    position: relative !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    overflow: hidden !important;
}

.entity-action-drawer .drawer-content-full-height > .capability-procedure-drawer-body--configure,
.capability-procedure-drawer-body--configure {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    flex: none !important;
    min-height: 0 !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    align-self: auto !important;
    box-sizing: border-box !important;
    background: var(--mud-palette-background);
}

.capability-procedure-drawer-configure-loading,
.capability-procedure-drawer-body--configure > .procedure-builder.procedure-builder--drawer,
.capability-procedure-drawer-body--configure > .procedure-builder--drawer {
    position: absolute !important;
    inset: 0 !important;
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    min-height: 0 !important;
    flex: none !important;
    display: flex !important;
    flex-direction: column !important;
    overflow: hidden !important;
    box-sizing: border-box !important;
    background: var(--mud-palette-background);
}

.capability-procedure-drawer-body--configure .procedure-builder--drawer .procedure-builder__header {
    position: static !important;
    flex: 0 0 auto !important;
    padding: 0.5rem 1rem;
}

.capability-procedure-drawer-body--configure .procedure-builder--drawer .procedure-builder__body {
    flex: 1 1 0 !important;
    min-height: 0 !important;
    overflow: hidden !important;
    display: flex !important;
}

.capability-procedure-drawer-body--configure .procedure-builder--drawer .procedure-builder__nav {
    width: 220px;
    flex: 0 0 auto;
    padding: 0.75rem 0.35rem;
    overflow-y: auto;
}

.capability-procedure-drawer-body--configure .procedure-builder--drawer .procedure-builder__content {
    padding: 1rem 1.25rem 2rem;
    max-width: none !important;
    overflow-y: auto !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
}

.capability-procedure-drawer-body--configure .procedure-builder--drawer .procedure-builder__footer {
    position: static !important;
    flex: 0 0 auto !important;
}
