/* Assistant Chat Widget */
.assistant-fab {
  position: fixed;
  right: 20px;
  bottom: 20px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  border: none;
  background: #0b5ed7;
  color: #fff;
  font-size: 18px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  cursor: pointer;
  z-index: 1200;
}
.assistant-fab.assistant-fab-v3 {
  right: 80px;
  background: #6f42c1;
}
.assistant-fab.assistant-fab-v3::after {
  content: attr(data-badge);
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff5c5c;
  color: #fff;
  border-radius: 999px;
  padding: 0 6px;
  font-size: 10px;
  display: none;
}
.assistant-fab.assistant-fab-v3[data-badge]:not([data-badge=""])::after {
  display: inline-block;
}

.assistant-panel {
  position: fixed;
  right: 20px;
  bottom: 80px;
  width: 360px;
  max-width: calc(100vw - 40px);
  height: 460px;
  background: #fff;
  border: 1px solid #e3e3e3;
  border-radius: 12px;
  display: none;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 12px 28px rgba(0,0,0,0.18);
  z-index: 1200;
}
.assistant-panel.open { display: flex; }
.assistant-panel.dragging { cursor: move; }
.assistant-panel.resizing { cursor: se-resize; }
.assistant-panel.assistant-panel-v3 {
  right: 80px;
  background: #fefefe;
}
.assistant-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  background: #f6f8fa;
  border-bottom: 1px solid #e3e3e3;
}
.assistant-header { cursor: move; user-select: none; }
.assistant-title { font-weight: 600; }
.assistant-close {
  background: transparent; border: none; font-size: 16px; cursor: pointer; color: #444;
}
.assistant-tabs { display: flex; gap: 6px; padding: 8px 10px; border-bottom: 1px solid #e3e3e3; background: #fff; }
.assistant-tab { border: 1px solid #d0d7de; background: #f6f8fa; padding: 6px 10px; border-radius: 8px; cursor: pointer; font-size: 12px; }
.assistant-tab.active { background: #e7f1ff; border-color: #99baff; }
.assistant-body { flex: 1; padding: 10px; background: #fff; overflow: hidden; }
.assistant-content-row { display: flex; gap: 10px; height: 100%; }
.assistant-messages { display: flex; flex-direction: column; flex: 1; overflow: auto; position: relative; }
.assistant-runcol { display: flex; flex-direction: column; width: 160px; min-width: 150px; max-width: 200px; border-left: 1px solid #eef1f4; padding-left: 8px; }
.assistant-runlog-heading { font-size: 11px; font-weight: 600; color: #505050; margin-bottom: 6px; }
.assistant-runlog { flex: 1; overflow: auto; padding-right: 4px; }
.assistant-runlog-item { border: 1px solid #e3e3e3; border-radius: 6px; background: #fafafa; padding: 6px; margin-bottom: 6px; box-shadow: 0 1px 2px rgba(0,0,0,0.04); }
.assistant-runlog-item.kind-call { border-left: 3px solid #99baff; }
.assistant-runlog-item.kind-result { border-left: 3px solid #84c184; }
.assistant-runlog-item.kind-summary { border-left: 3px solid #b3b3b3; }
.assistant-runlog-item.error, .assistant-runlog-item.kind-error { border-color: #f2b0b0; background: #fff5f5; }
.assistant-runlog-header { display: flex; align-items: center; justify-content: space-between; gap: 6px; font-size: 10px; font-weight: 600; color: #333; cursor: pointer; user-select: none; }
.assistant-runlog-copy { border: none; background: transparent; font-size: 10px; color: #0b5ed7; cursor: pointer; padding: 0; }
.assistant-runlog-copy:hover { text-decoration: underline; }
.assistant-runlog-details { display: none; margin-top: 4px; font-size: 10px; background: #fff; border-radius: 4px; padding: 6px; max-height: 140px; overflow: auto; white-space: pre-wrap; }
.assistant-runlog-details.open { display: block; }
.assistant-pane.hidden { display: none; }
.assistant-row { display: flex; align-items: center; gap: 8px; margin: 6px 0; }
.assistant-label { width: 100px; font-size: 12px; color: #444; }
.assistant-input, .assistant-select { flex: 1; padding: 6px 8px; border: 1px solid #d0d7de; border-radius: 6px; font-size: 13px; }
.assistant-btn { padding: 6px 10px; border: 1px solid #d0d7de; background: #f6f8fa; border-radius: 6px; cursor: pointer; font-size: 12px; }
.assistant-btn.primary { background: #0b5ed7; color: #fff; border-color: #0b5ed7; }
.assistant-suggest-list { position: absolute; margin-top: 2px; background: #fff; border: 1px solid #d0d7de; border-radius: 6px; box-shadow: 0 4px 12px rgba(0,0,0,0.12); z-index: 10; }
.assistant-suggest-item { padding: 6px 8px; cursor: pointer; }
.assistant-suggest-item:hover { background: #e7f1ff; }
.assistant-footer {
  display: flex; gap: 8px; padding: 10px; border-top: 1px solid #e3e3e3; background: #fafafa;
}
#assistantInput {
  flex: 1; padding: 7px 9px; border: 1px solid #d0d7de; border-radius: 8px; font-size: 12px;
}
.assistant-send {
  padding: 8px 12px; background: #0b5ed7; color: #fff; border: none; border-radius: 8px; cursor: pointer;
}
.assistant-agent-toggle { display: flex; align-items: center; gap: 6px; font-size: 12px; color: #444; }
.assistant-agent-label { user-select: none; }
.assistant-msg { margin: 6px 0; padding: 6px 8px; border-radius: 8px; white-space: pre-wrap; font-size: 12px; }
.assistant-msg.user { background: #e7f1ff; color: #083a7a; align-self: flex-end; }
.assistant-msg.bot { background: #f2f2f2; color: #222; }
.assistant-json { margin: 0; font-size: 12px; background: #f6f8fa; padding: 8px; border-radius: 6px; overflow: auto; }

/* Styled links inside assistant messages */
.assistant-msg.bot a.assistant-link {
  display: inline-block;
  padding: 2px 7px;
  margin: 2px 4px 2px 0;
  border: 1px solid #99baff;
  background: #eef4ff;
  color: #0b5ed7;
  text-decoration: none;
  border-radius: 6px;
  font-size: 10px;
  font-weight: 600;
}
.assistant-msg.bot a.assistant-link:hover {
  background: #e7f1ff;
  text-decoration: none;
}

/* New messages indicator (appears when user scrolled up) */
#assistantNewMsg.assistant-newmsg {
  position: absolute;
  right: 8px;
  bottom: 8px;
  z-index: 2;
  display: none;
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid #d0d7de;
  background: #0b5ed7;
  color: #fff;
  font-size: 12px;
  font-weight: 600;
  box-shadow: 0 4px 10px rgba(0,0,0,0.12);
  cursor: pointer;
}
#assistantNewMsg.assistant-newmsg.show { display: inline-block; }

/* Inline tool log (shown in chat after each user question) */
.assistant-inline-log {
  margin: 6px 0 4px;
  padding: 6px 8px;
  background: #f9fafb;
  border-left: 3px solid #d0d7de;
  border-radius: 6px;
}
.assistant-inline-title {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 10px;
  font-weight: 600;
  color: #555;
  margin-bottom: 4px;
  cursor: pointer;
  user-select: none;
}
.assistant-inline-caret { display: inline-block; transition: transform 0.15s ease; }
.assistant-inline-count { color: #777; font-weight: 600; }
.assistant-inline-items { margin-top: 2px; }
.assistant-inline-log.collapsed .assistant-inline-items { display: none; }
.assistant-inline-log.collapsed .assistant-inline-caret { transform: rotate(-90deg); }
.assistant-inline-item {
  font-size: 10px;
  color: #444;
  line-height: 1.3;
}

.assistant-messages { display: flex; flex-direction: column; }

/* Resizer handle */
.assistant-resizer {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 14px;
  height: 14px;
  cursor: se-resize;
  background: linear-gradient(135deg, transparent 0, transparent 50%, #c7ccd1 50%, #c7ccd1 60%, transparent 60%, transparent 100%);
  border-radius: 2px;
  opacity: 0.8;
}

@media (max-width: 480px) {
  .assistant-panel { right: 10px; bottom: 70px; width: calc(100vw - 20px); height: 60vh; }
  .assistant-content-row { flex-direction: column; }
  .assistant-runcol { max-width: none; min-width: 0; width: 100%; border-left: none; border-top: 1px solid #eef1f4; padding-left: 0; padding-top: 8px; }
  /* Denser typography on small screens */
  #assistantInput { font-size: 11px; padding: 6px 8px; }
  .assistant-msg { font-size: 11px; padding: 5px 7px; margin: 5px 0; }
  .assistant-msg.bot a.assistant-link { font-size: 9px; padding: 2px 6px; }
  .assistant-inline-title { font-size: 9px; }
  .assistant-inline-item { font-size: 9px; }
  #assistantNewMsg.assistant-newmsg { font-size: 11px; padding: 5px 9px; bottom: 6px; right: 6px; }
}

/* Working indicator */
.assistant-typing { font-size: 11px; color: #555; opacity: 0.9; }

/* Assistant v3 refinements */
.assistant-panel-v3 .assistant-v3-header .assistant-header-actions {
  display: flex;
  gap: 6px;
}
.assistant-v3-connector-btn {
  position: relative;
  border: none;
  background: #f0ebff;
  color: #5e3bb7;
  padding: 6px 8px;
  border-radius: 8px;
  cursor: pointer;
}
.assistant-v3-connector-btn[data-badge]:not([data-badge=""])::after {
  content: attr(data-badge);
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ff5c5c;
  border-radius: 999px;
  padding: 0 4px;
  color: #fff;
  font-size: 10px;
}
.assistant-panel-v3 .assistant-content-row {
  gap: 12px;
}
.assistant-panel-v3 .assistant-runcol {
  min-width: 180px;
}
.assistant-panel-v3 .assistant-runlog-item {
  font-size: 11px;
}
.assistant-v3-input {
  width: 100%;
  resize: none;
  border: 1px solid #d0d7de;
  border-radius: 8px;
  padding: 8px;
  font-size: 13px;
  font-family: inherit;
}
.assistant-v3-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.assistant-v3-stop {
  background: #fff0f0;
  color: #c53030;
}
.assistant-v3-send {
  min-width: 90px;
}
.assistant-v3-connector-tray {
  display: none;
  border-bottom: 1px solid #e3e3e3;
  background: #fafafa;
  padding: 8px 12px;
  flex-direction: column;
  gap: 8px;
}
.assistant-v3-connector-tray.open {
  display: flex;
}
.assistant-v3-connector-list {
  max-height: 160px;
  overflow: auto;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.assistant-v3-connector-item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: #333;
}
.assistant-v3-connector-empty {
  font-size: 12px;
  color: #777;
}
.assistant-v3-connector-footer {
  display: flex;
  justify-content: flex-end;
}
.assistant-panel-v3.assistant-busy .assistant-v3-header {
  background: #f3f0ff;
}
