/* Dialog chrome and picker lists shared by the desktop app and the Catalog client: the flush
   header bar of the lib-dialog and shell-dialog classes, and the grouped item lists the picker
   dialogs (value label sets, entity references, concepts, agents) render. Both hosts load this
   file; the rest of the Library and wizard styling stays in shell.css. */

/* Web-component FOUC guard: FluentUI v5 defines fluent-dialog lazily, and until the
   element upgrades, a just-opened dialog's content renders in normal document flow
   inside the dialog provider at the top of the page (pushing the shell down and
   flashing stray dialog innards). Hide it until it is defined; once upgraded, the
   content lives inside the native <dialog>, which stays hidden until shown modally,
   so this rule never hides a visible dialog. */
fluent-dialog:not(:defined),
fluent-drawer:not(:defined) {
    display: none;
}

/* Dialog footers stay a right-aligned row, primary action first and Cancel last,
   at every dialog width. FluentUI stacks the ActionTemplate buttons in a column
   when the dialog body is under 480px wide, which caught every dialog narrower
   than 528px. The [fuib] selectors match FluentUI's own rule so this one wins;
   long labels wrap instead of stacking. */
fluent-dialog[fuib] fluent-dialog-body[fuib] > div[slot="action"] {
    flex-direction: row !important;
    flex-wrap: wrap;
    justify-content: flex-end;
}

/* The narrow layout also adds extra space above the footer; use the wide spacing. */
fluent-dialog[fuib] fluent-dialog-body[fuib]:not([scrollable])::part(actions) {
    margin-block-start: calc(var(--spacingVerticalS) * -1);
    padding-block-start: var(--spacingVerticalS);
}

/* FluentUI v5 chrome overrides, scoped by DialogOptions.Class = "lib-dialog"
   (the Library) or "shell-dialog" (the Import and Export wizards, whose headers
   use the dlg-* aliases of the lib-header classes).
   The native dialog part is flush (padding 0), but fluent-dialog-body adds 24px
   padding, a row gap, title negative margins, and an always-rendered actions row;
   all are neutralized here so the header bar and panes run edge to edge. */
.lib-dialog::part(dialog),
.shell-dialog::part(dialog) {
    background: var(--surface-canvas);
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-2xl);
    box-shadow: var(--shadow-dialog);
    max-height: calc(100vh - 40px);
    overflow: hidden;
}

.lib-dialog fluent-dialog-body,
.shell-dialog fluent-dialog-body {
    display: flex;
    flex-direction: column;
    height: 100%;
    padding: 0;
    gap: 0;
    background: transparent;
}

.lib-dialog fluent-dialog-body::part(title),
.shell-dialog fluent-dialog-body::part(title) {
    display: block;
    position: static;
    margin: 0;
    padding: 0;
    background: transparent;
    flex: none;
}

.lib-dialog fluent-dialog-body::part(content),
.shell-dialog fluent-dialog-body::part(content) {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.lib-dialog fluent-dialog-body::part(actions),
.shell-dialog fluent-dialog-body::part(actions) {
    display: none;
}

/* The unclassed div FluentDialogBody wraps around ChildContent. */
.lib-dialog fluent-dialog-body > div:not([slot]),
.shell-dialog fluent-dialog-body > div:not([slot]) {
    flex: 1;
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.lib-header,
.dlg-header {
    height: 44px;
    flex: none;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    background: var(--surface-app);
    border-bottom: 1px solid var(--border-subtle);
}

.lib-header-icon,
.dlg-header-icon {
    display: flex;
    color: var(--text-muted);
}

.lib-header-title,
.dlg-header-title {
    font-size: 14px;
    font-weight: var(--fw-bold);
    color: var(--text-primary);
}

.lib-header-sub,
.dlg-header-sub {
    font-size: 12px;
    color: var(--text-faint);
}

.lib-header-spacer,
.dlg-header-spacer {
    flex: 1;
}

.lib-close,
.dlg-close {
    width: 30px;
    height: 30px;
    display: grid;
    place-items: center;
    border: none;
    border-radius: var(--radius-md);
    background: none;
    color: var(--text-muted);
    cursor: pointer;
}

.lib-close:hover,
.dlg-close:hover {
    background: var(--neutral-bg);
    color: var(--text-primary);
}

.lib-close svg,
.dlg-close svg {
    width: 14px;
    height: 14px;
}

.lib-item {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 0 8px;
    padding: 7px 12px;
    border: none;
    border-radius: var(--radius-md);
    background: none;
    font-size: 12.5px;
    font-family: var(--font-sans);
    text-align: left;
    color: var(--text-secondary);
    cursor: pointer;
}

.lib-item:hover {
    background: var(--neutral-bg);
}

.lib-item.selected,
.lib-item.selected:hover {
    font-weight: var(--fw-semibold);
    color: var(--text-primary);
    background: var(--accent-bg);
}

.lib-item-name {
    flex: 1;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-item-sub {
    flex: none;
    max-width: 90px;
    font-size: 11px;
    color: var(--text-faint);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* A Library item with its subtitle under the name (profiles). */
.lib-item.lib-item-stacked {
    flex-direction: column;
    align-items: stretch;
    gap: 1px;
}

.lib-item-stacked .lib-item-sub {
    max-width: none;
}

.lib-list-empty {
    padding: 4px 14px;
    font-size: 12px;
    line-height: var(--lh-normal);
    color: var(--text-faint);
}

.lib-list-group {
    flex: none;
    padding: 10px 14px 4px;
    font-size: 11px;
    font-weight: var(--fw-bold);
    letter-spacing: 0.4px;
    text-transform: uppercase;
    color: var(--text-faint);
}

.lib-empty {
    flex: 1;
    display: grid;
    place-items: center;
    font-size: 12.5px;
    color: var(--text-faint);
}
