/* 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__back.mud-icon-button {
    width: 2rem;
    height: 2rem;
    min-width: 2rem !important;
    padding: 0 !important;
    border-radius: 50% !important;
    border: 1px solid var(--mud-palette-lines-default) !important;
    background-color: var(--mud-palette-surface) !important;
    color: var(--mud-palette-text-secondary) !important;
    flex-shrink: 0;
}

.capability-procedure-drawer-header__back.mud-icon-button:hover {
    background-color: var(--mud-palette-action-default-hover) !important;
    color: var(--mud-palette-text-primary) !important;
}

.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.5rem;
    flex: 0 0 auto;
    flex-wrap: wrap;
}

/*
  View mode: body fills the drawer content slot.
  Split scroll — Sections rail flush left; document pane scrolls with scrollbar on the drawer right edge.
*/
.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%;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: var(--mud-palette-background);
}

.capability-procedure-drawer-view {
    display: grid !important;
    grid-template-columns: minmax(0, 1fr);
    grid-template-rows: minmax(0, 1fr);
    align-content: stretch;
    align-items: stretch;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    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;
    grid-row: 1;
    align-self: stretch;
    width: 220px;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    box-sizing: border-box;
    margin: 0;
    padding: 0.875rem 0.5rem 1.25rem 0.75rem;
    border-right: 1px solid var(--mud-palette-divider);
    background: color-mix(in srgb, var(--mud-palette-primary) 4%, var(--mud-palette-background));
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    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;
    border-left: 3px solid transparent;
    padding: 0.4rem 0.55rem 0.4rem 0.45rem;
    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) 10%, transparent);
    border-left-color: var(--mud-palette-primary);
}

/* Full-width scroll pane — scrollbar flush to drawer right edge; content padded inside */
.capability-procedure-drawer-view__document {
    grid-column: 1;
    grid-row: 1;
    align-self: stretch;
    justify-self: stretch;
    width: 100%;
    max-width: none;
    box-sizing: border-box;
    min-width: 0;
    min-height: 0;
    height: 100%;
    max-height: 100%;
    margin: 0;
    padding: 1rem 1.25rem 2rem;
    background: var(--mud-palette-background);
    overflow-x: hidden;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-gutter: auto;
}

.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: 48rem;
    min-height: min-content;
    margin: 0 auto;
    font-family: inherit;
    color: var(--mud-palette-text-primary);
}

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

/*
  Overview-aligned reading chrome (Capability Overview left column).
  Screen-only: Download PDF uses QuestPDF (ProcedureQuestPdfComposer), not these rules.
*/
.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__header,
.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__section {
    padding-left: 0;
    padding-right: 0;
    background: transparent;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__header {
    padding-top: 0;
    padding-bottom: 1rem;
    margin-bottom: 0.25rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__header--drawer-compact .procedure-doc-view__meta-grid {
    margin-top: 0;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__title {
    font-size: 1rem !important;
    font-weight: 600 !important;
    line-height: 1.4;
    letter-spacing: -0.025em;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__section {
    padding-top: 1.25rem;
    padding-bottom: 1.25rem;
    margin-bottom: 0;
    border-bottom: none;
}

/* Match NucleusDefinitionSection divider rhythm under section titles */
.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__section-title {
    font-size: 0.95rem !important;
    font-weight: 600 !important;
    line-height: 1.4;
    padding-bottom: 0.5rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--mud-palette-lines-default);
    color: var(--mud-palette-text-primary);
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__prose {
    font-size: 0.875rem;
    line-height: 1.4;
    letter-spacing: -0.025em;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__list {
    margin: 0.15rem 0 0;
    padding-left: 1.125rem;
    list-style: disc;
    line-height: 1.4;
    font-size: 0.875rem;
    color: var(--mud-palette-text-primary);
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__list li + li {
    margin-top: 0.35rem;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__method-step-title {
    font-size: 0.875rem !important;
    font-weight: 500 !important;
    line-height: 1.43;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__method-step {
    padding: 0.5rem 0 0.75rem;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__expected {
    font-size: 0.875rem;
    line-height: 1.4;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__checklist {
    font-size: 0.875rem;
    line-height: 1.4;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__checklist li {
    margin-bottom: 0.35rem;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__table {
    font-size: 0.875rem;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__table th,
.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__table td {
    font-size: 0.875rem;
}

.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__table.flat-table,
.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__table.mud-simple-table,
.capability-procedure-drawer-view .procedure-doc-view--overview .procedure-doc-view__table.mud-paper {
    border: none !important;
    box-shadow: none !important;
    background: transparent !important;
}

@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: 0.75rem 0.35rem 1rem 0.5rem;
    }

    .capability-procedure-drawer-view__document {
        padding: 0.875rem 0.875rem 1.75rem;
    }
}

/*
  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;
}

/* -------------------------------------------------------------------------
   Business Flow Document View — Story-first reader (mirrors Procedure TOC/document)
   ------------------------------------------------------------------------- */

.business-flow-document-drawer-body {
    display: flex !important;
    flex-direction: column !important;
    flex: 1 1 0 !important;
    min-height: 0 !important;
    height: 100% !important;
    width: 100%;
    margin: 0 !important;
    padding: 0 !important;
    overflow: hidden !important;
    background: var(--mud-palette-background);
}

.business-flow-document-view__toc-item--child {
    margin-left: 0.35rem;
}

.business-flow-document-view__toc-link--child {
    font-size: 0.75rem !important;
    padding-top: 0.3rem !important;
    padding-bottom: 0.3rem !important;
    color: var(--mud-palette-text-secondary);
}

.business-flow-document-view .business-flow-document-view__body {
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 48rem;
    min-height: min-content;
    margin: 0 auto;
}

.business-flow-document-view__overview-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 0.85rem 1.5rem;
    margin: 0;
    width: 100%;
    min-width: 0;
}

.business-flow-document-view__overview-item {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0.2rem;
    min-width: 0;
}

.business-flow-document-view__overview-label {
    font-size: 0.75rem;
    line-height: 1.3;
    color: var(--mud-palette-text-secondary);
}

.business-flow-document-view__overview-value {
    margin: 0;
    font-size: 0.875rem;
    line-height: 1.45;
    width: 100%;
    text-align: left;
    overflow-wrap: anywhere;
    color: var(--mud-palette-text-primary);
}

.business-flow-document-view__step {
    scroll-margin-top: 0.75rem;
    padding: 1rem 0 1.25rem;
    border-top: 1px solid var(--mud-palette-lines-default);
}

.business-flow-document-view__stage > .business-flow-document-view__step:first-of-type {
    border-top: none;
    padding-top: 0.25rem;
}

.business-flow-document-view__step-heading {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 0.75rem;
}

.business-flow-document-view__step-title {
    font-weight: 600;
    line-height: 1.4;
    min-width: 0;
}

.business-flow-document-view__step-seq {
    color: var(--mud-palette-text-secondary);
    font-weight: 500;
    margin-right: 0.15rem;
}

.business-flow-document-view__type-chip {
    flex-shrink: 0;
}

.business-flow-document-view__block-label {
    display: block;
    margin-bottom: 0.35rem;
    letter-spacing: 0.02em;
    text-transform: uppercase;
    font-weight: 600;
}

.business-flow-document-view__chip-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.35rem 0.5rem;
}

.business-flow-document-view__proc-item + .business-flow-document-view__proc-item {
    margin-top: 0.65rem;
}

.business-flow-document-view__proc-status {
    opacity: 0.8;
    font-weight: 400;
}

.business-flow-document-view__nested {
    padding: 0.75rem 0.85rem;
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: 6px;
    background: color-mix(in srgb, var(--mud-palette-primary) 3%, var(--mud-palette-surface));
}

.business-flow-document-view__nested--procedure {
    max-width: 100%;
    overflow-x: hidden;
}

.business-flow-document-view__nested .procedure-doc-view {
    max-width: none;
    margin: 0;
}

.business-flow-document-view__outcome-desc {
    margin-top: 0.2rem;
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
}

.business-flow-document-view__index-link {
    color: var(--mud-palette-primary);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}

.business-flow-document-view__index-link:hover {
    text-decoration: underline;
}

@media (max-width: 700px) {
    .business-flow-document-view__overview-grid {
        grid-template-columns: 1fr;
    }
}

