/* ============================================================
   AI Agent Chat Widget — "Hermes"
   Floating bottom-right popup chat
   ============================================================ */

/* ---- Raised position: avoid overlapping footer bars (wizard, chat) ---- */
.agent-fab.agent-fab-raised {
  bottom: 80px;
}
.agent-panel.agent-fab-raised {
  --agent-panel-bottom: 152px;
  bottom: var(--agent-panel-bottom);
  max-height: calc(
    100vh - var(--agent-panel-safe-top, 72px) - var(--agent-panel-bottom)
  );
}
.agent-fab-scraping-indicator.agent-fab-raised {
  bottom: 80px;
}

/* ---- Floating Action Button ---- */
.agent-fab {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 10000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--shadow-xl), 0 0 0 0 rgba(24, 24, 27, 0.3);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.agent-fab:hover {
  transform: scale(1.08);
  box-shadow: var(--shadow-xl), 0 0 0 8px rgba(24, 24, 27, 0.08);
}

.agent-fab:active {
  transform: scale(0.96);
}

.agent-fab svg {
  width: 26px;
  height: 26px;
  transition: transform 0.5s ease;
}

.agent-fab.open svg {
  transform: rotate(360deg);
}

/* Automatic court-update status attached to the Hermes button. */
.agent-fab-monitor-status {
  position: absolute;
  top: -5px;
  left: -5px;
  width: 19px;
  height: 19px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--background, #fff);
  border-radius: 50%;
  background: #2563eb;
  color: #fff;
  box-shadow: 0 2px 7px rgba(0, 0, 0, 0.25);
}

.agent-fab-monitor-status > svg {
  width: 11px;
  height: 11px;
  transform: none !important;
}

.agent-fab-monitor-status.checking > svg {
  animation: fab-scraping-spin 0.8s linear infinite;
}

.agent-fab-monitor-status.ok { background: #16a34a; }
.agent-fab-monitor-status.waiting { background: #d97706; }
.agent-fab-monitor-status.error { background: #dc2626; }
.agent-fab-monitor-status.unavailable { background: #71717a; }

.agent-fab-monitor-tooltip {
  position: absolute;
  right: -4px;
  bottom: calc(100% + 10px);
  width: max-content;
  max-width: 300px;
  padding: 8px 10px;
  border: 1px solid var(--border, #d4d4d8);
  border-radius: 8px;
  background: var(--popover, #18181b);
  color: var(--popover-foreground, #fafafa);
  box-shadow: var(--shadow-lg, 0 8px 24px rgba(0, 0, 0, 0.2));
  font-size: 12px;
  font-weight: 500;
  line-height: 1.35;
  text-align: left;
  white-space: normal;
  pointer-events: none;
  opacity: 0;
  visibility: hidden;
  transform: translateY(4px);
  transition: opacity 0.15s ease, transform 0.15s ease, visibility 0.15s;
}

.agent-fab-monitor-status:hover .agent-fab-monitor-tooltip,
.agent-fab:focus-visible .agent-fab-monitor-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

/* Unread badge */
.agent-fab-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--destructive);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: none;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

/* ---- Chat Panel ---- */
.agent-panel {
  --agent-panel-safe-top: 72px;
  --agent-panel-bottom: 96px;
  position: fixed;
  bottom: var(--agent-panel-bottom);
  right: 24px;
  z-index: 10000;
  width: 360px;
  height: 680px;
  /* Keep the sticky application header and its controls unobstructed. */
  max-height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
  background: var(--card);
  border-radius: 16px;
  border: 1px solid var(--border);
  box-shadow:
    0 25px 50px -12px rgba(0, 0, 0, 0.15),
    0 0 0 1px rgba(0, 0, 0, 0.03);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease, height 0.25s ease, max-height 0.25s ease;
}

.agent-panel.visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---- Panel Header ---- */
.agent-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.agent-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.agent-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--primary);
  color: var(--primary-foreground);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.agent-header-avatar svg {
  width: 18px;
  height: 18px;
}

.agent-header-info {
  min-width: 0;
}

.agent-header-title {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.agent-header-subtitle {
  font-size: 12px;
  color: var(--muted-foreground);
}

.agent-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-header-btn {
  width: 32px;
  height: 32px;
  border: none;
  background: transparent;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  transition: background 0.15s, color 0.15s;
}

.agent-header-btn:hover {
  background: var(--secondary);
  color: var(--foreground);
}

.agent-header-btn svg {
  width: 16px;
  height: 16px;
}

/* ---- Sessions Sidebar ---- */
.agent-sessions {
  position: absolute;
  inset: 0;
  background: var(--card);
  z-index: 2;
  display: flex;
  flex-direction: column;
  transform: translateX(-100%);
  transition: transform 0.25s ease;
}

.agent-sessions.visible {
  transform: translateX(0);
}

.agent-sessions-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.agent-sessions-header h3 {
  font-size: 14px;
  font-weight: 600;
  color: var(--foreground);
}

.agent-sessions-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-sessions-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.agent-session-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: background 0.15s;
}

.agent-session-item:hover {
  background: var(--secondary);
}

.agent-session-item.active {
  background: var(--secondary);
}

.agent-session-title {
  font-size: 13px;
  color: var(--foreground);
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-right: 8px;
}

.agent-session-date {
  font-size: 11px;
  color: var(--muted-foreground);
  flex-shrink: 0;
}

.agent-session-delete {
  width: 24px;
  height: 24px;
  border: none;
  background: transparent;
  border-radius: 6px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
  flex-shrink: 0;
  margin-left: 4px;
}

.agent-session-item:hover .agent-session-delete {
  opacity: 1;
}

.agent-session-delete:hover {
  background: rgba(239, 68, 68, 0.1);
  color: var(--destructive);
}

.agent-session-delete svg {
  width: 14px;
  height: 14px;
}

.agent-sessions-empty {
  display: flex;
  align-items: center;
  justify-content: center;
  flex: 1;
  color: var(--muted-foreground);
  font-size: 13px;
}

/* ---- Messages Area ---- */
.agent-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.agent-messages::-webkit-scrollbar {
  width: 4px;
}

.agent-messages::-webkit-scrollbar-track {
  background: transparent;
}

.agent-messages::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 4px;
}

/* ---- Welcome State ---- */
.agent-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  gap: 12px;
  padding: 32px 24px;
  text-align: center;
}

.agent-welcome-icon {
  width: 56px;
  height: 56px;
  border-radius: 16px;
  background: var(--secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--foreground);
}

.agent-welcome-icon svg {
  width: 28px;
  height: 28px;
}

.agent-welcome h3 {
  font-size: 16px;
  font-weight: 600;
  color: var(--foreground);
}

.agent-welcome p {
  font-size: 13px;
  color: var(--muted-foreground);
  line-height: 1.5;
  max-width: 280px;
}

.agent-suggestions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
  max-width: 300px;
  margin-top: 4px;
}

.agent-suggestion-btn {
  padding: 10px 14px;
  border: 1px solid var(--border);
  border-radius: 10px;
  background: var(--card);
  color: var(--foreground);
  font-size: 12.5px;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, border-color 0.15s;
  line-height: 1.4;
}

.agent-suggestion-btn:hover {
  background: var(--secondary);
  border-color: var(--ring);
}

/* ---- Message Bubbles ---- */
.agent-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  animation: agentMsgIn 0.2s ease;
}

@keyframes agentMsgIn {
  from {
    opacity: 0;
    transform: translateY(8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.agent-msg.user {
  align-self: flex-end;
}

.agent-msg.assistant {
  align-self: flex-start;
}

.agent-msg-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
}

.agent-msg.user .agent-msg-bubble {
  background: var(--primary);
  color: var(--primary-foreground);
  border-bottom-right-radius: 4px;
}

.agent-msg.assistant .agent-msg-bubble {
  background: var(--secondary);
  color: var(--foreground);
  border-bottom-left-radius: 4px;
}

/* Markdown inside assistant messages */
.agent-msg.assistant .agent-msg-bubble p {
  margin: 0 0 8px 0;
}

.agent-msg.assistant .agent-msg-bubble p:last-child {
  margin-bottom: 0;
}

.agent-msg.assistant .agent-msg-bubble strong {
  font-weight: 600;
}

.agent-msg.assistant .agent-msg-bubble em {
  font-style: italic;
}

.agent-msg.assistant .agent-msg-bubble code {
  font-family: 'SF Mono', 'Fira Code', monospace;
  font-size: 12px;
  background: rgba(0, 0, 0, 0.06);
  padding: 1px 5px;
  border-radius: 4px;
}

.agent-msg.assistant .agent-msg-bubble pre {
  background: #1e1e1e;
  color: #d4d4d4;
  padding: 10px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 8px 0;
  font-size: 12px;
  line-height: 1.5;
}

.agent-msg.assistant .agent-msg-bubble pre code {
  background: transparent;
  padding: 0;
  color: inherit;
}

.agent-msg.assistant .agent-msg-bubble ul,
.agent-msg.assistant .agent-msg-bubble ol {
  margin: 6px 0;
  padding-left: 20px;
}

.agent-msg.assistant .agent-msg-bubble li {
  margin: 2px 0;
}

.agent-msg.assistant .agent-msg-bubble h1,
.agent-msg.assistant .agent-msg-bubble h2,
.agent-msg.assistant .agent-msg-bubble h3,
.agent-msg.assistant .agent-msg-bubble h4 {
  margin: 10px 0 4px 0;
  font-weight: 600;
}

.agent-msg.assistant .agent-msg-bubble h1 { font-size: 16px; }
.agent-msg.assistant .agent-msg-bubble h2 { font-size: 15px; }
.agent-msg.assistant .agent-msg-bubble h3 { font-size: 14px; }
.agent-msg.assistant .agent-msg-bubble h4 { font-size: 13.5px; }

.agent-msg.assistant .agent-msg-bubble hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}

.agent-msg.assistant .agent-msg-bubble table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  font-size: 12.5px;
}

.agent-msg.assistant .agent-msg-bubble th,
.agent-msg.assistant .agent-msg-bubble td {
  border: 1px solid var(--border);
  padding: 5px 8px;
  text-align: left;
}

.agent-msg.assistant .agent-msg-bubble th {
  background: rgba(0, 0, 0, 0.03);
  font-weight: 600;
}

.agent-msg-time {
  font-size: 10.5px;
  color: var(--muted-foreground);
  margin-top: 4px;
  padding: 0 4px;
}

.agent-msg.user .agent-msg-time {
  text-align: right;
}

/* ---- Tool Execution Indicator ---- */
.agent-tool-indicator {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: var(--secondary);
  border-radius: 10px;
  font-size: 12px;
  color: var(--muted-foreground);
  align-self: flex-start;
  animation: agentMsgIn 0.2s ease;
}

.agent-tool-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: agentSpin 0.6s linear infinite;
}

@keyframes agentSpin {
  to { transform: rotate(360deg); }
}

.agent-tool-indicator.done {
  color: var(--success-color);
}

.agent-tool-indicator.done .agent-tool-spinner {
  border: none;
  animation: none;
}

.agent-tool-indicator.done .agent-tool-spinner::after {
  content: '✓';
  font-size: 12px;
  font-weight: 700;
}

/* ---- Typing Indicator ---- */
.agent-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 10px 16px;
  background: var(--secondary);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  align-self: flex-start;
  animation: agentMsgIn 0.2s ease;
}

.agent-typing-dot {
  width: 6px;
  height: 6px;
  background: var(--muted-foreground);
  border-radius: 50%;
  animation: agentBounce 1.4s ease-in-out infinite;
}

.agent-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.agent-typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes agentBounce {
  0%, 60%, 100% {
    transform: translateY(0);
    opacity: 0.4;
  }
  30% {
    transform: translateY(-4px);
    opacity: 1;
  }
}

/* ---- Input Area ---- */
.agent-input-area {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 8px 12px;
  border-top: 1px solid var(--border);
  background: var(--card);
  flex-shrink: 0;
}

.agent-input-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: transparent;
  border: none;
  border-radius: 0;
  padding: 0;
  min-height: 0;
}

.agent-input-wrapper:focus-within {
  border-color: transparent;
}

.agent-input {
  flex: 1;
  border: 1px solid var(--border);
  background: var(--secondary);
  border-radius: 10px;
  font-family: inherit;
  font-size: 13.5px;
  color: var(--foreground);
  resize: none;
  outline: none;
  padding: 7px 12px;
  max-height: 120px;
  line-height: 1.45;
  transition: border-color 0.15s;
}

.agent-input:focus {
  border-color: var(--ring);
}

.agent-input::placeholder {
  color: var(--muted-foreground);
}

.agent-send-btn {
  width: 36px;
  height: 36px;
  border: none;
  background: var(--primary);
  color: var(--primary-foreground);
  border-radius: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s, transform 0.15s;
}

.agent-send-btn:hover {
  opacity: 0.9;
}

.agent-send-btn:active {
  transform: scale(0.94);
}

.agent-send-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.agent-send-btn svg {
  width: 18px;
  height: 18px;
}

/* ---- Responsive ---- */
@media (max-width: 480px) {
  .agent-panel {
    --agent-panel-bottom: 72px;
    width: calc(100vw - 16px);
    height: calc(
      100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
    );
    max-height: calc(
      100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
    );
    bottom: var(--agent-panel-bottom);
    right: 8px;
    border-radius: 12px;
  }

  .agent-fab {
    bottom: 12px;
    right: 12px;
    width: 50px;
    height: 50px;
  }

  .agent-fab-scraping-indicator {
    right: 68px;
    bottom: 16px;
    max-width: 180px;
    font-size: 11px;
    padding: 5px 10px 5px 8px;
  }
}

/* ---- Error message ---- */
.agent-error {
  padding: 8px 12px;
  background: var(--destructive-foreground);
  border: 1px solid rgba(239, 68, 68, 0.2);
  border-radius: 10px;
  color: var(--destructive);
  font-size: 12.5px;
  align-self: center;
  text-align: center;
  animation: agentMsgIn 0.2s ease;
}

/* ---- Action Confirmation Card ---- */
.agent-action-confirm {
  background: var(--secondary);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 14px 16px;
  align-self: flex-start;
  max-width: 90%;
  animation: agentMsgIn 0.25s ease;
}

.agent-action-confirm-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 10px;
  font-weight: 600;
  font-size: 13.5px;
  color: var(--foreground);
}

.agent-action-confirm-icon {
  font-size: 16px;
  line-height: 1;
}

.agent-action-confirm-fields {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 12px;
  padding: 8px 10px;
  background: var(--background);
  border-radius: 8px;
  font-size: 12.5px;
}

.agent-action-field {
  display: flex;
  gap: 4px;
  line-height: 1.4;
}

.agent-action-field-label {
  color: var(--muted-foreground);
  font-weight: 500;
  white-space: nowrap;
}

.agent-action-field-value {
  color: var(--foreground);
  word-break: break-word;
}

.agent-action-confirm-buttons {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
}

.agent-action-btn {
  padding: 6px 16px;
  border: none;
  border-radius: 6px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  transition: opacity 0.15s, transform 0.1s;
}

.agent-action-btn:hover {
  opacity: 0.85;
}

.agent-action-btn:active {
  transform: scale(0.97);
}

.agent-action-btn-cancel {
  background: var(--muted);
  color: var(--muted-foreground);
}

.agent-action-btn-confirm {
  background: var(--primary);
  color: var(--primary-foreground, #fff);
}

.agent-action-btn:disabled {
  cursor: not-allowed;
  opacity: 0.5 !important;
}

.agent-action-confirm-resolved {
  border-color: transparent;
  padding: 10px 14px;
}

.agent-action-confirm-result {
  font-size: 13px;
  font-weight: 500;
}

.agent-action-confirm-result.success {
  color: var(--success-color, #22c55e);
}

.agent-action-confirm-result.cancelled {
  color: var(--muted-foreground);
}

.agent-action-confirm-result.error {
  color: var(--destructive);
}

/* ============================================================
   Embedded Browser Viewport (Electron desktop only)
   ============================================================ */

/* When the browser viewport is open, expand only into the space below
   the application header. The header buttons must remain clickable. */
.agent-panel.browser-active {
  height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
  max-height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
}

/* The raised variant supplies a larger --agent-panel-bottom above. */
.agent-panel.agent-fab-raised.browser-active {
  height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
  max-height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
}

/* When the browser is minimized inside an active viewport, shrink
   the panel back closer to its default height.                      */
.agent-panel.browser-active.browser-minimized {
  height: 680px;
  max-height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
}

.agent-panel.agent-fab-raised.browser-active.browser-minimized {
  height: 680px;
  max-height: calc(
    100vh - var(--agent-panel-safe-top) - var(--agent-panel-bottom)
  );
}

/* Ensure flex shrink works: messages must be able to collapse
   instead of overflowing behind the native overlay.              */
.agent-panel.browser-active .agent-messages {
  min-height: 120px;
}

/* Browser viewport container */
.agent-browser-viewport {
  display: flex;
  flex-direction: column;
  border-bottom: 1px solid var(--border);
  background: var(--muted);
  flex-shrink: 0;
  overflow: hidden;
}

/* Minimized browser: collapse frame, keep thin toolbar */
.agent-browser-viewport.minimized .agent-browser-frame {
  height: 0;
  min-height: 0;
  overflow: hidden;
}

.agent-browser-viewport.minimized .agent-browser-toolbar {
  min-height: 30px;
  padding: 4px 10px;
}

.agent-browser-viewport.minimized {
  border-bottom: 1px solid var(--border);
}

/* Toolbar with URL and controls */
.agent-browser-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 6px 10px;
  gap: 8px;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  min-height: 36px;
}

.agent-browser-status {
  display: flex;
  align-items: center;
  gap: 6px;
  flex: 1;
  min-width: 0;
}

.agent-browser-url {
  font-size: 11.5px;
  color: var(--muted-foreground);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-family: 'SFMono-Regular', 'Consolas', monospace;
}

.agent-browser-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: agentToolSpin 0.7s linear infinite;
  flex-shrink: 0;
}

.agent-browser-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.agent-browser-btn {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--muted-foreground);
  transition: background 0.15s, color 0.15s;
}

.agent-browser-btn:hover {
  background: var(--muted);
  color: var(--foreground);
}

.agent-browser-btn svg {
  width: 14px;
  height: 14px;
}

/* The frame area where Electron overlays the WebContentsView */
.agent-browser-frame {
  position: relative;
  height: 200px;
  min-height: 120px;
  background: #f8f9fa;
  overflow: hidden;
}

.agent-browser-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  gap: 10px;
  color: var(--muted-foreground);
  font-size: 13px;
}

.agent-browser-error {
  color: var(--destructive);
  font-size: 12.5px;
}

/* ============================================================
   Captcha Overlay (full-screen modal for solving captchas)
   ============================================================ */
.agent-captcha-overlay {
  position: fixed;
  inset: 0;
  z-index: 10002;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.agent-captcha-card {
  width: calc(100vw - 60px);
  max-width: 1300px;
  display: flex;
  flex-direction: column;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.3);
}

.agent-captcha-banner {
  background: var(--card);
  border: 1px solid var(--border);
  border-bottom: none;
  border-radius: 16px 16px 0 0;
  padding: 16px 24px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.agent-captcha-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: rgba(245, 158, 11, 0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.agent-captcha-icon svg {
  width: 18px;
  height: 18px;
  color: var(--warning-color, #f59e0b);
}

.agent-captcha-title {
  font-size: 15px;
  font-weight: 600;
  color: var(--foreground);
  margin: 0;
}

.agent-captcha-subtitle {
  font-size: 13px;
  color: var(--muted-foreground);
  margin: 2px 0 0;
}

.agent-captcha-frame {
  width: 100%;
  height: 600px;
  background: var(--muted);
  border: 1px solid var(--border);
  border-top: none;
  border-radius: 0 0 16px 16px;
  position: relative;
  /* Let clicks pass through to the native WebContentsView behind this DOM element */
  pointer-events: none;
}

/* Screenshot inserted in chat */
.agent-browser-screenshot {
  max-width: 100%;
  border-radius: 8px;
  margin-top: 6px;
  border: 1px solid var(--border);
  cursor: pointer;
}

.agent-browser-screenshot:hover {
  opacity: 0.9;
}

/* Scraper step indicators in chat */
.agent-tool-indicator.scraper-step {
  border-left: 3px solid var(--accent, #6366f1);
}

/* Responsive adjustments for browser viewport */
@media (max-width: 480px) {
  .agent-browser-frame {
    height: 160px;
    min-height: 100px;
  }
}

/* ---- Scraping Activity Indicator (beside FAB) ---- */
.agent-fab-scraping-indicator {
  position: fixed;
  bottom: 24px;
  right: 80px;
  z-index: 10001;
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 5px;
  min-height: 26px;
  padding: 3px 8px;
  box-sizing: border-box;
  background:
    linear-gradient(135deg, rgba(99, 102, 241, 0.26), rgba(59, 130, 246, 0.12)),
    color-mix(in srgb, var(--card, #111217) 78%, transparent);
  border: 1px solid rgba(165, 180, 252, 0.34);
  border-radius: 999px;
  box-shadow:
    0 8px 24px rgba(15, 23, 42, 0.24),
    inset 0 1px 0 rgba(255, 255, 255, 0.18);
  -webkit-backdrop-filter: blur(18px) saturate(165%);
  backdrop-filter: blur(18px) saturate(165%);
  font-size: 11px;
  font-weight: 600;
  color: var(--text-primary, #eef2ff);
  max-width: 72px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  pointer-events: auto;
  cursor: default;
  transition: max-width 0.18s ease, box-shadow 0.18s ease;
  animation: fab-scraping-fadein 0.3s ease;
}

.agent-fab-scraping-indicator:hover,
.agent-fab-scraping-indicator:focus-within {
  max-width: 350px;
  box-shadow:
    0 10px 30px rgba(15, 23, 42, 0.3),
    inset 0 1px 0 rgba(255, 255, 255, 0.22);
}

@keyframes fab-scraping-fadein {
  from { opacity: 0; transform: translateX(10px); }
  to   { opacity: 1; transform: translateX(0); }
}

.fab-scraping-spinner {
  width: 10px;
  height: 10px;
  border: 1.5px solid rgba(199, 210, 254, 0.46);
  border-top-color: #a5b4fc;
  border-radius: 50%;
  animation: fab-scraping-spin 0.8s linear infinite;
  flex-shrink: 0;
}

.fab-scraping-spinner.done {
  border: none;
  animation: none;
}
.fab-scraping-spinner.done::after {
  content: '✓';
  font-size: 11px;
  font-weight: 700;
  color: #16a34a;
}

.fab-scraping-spinner.error {
  border: none;
  animation: none;
}
.fab-scraping-spinner.error::after {
  content: '✗';
  font-size: 11px;
  font-weight: 700;
  color: #dc2626;
}

@keyframes fab-scraping-spin {
  to { transform: rotate(360deg); }
}

.fab-scraping-label {
  line-height: 1;
  overflow: hidden;
  text-overflow: ellipsis;
}

.fab-scraping-count {
  min-width: 37px;
  line-height: 1;
  text-align: center;
  font-variant-numeric: tabular-nums;
}

.fab-scraping-details {
  display: flex;
  flex: 0 1 auto;
  align-items: center;
  max-width: 0;
  margin-left: 0;
  padding-left: 0;
  border-left: 1px solid transparent;
  overflow: hidden;
  opacity: 0;
  transition:
    max-width 0.18s ease,
    margin-left 0.18s ease,
    padding-left 0.18s ease,
    opacity 0.12s ease;
}

.agent-fab-scraping-indicator:hover .fab-scraping-details,
.agent-fab-scraping-indicator:focus-within .fab-scraping-details {
  max-width: 330px;
  margin-left: 4px;
  padding-left: 8px;
  border-left-color: rgba(199, 210, 254, 0.28);
  opacity: 1;
}

@media (max-width: 480px) {
  .agent-fab-scraping-indicator:hover,
  .agent-fab-scraping-indicator:focus-within {
    max-width: calc(100vw - 92px);
  }

  .agent-fab-scraping-indicator:hover .fab-scraping-details,
  .agent-fab-scraping-indicator:focus-within .fab-scraping-details {
    max-width: 150px;
  }
}
