/* BayesPharma Copilot dark-mode + stacking hotfix.
   Scoped to the injected Innovator Copilot and Discovery Campaign tier card. */

/* The Copilot must always own the interaction layer while open. Account/profile
   widgets are rendered by a separate shell and previously painted over it. */
.bp-copilot-panel.innovator-copilot-panel,
.bp-workspace .bp-copilot-panel {
  z-index: 2147483600 !important;
  isolation: isolate;
}

.bp-copilot-launcher,
.bp-workspace .bp-copilot-launcher {
  z-index: 2147483500 !important;
}

/* Campaign-mode card: use Copilot theme tokens instead of inherited workspace
   whites/greys. The card is created dynamically by discovery-campaign-integrated-evidence.js. */
.bp-copilot-panel [data-campaign-tier-card="1"] {
  display: block !important;
  margin: .7rem .72rem !important;
  padding: .9rem !important;
  border: 1px solid var(--bp-copilot-line-strong) !important;
  border-radius: 1.1rem !important;
  background: linear-gradient(180deg,
    color-mix(in srgb, var(--bp-copilot-surface) 96%, var(--bp-copilot-accent) 4%),
    var(--bp-copilot-surface-2)) !important;
  color: var(--bp-copilot-ink) !important;
  box-shadow: 0 10px 30px rgba(2, 13, 31, .08) !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .bp-copilot-card-icon {
  display: none !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .bp-copilot-card-body {
  width: 100% !important;
  min-width: 0 !important;
  color: var(--bp-copilot-ink) !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] strong,
.bp-copilot-panel [data-campaign-tier-card="1"] p,
.bp-copilot-panel [data-campaign-tier-card="1"] small,
.bp-copilot-panel [data-campaign-tier-card="1"] span {
  color: inherit !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] > .bp-copilot-card-body > strong {
  display: block;
  margin: 0 0 .35rem;
  color: var(--bp-copilot-ink) !important;
  font-size: 1rem !important;
  font-weight: 900 !important;
  letter-spacing: -.02em;
}

.bp-copilot-panel [data-campaign-tier-card="1"] > .bp-copilot-card-body > p {
  margin: 0 0 .72rem !important;
  color: var(--bp-copilot-muted) !important;
  font-size: .72rem !important;
  line-height: 1.5 !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .innovator-card-kicker {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  margin-bottom: .62rem !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .innovator-card-kicker small {
  color: var(--bp-copilot-muted) !important;
  font-size: .54rem !important;
  font-weight: 900 !important;
  letter-spacing: .09em;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .innovator-evidence-badge {
  flex: 0 0 auto;
  padding: .28rem .48rem !important;
  border: 1px solid color-mix(in srgb, var(--bp-copilot-accent) 22%, transparent) !important;
  border-radius: 999px !important;
  background: var(--bp-copilot-accent-soft) !important;
  color: var(--bp-copilot-accent) !important;
  font-size: .5rem !important;
  font-weight: 900 !important;
  letter-spacing: .05em;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .bp-chat-tier-options {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: .46rem !important;
  margin: .65rem 0 .8rem !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .bp-chat-tier-options button {
  width: 100% !important;
  min-width: 0 !important;
  min-height: 2.7rem !important;
  margin: 0 !important;
  padding: .58rem .64rem !important;
  border: 1px solid var(--bp-copilot-line-strong) !important;
  border-radius: .78rem !important;
  background: var(--bp-copilot-surface) !important;
  color: var(--bp-copilot-ink) !important;
  font: 850 .69rem/1.2 system-ui, sans-serif !important;
  text-align: left !important;
  box-shadow: none !important;
  transition: border-color .16s ease, background .16s ease, transform .16s ease !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .bp-chat-tier-options button:hover,
.bp-copilot-panel [data-campaign-tier-card="1"] .bp-chat-tier-options button:focus-visible {
  border-color: color-mix(in srgb, var(--bp-copilot-accent) 58%, var(--bp-copilot-line-strong)) !important;
  background: var(--bp-copilot-accent-soft) !important;
  color: var(--bp-copilot-ink) !important;
  transform: translateY(-1px);
  outline: none !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .bp-chat-tier-options button[aria-pressed="true"],
.bp-copilot-panel [data-campaign-tier-card="1"] .bp-chat-tier-options button.is-selected {
  border-color: var(--bp-copilot-accent) !important;
  background: var(--bp-copilot-accent-soft) !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .innovator-boundary {
  margin-top: .62rem !important;
  padding: .62rem .7rem !important;
  border: 1px solid color-mix(in srgb, var(--bp-copilot-accent) 18%, var(--bp-copilot-line)) !important;
  border-radius: .72rem !important;
  background: color-mix(in srgb, var(--bp-copilot-accent-soft) 55%, var(--bp-copilot-surface)) !important;
  color: var(--bp-copilot-muted) !important;
  font-size: .62rem !important;
  line-height: 1.45 !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .innovator-entity-actions {
  display: flex !important;
  flex-wrap: wrap !important;
  gap: .42rem !important;
  margin-top: .72rem !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .innovator-entity-actions button,
.bp-copilot-panel [data-campaign-tier-card="1"] .innovator-entity-actions a {
  min-height: 2.25rem !important;
  margin: 0 !important;
  padding: .5rem .7rem !important;
  border: 1px solid var(--bp-copilot-line-strong) !important;
  border-radius: .68rem !important;
  background: var(--bp-copilot-surface) !important;
  color: var(--bp-copilot-ink) !important;
  font: 800 .63rem/1.15 system-ui, sans-serif !important;
  text-decoration: none !important;
}

.bp-copilot-panel [data-campaign-tier-card="1"] .innovator-entity-actions button:hover,
.bp-copilot-panel [data-campaign-tier-card="1"] .innovator-entity-actions a:hover {
  border-color: var(--bp-copilot-accent) !important;
  background: var(--bp-copilot-accent-soft) !important;
  color: var(--bp-copilot-accent) !important;
}

/* Dark mode: explicitly remove the washed-out grey inherited from workspace cards. */
html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] {
  border-color: rgba(140, 180, 235, .19) !important;
  background: linear-gradient(180deg, #10213a 0%, #0c192c 100%) !important;
  color: #f3f7ff !important;
  box-shadow: 0 18px 42px rgba(0, 0, 0, .26) !important;
}

html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] > .bp-copilot-card-body > p,
html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] .innovator-boundary {
  color: #aebed5 !important;
}

html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] .bp-chat-tier-options button,
html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] .innovator-entity-actions button,
html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] .innovator-entity-actions a {
  border-color: rgba(151, 188, 238, .2) !important;
  background: #0a1729 !important;
  color: #eef5ff !important;
}

html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] .bp-chat-tier-options button:hover,
html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] .bp-chat-tier-options button:focus-visible,
html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] .innovator-entity-actions button:hover,
html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] .innovator-entity-actions a:hover {
  border-color: #6aa9ff !important;
  background: #142f54 !important;
  color: #ffffff !important;
}

html[data-theme="dark"] .bp-copilot-panel [data-campaign-tier-card="1"] .innovator-boundary {
  border-color: rgba(102, 169, 255, .18) !important;
  background: #0a1c32 !important;
}

/* Header resilience. Keep title/control groups from colliding even on narrow desktop
   panels and large browser text settings. */
.bp-copilot-panel .bp-copilot-head {
  position: relative;
  z-index: 2;
  min-width: 0;
}

.bp-copilot-panel .bp-copilot-title {
  min-width: 0 !important;
  overflow: hidden;
}

.bp-copilot-panel .bp-copilot-title-row {
  min-width: 0;
  flex-wrap: wrap;
  row-gap: .18rem;
}

.bp-copilot-panel .bp-copilot-title-row > strong {
  min-width: 0;
  max-width: 100% !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bp-copilot-panel .bp-copilot-head-actions {
  position: relative;
  z-index: 3;
  flex: 0 0 auto !important;
  margin-left: auto;
}

/* Make the main conversation/composer visually coherent in dark mode. */
html[data-theme="dark"] .bp-copilot-panel .bp-copilot-messages {
  background: #07101f !important;
}

html[data-theme="dark"] .bp-copilot-panel .bp-copilot-composer-wrap {
  border-top-color: rgba(177, 209, 250, .12) !important;
  background: #0b1729 !important;
}

html[data-theme="dark"] .bp-copilot-panel .bp-copilot-composer {
  border-color: rgba(151, 188, 238, .22) !important;
  background: #071426 !important;
}

html[data-theme="dark"] .bp-copilot-panel #innovatorCopilotInput {
  color: #eef5ff !important;
  background: transparent !important;
}

html[data-theme="dark"] .bp-copilot-panel #innovatorCopilotInput::placeholder {
  color: #8297b5 !important;
}

/* Mobile bottom-navigation clearance.
   The Innovator home uses a sticky bottom action dock; keep both the collapsed
   Copilot launcher and the expanded panel completely above that interaction
   surface.  env(safe-area-inset-bottom) also protects gesture/navigation areas
   on iOS and Android webviews. */
@media (max-width: 700px) {
  :root {
    --bp-mobile-nav-clearance: 6.35rem;
  }

  .bp-copilot-launcher,
  .bp-workspace .bp-copilot-launcher {
    bottom: calc(var(--bp-mobile-nav-clearance) + env(safe-area-inset-bottom, 0px)) !important;
    right: max(.85rem, env(safe-area-inset-right)) !important;
    max-width: calc(100vw - 1.7rem);
  }

  .bp-copilot-panel.innovator-copilot-panel,
  .bp-workspace .bp-copilot-panel {
    top: max(.45rem, env(safe-area-inset-top)) !important;
    right: max(.45rem, env(safe-area-inset-right)) !important;
    bottom: calc(var(--bp-mobile-nav-clearance) + env(safe-area-inset-bottom, 0px)) !important;
    left: max(.45rem, env(safe-area-inset-left)) !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
  }
}

@media (max-width: 420px) {
  :root {
    --bp-mobile-nav-clearance: 6.6rem;
  }

  .bp-copilot-launcher,
  .bp-workspace .bp-copilot-launcher {
    min-height: 3.15rem;
  }
}
