/* BayesPharma Innovator Copilot v4 UI fix
   Replaces the previous override layer. Keeps the existing runtime intact while
   fixing missing icon-font fallbacks, oversized blank controls, native scrollbars,
   cramped welcome content, and workspace-specific cascade conflicts. */

:root {
  --bp-copilot-bg: #f6f9ff;
  --bp-copilot-surface: #ffffff;
  --bp-copilot-surface-2: #f1f5fc;
  --bp-copilot-surface-3: #e8f0ff;
  --bp-copilot-ink: #08172d;
  --bp-copilot-muted: #65758e;
  --bp-copilot-line: rgba(22, 62, 119, .12);
  --bp-copilot-line-strong: rgba(22, 62, 119, .20);
  --bp-copilot-accent: #1268f4;
  --bp-copilot-accent-2: #6658ed;
  --bp-copilot-accent-soft: #eaf2ff;
  --bp-copilot-user: #0d5ed2;
  --bp-copilot-shadow: 0 28px 80px rgba(20, 53, 99, .18), 0 8px 26px rgba(20, 53, 99, .09);
}

html[data-theme="dark"] {
  --bp-copilot-bg: #07101f;
  --bp-copilot-surface: #0d192d;
  --bp-copilot-surface-2: #12233d;
  --bp-copilot-surface-3: #183052;
  --bp-copilot-ink: #eff6ff;
  --bp-copilot-muted: #9fb0ca;
  --bp-copilot-line: rgba(191, 218, 255, .12);
  --bp-copilot-line-strong: rgba(191, 218, 255, .2);
  --bp-copilot-accent: #6aa9ff;
  --bp-copilot-accent-2: #a18cff;
  --bp-copilot-accent-soft: #142f54;
  --bp-copilot-user: #195da9;
  --bp-copilot-shadow: 0 30px 90px rgba(0, 0, 0, .5), 0 10px 28px rgba(0, 0, 0, .28);
}

/* Never depend on Font Awesome for the primary controls. */
.bp-workspace .bp-copilot-launcher-icon i,
.bp-workspace .bp-copilot-mark i,
.bp-workspace .bp-copilot-welcome-orb i,
.bp-workspace #innovatorCopilotExpand i,
.bp-workspace #innovatorCopilotNew i,
.bp-workspace #innovatorCopilotClose i,
.bp-workspace #innovatorCopilotSend i,
.bp-copilot-panel .bp-copilot-mark i,
.bp-copilot-panel .bp-copilot-welcome-orb i,
.bp-copilot-panel #innovatorCopilotExpand i,
.bp-copilot-panel #innovatorCopilotNew i,
.bp-copilot-panel #innovatorCopilotClose i,
.bp-copilot-panel #innovatorCopilotSend i {
  display: none !important;
}

.bp-copilot-launcher-icon::before,
.bp-copilot-mark::before,
.bp-copilot-welcome-orb::before {
  content: "✦";
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  font-size: 1rem;
  font-weight: 900;
  line-height: 1;
}

#innovatorCopilotExpand::before { content: "↗"; }
#innovatorCopilotNew::before { content: "+"; }
#innovatorCopilotClose::before { content: "×"; }
#innovatorCopilotSend::before { content: "↑"; }

/* Launcher */
.bp-workspace .bp-copilot-launcher,
.bp-copilot-launcher {
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  display: inline-flex;
  align-items: center;
  gap: .64rem;
  min-height: 3.45rem;
  padding: .5rem .9rem .5rem .56rem;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: 1rem;
  background: linear-gradient(135deg, #0759d5 0%, #0b73ec 58%, #6259ec 125%);
  color: #fff !important;
  box-shadow: 0 18px 44px rgba(5, 73, 165, .28), inset 0 1px 0 rgba(255,255,255,.18);
}

.bp-workspace .bp-copilot-launcher:hover,
.bp-copilot-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 22px 52px rgba(5,73,165,.34), inset 0 1px 0 rgba(255,255,255,.18);
}

.bp-workspace .bp-copilot-launcher-icon,
.bp-copilot-launcher-icon {
  display: grid;
  place-items: center;
  width: 2.3rem;
  height: 2.3rem;
  flex: 0 0 2.3rem;
  border: 1px solid rgba(255,255,255,.18);
  border-radius: .78rem;
  background: rgba(255,255,255,.14);
  color: #fff !important;
}

.bp-copilot-launcher-copy {
  display: grid;
  gap: .05rem;
  min-width: 0;
  text-align: left;
}

.bp-copilot-launcher-copy strong {
  color: #fff !important;
  font-size: .84rem;
  font-weight: 900;
  line-height: 1.15;
  white-space: nowrap;
}

.bp-copilot-launcher-copy small {
  color: rgba(255,255,255,.74) !important;
  font-size: .59rem;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
}

/* Panel shell */
.bp-workspace .bp-copilot-panel,
.bp-copilot-panel.innovator-copilot-panel {
  right: max(1.15rem, env(safe-area-inset-right));
  bottom: max(1.15rem, env(safe-area-inset-bottom));
  width: min(438px, calc(100vw - 2.3rem));
  height: min(700px, calc(100dvh - 2.3rem));
  min-height: min(530px, calc(100dvh - 2.3rem));
  grid-template-rows: auto auto auto minmax(0,1fr) auto !important;
  overflow: hidden;
  border: 1px solid var(--bp-copilot-line-strong);
  border-radius: 1.42rem;
  background: var(--bp-copilot-bg);
  color: var(--bp-copilot-ink) !important;
  box-shadow: var(--bp-copilot-shadow);
}

/* Header */
.bp-workspace .bp-copilot-head,
.bp-copilot-panel .bp-copilot-head {
  display: flex;
  align-items: center;
  gap: .65rem;
  min-height: 74px;
  padding: .7rem .74rem .7rem .78rem;
  border-bottom: 1px solid var(--bp-copilot-line);
  background: color-mix(in srgb, var(--bp-copilot-surface) 96%, transparent);
  backdrop-filter: blur(18px) saturate(135%);
}

.bp-workspace .bp-copilot-mark,
.bp-copilot-panel .bp-copilot-mark {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  flex: 0 0 2.55rem;
  border-radius: .82rem;
  background: linear-gradient(145deg, #0759d5, #176fe5 60%, #665de7);
  color: #fff !important;
  box-shadow: 0 8px 18px rgba(17,103,229,.2), inset 0 1px rgba(255,255,255,.18);
}

.bp-workspace .bp-copilot-title,
.bp-copilot-panel .bp-copilot-title {
  min-width: 0;
  flex: 1;
}

.bp-workspace .bp-copilot-title-row,
.bp-copilot-panel .bp-copilot-title-row {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-width: 0;
}

.bp-workspace .bp-copilot-title-row strong,
.bp-copilot-panel .bp-copilot-title-row strong {
  max-width: 12.5rem;
  overflow: hidden;
  color: var(--bp-copilot-ink) !important;
  font-size: .95rem;
  font-weight: 900;
  letter-spacing: -.024em;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bp-workspace .bp-copilot-free-badge,
.bp-copilot-panel .bp-copilot-free-badge {
  display: inline-flex;
  align-items: center;
  min-height: 1.22rem;
  padding: 0 .42rem;
  border: 1px solid color-mix(in srgb, var(--bp-copilot-accent) 16%, transparent);
  border-radius: 999px;
  background: var(--bp-copilot-accent-soft);
  color: var(--bp-copilot-accent) !important;
  font-size: .51rem;
  font-weight: 900;
  letter-spacing: .06em;
}

.bp-workspace .bp-copilot-subtitle,
.bp-copilot-panel .bp-copilot-subtitle {
  display: block;
  margin-top: .1rem;
  color: var(--bp-copilot-muted) !important;
  font-size: .65rem;
  font-weight: 650;
  line-height: 1.2;
}

.bp-workspace .bp-copilot-presence,
.bp-copilot-panel .bp-copilot-presence {
  margin-top: .13rem;
  color: var(--bp-copilot-muted) !important;
  font-size: .59rem;
}

.bp-workspace .bp-copilot-head-actions,
.bp-copilot-panel .bp-copilot-head-actions {
  display: flex;
  align-items: center;
  gap: .22rem;
  flex: 0 0 auto;
}

.bp-workspace #innovatorCopilotExpand,
.bp-workspace #innovatorCopilotNew,
.bp-workspace #innovatorCopilotClose,
.bp-copilot-panel #innovatorCopilotExpand,
.bp-copilot-panel #innovatorCopilotNew,
.bp-copilot-panel #innovatorCopilotClose {
  display: grid !important;
  place-items: center !important;
  width: 2.12rem !important;
  height: 2.12rem !important;
  min-width: 2.12rem !important;
  min-height: 2.12rem !important;
  padding: 0 !important;
  border: 1px solid var(--bp-copilot-line) !important;
  border-radius: .68rem !important;
  background: var(--bp-copilot-surface-2) !important;
  color: var(--bp-copilot-ink) !important;
  font: 800 .92rem/1 system-ui, sans-serif !important;
  box-shadow: none !important;
}

.bp-workspace #innovatorCopilotExpand:hover,
.bp-workspace #innovatorCopilotNew:hover,
.bp-workspace #innovatorCopilotClose:hover,
.bp-copilot-panel #innovatorCopilotExpand:hover,
.bp-copilot-panel #innovatorCopilotNew:hover,
.bp-copilot-panel #innovatorCopilotClose:hover {
  border-color: color-mix(in srgb, var(--bp-copilot-accent) 30%, var(--bp-copilot-line)) !important;
  background: var(--bp-copilot-accent-soft) !important;
  color: var(--bp-copilot-accent) !important;
}

.bp-workspace #innovatorCopilotExpand span,
.bp-workspace #innovatorCopilotNew span,
.bp-copilot-panel #innovatorCopilotExpand span,
.bp-copilot-panel #innovatorCopilotNew span {
  display: none !important;
}

/* Context */
.bp-workspace .innovator-contextbar,
.bp-copilot-panel .innovator-contextbar {
  display: flex;
  align-items: center;
  gap: .4rem;
  min-height: 38px;
  padding: .34rem .68rem;
  border-bottom: 1px solid var(--bp-copilot-line);
  background: color-mix(in srgb, var(--bp-copilot-accent-soft) 38%, var(--bp-copilot-surface));
}

.bp-workspace .innovator-context-chips,
.bp-copilot-panel .innovator-context-chips {
  min-width: 0;
  flex: 1;
}

.bp-workspace .innovator-context-chips span,
.bp-copilot-panel .innovator-context-chips span {
  min-height: 1.65rem;
  padding: .24rem .42rem;
  border: 1px solid var(--bp-copilot-line);
  border-radius: .6rem;
  background: var(--bp-copilot-surface);
}

.bp-workspace .innovator-context-clear,
.bp-copilot-panel .innovator-context-clear {
  flex: 0 0 auto;
  min-height: 1.75rem;
  padding: .22rem .48rem !important;
  border: 1px solid var(--bp-copilot-line) !important;
  border-radius: .58rem !important;
  background: var(--bp-copilot-surface) !important;
  color: var(--bp-copilot-muted) !important;
  font-size: .58rem !important;
  font-weight: 800 !important;
  line-height: 1 !important;
}

.bp-workspace .innovator-context-empty,
.bp-copilot-panel .innovator-context-empty {
  color: var(--bp-copilot-muted) !important;
  font-size: .61rem;
  font-weight: 650;
}

/* Modes */
.bp-workspace .innovator-copilot-modebar,
.bp-copilot-panel .innovator-copilot-modebar {
  display: flex;
  align-items: center;
  gap: .22rem;
  padding: .4rem .58rem;
  overflow-x: auto;
  border-bottom: 1px solid var(--bp-copilot-line);
  background: var(--bp-copilot-surface);
  scrollbar-width: none;
}

.bp-workspace .innovator-copilot-modebar::-webkit-scrollbar,
.bp-copilot-panel .innovator-copilot-modebar::-webkit-scrollbar { display: none; }

.bp-workspace .innovator-copilot-mode,
.bp-copilot-panel .innovator-copilot-mode {
  flex: 1 0 auto;
  min-height: 1.95rem;
  padding: .3rem .48rem !important;
  border: 1px solid transparent !important;
  border-radius: .58rem !important;
  background: transparent !important;
  color: var(--bp-copilot-muted) !important;
  font-size: .59rem !important;
  font-weight: 820 !important;
  line-height: 1 !important;
}

.bp-workspace .innovator-copilot-mode i,
.bp-copilot-panel .innovator-copilot-mode i { display: none !important; }

.bp-workspace .innovator-copilot-mode.active,
.bp-workspace .innovator-copilot-mode:hover,
.bp-copilot-panel .innovator-copilot-mode.active,
.bp-copilot-panel .innovator-copilot-mode:hover {
  border-color: color-mix(in srgb, var(--bp-copilot-accent) 20%, var(--bp-copilot-line)) !important;
  background: var(--bp-copilot-accent-soft) !important;
  color: var(--bp-copilot-accent) !important;
}

/* Conversation */
.bp-workspace .bp-copilot-messages,
.bp-copilot-panel .bp-copilot-messages {
  min-height: 0;
  overflow-y: auto !important;
  padding: .82rem .78rem 1rem;
  background: radial-gradient(circle at 100% 0, color-mix(in srgb, var(--bp-copilot-accent) 6%, transparent), transparent 15rem), var(--bp-copilot-bg);
  overscroll-behavior: contain;
  scrollbar-width: none;
}

.bp-workspace .bp-copilot-messages::-webkit-scrollbar,
.bp-copilot-panel .bp-copilot-messages::-webkit-scrollbar,
.bp-workspace .bp-copilot-messages::-webkit-scrollbar-button,
.bp-copilot-panel .bp-copilot-messages::-webkit-scrollbar-button {
  width: 0;
  height: 0;
  display: none;
}

.bp-workspace .bp-copilot-welcome,
.bp-copilot-panel .bp-copilot-welcome {
  min-height: auto !important;
  justify-content: flex-start !important;
  padding: .35rem .02rem .6rem !important;
  text-align: left !important;
}

.bp-workspace .bp-copilot-welcome-orb,
.bp-copilot-panel .bp-copilot-welcome-orb {
  display: grid;
  place-items: center;
  width: 2.55rem;
  height: 2.55rem;
  margin: 0 0 .56rem;
  border: 1px solid color-mix(in srgb, var(--bp-copilot-accent) 16%, transparent);
  border-radius: .8rem;
  background: linear-gradient(145deg, #eaf2ff, #eef0ff);
  color: var(--bp-copilot-accent) !important;
  box-shadow: 0 7px 18px rgba(24,94,191,.07);
}

html[data-theme="dark"] .bp-copilot-welcome-orb {
  background: linear-gradient(145deg, #14325a, #28284e);
}

.bp-workspace .bp-copilot-welcome-kicker,
.bp-copilot-panel .bp-copilot-welcome-kicker {
  color: var(--bp-copilot-accent) !important;
  font-size: .55rem !important;
  font-weight: 950 !important;
  letter-spacing: .105em !important;
}

.bp-workspace .bp-copilot-welcome h2,
.bp-copilot-panel .bp-copilot-welcome h2 {
  margin: .3rem 0 0 !important;
  color: var(--bp-copilot-ink) !important;
  font-size: 1.12rem !important;
  line-height: 1.12 !important;
  letter-spacing: -.035em !important;
}

.bp-workspace .bp-copilot-welcome p,
.bp-copilot-panel .bp-copilot-welcome p {
  max-width: none !important;
  margin: .48rem 0 .7rem !important;
  color: var(--bp-copilot-muted) !important;
  font-size: .72rem !important;
  line-height: 1.48 !important;
}

.bp-workspace .bp-copilot-welcome p strong,
.bp-copilot-panel .bp-copilot-welcome p strong { color: var(--bp-copilot-ink) !important; }

.bp-workspace .bp-copilot-suggestions,
.bp-copilot-panel .bp-copilot-suggestions {
  display: grid !important;
  grid-template-columns: repeat(2, minmax(0,1fr)) !important;
  gap: .38rem !important;
}

.bp-workspace .bp-copilot-suggestion,
.bp-copilot-panel .bp-copilot-suggestion {
  width: 100% !important;
  min-height: 2.35rem !important;
  justify-content: space-between !important;
  gap: .45rem !important;
  padding: .52rem .58rem !important;
  border: 1px solid var(--bp-copilot-line) !important;
  border-radius: .68rem !important;
  background: var(--bp-copilot-surface) !important;
  color: var(--bp-copilot-ink) !important;
  box-shadow: 0 3px 10px rgba(25,62,112,.03) !important;
  font-size: .66rem !important;
  font-weight: 760 !important;
  line-height: 1.25 !important;
  text-align: left !important;
}

.bp-workspace .bp-copilot-suggestion i,
.bp-copilot-panel .bp-copilot-suggestion i { display: none !important; }

.bp-workspace .bp-copilot-suggestion:hover,
.bp-copilot-panel .bp-copilot-suggestion:hover {
  transform: translateY(-1px);
  border-color: color-mix(in srgb, var(--bp-copilot-accent) 28%, var(--bp-copilot-line)) !important;
  background: color-mix(in srgb, var(--bp-copilot-accent-soft) 50%, var(--bp-copilot-surface)) !important;
}

/* Existing conversation content */
.bp-workspace .bp-copilot-bubble-user,
.bp-copilot-panel .bp-copilot-bubble-user {
  max-width: 86%;
  border-radius: .88rem .88rem .28rem .88rem;
  background: linear-gradient(135deg, #095fda, #315fd8);
  color: #fff !important;
  font-size: .75rem;
  line-height: 1.48;
}

.bp-workspace .bp-copilot-assistant-text,
.bp-copilot-panel .bp-copilot-assistant-text {
  color: var(--bp-copilot-ink) !important;
  font-size: .75rem;
  line-height: 1.56;
}

/* Composer */
.bp-workspace .bp-copilot-composer-wrap,
.bp-copilot-panel .bp-copilot-composer-wrap {
  padding: .62rem .68rem .58rem !important;
  border-top: 1px solid var(--bp-copilot-line) !important;
  background: var(--bp-copilot-surface) !important;
}

.bp-workspace .bp-copilot-composer,
.bp-copilot-panel .bp-copilot-composer {
  display: flex !important;
  align-items: flex-end !important;
  gap: .42rem !important;
  padding: .36rem .38rem .36rem .7rem !important;
  border: 1px solid var(--bp-copilot-line-strong) !important;
  border-radius: 1rem !important;
  background: var(--bp-copilot-surface) !important;
  box-shadow: 0 5px 16px rgba(24,62,118,.05) !important;
}

.bp-workspace .bp-copilot-composer:focus-within,
.bp-copilot-panel .bp-copilot-composer:focus-within {
  border-color: color-mix(in srgb, var(--bp-copilot-accent) 50%, var(--bp-copilot-line)) !important;
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--bp-copilot-accent) 10%, transparent), 0 6px 20px rgba(24,62,118,.07) !important;
}

.bp-workspace #innovatorCopilotInput,
.bp-copilot-panel #innovatorCopilotInput {
  flex: 1 1 auto !important;
  width: auto !important;
  min-width: 0 !important;
  min-height: 2.7rem !important;
  max-height: 7.2rem !important;
  margin: 0 !important;
  padding: .62rem 0 .52rem !important;
  border: 0 !important;
  outline: 0 !important;
  border-radius: 0 !important;
  background: transparent !important;
  color: var(--bp-copilot-ink) !important;
  box-shadow: none !important;
  resize: none !important;
  overflow-y: auto !important;
  scrollbar-width: none !important;
  font-size: .76rem !important;
  line-height: 1.45 !important;
}

.bp-workspace #innovatorCopilotInput::-webkit-scrollbar,
.bp-copilot-panel #innovatorCopilotInput::-webkit-scrollbar,
.bp-workspace #innovatorCopilotInput::-webkit-scrollbar-button,
.bp-copilot-panel #innovatorCopilotInput::-webkit-scrollbar-button {
  width: 0 !important;
  height: 0 !important;
  display: none !important;
}

.bp-workspace #innovatorCopilotInput::placeholder,
.bp-copilot-panel #innovatorCopilotInput::placeholder {
  color: color-mix(in srgb, var(--bp-copilot-muted) 86%, transparent) !important;
  opacity: 1 !important;
}

.bp-workspace #innovatorCopilotSend,
.bp-copilot-panel #innovatorCopilotSend {
  display: grid !important;
  place-items: center !important;
  width: 2.55rem !important;
  height: 2.55rem !important;
  min-width: 2.55rem !important;
  min-height: 2.55rem !important;
  flex: 0 0 2.55rem !important;
  margin: 0 !important;
  padding: 0 !important;
  border: 0 !important;
  border-radius: .78rem !important;
  background: linear-gradient(135deg, #075fdc, #1268f4 62%, #6658ed) !important;
  color: #fff !important;
  box-shadow: 0 7px 16px rgba(18,104,244,.22) !important;
  font: 900 1rem/1 system-ui, sans-serif !important;
}

.bp-workspace #innovatorCopilotSend:hover,
.bp-copilot-panel #innovatorCopilotSend:hover {
  transform: translateY(-1px);
  box-shadow: 0 9px 20px rgba(18,104,244,.28) !important;
}

.bp-workspace .bp-copilot-note,
.bp-copilot-panel .bp-copilot-note {
  margin: .42rem .16rem 0 !important;
  color: var(--bp-copilot-muted) !important;
  font-size: .54rem !important;
  line-height: 1.35 !important;
}

/* Keep any browser scrollbar buttons from appearing as giant native controls. */
.bp-copilot-panel *::-webkit-scrollbar-button { display: none !important; width: 0 !important; height: 0 !important; }

@media (max-width: 700px) {
  .bp-workspace .bp-copilot-panel,
  .bp-copilot-panel.innovator-copilot-panel {
    inset: max(.45rem, env(safe-area-inset-top)) max(.45rem, env(safe-area-inset-right)) max(.45rem, env(safe-area-inset-bottom)) max(.45rem, env(safe-area-inset-left)) !important;
    width: auto !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: none !important;
    border-radius: 1rem !important;
  }

  .bp-workspace .bp-copilot-head,
  .bp-copilot-panel .bp-copilot-head {
    min-height: 68px;
    padding: .6rem .62rem;
  }

  .bp-workspace .bp-copilot-title-row strong,
  .bp-copilot-panel .bp-copilot-title-row strong { max-width: 9.5rem; font-size: .88rem; }

  .bp-workspace .bp-copilot-subtitle,
  .bp-copilot-panel .bp-copilot-subtitle { display: none; }

  .bp-workspace #innovatorCopilotExpand,
  .bp-copilot-panel #innovatorCopilotExpand { display: none !important; }

  .bp-workspace .innovator-contextbar,
  .bp-copilot-panel .innovator-contextbar { padding: .32rem .5rem; }

  .bp-workspace .innovator-copilot-modebar,
  .bp-copilot-panel .innovator-copilot-modebar { padding: .34rem .46rem; }

  .bp-workspace .bp-copilot-messages,
  .bp-copilot-panel .bp-copilot-messages { padding: .68rem .62rem .8rem; }

  .bp-workspace .bp-copilot-suggestions,
  .bp-copilot-panel .bp-copilot-suggestions { grid-template-columns: 1fr !important; }

  .bp-workspace .bp-copilot-composer-wrap,
  .bp-copilot-panel .bp-copilot-composer-wrap { padding: .5rem .52rem .48rem !important; }

  .bp-workspace .bp-copilot-note,
  .bp-copilot-panel .bp-copilot-note { display: none !important; }
}

@media (max-width: 420px) {
  .bp-copilot-launcher-copy small { display: none; }
  .bp-workspace .bp-copilot-launcher,
  .bp-copilot-launcher { padding-right: .68rem; }
  .bp-workspace .bp-copilot-free-badge,
  .bp-copilot-panel .bp-copilot-free-badge { display: none; }
  .bp-workspace #innovatorCopilotNew,
  .bp-copilot-panel #innovatorCopilotNew { display: none !important; }
}
