/* ToolPilot Pro site assistant ("Pilot") — floating help chatbot.
   Uses the site's CSS variables so it follows light/dark mode automatically. */

#tpp-chat-launcher {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 300;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  box-shadow: var(--shadow-lg);
  transition: transform .18s ease, box-shadow .18s ease;
}
#tpp-chat-launcher:hover { transform: scale(1.07); }
#tpp-chat-launcher:active { transform: scale(.96); }
#tpp-chat-launcher svg { width: 28px; height: 28px; }
#tpp-chat-launcher .tpp-chat-logo {
  width: 58px; height: 58px; border-radius: 50%;
  object-fit: cover; display: block;
}
#tpp-chat-launcher .tpp-chat-close-ic { display: none; width: 28px; height: 28px; }
#tpp-chat-launcher.open .tpp-chat-logo { display: none; }
#tpp-chat-launcher.open .tpp-chat-close-ic { display: block; }

/* lift above the cookie bar while it is visible */
body.tpp-cookie-visible #tpp-chat-launcher { bottom: 104px; }
body.tpp-cookie-visible #tpp-chat-panel { bottom: 176px; }

#tpp-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 94px;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 140px);
  z-index: 301;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: var(--card);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
}
#tpp-chat-panel[hidden] { display: none; }

.tpp-chat-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff;
  flex: 0 0 auto;
}
.tpp-chat-avatar {
  width: 38px; height: 38px; border-radius: 50%;
  overflow: hidden; flex: 0 0 auto;
  border: 2px solid rgba(255,255,255,.35);
}
.tpp-chat-avatar img { width: 100%; height: 100%; object-fit: cover; display: block; }
.tpp-chat-head .tpp-chat-title { font-weight: 700; font-size: 15px; line-height: 1.2; }
.tpp-chat-head .tpp-chat-sub { font-size: 12px; opacity: .85; }
.tpp-chat-head .tpp-chat-x {
  margin-left: auto; background: none; border: none; color: #fff;
  font-size: 22px; cursor: pointer; line-height: 1; padding: 4px 8px;
  border-radius: 8px;
}
.tpp-chat-head .tpp-chat-x:hover { background: rgba(255,255,255,.15); }

#tpp-chat-msgs {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 14px 14px 6px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--bg);
}
.tpp-msg { max-width: 86%; font-size: 14px; line-height: 1.55; }
.tpp-msg.bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  color: var(--ink);
  border-radius: 4px 16px 16px 16px;
  padding: 10px 13px;
}
.tpp-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  color: #fff;
  border-radius: 16px 4px 16px 16px;
  padding: 10px 13px;
}
.tpp-msg.bot p { margin: 0 0 8px; }
.tpp-msg.bot p:last-child { margin-bottom: 0; }
.tpp-msg.bot ol, .tpp-msg.bot ul { margin: 6px 0 8px; padding-left: 20px; }
.tpp-msg.bot li { margin-bottom: 4px; }

a.tpp-chat-card {
  display: block;
  margin-top: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: var(--bg);
  text-decoration: none;
  color: var(--ink);
  transition: border-color .15s ease, transform .15s ease;
}
a.tpp-chat-card:hover { border-color: var(--brand); transform: translateY(-1px); }
a.tpp-chat-card strong { display: block; font-size: 13.5px; margin-bottom: 3px; color: var(--brand); }
a.tpp-chat-card span { display: block; font-size: 12.5px; color: var(--muted); line-height: 1.5; }
a.tpp-chat-card em { display: block; font-style: normal; font-size: 12px; font-weight: 600; margin-top: 5px; color: var(--brand2); }

.tpp-typing { display: inline-flex; gap: 5px; padding: 4px 2px; }
.tpp-typing i {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted); opacity: .5;
  animation: tpp-blink 1.1s infinite;
}
.tpp-typing i:nth-child(2) { animation-delay: .18s; }
.tpp-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes tpp-blink { 0%,100% { opacity: .25; } 50% { opacity: 1; } }

#tpp-chat-chips {
  display: flex; gap: 8px; overflow-x: auto;
  padding: 8px 14px; flex: 0 0 auto;
  background: var(--bg);
  scrollbar-width: none;
}
#tpp-chat-chips::-webkit-scrollbar { display: none; }
#tpp-chat-chips button {
  flex: 0 0 auto;
  border: 1px solid var(--brand);
  background: transparent;
  color: var(--brand);
  font-size: 12.5px; font-weight: 600;
  padding: 7px 13px; border-radius: 999px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
#tpp-chat-chips button:hover { background: var(--brand); color: #fff; }

#tpp-chat-form {
  display: flex; gap: 8px; padding: 10px 14px 14px;
  background: var(--bg); flex: 0 0 auto;
}
#tpp-chat-input {
  flex: 1 1 auto;
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 14px;
  background: var(--card);
  color: var(--ink);
  outline: none;
  min-width: 0;
}
#tpp-chat-input:focus { border-color: var(--brand); }
#tpp-chat-send {
  flex: 0 0 auto;
  width: 42px; height: 42px; border-radius: 50%;
  border: none; cursor: pointer;
  background: linear-gradient(135deg, var(--brand), var(--brand2));
  display: flex; align-items: center; justify-content: center;
}
#tpp-chat-send svg { width: 18px; height: 18px; fill: #fff; }

@media (max-width: 480px) {
  #tpp-chat-panel {
    right: 12px; left: 12px; bottom: 12px;
    width: auto; max-width: none;
    height: 72vh; max-height: none;
  }
  #tpp-chat-launcher { right: 16px; bottom: 16px; }
  body.tpp-cookie-visible #tpp-chat-launcher { bottom: 96px; }
  body.tpp-cookie-visible #tpp-chat-panel { bottom: 12px; }
}
