/* agentchase-helper overlay (issue #307)
   Floating chatbot for issues.chaserich.com. Scoped under .acah-* to avoid
   collisions with Forgejo + icsb status bar. Dark theme parity with arc-green. */

#acah-root {
  position: fixed;
  right: 16px;
  bottom: 60px;
  z-index: 10000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 13px;
  line-height: 1.45;
  color: #d4d4d4;
  /* Move the whole root (FAB + panel anchor) when the status-bar tray opens
     so the FAB doesn't overlap the 280px composer panel. The bar is 28px,
     the panel is 280px, gap 16px => 324px lift. */
  transition: bottom 0.2s ease;
}

html[data-icsb-open="true"] #acah-root {
  bottom: 324px;
}

#acah-root.acah-hidden { display: none; }

.acah-fab {
  width: 64px;
  height: 64px;
  border-radius: 32px;
  background: linear-gradient(145deg, #2c5a48 0%, #1f4035 100%);
  color: #ddf3ea;
  border: 1px solid #3a7a63;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), 0 0 0 1px rgba(58, 122, 99, 0.2);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.15s ease, box-shadow 0.15s ease;
  padding: 0;
  /* Sensory-friendly slow pulse. Low contrast, mint/teal accent. */
  animation: acah-glow 4.5s ease-in-out infinite;
}

.acah-fab:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.5), 0 0 0 1px rgba(58, 122, 99, 0.35);
}

.acah-fab:focus { outline: 2px solid #4fa688; outline-offset: 2px; }
.acah-fab svg,
.acah-fab .acah-fab-icon { width: 36px; height: 36px; }

@keyframes acah-glow {
  0%, 100% { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), 0 0 14px 2px rgba(106, 200, 168, 0.15); }
  50%      { box-shadow: 0 4px 14px rgba(0, 0, 0, 0.4), 0 0 24px 6px rgba(106, 200, 168, 0.35); }
}

@media (prefers-reduced-motion: reduce) {
  .acah-fab { animation: none; }
  #acah-root { transition: none; }
}

/* Panel slides up from the FAB; the FAB hides while panel is open. */
.acah-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 380px;
  height: 60vh;
  max-height: 600px;
  background: #14191f;
  border: 1px solid #2a3640;
  border-radius: 10px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.55);
  display: none;
  flex-direction: column;
  overflow: hidden;
  transform: translateY(8px);
  opacity: 0;
  transition: transform 0.18s ease, opacity 0.18s ease;
}

#acah-root.acah-open .acah-panel {
  display: flex;
  transform: translateY(0);
  opacity: 1;
}
#acah-root.acah-open .acah-fab { display: none; }

.acah-header {
  height: 40px;
  flex: 0 0 40px;
  background: #1b232c;
  border-bottom: 1px solid #2a3640;
  display: flex;
  align-items: center;
  padding: 0 10px;
  gap: 8px;
}

.acah-title {
  flex: 1;
  font-weight: 600;
  color: #ddf3ea;
  font-size: 13px;
}

.acah-icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: #a0adb9;
  width: 26px;
  height: 26px;
  border-radius: 4px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  font-size: 14px;
  line-height: 1;
}
.acah-icon-btn:hover {
  background: #243140;
  color: #f0f0f0;
  border-color: #2a3640;
}

.acah-thread {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: #14191f;
}

.acah-msg {
  max-width: 88%;
  padding: 8px 10px;
  border-radius: 8px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.acah-msg-user {
  align-self: flex-end;
  background: #2c5a48;
  color: #ddf3ea;
  border: 1px solid #3a7a63;
}

.acah-msg-assistant {
  align-self: flex-start;
  background: #1b232c;
  color: #d4d4d4;
  border: 1px solid #2a3640;
}

.acah-msg-system,
.acah-msg-tool {
  align-self: stretch;
  background: transparent;
  color: #7a8693;
  font-size: 11.5px;
  font-style: italic;
  padding: 2px 4px;
  border: none;
}

.acah-msg-error {
  align-self: stretch;
  background: #3a1e1e;
  color: #f4b6b6;
  border: 1px solid #5a2a2a;
  font-size: 12px;
}

.acah-msg p { margin: 0 0 6px; }
.acah-msg p:last-child { margin-bottom: 0; }
.acah-msg code {
  background: #0e1318;
  padding: 1px 4px;
  border-radius: 3px;
  font-size: 11.5px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}
.acah-msg pre {
  background: #0e1318;
  border: 1px solid #1f2a35;
  border-radius: 5px;
  padding: 6px 8px;
  overflow-x: auto;
  margin: 4px 0;
  font-size: 11.5px;
}
.acah-msg pre code { padding: 0; background: transparent; }
.acah-msg a { color: #7fcbb1; text-decoration: underline; }
.acah-msg a:hover { color: #a3e2cb; }
.acah-msg strong { color: #f0f0f0; font-weight: 600; }
.acah-msg em { color: #c9d2db; font-style: italic; }

.acah-pending {
  align-self: stretch;
  background: #2a2415;
  border: 1px solid #4a3f1f;
  border-radius: 6px;
  padding: 8px 10px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.acah-pending-label {
  color: #e8d987;
  font-size: 12px;
  font-weight: 600;
}

.acah-pending-detail {
  color: #cfc28b;
  font-size: 11.5px;
  white-space: pre-wrap;
  word-break: break-word;
}

.acah-pending-actions { display: flex; gap: 6px; }

.acah-btn {
  border: 1px solid #2a3640;
  background: #1b232c;
  color: #ddf3ea;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-size: 12px;
}
.acah-btn:hover { background: #243140; }
.acah-btn-primary { background: #2c5a48; border-color: #3a7a63; }
.acah-btn-primary:hover { background: #356a55; }
.acah-btn-danger { background: #5a2a2a; border-color: #7a3a3a; color: #f4b6b6; }
.acah-btn-danger:hover { background: #6a3535; }

/* Suggestion pills: shown above the input on an empty thread. Hidden once
   the user has sent at least one message. */
.acah-suggestions {
  flex: 0 0 auto;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 8px 10px;
  border-top: 1px solid #2a3640;
  background: #14191f;
}

.acah-suggestions:empty { display: none; }

.acah-pill {
  background: #1b232c;
  border: 1px solid #2a3640;
  color: #b6d4c6;
  padding: 4px 10px;
  border-radius: 999px;
  font: inherit;
  font-size: 11.5px;
  line-height: 1.3;
  cursor: pointer;
  white-space: normal;
  text-align: left;
  transition: background 0.12s ease, border-color 0.12s ease, color 0.12s ease;
}

.acah-pill:hover {
  background: #243140;
  border-color: #3a7a63;
  color: #ddf3ea;
}

.acah-pill:focus {
  outline: 2px solid #4fa688;
  outline-offset: 1px;
}

.acah-input-row {
  flex: 0 0 auto;
  border-top: 1px solid #2a3640;
  background: #1b232c;
  padding: 8px;
  display: flex;
  align-items: flex-end;
  gap: 6px;
}

.acah-input {
  flex: 1;
  background: #14191f;
  border: 1px solid #2a3640;
  color: #f0f0f0;
  padding: 6px 8px;
  border-radius: 5px;
  resize: none;
  font: inherit;
  line-height: 1.4;
  min-height: 32px;
  max-height: 96px;
}

.acah-input:focus { outline: none; border-color: #3a7a63; }

.acah-send {
  background: #2c5a48;
  color: #ddf3ea;
  border: 1px solid #3a7a63;
  padding: 6px 10px;
  border-radius: 5px;
  cursor: pointer;
  font-weight: 600;
}
.acah-send:disabled { opacity: 0.6; cursor: not-allowed; }
.acah-send:hover:not(:disabled) { background: #356a55; }

.acah-typing {
  align-self: flex-start;
  color: #7a8693;
  font-size: 11.5px;
  font-style: italic;
  padding: 2px 4px;
}

.acah-spinner {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #7a8693;
  animation: acah-pulse 0.9s infinite ease-in-out;
  margin-right: 4px;
}

@keyframes acah-pulse {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* Mobile: FAB shrinks; panel takes ~85vw x 70vh. */
@media (max-width: 480px) {
  #acah-root {
    right: 10px;
    bottom: 50px;
  }
  .acah-fab {
    width: 52px;
    height: 52px;
    border-radius: 26px;
  }
  .acah-fab svg,
  .acah-fab .acah-fab-icon { width: 30px; height: 30px; }
  .acah-panel {
    width: 85vw;
    height: 70vh;
    max-height: none;
  }
  /* On mobile the status-bar tray expands to ~50vh, so lift the FAB
     correspondingly (tray + 28px bar + 16px gap). */
  html[data-icsb-open="true"] #acah-root {
    bottom: calc(50vh + 16px + 28px);
  }
}
