/* DataScope Agent Chat — global floating panel */
.agent-chat-fab {
  position: fixed;
  bottom: 24px;
  left: 24px;
  z-index: 900;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #8b5cf6, #6ea8ff);
  box-shadow: 0 4px 20px rgba(139, 92, 246, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s, box-shadow 0.2s;
  padding: 0;
  color: white;
}
.agent-chat-fab:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(139, 92, 246, 0.55);
}
.agent-chat-fab svg { width: 26px; height: 26px; }

/* Panel */
.agent-chat-panel {
  position: fixed;
  bottom: 86px;
  left: 24px;
  z-index: 901;
  width: 380px;
  max-width: calc(100vw - 48px);
  height: 520px;
  max-height: calc(100vh - 120px);
  background: #131833;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 16px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.95);
  pointer-events: none;
  transition: opacity 0.2s, transform 0.2s;
}
.agent-chat-panel.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Panel header */
.acp-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(22, 29, 61, 0.6);
  flex-shrink: 0;
}
.acp-back {
  width: 28px; height: 28px;
  border-radius: 6px; border: none;
  background: transparent; color: #9aa4c7;
  font-size: 18px; cursor: pointer;
  display: none; align-items: center; justify-content: center;
}
.acp-back:hover { background: rgba(255,255,255,.08); color: #e7ecff; }
.acp-back.visible { display: flex; }
.acp-header-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; color: white;
  flex-shrink: 0;
}
.acp-header-text { flex: 1; }
.acp-header-name { font-weight: 700; font-size: 14px; color: #e7ecff; }
.acp-header-sub { font-size: 11px; color: #4ade80; }
.acp-close {
  width: 28px; height: 28px;
  border-radius: 6px; border: none;
  background: transparent; color: #9aa4c7;
  font-size: 18px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.acp-close:hover { background: rgba(255,255,255,.08); color: #e7ecff; }

/* Agent list view */
.acp-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.acp-list-empty {
  text-align: center;
  color: #9aa4c7;
  padding: 40px 16px;
  font-size: 14px;
}
.acp-list-empty a { color: #6ea8ff; font-weight: 600; }
.acp-list-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
}
.acp-list-item:hover { background: rgba(110, 168, 255, 0.08); }
.acp-list-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 16px; color: white;
  flex-shrink: 0;
}
.acp-list-info { flex: 1; min-width: 0; }
.acp-list-name {
  font-size: 14px; font-weight: 700; color: #e7ecff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acp-list-desc {
  font-size: 12px; color: #9aa4c7;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* Conversation list view */
.acp-convos {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}
.acp-new-convo-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 12px;
  margin-bottom: 4px;
  border-radius: 12px;
  border: 1px dashed rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.06);
  color: #a78bfa;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s;
}
.acp-new-convo-btn:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.5);
}
.acp-convos-empty {
  text-align: center;
  color: #9aa4c7;
  padding: 32px 16px;
  font-size: 13px;
}
.acp-convo-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: 10px;
  cursor: pointer;
  transition: background 0.15s;
}
.acp-convo-item:hover { background: rgba(110, 168, 255, 0.08); }
.acp-convo-info { flex: 1; min-width: 0; }
.acp-convo-title {
  font-size: 13px;
  font-weight: 600;
  color: #e7ecff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.acp-convo-meta {
  font-size: 11px;
  color: #9aa4c7;
  margin-top: 2px;
}
.acp-convo-del {
  width: 24px; height: 24px;
  border-radius: 6px; border: none;
  background: transparent;
  color: #9aa4c7;
  font-size: 16px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
}
.acp-convo-item:hover .acp-convo-del { opacity: 1; }
.acp-convo-del:hover { background: rgba(248, 113, 113, 0.15); color: #f87171; }

/* Chat view */
.acp-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 10px;
}
.acp-messages.visible { display: flex; }

.acp-msg {
  max-width: 88%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13px;
  line-height: 1.5;
  word-break: break-word;
  animation: acp-msg-in 0.2s ease-out;
}
@keyframes acp-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.acp-msg.bot {
  align-self: flex-start;
  background: rgba(139, 92, 246, 0.12);
  border: 1px solid rgba(139, 92, 246, 0.18);
  color: #e7ecff;
}
.acp-msg.user {
  align-self: flex-end;
  background: rgba(110, 168, 255, 0.15);
  border: 1px solid rgba(110, 168, 255, 0.2);
  color: #e7ecff;
}
.acp-md-h2 { display: block; font-weight: 700; color: #e7ecff; font-size: 13px; margin: 6px 0 2px; }
.acp-md-h3 { display: block; font-weight: 600; color: #a78bfa; font-size: 12px; margin: 5px 0 2px; }
.acp-md-hr { border: none; border-top: 1px solid rgba(255,255,255,.1); margin: 8px 0; }
.acp-md-table-row { display: block; font-size: 11px; opacity: .75; font-family: monospace; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Tool execution indicator */
.acp-tool-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  border-radius: 10px;
  background: rgba(74, 222, 128, 0.1);
  border: 1px solid rgba(74, 222, 128, 0.2);
  color: #4ade80;
  font-size: 12px;
  font-weight: 600;
  animation: acp-msg-in 0.2s ease-out;
}
.acp-tool-badge.pending {
  background: rgba(251, 191, 36, 0.1);
  border-color: rgba(251, 191, 36, 0.2);
  color: #fbbf24;
}

/* Typing indicator */
.acp-typing {
  display: flex;
  gap: 4px;
  padding: 10px 14px;
  align-self: flex-start;
}
.acp-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #8b5cf6;
  opacity: 0.4;
  animation: acp-typing-dot 1.2s infinite;
}
.acp-typing span:nth-child(2) { animation-delay: 0.2s; }
.acp-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes acp-typing-dot {
  0%, 60%, 100% { opacity: 0.4; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* Streaming cursor */
.acp-cursor {
  display: inline-block;
  width: 2px; height: 1em;
  background: #8b5cf6;
  margin-left: 2px;
  vertical-align: text-bottom;
  animation: acp-blink 0.7s steps(1) infinite;
}
@keyframes acp-blink {
  0%, 100% { opacity: 1; }
  50% { opacity: 0; }
}

/* Input area */
.acp-input-area {
  display: none;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(22, 29, 61, 0.4);
  flex-shrink: 0;
}
.acp-input-area.visible { display: flex; flex-direction: column; gap: 0; padding: 0; }
.acp-input {
  flex: 1;
  font: inherit; font-size: 13px;
  color: #e7ecff;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 8px 12px;
  outline: none;
}
.acp-input:focus { border-color: rgba(139, 92, 246, 0.4); }
.acp-input::placeholder { color: #9aa4c7; }
.acp-send {
  width: 36px; height: 36px;
  border-radius: 10px; border: none;
  background: linear-gradient(135deg, #8b5cf6, #6ea8ff);
  color: white; font-size: 16px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: filter 0.15s;
}
.acp-send:hover { filter: brightness(1.15); }



/* Toast notification */
.acp-toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 999;
  padding: 10px 20px;
  border-radius: 10px;
  background: rgba(22, 29, 61, 0.95);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: #e7ecff;
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 8px 24px rgba(0,0,0,.4);
  animation: acp-toast-in 0.3s ease-out;
  white-space: nowrap;
}
.acp-toast.out {
  animation: acp-toast-out 0.3s ease-in forwards;
}
.acp-toast-link {
  color: #8b5cf6;
  font-weight: 700;
  margin-left: 6px;
}
.acp-toast-link:hover { text-decoration: underline; }
@keyframes acp-toast-in {
  from { opacity: 0; transform: translateX(-50%) translateY(10px); }
  to { opacity: 1; transform: translateX(-50%) translateY(0); }
}
@keyframes acp-toast-out {
  from { opacity: 1; transform: translateX(-50%) translateY(0); }
  to { opacity: 0; transform: translateX(-50%) translateY(10px); }
}

/* ── Full screen mode ─────────────────────────────────────── */
.agent-chat-panel.fullscreen {
  inset: 0;
  width: 100vw;
  height: 100vh;
  max-width: 100vw;
  max-height: 100vh;
  border-radius: 0;
  border: none;
}

/* ── Expand button ────────────────────────────────────────── */
.acp-expand {
  width: 28px; height: 28px;
  border-radius: 6px; border: none;
  background: transparent; color: #9aa4c7;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.acp-expand:hover { background: rgba(255,255,255,.08); color: #e7ecff; }

/* ── Input area restructure ───────────────────────────────── */
.acp-input-area.visible { display: flex; flex-direction: column; gap: 0; }
.acp-draft-row {
  display: none; align-items: center; gap: 8px;
  padding: 6px 14px 4px;
}
.acp-draft-row.visible { display: flex; }
.acp-draft-label {
  font-size: 11px; font-weight: 700; color: #8b5cf6;
  letter-spacing: .04em; flex-shrink: 0;
}
.acp-draft-duration {
  font: inherit; font-size: 11px;
  background: rgba(139,92,246,.12); color: #c4b5fd;
  border: 1px solid rgba(139,92,246,.3); border-radius: 6px;
  padding: 2px 6px; cursor: pointer; flex-shrink: 0;
}
.acp-draft-duration:focus { outline: none; border-color: rgba(139,92,246,.6); }
.acp-timer-display {
  font-size: 11px; font-weight: 700; color: #fbbf24;
  letter-spacing: .04em; margin-left: auto; flex-shrink: 0;
}
.acp-send-row {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px 12px;
}
.acp-send-row .acp-input { flex: 1; }
.acp-send-row .acp-send { flex-shrink: 0; }

/* ── Draft mode toggle button ─────────────────────────────── */
.acp-draft-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none;
  background: rgba(255,255,255,.06); color: #5c6474;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, color .15s, box-shadow .15s;
}
.acp-draft-btn:hover { background: rgba(139,92,246,.15); color: #c4b5fd; }
.acp-draft-btn.active {
  background: linear-gradient(135deg, #7c3aed, #8b5cf6);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(139,92,246,.5), 0 2px 8px rgba(139,92,246,.4);
}

/* ── Mic / speech-to-text button ─────────────────────────── */
.acp-mic-btn {
  width: 30px; height: 30px; border-radius: 8px; border: none;
  background: rgba(255,255,255,.06); color: #5c6474;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; transition: background .15s, color .15s, box-shadow .15s;
}
.acp-mic-btn:hover { background: rgba(239,68,68,.12); color: #f87171; }
.acp-mic-btn.recording {
  background: #ef4444;
  color: #fff;
  box-shadow: 0 0 0 2px rgba(239,68,68,.4), 0 2px 8px rgba(239,68,68,.35);
  animation: acp-mic-pulse 1.4s ease-in-out infinite;
}
@keyframes acp-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(239,68,68,.4), 0 2px 8px rgba(239,68,68,.35); }
  50%       { box-shadow: 0 0 0 5px rgba(239,68,68,.15), 0 2px 14px rgba(239,68,68,.45); }
}

/* ── Artifact preview card ────────────────────────────────── */
.acp-artifact-card {
  align-self: stretch;
  background: rgba(110,168,255,.06);
  border: 1px solid rgba(110,168,255,.15);
  border-radius: 10px;
  padding: 10px 12px;
  animation: acp-msg-in .2s ease-out;
}
.acp-artifact-card.draft {
  background: rgba(139,92,246,.07);
  border-color: rgba(139,92,246,.2);
}
.acp-artifact-top {
  display: flex; align-items: center; gap: 6px;
  margin-bottom: 5px;
}
.acp-artifact-icon { font-size: 14px; }
.acp-artifact-type {
  font-size: 10.5px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .05em; color: #6ea8ff;
}
.acp-artifact-card.draft .acp-artifact-type { color: #a78bfa; }
.acp-artifact-draft-badge {
  margin-left: auto; font-size: 9px; font-weight: 700;
  padding: 1px 5px; border-radius: 4px; text-transform: uppercase;
  background: rgba(139,92,246,.2); color: #c4b5fd;
  border: 1px solid rgba(139,92,246,.3); letter-spacing: .05em;
}
.acp-artifact-title {
  font-size: 13px; font-weight: 600; color: #e7ecff;
  margin-bottom: 3px; line-height: 1.3;
}
.acp-artifact-preview-text {
  font-size: 11.5px; color: #6b7896; line-height: 1.4;
  white-space: pre-wrap; word-break: break-word;
}

/* ── Draft review row (fixed in input area) ───────────────── */
.acp-review-row {
  display: none;
  flex-direction: column;
  background: rgba(15,20,45,.98);
  border-top: 2px solid rgba(139,92,246,.5);
  max-height: 320px;
}
.acp-review-row.visible { display: flex; }
.acp-review-header {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 14px;
  background: rgba(139,92,246,.15);
  border-bottom: 1px solid rgba(139,92,246,.2);
  flex-shrink: 0;
}
.acp-review-icon-sm { font-size: 16px; flex-shrink: 0; }
.acp-review-title-sm {
  flex: 1; font-size: 13px; font-weight: 700; color: #e7ecff;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.acp-review-progress {
  font-size: 11px; font-weight: 700; color: #a78bfa;
  text-transform: uppercase; letter-spacing: .05em;
  flex-shrink: 0;
}
.acp-review-content {
  flex: 1; overflow-y: auto; padding: 10px 14px;
  font-size: 12px; color: #8b95b8; line-height: 1.55;
  white-space: pre-wrap; word-break: break-word;
  min-height: 60px;
}
.acp-review-actions {
  display: flex; gap: 8px; padding: 8px 14px;
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.acp-review-decline, .acp-review-accept {
  flex: 1; padding: 8px 0;
  border-radius: 8px; border: none; cursor: pointer;
  font: inherit; font-size: 13px; font-weight: 700;
  transition: filter .15s;
}
.acp-review-decline {
  background: rgba(248,113,113,.12); color: #f87171;
  border: 1px solid rgba(248,113,113,.25);
}
.acp-review-accept {
  background: rgba(74,222,128,.15); color: #4ade80;
  border: 1px solid rgba(74,222,128,.3);
}
.acp-review-decline:hover { filter: brightness(1.2); }
.acp-review-accept:hover { filter: brightness(1.2); }

@media (max-width: 480px) {
  .agent-chat-panel {
    left: 12px;
    bottom: 80px;
    width: calc(100vw - 24px);
  }
  .agent-chat-fab {
    left: 12px;
    bottom: 12px;
  }
}

@media (max-width: 700px) {
  .agent-chat-fab { bottom: 80px; }
  .agent-chat-panel { bottom: 144px; }
}
