/* BioStudio AI — Windows 11 style context menus */

.ctx-menu {
  position: fixed;
  z-index: 20000;
  min-width: 220px;
  max-width: 320px;
  padding: 6px;
  border-radius: 10px;
  background: var(--menu-bg, #ffffff);
  backdrop-filter: blur(min(34px, var(--bs-max-blur, 34px))) saturate(1.6);
  -webkit-backdrop-filter: blur(min(34px, var(--bs-max-blur, 34px))) saturate(1.6);
  border: 1px solid var(--menu-border, rgba(15, 23, 42, 0.12));
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.28), 0 0 0 0.5px rgba(0, 0, 0, 0.08);
  color: var(--ink, #132238);
  color-scheme: inherit;
  transform-origin: top left;
  opacity: 0;
  transform: scale(0.98);
  transition: opacity 0.06s ease, transform 0.06s ease;
  will-change: opacity, transform;
}
.ctx-menu.ctx-in { opacity: 1; transform: scale(1); }

.ctx-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  height: 34px;
  padding: 0 10px 0 8px;
  border-radius: 6px;
  font-size: 13px;
  text-align: left;
  color: var(--ink, #132238);
  white-space: nowrap;
}
.ctx-item:hover:not([disabled]) { background: var(--menu-hover, rgba(15, 23, 42, 0.06)); }
.ctx-item[disabled] { opacity: 0.4; cursor: default; }
.ctx-item.danger:hover:not([disabled]) { background: rgba(232, 17, 35, 0.12); color: #d11; }

.ctx-icon {
  width: 18px;
  height: 18px;
  flex: 0 0 18px;
  display: grid;
  place-items: center;
  color: var(--ink-soft);
}
.ctx-icon .icon { width: 16px; height: 16px; }
.ctx-check { width: 16px; height: 16px; color: var(--accent); }
.ctx-check svg { width: 100%; height: 100%; }

.ctx-swatch {
  width: 14px;
  height: 14px;
  border-radius: 50%;
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.28);
  background: transparent;
}
.ctx-swatch.is-empty {
  box-shadow: inset 0 0 0 1.5px color-mix(in srgb, var(--ink-soft) 70%, transparent);
}
.ctx-swatch.is-checked {
  box-shadow: inset 0 0 0 1px rgba(15, 23, 42, 0.3), 0 0 0 2px var(--accent, #2563eb);
}

.ctx-label { flex: 1; overflow: hidden; text-overflow: ellipsis; }

.ctx-shortcut {
  font-size: 11.5px;
  color: var(--ink-soft);
  letter-spacing: 0.3px;
}
.ctx-arrow {
  width: 14px;
  height: 14px;
  color: var(--ink-soft);
  display: grid;
  place-items: center;
}
.ctx-arrow .icon { width: 14px; height: 14px; }

.ctx-sep {
  height: 1px;
  margin: 5px 8px;
  background: var(--menu-border, rgba(0, 0, 0, 0.1));
}

.ctx-header {
  padding: 6px 10px 4px;
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.4px;
  text-transform: uppercase;
  color: var(--ink-soft);
}

/* Desktop shell menus follow the active OS theme tokens (flyout/ink).
   App windows stamp data-app-color-theme onto portaled menus so they
   follow that window instead of the shell. Fallback keeps classic light. */
html body .ctx-menu[role="menu"]:not([data-app-color-theme]) {
  --menu-bg: var(--flyout-bg, #ffffff);
  --menu-border: var(--flyout-border, rgba(15, 23, 42, 0.12));
  --menu-hover: var(--tb-hover, rgba(15, 23, 42, 0.06));
  background: var(--menu-bg, var(--flyout-bg, #ffffff));
  color: var(--ink, #132238);
  color-scheme: inherit;
}

/* Menus launched from a Report Studio / PowerPoint surface embedded in
   Clarity are portaled to <body>. Carry the host palette with them so opening
   a menu does not suddenly reveal the standalone Office styling. */
html body .ctx-menu[role="menu"][data-clarity-embed-menu] {
  --menu-bg: var(--clarity-surface) !important;
  --menu-border: var(--clarity-line) !important;
  --menu-hover: color-mix(in srgb, var(--clarity-primary-soft) 70%, var(--clarity-surface)) !important;
  --ink: var(--clarity-text) !important;
  --ink-soft: var(--clarity-muted) !important;
  background: var(--clarity-surface) !important;
  border-color: var(--clarity-line) !important;
  color: var(--clarity-text) !important;
  color-scheme: light;
  font-family: "InterVariable", Inter, ui-sans-serif, system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
html body .ctx-menu[role="menu"][data-clarity-embed-menu] * {
  --ink: var(--clarity-text) !important;
  --ink-soft: var(--clarity-muted) !important;
}
html body .ctx-menu[role="menu"][data-clarity-embed-menu] .ctx-item {
  color: var(--clarity-text) !important;
}
html body .ctx-menu[role="menu"][data-clarity-embed-menu] .ctx-item:hover:not([disabled]) {
  background: var(--menu-hover) !important;
}
html body .ctx-menu[role="menu"][data-clarity-embed-menu][data-clarity-tone="dark"] {
  color-scheme: dark;
}

html.shell-mobile .ctx-menu,
body.shell-mobile .ctx-menu {
  left: 8px !important;
  right: 8px !important;
  width: auto;
  max-width: none;
  bottom: calc(var(--ios-tab-h, 49px) + 8px);
  top: auto !important;
  max-height: min(52dvh, 420px);
  overflow: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 14px;
  padding: 8px;
  transform-origin: bottom center;
}

html.shell-mobile .ctx-item {
  min-height: 44px;
  height: auto;
  padding: 10px 12px;
  font-size: 16px;
}

