/* =========================================================
   ASK FUELCFO — floating AI assistant widget
   Depends on the design tokens declared in outsourcing-cpa-firms.css
   (--ocf-green-*, --ocf-mint*, --ocf-line, --ocf-text, --ocf-muted).
   ========================================================= */

.fai {
  --fai-w: 400px;
  --fai-h: 620px;
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90000;
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* ---------- launcher ---------- */
.fai-launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 13px 20px 13px 16px;
  border: 0;
  border-radius: 999px;
  background: var(--ocf-green-700, #004942);
  color: #fff;
  font: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(0, 41, 37, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease, background 0.18s ease;
}
.fai-launcher:hover {
  background: var(--ocf-green-600, #0a5d53);
  transform: translateY(-2px);
  box-shadow: 0 18px 42px rgba(0, 41, 37, 0.34);
}
.fai-launcher:focus-visible {
  outline: 3px solid var(--ocf-mint-2, #5fe3c0);
  outline-offset: 3px;
}
.fai-launcher svg {
  width: 22px;
  height: 22px;
  flex: none;
}
.fai-launcher-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ocf-mint, #a3ffe4);
  flex: none;
}
.fai.is-open .fai-launcher {
  opacity: 0;
  pointer-events: none;
}

/* ---------- panel ---------- */
.fai-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: var(--fai-w);
  height: min(var(--fai-h), calc(100vh - 48px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: 20px;
  background: #fff;
  border: 1px solid var(--ocf-line, #e6e8e3);
  box-shadow: 0 30px 70px rgba(0, 41, 37, 0.24);
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  transform-origin: 100% 100%;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.fai.is-open .fai-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ---------- header ---------- */
.fai-head {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 16px 16px 15px;
  background: var(--ocf-green-900, #002925);
  color: #fff;
  flex: none;
  /* keeps the thread from appearing to bleed into the header when scrolled */
  position: relative;
  z-index: 2;
  box-shadow: 0 4px 12px rgba(0, 41, 37, 0.16);
}
.fai-head-icon {
  width: 38px;
  height: 38px;
  flex: none;
  display: grid;
  place-items: center;
  border-radius: 11px;
  background: rgba(163, 255, 228, 0.14);
  color: var(--ocf-mint, #a3ffe4);
}
.fai-head-icon svg {
  width: 20px;
  height: 20px;
}
.fai-head-text {
  flex: 1;
  min-width: 0;
}
.fai-head-title {
  font-family: "Outfit", "Inter", system-ui, sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: -0.01em;
  margin: 0 0 2px;
}
.fai-head-sub {
  margin: 0;
  font-size: 12.5px;
  line-height: 1.45;
  color: rgba(255, 255, 255, 0.66);
}
.fai-head-btn {
  flex: none;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: rgba(255, 255, 255, 0.72);
  font-size: 19px;
  line-height: 1;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.fai-head-btn:hover {
  background: rgba(255, 255, 255, 0.12);
  color: #fff;
}
.fai-head-btn:focus-visible {
  outline: 2px solid var(--ocf-mint-2, #5fe3c0);
  outline-offset: 1px;
}

/* ---------- thread ---------- */
.fai-thread {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 18px 16px 6px;
  background: #fbfcfb;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.fai-thread::-webkit-scrollbar {
  width: 8px;
}
.fai-thread::-webkit-scrollbar-thumb {
  background: #dfe4e1;
  border-radius: 8px;
}

.fai-msg {
  max-width: 88%;
  font-size: 14.5px;
  line-height: 1.62;
}
.fai-msg--user {
  align-self: flex-end;
  background: var(--ocf-green-700, #004942);
  color: #fff;
  padding: 11px 15px;
  border-radius: 16px 16px 4px 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.fai-msg--bot {
  align-self: flex-start;
  color: var(--ocf-text, #16201d);
  max-width: 100%;
}
.fai-msg--bot p {
  margin: 0 0 9px;
}
.fai-msg--bot p:last-child {
  margin-bottom: 0;
}
.fai-msg--bot ul {
  margin: 0 0 9px;
  padding-left: 20px;
}
.fai-msg--bot li {
  margin: 0 0 4px;
}
.fai-msg--bot strong {
  font-weight: 650;
  color: var(--ocf-green-800, #003c36);
}
.fai-msg--bot a {
  color: var(--ocf-green-600, #0a5d53);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.fai-msg--bot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  background: #eef2f0;
  padding: 1px 5px;
  border-radius: 4px;
}
.fai-msg--error {
  align-self: flex-start;
  font-size: 13.5px;
  line-height: 1.55;
  color: #8a2b20;
  background: #fdf1ef;
  border: 1px solid #f4d5cf;
  padding: 10px 13px;
  border-radius: 12px;
}

/* streaming caret */
.fai-msg--bot.is-streaming > :last-child::after {
  content: "";
  display: inline-block;
  width: 7px;
  height: 15px;
  margin-left: 3px;
  vertical-align: -2px;
  background: var(--ocf-green-500, #008060);
  animation: fai-blink 1s steps(2, start) infinite;
}
@keyframes fai-blink {
  to {
    visibility: hidden;
  }
}

/* thinking dots */
.fai-dots {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  padding: 4px 0;
}
.fai-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #b7c3bd;
  animation: fai-bounce 1.15s ease-in-out infinite;
}
.fai-dots span:nth-child(2) {
  animation-delay: 0.16s;
}
.fai-dots span:nth-child(3) {
  animation-delay: 0.32s;
}
@keyframes fai-bounce {
  0%, 65%, 100% {
    transform: translateY(0);
    opacity: 0.55;
  }
  32% {
    transform: translateY(-5px);
    opacity: 1;
  }
}

/* ---------- suggestion chips ---------- */
.fai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 16px 14px;
  background: #fbfcfb;
  flex: none;
}
.fai-chip {
  border: 1px solid var(--ocf-line, #e6e8e3);
  background: #fff;
  color: var(--ocf-green-700, #004942);
  font: inherit;
  font-size: 12.5px;
  font-weight: 550;
  line-height: 1.3;
  text-align: left;
  padding: 8px 12px;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
}
.fai-chip:hover {
  border-color: var(--ocf-green-500, #008060);
  background: #f1fbf7;
}
.fai-chip:focus-visible {
  outline: 2px solid var(--ocf-green-500, #008060);
  outline-offset: 1px;
}

/* ---------- composer ---------- */
.fai-form {
  flex: none;
  border-top: 1px solid var(--ocf-line, #e6e8e3);
  background: #fff;
  padding: 11px 12px;
}
.fai-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  border: 1px solid var(--ocf-line, #e6e8e3);
  border-radius: 14px;
  padding: 6px 6px 6px 12px;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.fai-input-row:focus-within {
  border-color: var(--ocf-green-500, #008060);
  box-shadow: 0 0 0 3px rgba(0, 128, 96, 0.12);
}
.fai-input {
  flex: 1;
  min-width: 0;
  border: 0;
  outline: 0;
  resize: none;
  background: transparent;
  font: inherit;
  font-size: 14.5px;
  line-height: 1.5;
  color: var(--ocf-text, #16201d);
  max-height: 120px;
  padding: 6px 0;
}
.fai-input::placeholder {
  color: #9aa8a2;
}
.fai-send {
  flex: none;
  width: 36px;
  height: 36px;
  display: grid;
  place-items: center;
  border: 0;
  border-radius: 10px;
  background: var(--ocf-green-700, #004942);
  color: #fff;
  cursor: pointer;
  transition: background 0.15s ease, opacity 0.15s ease;
}
.fai-send svg {
  width: 17px;
  height: 17px;
}
.fai-send:hover:not(:disabled) {
  background: var(--ocf-green-600, #0a5d53);
}
.fai-send:disabled {
  opacity: 0.42;
  cursor: not-allowed;
}
.fai-send:focus-visible {
  outline: 2px solid var(--ocf-green-500, #008060);
  outline-offset: 2px;
}
.fai-legal {
  margin: 8px 2px 0;
  font-size: 11px;
  line-height: 1.45;
  color: var(--ocf-muted, #5c6b65);
  text-align: center;
}
.fai-legal a {
  color: inherit;
  text-decoration: underline;
}

/* ---------- responsive ---------- */
@media (max-width: 560px) {
  .fai {
    right: 16px;
    bottom: 16px;
  }
  /* icon-only launcher — the label and status dot would crowd the circle */
  .fai-launcher span {
    display: none;
  }
  .fai-launcher {
    padding: 15px;
  }
  .fai-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    border: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .fai-launcher,
  .fai-panel {
    transition: none;
  }
  .fai-dots span,
  .fai-msg--bot.is-streaming > :last-child::after {
    animation: none;
  }
}

@media print {
  .fai {
    display: none;
  }
}
