/* The stack of secondary sections inside the main page (issue #284, core/secondaryStack.ts).
   The host is a sibling of <main> in the shell body row, so it takes exactly the room <main>
   takes — the docked chat, voice and help panels are other siblings and stay where they are.
   While an entry is active <main> is hidden, not unmounted: the page keeps its state. */
.lf-shell-body[data-lf-secondary-active="1"] > main { display: none; }

.lf-secondary-host {
  flex: 1 1 auto;
  min-width: 0;
  min-height: 0;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  padding: 8px;
}
.lf-secondary-host[hidden] { display: none; }

/* Enlarge on a stack page fills the host, not the hidden <main>. The entry and its body are
   positioned, which would stop the section short of the host; they step aside while it lasts.
   A window host stays absolute so it still covers the window. */
.lf-secondary-host.lf-secondary-host-fullscreen { position: relative; }
.lf-window-body > .lf-secondary-host.lf-secondary-host-fullscreen { position: absolute; }
.lf-secondary-host.lf-secondary-host-fullscreen > .lf-secondary-entry:has(.section-is-fullscreen),
.lf-secondary-host.lf-secondary-host-fullscreen > .lf-secondary-entry:has(.section-is-fullscreen) > .lf-secondary-entry-body {
  position: static;
  overflow: visible;
}

.lf-secondary-entry {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  position: relative;
  border: 1px solid var(--bs-border-color, #ced4da);
  border-radius: 6px;
  background: var(--bs-body-bg, #fff);
  overflow: hidden;
}
.lf-secondary-entry[hidden] { display: none; }

/* A child section brings its own title bar, with the close after Enlarge. The entry is then
   the page, not a card wrapped around the page. */
.lf-secondary-entry.is-headerless {
  border: 0;
  border-radius: 0;
  background: transparent;
}
.lf-secondary-section {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}
.lf-secondary-section > .section-page-container {
  flex: 1 1 auto;
  min-height: 0;
}

.lf-secondary-entry-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 10px;
  border-bottom: 1px solid var(--bs-border-color, #ced4da);
  background: var(--bs-tertiary-bg, #f8f9fa);
}
.lf-secondary-entry-title { flex: 1 1 auto; margin: 0; font-size: 1rem; font-weight: 600; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-secondary-entry-body { flex: 1 1 auto; min-height: 0; overflow: auto; position: relative; display: flex; flex-direction: column; }
.lf-secondary-entry-body > * { flex: 1 1 auto; min-height: 0; }

/* Toolbar button and its list. The button lives on the command toolbar (the FullEdit strip,
   or the section bar when that strip is not on screen). The count is how many surfaces are
   open, including the main page; a warning underline means one of them has unsaved work. */
.lf-secondary-pin {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
}
.lf-secondary-pin[hidden] { display: none; }
.lf-secondary-toggle { position: relative; overflow: visible; }
.lf-secondary-toggle[hidden] { display: none !important; }
.lf-secondary-toggle.is-dirty { box-shadow: inset 0 -2px 0 var(--bs-warning, #ffc107); }
.lf-secondary-count {
  position: absolute;
  top: -0.3rem;
  right: -0.3rem;
  min-width: 1rem;
  height: 1rem;
  padding: 0 0.2rem;
  border-radius: 999px;
  background: var(--bs-warning, #ffc107);
  color: #212529;
  font-size: 0.65rem;
  font-weight: 700;
  line-height: 1rem;
  text-align: center;
  pointer-events: none;
}

.lf-secondary-menu {
  position: fixed;
  z-index: 1090;
  min-width: 260px;
  max-width: min(420px, 96vw);
  background: var(--bs-body-bg, #fff);
  color: var(--bs-body-color, #212529);
  border: 1px solid var(--bs-border-color, #ced4da);
  border-radius: 6px;
  box-shadow: 0 6px 24px rgba(0, 0, 0, .25);
  padding: 4px;
}
.lf-secondary-menu[hidden] { display: none; }
.lf-secondary-row { display: flex; align-items: center; gap: 6px; border-radius: 4px; }
.lf-secondary-row:hover, .lf-secondary-row:focus-within { background: var(--bs-secondary-bg, #e9ecef); }
.lf-secondary-row[aria-current="true"] { font-weight: 600; }
.lf-secondary-pick { flex: 1 1 auto; text-align: left; background: none; border: 0; padding: 6px 8px; color: inherit; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.lf-secondary-close { background: none; border: 0; padding: 4px 8px; color: inherit; opacity: .65; }
.lf-secondary-close:hover { opacity: 1; }
.lf-secondary-dirty { color: var(--bs-warning, #ffc107); font-size: .6rem; }

/* Views management as a stack entry: the two panes fill the entry. */
.section-views-stacked { position: static; inset: auto; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; min-height: 0; }
.section-views-stacked .section-views-body { flex: 1 1 auto; min-height: 0; }

/* Conflict merge as a stack entry. */
.section-conflict-stacked { position: static; inset: auto; display: flex; flex-direction: column; align-items: stretch; justify-content: flex-start; min-height: 0; }

/* Mail merge as a stack entry. */
.mailmerge-overlay-stack { display: flex; flex-direction: column; min-height: 0; }
.mailmerge-overlay-stack .mailmerge-preview { flex: 1 1 auto; min-height: 0; overflow: auto; }

/* Linked-records panel as a stack entry: fills the entry instead of floating over the page. */
.lf-blocking-stacked { position: static; inset: auto; display: flex; }
.lf-blocking-stacked .lf-blocking { width: 100%; height: 100%; border: 0; border-radius: 0; }

/* FK picker as a stack entry (only when configured; the picker's default is a popup). */
.section-picker-stacked { position: static; inset: auto; display: flex; }
.section-picker-stacked .section-picker { width: 100%; height: 100%; max-width: none; max-height: none; border: 0; border-radius: 0; }

/* Popup-built panels still shown as stack entries. Document conversion, the PDF
   viewer and mail merge are headerless empty descriptors, so they do not come through here. */
.lf-panel-stacked { position: static; inset: auto; display: flex; flex-direction: column; min-height: 0; height: 100%; }
.lf-panel-stacked .section-picker { position: static; transform: none; width: 100%; max-width: none; height: 100%; max-height: none; border: 0; border-radius: 0; }

/* The record detail (SectionModal) as a stack entry: it fills the entry instead of floating. */
.section-detail-modal.section-modal-stacked { position: static; display: flex; flex-direction: column; opacity: 1; background: none; width: auto; height: auto; overflow: hidden; }
.section-detail-modal.section-modal-stacked .modal-dialog { flex: 1 1 auto; min-height: 0; max-width: none; width: 100%; height: auto; margin: 0; transform: none; display: flex; }
.section-detail-modal.section-modal-stacked .modal-content { flex: 1 1 auto; min-height: 0; max-height: none; height: auto; border: 0; border-radius: 0; }
.section-detail-modal.section-modal-stacked .section-modal-btn-enlarge { display: none; }

/* SpaDesktop: a window has a stack of its own. The host is a sibling of the surface inside the
   window body and covers it; the surface stays mounted underneath, hidden. */
.lf-window-body > .lf-secondary-host { position: absolute; inset: 0; z-index: 1; background: var(--bs-body-bg, #fff); }
.lf-surface-inline[data-lf-secondary-active="1"] { display: none; }
