/* Organisation Foundation — shared workspace layout, section headers, and list rows. */

/*
 * WorkspaceLayout keeps overflow-hidden on the column for bounded flex layout.
 * Organisation Foundation uses organisation-foundation-scroll-host as the single vertical scroll container.
 */
.organisation-foundation-scroll-host {
    overflow-y: auto !important;
    overflow-x: hidden !important;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
}

/* Page content grows inside the scroll host; do not clip or create a nested scroll trap. */
.organisation-foundation-scroll-host .app-content-shell.page-section.organisation-page-shell {
    display: block;
    flex: none;
    min-height: auto;
    height: auto;
    overflow: visible;
}

.organisation-foundation-page {
    --foundation-surface-radius: var(--nucleus-surface-radius, 6px);
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

.organisation-foundation-workspace-body {
    min-width: 0;
    min-height: 0;
    overflow: visible;
}

/* Organisation Foundation detail cards — page scroll, not internal clip. */
.organisation-foundation-page .foundation-cap-group-card,
.organisation-foundation-page .org-person-card,
.organisation-foundation-page .org-team-card,
.organisation-foundation-page .org-location-card,
.organisation-foundation-page .org-asset-card--full-detail,
.organisation-foundation-page .foundation-detail,
.organisation-foundation-page .organisation-governance-tab,
.organisation-foundation-page .organisation-admin-landing {
    overflow: visible;
    max-height: none;
}

.organisation-foundation-page .foundation-cap-embedded-entity,
.organisation-foundation-page .foundation-cap-group-card--embedded-entity {
    overflow: visible;
    max-height: none;
}

.foundation-capabilities-overview,
.foundation-workspace,
.foundation-workspace__master,
.foundation-workspace__detail {
    min-width: 0;
    min-height: 0;
    overflow: visible;
    max-height: none;
}


.foundation-overview-card,
.foundation-card,
.foundation-panel,
.workspace-card,
.linked-item-card,
.foundation-structure-row {
    border-radius: var(--foundation-surface-radius, 6px);
}

.organisation-foundation-page .mud-paper-outlined {
    border-radius: var(--foundation-surface-radius, 6px);
    border-color: var(--nucleus-surface-border, var(--mud-palette-lines-default));
    box-shadow: var(--nucleus-surface-shadow, 0 1px 2px color-mix(in srgb, var(--mud-palette-text-primary) 4%, transparent));
}

/* Capability model + other Foundation list/detail shells — clip row fills to 6px corners */
.organisation-foundation-page .foundation-capabilities-overview__list-wrap,
.organisation-foundation-page .foundation-cap-group-card.nucleus-surface-card,
.organisation-foundation-page .foundation-cap-group-card.mud-paper-outlined,
.organisation-foundation-page .foundation-list-wrap,
.organisation-foundation-page .foundation-flat-list,
.organisation-foundation-page .foundation-cap-group-card__cap-list,
.organisation-foundation-page .linked-item-card {
    border-color: var(--nucleus-surface-border, var(--mud-palette-lines-default));
}

.organisation-foundation-page .foundation-capabilities-overview__list-wrap,
.organisation-foundation-page .foundation-cap-group-card__cap-list,
.organisation-foundation-page .foundation-list-wrap,
.organisation-foundation-page .foundation-flat-list {
    overflow: hidden;
}

.organisation-foundation-page .foundation-capabilities-overview__list-wrap.mud-paper-outlined.nucleus-surface-card,
.organisation-foundation-page .foundation-cap-group-card.mud-paper-outlined.nucleus-surface-card,
.organisation-foundation-page .foundation-list-wrap.mud-paper-outlined.nucleus-surface-card,
.organisation-foundation-page .foundation-flat-list.mud-paper-outlined.nucleus-surface-card,
.organisation-foundation-page .foundation-dept-table-wrap.mud-paper-outlined.nucleus-surface-card,
.organisation-foundation-page .dept-flows-list-card.mud-paper-outlined.nucleus-surface-card,
.organisation-foundation-page .capability-group__list.mud-paper-outlined,
.organisation-foundation-page .organisation-governance-panel.mud-paper-outlined.nucleus-surface-card,
.organisation-foundation-page .governance-embedded-register-panel.mud-paper-outlined {
    border-radius: var(--foundation-surface-radius, 6px) !important;
    border-color: var(--nucleus-surface-border, var(--mud-palette-lines-default)) !important;
    box-shadow: var(--nucleus-surface-shadow, 0 1px 2px color-mix(in srgb, var(--mud-palette-text-primary) 4%, transparent));
}

/* Named Organisation Foundation card shells (tabs + drill-ins) */
.organisation-foundation-page .foundation-detail,
.organisation-foundation-page .foundation-overview-banner,
.organisation-foundation-page .foundation-list-wrap,
.organisation-foundation-page .foundation-flat-list,
.organisation-foundation-page .foundation-assets-spine-card,
.organisation-foundation-page .foundation-dept-summary-card,
.organisation-foundation-page .foundation-dept-table-wrap,
.organisation-foundation-page .foundation-cap-group-card,
.organisation-foundation-page .foundation-cap-detail-card,
.organisation-foundation-page .foundation-capabilities-overview__list-wrap,
.organisation-foundation-page .dept-flows-list-card,
.organisation-foundation-page .organisation-section-card,
.organisation-foundation-page .organisation-governance-outer,
.organisation-foundation-page .organisation-admin-landing,
.organisation-foundation-page .org-person-card,
.organisation-foundation-page .org-team-card,
.organisation-foundation-page .org-location-card,
.organisation-foundation-page .business-flow-foundation-overview-panel,
.organisation-foundation-page .org-asset-card,
.organisation-foundation-page .foundation-story-card,
.organisation-foundation-page .organisation-governance-panel,
.organisation-foundation-page .organisation-admin-panel,
.organisation-foundation-page .governance-risk-detail-panel,
.organisation-foundation-page .governance-control-detail-panel,
.organisation-foundation-page .governance-policy-detail-panel,
.organisation-foundation-page .governance-standard-detail-panel,
.organisation-foundation-page .governance-embedded-detail-panel,
.organisation-foundation-page .governance-risk-detail-panel {
    border-radius: var(--foundation-surface-radius, 6px);
}

body.theme-dark .organisation-foundation-page .mud-paper-outlined {
    box-shadow: 0 1px 3px color-mix(in srgb, var(--mud-palette-text-primary) 8%, transparent);
}

.foundation-workspace-section-intro__title {
    font-size: 0.9375rem;
    font-weight: 650;
    line-height: 1.3;
    color: var(--mud-palette-text-primary);
}

.foundation-workspace-section-intro__desc {
    font-size: 0.8125rem;
    line-height: 1.4;
    margin-top: 4px;
}

.foundation-section-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
    margin-bottom: 16px;
}

.foundation-section-header__title {
    font-size: 1.25rem;
    font-weight: 600;
    line-height: 1.3;
    margin: 0;
    color: var(--mud-palette-text-primary);
}

.foundation-section-header__description {
    font-size: 0.875rem;
    line-height: 1.45;
    margin: 4px 0 0;
    color: var(--mud-palette-text-secondary);
}

.foundation-section-header__hint {
    font-size: 0.8125rem;
    line-height: 1.4;
    margin: 6px 0 0;
    color: var(--mud-palette-text-secondary);
}

.foundation-section-header__actions {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

/* Full-width list by default; 25/75 when an item is selected. */
.foundation-workspace {
    display: block;
    width: 100%;
}

.foundation-workspace--split {
    display: grid;
    grid-template-columns: minmax(280px, 25%) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

@media (max-width: 959.98px) {
    .foundation-workspace--split {
        grid-template-columns: 1fr;
    }

    .foundation-workspace--split.foundation-workspace--hide-list-on-mobile .foundation-workspace__master {
        display: none;
    }
}

.foundation-workspace__master,
.foundation-workspace__detail {
    min-width: 0;
    overflow: visible;
    max-height: none;
}

.foundation-workspace__detail {
    animation: foundation-workspace-detail-in 0.24s ease-out;
}

.foundation-workspace-toolbar {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
    margin: 0 0 12px;
}

.organisation-foundation-workspace-body {
    min-width: 0;
}

@keyframes foundation-workspace-detail-in {
    from {
        opacity: 0;
        transform: translateX(12px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .foundation-workspace__detail {
        animation: none;
    }
}

.foundation-list-wrap {
    overflow: visible;
    max-height: none;
}

.foundation-list {
    height: auto;
    max-height: none;
    overflow: visible;
}

/* Shared list row — full and compact modes use the same component. */
.foundation-list-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: transparent;
    border: 0;
    border-bottom: 1px solid var(--mud-palette-divider);
    padding: 12px 16px;
    cursor: pointer;
    color: inherit;
    font: inherit;
    transition: background-color 120ms ease;
}

.foundation-workspace--split .foundation-list-row {
    padding: 10px 12px;
}

.foundation-list-row:last-child {
    border-bottom: 0;
}

.foundation-list-row:hover {
    background: var(--mud-palette-action-default-hover);
}

.foundation-list-row--selected,
.foundation-list-row--selected:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface));
    box-shadow: none;
}

.foundation-list-row__main {
    flex: 1 1 auto;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.foundation-list-row__title {
    font-size: 14px;
    font-weight: 600;
    line-height: 1.3;
    color: var(--mud-palette-text-primary);
}

.foundation-list-row__title--link {
    text-decoration: none !important;
    font-weight: 600;
}

.foundation-list-row__title--link:hover {
    text-decoration: underline !important;
}

.foundation-list-row__sub {
    font-size: 12px;
    color: var(--mud-palette-text-secondary);
    line-height: 1.4;
}

.foundation-list-row__meta {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    flex-shrink: 0;
}

.foundation-list-row__meta-text {
    font-size: 11px;
    font-weight: 500;
    color: var(--mud-palette-text-secondary);
    white-space: nowrap;
}

/* Hide noisy meta in compact (split) mode */
.foundation-workspace--split .foundation-list-row__meta--full-only {
    display: none;
}

.foundation-workspace--split .foundation-list-row__sub--full-only {
    display: none;
}

@media (max-width: 959.98px) {
    .foundation-workspace--split .foundation-list-row__meta--full-only,
    .foundation-workspace--split .foundation-list-row__sub--full-only {
        display: flex;
    }

    .foundation-workspace--split .foundation-list-row__sub--full-only {
        display: block;
    }
}

/* Legacy workspace card aliases (Business Flows, Assets, Governance) */
.foundation-workspace-card {
    display: block;
    width: 100%;
}

.foundation-workspace-card.foundation-split {
    display: grid;
    grid-template-columns: minmax(280px, 25%) minmax(0, 1fr);
    gap: 1rem;
    align-items: start;
}

@media (max-width: 959.98px) {
    .foundation-workspace-card.foundation-split {
        grid-template-columns: 1fr;
    }
}

.foundation-left-spine,
.foundation-right-panel {
    min-width: 0;
    overflow: visible;
    max-height: none;
}

.foundation-workspace-header {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px 16px;
}

.foundation-workspace-header__title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--mud-palette-text-primary);
}

.foundation-workspace-header__subtitle {
    font-size: 0.875rem;
    color: var(--mud-palette-text-secondary);
}

.foundation-workspace-header__hint {
    font-size: 0.8125rem;
    color: var(--mud-palette-text-secondary);
}

/* Story rows (Business Flows / Assets) — align selection with foundation-list-row */
.foundation-story-row {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 12px;
    width: 100%;
    text-align: left;
    background: var(--mud-palette-surface);
    border: 1px solid var(--mud-palette-lines-default);
    border-radius: var(--foundation-surface-radius, 6px);
    padding: 12px 14px;
    cursor: pointer;
    color: inherit;
    font: inherit;
    transition: background-color 120ms ease, border-color 120ms ease;
}

.foundation-story-row + .foundation-story-row {
    margin-top: 8px;
}

.foundation-story-row:hover {
    background: var(--mud-palette-action-default-hover);
}

.foundation-story-row.is-selected,
.foundation-story-row.is-selected:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface));
    border-color: var(--mud-palette-divider);
    box-shadow: none;
}

.foundation-workspace-card.foundation-split .foundation-story-row {
    border-radius: 0;
    border-left: 0;
    border-right: 0;
    border-top: 0;
    background: transparent;
    padding: 10px 12px;
}

.foundation-workspace-card.foundation-split .foundation-story-row + .foundation-story-row {
    margin-top: 0;
}

.foundation-workspace-card.foundation-split .foundation-story-row.is-selected {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface));
}

.foundation-workspace-card.foundation-split .foundation-story-list {
    padding: 0 !important;
}

.foundation-workspace-card.foundation-split .foundation-flow-row__description,
.foundation-workspace-card.foundation-split .foundation-pill--full-only {
    display: none;
}

/* CRM master-detail alignment with Foundation tabs */
@media (min-width: 960px) {
    .crm-master-detail-section.is-detail-open {
        grid-template-columns: minmax(280px, 25%) minmax(0, 1fr);
        gap: 1rem;
    }
}

.master-detail-spine-list .sidebar-compact-row.is-selected,
.master-detail-spine-list .sidebar-compact-row.is-selected:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface));
    box-shadow: none;
}

.flat-table tbody tr.selected-row,
.flat-table tbody tr.selected-row:hover {
    background: color-mix(in srgb, var(--mud-palette-primary) 8%, var(--mud-palette-surface)) !important;
    box-shadow: none !important;
}
