/* AI Bot floating panel + shared chat chrome */

.bot-chat-panel {
  position: fixed;
  inset: 0;
  z-index: 120;
  pointer-events: none;
}

.bot-chat-panel.is-open {
  pointer-events: auto;
}

.bot-chat-panel-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.28);
  opacity: 0;
  transition: opacity 0.18s ease;
}

.bot-chat-panel.is-open .bot-chat-panel-backdrop {
  opacity: 1;
}

.bot-chat-panel-card {
  position: absolute;
  right: 88px;
  bottom: 16px;
  width: min(420px, calc(100vw - 24px));
  height: min(860px, calc(100vh - 28px));
  background: #fff;
  border: 1px solid var(--color-border, #e2e5ea);
  border-radius: 14px;
  box-shadow: var(--shadow-lg, 0 18px 48px rgba(15, 23, 42, 0.18));
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transform: translateY(12px) scale(0.98);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

.bot-chat-panel.is-open .bot-chat-panel-card {
  transform: none;
  opacity: 1;
}

.bot-chat-panel-body {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.bot-chat-root,
.bot-chat-shell {
  height: 100%;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.bot-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--color-border, #e2e5ea);
  background: linear-gradient(180deg, #f8fbff 0%, #fff 100%);
  flex-shrink: 0;
}

.bot-chat-header-main {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
  flex: 1;
}

.bot-chat-title {
  display: inline;
  font-size: 15px;
  font-weight: 600;
  color: var(--color-text, #0f172a);
  white-space: nowrap;
}

.bot-chat-sub {
  display: inline;
  margin-top: 0;
  font-size: 12px;
  color: var(--color-text-muted, #64748b);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.bot-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.bot-chat-link {
  font-size: 12px;
  color: var(--color-primary, #117fff);
  text-decoration: none;
  white-space: nowrap;
}

.bot-chat-link:hover {
  text-decoration: underline;
}

.bot-chat-icon-btn {
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--color-text-muted, #64748b);
  font-size: 20px;
  line-height: 1;
  cursor: pointer;
}

.bot-chat-icon-btn:hover {
  background: var(--color-primary-muted, #eef5ff);
  color: var(--color-primary, #117fff);
}

.bot-chat-main {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 8px 12px 8px;
}

.bot-chat-input.agent-chat-input {
  position: relative;
  display: block;
  gap: 0;
  border-top: 1px solid var(--color-border, #e2e5ea);
  padding-top: 8px;
  flex-shrink: 0;
}

.bot-chat-input.agent-chat-input textarea {
  width: 100%;
  box-sizing: border-box;
  resize: none;
  min-height: 48px;
  max-height: 120px;
  padding: 10px 76px 10px 12px;
  border-radius: 8px;
  border: 1px solid var(--color-border, #e2e5ea);
  font: inherit;
  line-height: 1.45;
}

.bot-chat-input .bot-chat-actions.agent-chat-actions {
  position: absolute;
  right: 8px;
  bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  margin: 0;
  justify-content: flex-end;
}

.bot-chat-input .bot-chat-actions .btn {
  min-width: 52px;
}

.bot-chat-root--compact .bot-chat-messages {
  min-height: 0;
  max-height: none;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

.bot-chat-error {
  margin: 0;
  padding: 8px 10px;
  border-radius: 8px;
  background: #fff1f2;
  color: #be123c;
  font-size: 13px;
}

.bot-chat-disclaimer {
  margin: 0;
  padding: 0;
  font-size: 10.5px;
  color: var(--color-text-muted, #64748b);
  line-height: 1.3;
  flex-shrink: 0;
}

.bot-chat-tasks {
  border: 1px solid var(--color-border, #e2e5ea);
  border-radius: 10px;
  background: #f8fafc;
  flex-shrink: 0;
}

.bot-tasks-details {
  margin: 0;
}

.bot-tasks-summary {
  list-style: none;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 8px 10px;
  cursor: pointer;
  user-select: none;
  font-size: 12px;
}

.bot-tasks-summary::-webkit-details-marker {
  display: none;
}

.bot-tasks-summary::before {
  content: '▸';
  color: var(--color-text-muted, #64748b);
  margin-right: 2px;
  transition: transform 0.15s ease;
}

.bot-tasks-details[open] > .bot-tasks-summary::before {
  transform: rotate(90deg);
  display: inline-block;
}

.bot-tasks-summary-title {
  font-weight: 600;
  color: var(--color-text, #0f172a);
}

.bot-tasks-summary-meta {
  color: var(--color-text-muted, #64748b);
  white-space: nowrap;
}

.bot-tasks-list {
  list-style: none;
  margin: 0;
  padding: 0 10px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 132px;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  border-top: 1px solid color-mix(in srgb, var(--color-border, #e2e5ea) 70%, transparent);
}

.bot-task {
  display: grid;
  grid-template-columns: 10px 1fr auto;
  gap: 8px;
  align-items: center;
  font-size: 12.5px;
}

.bot-task-title {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-task-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #cbd5e1;
  flex-shrink: 0;
}

.bot-task--pending .bot-task-dot {
  background: #94a3b8;
}

.bot-task--running .bot-task-dot {
  background: var(--color-primary, #117fff);
  box-shadow: 0 0 0 3px rgba(17, 127, 255, 0.18);
}

.bot-task--done .bot-task-dot {
  background: #16a34a;
}

.bot-task--failed .bot-task-dot {
  background: #e11d48;
}

.bot-task-status {
  color: var(--color-text-muted, #64748b);
  font-size: 11px;
  flex-shrink: 0;
}

.bot-chart {
  margin: 12px 0;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--color-border, #e2e5ea);
  background: #fff;
}

.bot-chart-title {
  font-size: 13px;
  font-weight: 600;
  color: var(--color-text, #0f172a);
  margin-bottom: 8px;
}

.bot-chart canvas {
  width: 100% !important;
  max-height: 320px;
}

.bot-chart--error {
  background: #fff7ed;
}

.bot-chart-error {
  margin: 8px 0 0;
  font-size: 12px;
  color: #c2410c;
}

/* full page — taller chat */
.bot-page-layout {
  margin-top: 8px;
}

.bot-page-layout .bot-chat-root {
  height: min(94vh, calc(100vh - 140px));
  min-height: 640px;
}

.bot-page-layout .bot-chat-shell {
  display: grid;
  grid-template-columns: 220px minmax(0, 1fr);
  grid-template-rows: auto minmax(0, 1fr);
  gap: 0;
  border: 1px solid var(--color-border, #e2e5ea);
  border-radius: 12px;
  overflow: hidden;
  background: #fff;
  height: 100%;
  min-height: 0;
}

.bot-page-layout .bot-chat-header {
  grid-column: 1 / -1;
}

.bot-page-layout .bot-chat-main {
  min-height: 0;
  height: 100%;
  display: flex;
  flex-direction: column;
  padding: 10px 14px 10px;
  overflow: hidden;
}

.bot-chat-sessions {
  border-right: 1px solid var(--color-border, #e2e5ea);
  background: #f8fafc;
  padding: 0;
  overflow: hidden;
  min-height: 0;
  display: flex;
  flex-direction: column;
}

.bot-chat-sessions-head {
  font-size: 12px;
  font-weight: 600;
  color: var(--color-text-muted, #64748b);
  padding: 10px 12px 6px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.bot-chat-sessions-list {
  flex: 1;
  min-height: 0;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 0 8px 12px;
}

.bot-session-group {
  margin-top: 8px;
}

.bot-session-group:first-child {
  margin-top: 2px;
}

.bot-session-group-title {
  position: sticky;
  top: 0;
  z-index: 1;
  padding: 8px 4px 4px 4px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.02em;
  color: var(--color-text-muted, #64748b);
  background: #f8fafc;
}

/* floating panel: history as full-height drawer */
.bot-chat-root--compact {
  position: relative;
}

.bot-chat-root--compact .bot-chat-shell {
  position: relative;
}

.bot-chat-sessions--drawer {
  position: absolute;
  inset: 0;
  z-index: 5;
  width: 100%;
  border-right: 0;
  background: #f8fafc;
  box-shadow: none;
}

.bot-chat-history-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 0;
  cursor: pointer;
  font: inherit;
}

.bot-session-item {
  width: calc(100% - 12px);
  margin-left: 12px;
  box-sizing: border-box;
  text-align: left;
  border: 0;
  background: transparent;
  border-radius: 8px;
  padding: 8px 10px;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.bot-session-item:hover,
.bot-session-item.is-active {
  background: #fff;
  box-shadow: inset 0 0 0 1px var(--color-border, #e2e5ea);
}

.bot-session-title {
  font-size: 13px;
  color: var(--color-text, #0f172a);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.bot-session-meta {
  font-size: 11px;
  color: var(--color-text-muted, #64748b);
}

.bot-sessions-empty {
  margin: 0;
  font-size: 12px;
  color: var(--color-text-muted, #64748b);
}

.bot-page-layout .bot-chat-messages {
  max-height: none;
  min-height: 0;
  flex: 1;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 900px) {
  .bot-chat-panel-card {
    right: 10px;
    bottom: 10px;
    width: calc(100vw - 20px);
    height: min(88vh, 860px);
  }

  .bot-page-layout .bot-chat-shell {
    grid-template-columns: 1fr;
    position: relative;
  }
}

.contact-dock-btn--bot {
  background: linear-gradient(180deg, #eff6ff 0%, #fff 100%);
  border-color: rgba(17, 127, 255, 0.28);
  color: var(--color-primary, #117fff);
}

.contact-dock-btn--bot:hover,
.contact-dock-item.is-open .contact-dock-btn--bot {
  background: var(--color-primary, #117fff);
  color: #fff;
  border-color: var(--color-primary, #117fff);
}

.agent-msg-foot {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 8px;
  padding-top: 2px;
}

.bot-share-wrap {
  position: relative;
  display: inline-flex;
}

.bot-share-menu {
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  min-width: 148px;
  padding: 6px;
  border-radius: 10px;
  background: #fff;
  border: 1px solid rgba(15, 23, 42, 0.08);
  box-shadow: 0 10px 28px rgba(15, 23, 42, 0.12);
  display: flex;
  flex-direction: column;
  gap: 2px;
  z-index: 5;
}

.bot-share-menu[hidden] {
  display: none !important;
}

.bot-share-menu button {
  appearance: none;
  border: 0;
  background: transparent;
  text-align: left;
  padding: 8px 10px;
  border-radius: 8px;
  font-size: 12px;
  color: #0f172a;
  cursor: pointer;
  white-space: nowrap;
}

.bot-share-menu button:hover {
  background: color-mix(in srgb, var(--color-primary, #117fff) 10%, transparent);
  color: var(--color-primary, #117fff);
}

.bot-msg-copy {
  position: relative;
  appearance: none;
  border: 0;
  background: transparent;
  color: var(--color-text-muted, #94a3b8);
  width: 26px;
  height: 26px;
  padding: 0;
  border-radius: 6px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.bot-msg-copy:hover {
  color: var(--color-primary, #117fff);
  background: color-mix(in srgb, var(--color-primary, #117fff) 10%, transparent);
}

.bot-msg-copy:focus-visible {
  outline: 2px solid color-mix(in srgb, var(--color-primary, #117fff) 45%, transparent);
  outline-offset: 1px;
}

.bot-msg-copy-icon {
  display: block;
  pointer-events: none;
}

.bot-msg-copy::after {
  content: attr(data-tip);
  position: absolute;
  right: 0;
  bottom: calc(100% + 6px);
  padding: 4px 8px;
  border-radius: 6px;
  background: #0f172a;
  color: #fff;
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transform: translateY(2px);
  transition: opacity 0.12s ease, transform 0.12s ease;
  z-index: 3;
}

.bot-msg-copy:hover::after,
.bot-msg-copy:focus-visible::after {
  opacity: 1;
  transform: none;
}

.bot-msg-copy.is-copied {
  color: #16a34a;
}

/* Bot 分享弹层（邮箱 / 企微） */
.bot-share-dialog {
  position: fixed;
  inset: 0;
  z-index: 1200;
  display: grid;
  place-items: center;
  padding: 20px;
}

.bot-share-dialog[hidden] {
  display: none !important;
}

.bot-share-dialog-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 23, 42, 0.48);
}

.bot-share-dialog-panel {
  position: relative;
  width: min(440px, 100%);
  background: #fff;
  border-radius: 14px;
  padding: 18px 20px 16px;
  box-shadow: 0 18px 48px rgba(15, 23, 42, 0.18);
  border: 1px solid rgba(15, 23, 42, 0.06);
}

.bot-share-dialog-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 14px;
}

.bot-share-dialog-head h2 {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 650;
  color: #0f172a;
}

.bot-share-dialog-x {
  appearance: none;
  border: 0;
  background: transparent;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  font-size: 22px;
  line-height: 1;
  color: #64748b;
  cursor: pointer;
}

.bot-share-dialog-x:hover {
  background: #f1f5f9;
  color: #0f172a;
}

.bot-share-dialog-label {
  display: flex;
  flex-direction: column;
  gap: 8px;
  font-size: 13px;
  color: #475569;
  font-weight: 500;
}

.bot-share-dialog-input,
.bot-share-dialog-textarea,
.bot-share-dialog-select {
  width: 100%;
  box-sizing: border-box;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 14px;
  line-height: 1.45;
  color: #0f172a;
  background: #fff;
  outline: none;
  resize: vertical;
  font-family: inherit;
}

.bot-share-dialog-input:focus,
.bot-share-dialog-textarea:focus,
.bot-share-dialog-select:focus {
  border-color: color-mix(in srgb, var(--color-primary, #117fff) 55%, #94a3b8);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--color-primary, #117fff) 18%, transparent);
}

.bot-share-dialog-history {
  margin-bottom: 12px;
}

.bot-share-dialog-hint {
  margin: 10px 0 0;
  font-size: 12px;
  line-height: 1.5;
  color: #64748b;
}

.bot-share-dialog-error {
  margin: 10px 0 0;
  font-size: 12px;
  color: #dc2626;
}

.bot-share-dialog-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  margin-top: 16px;
}

body.bot-share-dialog-open {
  overflow: hidden;
}
