/**
 * Shell layout: fixed header + MFE area below. Scroll stays inside #mfe-root.
 * Exports --bsc-shell-header-height and --bsc-mfe-height for MFE chrome.
 */
:root {
  --bsc-shell-header-height: 4rem; /* 64px */
  --bsc-mfe-height: calc(100dvh - var(--bsc-shell-header-height));
  --bsc-topbar-accent-foreground: #f8a545;
  /* Shell stacking ladder — layout contract (see docs/design-system-mfe-handoff.md) */
  --bsc-z-mfe: 0;
  --bsc-z-header: 10050;
  --bsc-z-shell-dropdown: 10060;
  --bsc-z-dialog-overlay: 10070;
  --bsc-z-dialog-content: 10071;
  --bsc-z-sheet-overlay: 10040;
  --bsc-z-sheet-content: 10041;
  --bsc-z-select-popover: 10080;
  --bsc-z-transition: 9998;
}

html {
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}

body {
  margin: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  max-height: 100dvh;
  overflow: hidden;
}

#header-root {
  position: relative;
  z-index: var(--bsc-z-header);
  flex: 0 0 var(--bsc-shell-header-height);
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  align-self: stretch;
  /* Host-owned topbar tokens (Ariad DS brand). Mapped to --sidebar-* for AriadTopbar. */
  --bsc-topbar-bg: #0f3e71;
  --bsc-topbar-foreground: #ffffff;
  --bsc-topbar-muted-foreground: #e4eefa;
  --bsc-topbar-accent: #194673;
  --bsc-topbar-accent-foreground: #f8a545;
  --bsc-topbar-border: #1f66aa;
  --bsc-topbar-ring: #f8a545;
  --sidebar: var(--bsc-topbar-bg);
  --sidebar-foreground: var(--bsc-topbar-foreground);
  --sidebar-muted-foreground: var(--bsc-topbar-muted-foreground);
  --sidebar-accent: var(--bsc-topbar-accent);
  --sidebar-accent-foreground: var(--bsc-topbar-accent-foreground);
  --sidebar-border: var(--bsc-topbar-border);
  --sidebar-ring: var(--bsc-topbar-ring);
}

html.dark #header-root {
  --bsc-topbar-bg: #171717;
  --bsc-topbar-foreground: #fafafa;
  --bsc-topbar-muted-foreground: #f2f7fd;
  --bsc-topbar-accent: #404040;
  --bsc-topbar-accent-foreground: #f8a545;
  --bsc-topbar-border: #ffffff1a;
  --bsc-topbar-ring: #f8a545;
  --sidebar: var(--bsc-topbar-bg);
  --sidebar-foreground: var(--bsc-topbar-foreground);
  --sidebar-muted-foreground: var(--bsc-topbar-muted-foreground);
  --sidebar-accent: var(--bsc-topbar-accent);
  --sidebar-accent-foreground: var(--bsc-topbar-accent-foreground);
  --sidebar-border: var(--bsc-topbar-border);
  --sidebar-ring: var(--bsc-topbar-ring);
}

#mfe-root {
  position: relative;
  z-index: var(--bsc-z-mfe);
  flex: 0 0 var(--bsc-mfe-height);
  height: var(--bsc-mfe-height);
  max-height: var(--bsc-mfe-height);
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--background, #fcfcfc);
}

#mfe-root > .host-shell-page {
  --sidebar: var(--background);
  --sidebar-foreground: var(--foreground);
  --sidebar-muted-foreground: var(--muted-foreground);
  --sidebar-accent: var(--muted);
  --sidebar-accent-foreground: var(--bsc-topbar-accent-foreground);
  /* Soft edge between admin nav and content (avoid bright --border line). */
  --sidebar-border: transparent;
  --sidebar-ring: var(--ring);
}

/** Active single-spa app root: fill #mfe-root (avoid body scroll / bleed-through). */
#mfe-root > * {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/** Host-owned pages (admin access, access denied): scroll inside the MFE slot. */
#mfe-root > .host-shell-page {
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior-y: contain;
}

/* Host-owned body portaled overlays (Feedback, admin dialogs, header menus) */
body > [data-slot='dialog-overlay']:has(~ [data-slot='dialog-content'][data-bsc-portal='host']) {
  z-index: var(--bsc-z-dialog-overlay) !important;
  inset: 0 !important;
  top: 0 !important;
  height: 100dvh !important;
  max-height: 100dvh !important;
}

[data-bsc-portal='host'][data-slot='dialog-content'] {
  z-index: var(--bsc-z-dialog-content) !important;
}

[data-bsc-portal='host'][data-slot='select-content'] {
  z-index: var(--bsc-z-select-popover) !important;
}

[data-bsc-portal='host'][data-slot='dropdown-menu-content'],
[data-bsc-portal='host'][data-slot='dropdown-menu-sub-content'] {
  z-index: var(--bsc-z-shell-dropdown) !important;
}

/* Host-owned sheets — sit in the MFE band below the fixed topbar (not under it). */
body > [data-slot='sheet-overlay']:has(~ [data-slot='sheet-content'][data-bsc-portal='host']) {
  z-index: var(--bsc-z-sheet-overlay) !important;
  top: var(--bsc-shell-header-height) !important;
  bottom: 0 !important;
  height: auto !important;
  max-height: none !important;
}

[data-bsc-portal='host'][data-slot='sheet-content'] {
  z-index: var(--bsc-z-sheet-content) !important;
  top: var(--bsc-shell-header-height) !important;
  bottom: 0 !important;
  height: auto !important;
  max-height: none !important;
}
