/* ============================================================
   The Konnectdots AI Assistant chat (/get-matched, and the /home-test experiment).
   Markup: app/Views/includes/assistant_chat.php. Behaviour: js/assistant_chat.js.
   Everything is prefixed kda- so it cannot touch, or be touched by, the rest of the site.
   ============================================================ */

.kda-section {
  --kda-blue: var(--kd-blue, #1e5baa);
  --kda-orange: var(--kd-orange, #f47b20);
  --kda-ink: #111827;
  --kda-text: #374151;
  --kda-muted: #6b7280;
  --kda-line: #e5e7eb;
  --kda-soft: #f5f7fa;
  padding: 56px 0 48px;
  background: #ffffff;
  font-family: 'Poppins', system-ui, -apple-system, 'Segoe UI', sans-serif;
}

.kda-section__inner {
  max-width: 880px;
  margin: 0 auto;
  padding: 0 16px;
}

.kda-section__title {
  margin: 0 0 8px;
  text-align: center;
  font-size: clamp(24px, 3.4vw, 34px);
  font-weight: 700;
  line-height: 1.25;
  color: var(--kda-ink);
}

.kda-section__sub {
  margin: 0 auto 24px;
  max-width: 640px;
  text-align: center;
  font-size: 15.5px;
  line-height: 1.6;
  color: var(--kda-muted);
}

.kda-section__browse {
  margin: 18px 0 0;
  text-align: center;
  font-size: 13.5px;
  line-height: 1.9;
  color: var(--kda-muted);
}
.kda-section__browse a { color: var(--kda-blue); text-decoration: none; margin: 0 2px; }
.kda-section__browse a:hover { text-decoration: underline; }

/* ---------- the window ---------- */

.kda {
  display: flex;
  flex-direction: column;
  height: clamp(540px, 80vh, 760px);
  background: #ffffff;
  border: 1px solid var(--kda-line);
  border-radius: 18px;
  box-shadow: 0 10px 40px rgba(17, 24, 39, 0.07);
  overflow: hidden;
}

.kda__bar {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--kda-line);
  background: #fbfcfd;
}

.kda__bar-title {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-size: 13.5px;
  font-weight: 600;
  color: var(--kda-ink);
}

.kda__dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.18);
}

.kda__new {
  padding: 6px 12px;
  border: 1px solid var(--kda-line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--kda-text);
  font: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}
.kda__new:hover { border-color: var(--kda-blue); color: var(--kda-blue); }

.kda__messages {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 18px 8px;
  scroll-behavior: smooth;
}

/* ---------- messages ---------- */

.kda-msg { margin: 0 0 18px; display: flex; flex-direction: column; }
.kda-msg--user { align-items: flex-end; }
.kda-msg--bot  { align-items: flex-start; }

.kda-bubble {
  max-width: min(88%, 640px);
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 15px;
  line-height: 1.6;
  overflow-wrap: anywhere;
}
.kda-msg--user .kda-bubble { background: var(--kda-blue); color: #ffffff; border-bottom-right-radius: 5px; }
.kda-msg--bot .kda-bubble  { background: var(--kda-soft); color: var(--kda-ink); border-bottom-left-radius: 5px; }
.kda-msg--bot .kda-bubble + .kda-bubble { margin-top: 8px; }
.kda-bubble--error { background: #fef2f2!important; color: #991b1b !important; }

.kda-link { color: var(--kda-blue); font-weight: 600; text-decoration: none; }
.kda-link:hover { text-decoration: underline; }

/* ---------- the list of professionals: a plain numbered list, not cards ---------- */

.kda-list {
  list-style: none;
  margin: 10px 0 0;
  padding: 0;
  width: min(100%, 700px);
  border-top: 1px solid var(--kda-line);
}

.kda-item {
  display: grid;
  grid-template-columns: 22px 44px minmax(0, 1fr) auto;
  gap: 4px 12px;
  align-items: start;
  padding: 14px 2px;
  border-bottom: 1px solid var(--kda-line);
}

.kda-item__rank {
  padding-top: 2px;
  font-size: 13px;
  font-weight: 700;
  color: var(--kda-muted);
}

.kda-item__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  background: #e5e7eb;
}

.kda-item__avatar--initials {
  display: flex;
  align-items: center;
  justify-content: center;
  background: #dbe7f6;
  color: var(--kda-blue);
  font-size: 15px;
  font-weight: 700;
}

.kda-item__main { min-width: 0; }

.kda-item__name {
  font-size: 15.5px;
  font-weight: 700;
  line-height: 1.35;
  color: var(--kda-ink);
  text-decoration: none;
}
.kda-item__name:hover { color: var(--kda-blue); text-decoration: underline; }

.kda-item__verified {
  display: inline-block;
  margin-left: 6px;
  padding: 1px 7px;
  border-radius: 999px;
  background: #e7f7ee;
  color: #15803d;
  font-size: 11px;
  font-weight: 600;
  vertical-align: 1px;
}

.kda-item__line { margin-top: 1px; font-size: 13.5px; line-height: 1.5; color: var(--kda-muted); }
.kda-item__facts { margin-top: 2px; font-size: 14px; line-height: 1.5; color: var(--kda-text); font-weight: 500; }
.kda-item__note { margin-top: 2px; font-size: 12.5px; color: #b45309; }

.kda-item__tags { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.kda-item__tag {
  padding: 2px 9px;
  border-radius: 999px;
  background: #eef2f7;
  color: var(--kda-text);
  font-size: 12px;
}

.kda-item__actions { display: flex; flex-direction: column; gap: 6px; align-items: stretch; }

.kda-btn {
  padding: 7px 14px;
  border: 1px solid var(--kda-blue);
  border-radius: 999px;
  background: var(--kda-blue);
  color: #ffffff;
  font: inherit;
  font-size: 13px;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.kda-btn:hover { filter: brightness(0.93); }
.kda-btn--ghost { background: #ffffff; color: var(--kda-blue); }
.kda-btn--ghost:hover { background: #f1f6fc; filter: none; }

.kda-list-note { margin: 8px 0 0; font-size: 12.5px; color: var(--kda-muted); }

/* ---------- quick replies ---------- */

.kda-chips { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.kda-chip {
  padding: 8px 14px;
  border: 1px solid var(--kda-line);
  border-radius: 999px;
  background: #ffffff;
  color: var(--kda-blue);
  font: inherit;
  font-size: 13.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.kda-chip:hover { background: #f1f6fc; border-color: var(--kda-blue); }

/* ---------- the inquiry form ---------- */

.kda-inquiry {
  width: min(100%, 460px);
  margin-top: 10px;
  padding: 16px;
  border: 1px solid var(--kda-line);
  border-radius: 14px;
  background: #ffffff;
}
.kda-inquiry__title { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: var(--kda-ink); }
.kda-inquiry__hint { margin: 0 0 12px; font-size: 12.5px; line-height: 1.5; color: var(--kda-muted); }
.kda-inquiry__field { display: block; margin-bottom: 10px; }
.kda-inquiry__field span { display: block; margin-bottom: 3px; font-size: 12.5px; font-weight: 600; color: var(--kda-text); }
.kda-inquiry__field input {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  font: inherit;
  font-size: 15px;
  box-sizing: border-box;
}
.kda-inquiry__field input:focus { outline: 2px solid var(--kda-blue); outline-offset: 1px; border-color: transparent; }
.kda-inquiry__trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.kda-inquiry__error { margin: 0 0 10px; font-size: 13px; color: #b91c1c; }
.kda-inquiry__row { display: flex; gap: 8px; align-items: center; }
.kda-inquiry__cancel { background: none; border: none; color: var(--kda-muted); font: inherit; font-size: 13px; cursor: pointer; }
.kda-inquiry__cancel:hover { color: var(--kda-ink); }
.kda-ok { color: #166534 !important; background: #ecfdf3 !important; }

/* ---------- typing indicator ---------- */

.kda-typing { display: inline-flex; gap: 5px; padding: 14px 16px; background: var(--kda-soft); border-radius: 16px; border-bottom-left-radius: 5px; }
.kda-typing i { width: 7px; height: 7px; border-radius: 50%; background: #9ca3af; animation: kdaBounce 1.2s infinite ease-in-out; }
.kda-typing i:nth-child(2) { animation-delay: 0.15s; }
.kda-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes kdaBounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-5px); opacity: 1; } }

/* ---------- the input ---------- */

.kda__form {
  flex: 0 0 auto;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 14px;
  border-top: 1px solid var(--kda-line);
  background: #ffffff;
}

.kda__input {
  flex: 1 1 auto;
  min-width: 0;
  max-height: 140px;
  padding: 11px 16px;
  border: 1px solid #d1d5db;
  border-radius: 22px;
  background: #ffffff;
  color: var(--kda-ink);
  font: inherit;
  font-size: 15px;
  line-height: 1.45;
  resize: none;
  overflow-y: hidden;
  box-sizing: border-box;
}
.kda__input:focus { outline: 2px solid var(--kda-blue); outline-offset: 0; border-color: transparent; }

.kda__send {
  flex: 0 0 auto;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--kda-blue);
  color: #ffffff;
  cursor: pointer;
}
.kda__send:hover { filter: brightness(0.92); }
.kda__send:disabled { background: #9ca3af; cursor: not-allowed; }
.kda__send svg { width: 20px; height: 20px; }

.kda__note { margin: 0; padding: 0 16px 12px; font-size: 11.5px; line-height: 1.5; color: #9ca3af; text-align: center; }

.kda__sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

.kda button:focus-visible, .kda a:focus-visible, .kda input:focus-visible { outline: 3px solid var(--kda-orange); outline-offset: 2px; }

/* ---------- phones ---------- */

@media (max-width: 600px) {
  .kda-section { padding: 36px 0 32px; }
  .kda { height: min(86vh, 700px); border-radius: 14px; }
  .kda__messages { padding: 14px 12px 6px; }
  .kda-bubble { max-width: 94%; font-size: 14.5px; }

  .kda-item { grid-template-columns: 18px 40px minmax(0, 1fr); }
  .kda-item__avatar { width: 40px; height: 40px; }
  .kda-item__actions { grid-column: 3; flex-direction: row; margin-top: 6px; }
  .kda-item__actions .kda-btn { flex: 1 1 0; }
}

@media (prefers-reduced-motion: reduce) {
  .kda__messages { scroll-behavior: auto; }
  .kda-typing i { animation: none; opacity: 0.7; }
}

/* ---------- testing only: per-answer model / time / cost line (only when the page sets data-debug="1") ---------- */

.kda-meta {
  margin-top: 5px;
  font-size: 11.5px;
  letter-spacing: 0.01em;
  color: #9ca3af;
  font-variant-numeric: tabular-nums;
}

/* ---------- why a list was made, and why each person is on it (both layouts) ---------- */

.kda-criteria { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; margin: 12px 0 2px; }
.kda-criteria__label { margin-right: 2px; font-size: 12px; font-weight: 600; color: var(--kda-muted); }
.kda-criteria__pill { padding: 3px 10px; border-radius: 999px; background: #eaf1fb; color: var(--kda-blue); font-size: 12.5px; font-weight: 500; }

.kda-item__fit { display: flex; flex-wrap: wrap; gap: 2px 14px; margin-top: 6px; font-size: 12.5px; font-weight: 500; line-height: 1.5; color: #15803d; }
.kda-item__fit span::before { content: "\2713"; margin-right: 5px; font-weight: 700; }
.kda-item__tag--hit { background: #e3edfa; color: var(--kda-blue); font-weight: 600; }

/* "#2 Name: ..." in an answer about the people on screen: the number as a small marker, like the list's */
.kda-ref { display: inline-flex; align-items: center; justify-content: center; width: 20px; height: 20px; margin-right: 4px; border-radius: 50%; background: var(--kda-soft); color: var(--kda-text); font-size: 11.5px; font-weight: 700; vertical-align: 1px; }
