/* Desktop agent bubble. The same #chat-overlay, parked bottom-right. */

#chat-dock-btn,
#terminal-dock-btn {
  position: fixed;
  right: 14px;
  bottom: 14px;
  z-index: 11060;
  width: 36px;
  height: 36px;
  padding: 0;
  border-radius: 999px;
  border: 1px solid rgba(45, 212, 191, 0.45);
  background: rgba(8, 14, 24, 0.92);
  box-shadow: 0 0 16px rgba(45, 212, 191, 0.22);
  color: #5eead4;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
}

#chat-dock-btn svg,
#terminal-dock-btn svg {
  display: block;
}

#chat-dock-btn:hover,
#terminal-dock-btn:hover {
  border-color: rgba(45, 212, 191, 0.75);
  box-shadow: 0 0 22px rgba(45, 212, 191, 0.35);
}

.alert-bot-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  flex: 0 0 28px;
  border-radius: 999px;
  border: 1px solid rgba(45, 212, 191, 0.45);
  background: rgba(8, 14, 24, 0.92);
  box-shadow: 0 0 12px rgba(45, 212, 191, 0.18);
  color: #5eead4;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.alert-bot-btn svg { display: block; }

.alert-bot-btn:hover {
  border-color: rgba(45, 212, 191, 0.75);
  box-shadow: 0 0 18px rgba(45, 212, 191, 0.32);
}

html[data-theme="light"] .alert-bot-btn {
  background: var(--bg-elevated, #fff);
  border-color: #0e7490;
  color: #0e7490;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

html[data-theme="light"] #chat-dock-btn,
html[data-theme="light"] #terminal-dock-btn {
  background: var(--bg-elevated, #fff);
  border-color: #0e7490;
  color: #0e7490;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.12);
}

.chat-dock-new {
  display: none;
  width: 26px;
  height: 26px;
  margin: 0 2px 0 0;
  padding: 0;
  border-radius: 50%;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  --tl-accent: #00f0ff;
  --tl-accent-rgb: 0, 240, 255;
  --tl-border: rgba(0, 240, 255, 0.12);
  --tl-bg: rgba(0, 240, 255, 0.02);
  background: var(--tl-bg);
  border: 1.5px solid var(--tl-border);
  color: var(--tl-accent);
}
.chat-dock-new svg {
  width: 13px;
  height: 13px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}
.chat-dock-new:disabled,
.chat-dock-new:disabled:hover {
  opacity: 0.35;
  cursor: default;
  background: var(--tl-bg);
  border-color: var(--tl-border);
  box-shadow: none;
}
html[data-theme="light"] .chat-dock-new {
  --tl-accent: #0e7490;
  --tl-accent-rgb: 14, 116, 144;
  --tl-border: #d5dbe3;
  --tl-bg: #eef1f4;
}
#chat-overlay.is-docked .chat-close-bar {
  justify-content: flex-start;
  padding: 8px 8px 0;
}
#chat-overlay.is-docked .chat-dock-new {
  display: flex;
  margin: 0 auto 0 0;
}

.chat-dock-expand,
.chat-dock-reduce {
  display: none;
  background: none;
  border: none;
  color: var(--text-muted, #6a7080);
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  align-items: center;
  justify-content: center;
}

.chat-dock-expand svg,
.chat-dock-reduce svg {
  width: 16px;
  height: 16px;
  stroke: currentColor;
  stroke-width: 2;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.chat-dock-expand:hover,
.chat-dock-reduce:hover {
  color: var(--text-primary, #e6e8ec);
  background: rgba(255, 255, 255, 0.06);
}

@media (min-width: 769px) {
  #chat-overlay.active:not(.is-docked):not(.is-hosting) .chat-dock-reduce {
    display: flex;
  }
}

body:has(.st-modal:not([hidden])) #chat-overlay.is-docked {
  z-index: 210000;
}
body:has(#cold-open:not([hidden])) #chat-overlay.is-docked {
  z-index: 11040;
}

#chat-overlay.is-docked {
  position: fixed;
  top: auto;
  left: auto;
  right: 14px;
  bottom: 60px;
  width: min(400px, calc(100vw - 28px));
  height: min(560px, calc(100vh - 110px));
  z-index: 11040;
  display: flex;
  border: 1px solid var(--border);
  border-radius: 14px;
  background: var(--bg-primary);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.35);
  padding: 0;
  overflow: hidden;
}

html:not([data-theme="light"]) #chat-overlay.is-docked {
  border-color: rgba(45, 212, 191, 0.7);
  box-shadow: 0 0 0 1px rgba(45, 212, 191, 0.25), 0 0 22px rgba(45, 212, 191, 0.28), 0 16px 48px rgba(0, 0, 0, 0.35);
}

#chat-overlay.is-docked .chat-input-area {
  padding: 8px 12px 12px;
  max-width: none;
}

#chat-overlay.is-docked .chat-messages {
  padding: 12px;
  max-width: none;
  min-width: 0;
}
#chat-overlay.is-docked .chat-msg,
#chat-overlay.is-docked .chat-msg-bubble {
  min-width: 0;
  max-width: 100%;
}
#chat-overlay.is-docked .chat-md-scroll {
  display: block;
  max-width: 100%;
  margin: 8px 0;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  -webkit-overflow-scrolling: touch;
}
#chat-overlay.is-docked .chat-md-scroll > table {
  width: max-content;
  min-width: 100%;
  margin: 0;
  overflow: visible;
}
#chat-overlay.is-docked .chat-md-scroll th,
#chat-overlay.is-docked .chat-md-scroll td {
  min-width: 9em;
  max-width: 18em;
  white-space: normal;
  vertical-align: top;
}
#chat-overlay.is-docked .chat-navigator,
#chat-overlay.is-docked .chat-shortcuts,
#chat-overlay.is-docked .chat-starter-wrap,
#chat-overlay.is-docked .chat-timeline,
#chat-overlay.is-docked .chat-strategies,
#chat-overlay.is-docked .chat-mobile-header-actions {
  display: none !important;
}

#chat-overlay.is-docked .chat-dock-expand {
  display: flex;
}

#chat-overlay.is-docked .chat-main.is-empty #chat-messages {
  display: none !important;
}

#chat-overlay.is-docked .chat-main.is-empty .chat-input-area {
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  height: 100%;
  max-width: none;
  margin: 0;
  padding: 16px 14px 20px;
  gap: 18px;
  grid-template-rows: none;
}

#chat-overlay.is-docked .chat-main.is-empty .chat-empty-header {
  align-self: center;
  width: 100%;
  margin-bottom: 0;
  text-align: center;
}

#chat-overlay.is-docked .chat-empty-logo {
  width: 64px;
  height: 64px;
}

#chat-overlay.is-docked .chat-empty-heading {
  font-size: 22px;
}

#chat-overlay.is-docked .chat-main.is-empty .chat-input-wrapper {
  width: 100%;
}

#chat-overlay.is-docked .chat-run-footer {
  grid-template-columns: minmax(0, auto) minmax(0, 1fr) auto;
  gap: 8px 6px;
  width: 100%;
}

#chat-overlay.is-docked .chat-run-footer-meta,
#chat-overlay.is-docked .chat-run-footer-right .chat-rating-label,
#chat-overlay.is-docked .chat-suggested-label {
  display: none;
}

#chat-overlay.is-docked .chat-run-footer-right {
  gap: 0;
}

#chat-overlay.is-docked .chat-run-footer-center {
  gap: 0;
}

#chat-overlay.is-docked .chat-run-footer-btn {
  width: 26px;
  height: 26px;
}

#chat-overlay.is-docked .chat-suggested-actions {
  width: 100%;
  max-width: 100%;
  min-width: 0;
  justify-content: flex-start;
  flex-wrap: nowrap;
  overflow-x: auto;
  overflow-y: hidden;
  overscroll-behavior-x: contain;
  scroll-snap-type: x mandatory;
  scrollbar-width: none;
  padding: 8px 0 0;
  box-sizing: border-box;
}

#chat-overlay.is-docked .chat-suggested-actions::-webkit-scrollbar {
  display: none;
}

#chat-overlay.is-docked .chat-suggested-actions .chat-suggested-pill,
#chat-overlay.is-docked .chat-suggested-actions:has(.chat-suggested-pill:hover) .chat-suggested-pill,
#chat-overlay.is-docked .chat-suggested-actions:has(.chat-suggested-pill:hover) .chat-suggested-pill:hover,
#chat-overlay.is-docked .chat-suggestion-chip {
  flex: 0 0 78%;
  width: 78%;
  min-width: 78%;
  max-width: 78%;
  scroll-snap-align: start;
  scroll-snap-stop: always;
  box-sizing: border-box;
}

body:has(#chat-overlay.active:not(.is-docked)) #chat-dock-btn {
  display: none !important;
}

@media (min-width: 769px) {
  body:has(#chat-overlay.active:not(.is-docked)) #terminal-dock-btn {
    display: inline-flex;
  }
}

@media (max-width: 768px) {
  #chat-dock-btn,
  #terminal-dock-btn {
    display: none !important;
  }
}

@media (min-width: 769px) {
  #chat-dock-btn,
  #terminal-dock-btn {
    position: fixed;
    right: 14px;
    bottom: 14px;
  }

  #chat-overlay.is-docked {
    right: calc(var(--shell-rail, 48px) + 8px);
  }

  body:not(:has(#right-sidebar .nav-tree-category)) #chat-overlay.is-docked {
    right: 14px;
  }
}
