/* Datascape Industrial — help agent widget */

.dsi-chat-fab {
  position: fixed;
  bottom: 20px;
  right: 20px;
  height: 52px;
  padding: 0 20px 0 16px;
  border: 2px solid var(--accent);
  border-radius: 26px;
  background: var(--bg);
  color: var(--accent);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  font-size: 0.95rem;
  font-weight: 700;
  letter-spacing: 0.02em;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  gap: 10px;
  transition: background 0.2s, color 0.2s, transform 0.2s;
  z-index: 998;
}
.dsi-chat-fab:hover { background: var(--accent); color: var(--bg); transform: scale(1.04); }
.dsi-chat-fab:focus-visible { outline: 2px solid var(--white); outline-offset: 2px; }
.dsi-chat-fab svg { width: 22px; height: 22px; fill: currentColor; flex: none; }
.dsi-chat-fab .dsi-fab-label { white-space: nowrap; }
.dsi-chat-fab .dsi-ico-close { display: none; }
.dsi-chat-fab[aria-expanded="true"] .dsi-ico-open { display: none; }
.dsi-chat-fab[aria-expanded="true"] .dsi-ico-close { display: block; }

.dsi-chat-panel {
  position: fixed;
  bottom: 88px;
  right: 20px;
  width: 370px;
  max-width: calc(100vw - 40px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: var(--bg-card);
  border: 1px solid var(--bg-light);
  border-radius: 10px;
  box-shadow: 0 10px 40px rgba(0,0,0,0.5);
  display: none;
  flex-direction: column;
  overflow: hidden;
  z-index: 999;
}
.dsi-chat-panel.dsi-open { display: flex; }

.dsi-chat-head {
  background: var(--bg-light);
  padding: 0.85rem 1rem;
  border-bottom: 1px solid #454545;
  flex: 0 0 auto;
}
.dsi-chat-head strong { color: var(--white); font-size: 1rem; font-weight: 700; }
.dsi-chat-head span { display: block; color: var(--text-muted); font-size: 0.78rem; }

.dsi-chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  font-size: 0.92rem;
  line-height: 1.5;
}

.dsi-msg { max-width: 85%; padding: 0.6rem 0.8rem; border-radius: 10px; overflow-wrap: break-word; }
.dsi-msg-user { align-self: flex-end; background: var(--accent); color: var(--white); border-bottom-right-radius: 3px; }
.dsi-msg-bot  { align-self: flex-start; background: var(--bg-light); color: var(--text); border-bottom-left-radius: 3px; }
.dsi-msg-cta { align-self: flex-start; background: none; padding: 0.2rem 0 0.4rem; display: flex; flex-direction: column; gap: 0.3rem; }
.dsi-cta { display: inline-block; background: var(--accent); color: var(--white); font-weight: 700; padding: 0.55rem 0.9rem; border-radius: 8px; text-decoration: none; }
.dsi-cta:hover { background: var(--accent-hover); }
.dsi-cta-hint { color: var(--text-muted); font-size: 0.78rem; }
.dsi-msg-note { align-self: center; background: none; color: var(--text-muted); font-size: 0.8rem; text-align: center; max-width: 100%; }

/* Markdown emitted by the renderer. Keep this list in step with mdToNodes(). */
.dsi-msg p { margin: 0 0 0.5rem; }
.dsi-msg p:last-child { margin-bottom: 0; }
.dsi-msg ul { margin: 0.3rem 0 0.5rem 1.1rem; }
.dsi-msg li { margin-bottom: 0.2rem; }
.dsi-msg strong { font-weight: 700; color: var(--white); }
.dsi-msg-user strong { color: var(--white); }
.dsi-msg code { background: rgba(0,0,0,0.3); padding: 0.1rem 0.3rem; border-radius: 3px; font-size: 0.85em; }
.dsi-msg-bot a { color: var(--accent); text-decoration: underline; }

.dsi-typing { display: flex; gap: 4px; align-items: center; }
.dsi-typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-muted);
  animation: dsi-bounce 1.2s infinite ease-in-out both;
}
.dsi-typing i:nth-child(2) { animation-delay: 0.15s; }
.dsi-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes dsi-bounce { 0%, 80%, 100% { opacity: 0.3; } 40% { opacity: 1; } }

.dsi-chat-form {
  flex: 0 0 auto;
  display: flex;
  gap: 0.5rem;
  padding: 0.7rem;
  border-top: 1px solid #454545;
  background: var(--bg-card);
}
.dsi-hp { position: absolute; left: -9999px; width: 1px; height: 1px; opacity: 0; pointer-events: none; }
.dsi-chat-form textarea {
  flex: 1 1 auto;
  resize: none;
  height: 42px;
  max-height: 110px;
  padding: 0.6rem 0.7rem;
  border: 1px solid #4a4a4a;
  border-radius: 6px;
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 0.92rem;
  line-height: 1.4;
}
.dsi-chat-form textarea:focus { outline: none; border-color: var(--accent); }
.dsi-chat-form button {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  border: none; border-radius: 6px;
  background: var(--accent); color: var(--white);
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.dsi-chat-form button:hover:not(:disabled) { background: var(--accent-hover); }
.dsi-chat-form button:disabled { opacity: 0.45; cursor: default; }
.dsi-chat-form button svg { width: 19px; height: 19px; fill: currentColor; }

.dsi-chat-foot {
  flex: 0 0 auto;
  padding: 0 0.7rem 0.6rem;
  background: var(--bg-card);
  color: var(--text-muted);
  font-size: 0.7rem;
  text-align: center;
}

@media (max-width: 480px) {
  .dsi-chat-panel { right: 10px; left: 10px; width: auto; bottom: 80px; }
  .dsi-chat-fab { bottom: 14px; right: 14px; height: 48px; padding: 0 16px 0 14px; }
}

@media (prefers-reduced-motion: reduce) {
  .dsi-chat-fab, .dsi-chat-form button, .dsi-typing i { transition: none; animation: none; }
}
