/* ── Effectual AI chat widget ─────────────────────────────────────── */

#ef-chat-launcher {
  position: fixed; right: 24px; bottom: 24px; z-index: 9998;
  width: 60px; height: 60px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand-purple-deep, #3D1B69);
  color: #fff; display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(75, 31, 139, .4);
  transition: transform .2s ease, background .2s ease, box-shadow .2s ease;
}
#ef-chat-launcher:hover { transform: scale(1.08); background: var(--brand-purple, #8B5CF6); }
#ef-chat-launcher svg { width: 28px; height: 28px; }
#ef-chat-launcher .ef-chat-close-icon { display: none; }
#ef-chat-launcher.is-open .ef-chat-open-icon { display: none; }
#ef-chat-launcher.is-open .ef-chat-close-icon { display: block; }

#ef-chat-panel {
  position: fixed; right: 24px; bottom: 96px; z-index: 9999;
  width: 380px; max-width: calc(100vw - 32px);
  height: 560px; max-height: calc(100vh - 130px);
  display: flex; flex-direction: column;
  background: #fff; border: 1px solid rgba(139, 92, 246, .18);
  border-radius: 20px; overflow: hidden;
  box-shadow: 0 24px 64px rgba(20, 10, 50, .28);
  opacity: 0; visibility: hidden; transform: translateY(16px) scale(.97);
  transform-origin: bottom right;
  transition: opacity .25s ease, transform .25s ease, visibility 0s linear .25s;
}
#ef-chat-panel.is-open {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .25s ease, transform .25s ease, visibility 0s;
}

.ef-chat-header {
  padding: 18px 20px;
  background: linear-gradient(135deg, #1A0B3A 0%, #3D1B69 60%, #8B5CF6 130%);
  color: #fff; flex-shrink: 0;
}
.ef-chat-header h3 { margin: 0; font-size: 16px; font-weight: 700; color: #fff; }
.ef-chat-header p { margin: 3px 0 0; font-size: 12px; color: rgba(255, 255, 255, .75); }
.ef-chat-header .ef-chat-dot {
  display: inline-block; width: 8px; height: 8px; border-radius: 50%;
  background: #4ADE80; margin-right: 6px; vertical-align: 1px;
  animation: ef-chat-pulse 2s ease-out infinite;
}
@keyframes ef-chat-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(74, 222, 128, .65); }
  70%  { box-shadow: 0 0 0 7px rgba(74, 222, 128, 0); }
  100% { box-shadow: 0 0 0 0 rgba(74, 222, 128, 0); }
}

.ef-chat-messages {
  flex: 1; overflow-y: auto; padding: 18px 16px;
  display: flex; flex-direction: column; gap: 10px;
  background: #FAF9FE;
}
.ef-chat-msg {
  max-width: 84%; padding: 10px 14px; border-radius: 16px;
  font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-wrap: break-word;
}
.ef-chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #8B5CF6 0%, #D946EF 100%);
  color: #fff; border-bottom-right-radius: 5px;
}
.ef-chat-msg.bot {
  align-self: flex-start;
  background: #fff; color: #1f1f2e;
  border: 1px solid rgba(139, 92, 246, .15);
  border-bottom-left-radius: 5px;
}
.ef-chat-msg.error { background: #FEF2F2; border-color: #FECACA; color: #991B1B; }

.ef-chat-msg.bot a { color: var(--brand-purple, #8B5CF6); font-weight: 600; text-decoration: underline; }
.ef-chat-sources {
  margin-top: 9px; padding-top: 7px;
  border-top: 1px solid rgba(139, 92, 246, .18);
  font-size: 11.5px; color: #6B6485; white-space: pre-wrap;
}
.ef-chat-sources a { font-weight: 500; }

.ef-chat-chips { display: flex; flex-wrap: wrap; gap: 8px; padding: 2px 0; }
.ef-chat-chip {
  border: 1.5px solid rgba(139, 92, 246, .4); background: #fff;
  color: #5B21B6; border-radius: 999px; padding: 7px 13px;
  font: inherit; font-size: 12.5px; cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.ef-chat-chip:hover { background: var(--brand-purple, #8B5CF6); border-color: transparent; color: #fff; }

.ef-chat-typing { align-self: flex-start; padding: 14px 16px; display: flex; gap: 5px; }
.ef-chat-typing span {
  width: 7px; height: 7px; border-radius: 50%; background: #8B5CF6; opacity: .4;
  animation: ef-chat-blink 1.2s infinite;
}
.ef-chat-typing span:nth-child(2) { animation-delay: .2s; }
.ef-chat-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes ef-chat-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.ef-chat-input {
  flex-shrink: 0; display: flex; align-items: flex-end; gap: 8px;
  padding: 12px; background: #fff; border-top: 1px solid rgba(139, 92, 246, .12);
}
.ef-chat-input textarea {
  flex: 1; resize: none; border: 1.5px solid #E5E1F2; border-radius: 14px;
  padding: 10px 14px; font: inherit; font-size: 14px; line-height: 1.4;
  max-height: 110px; outline: none; background: #FAF9FE;
}
.ef-chat-input textarea:focus { border-color: #8B5CF6; }
.ef-chat-input button {
  width: 40px; height: 40px; border-radius: 50%; border: 0; cursor: pointer;
  background: var(--brand-purple-deep, #3D1B69);
  color: #fff; display: grid; place-items: center; flex-shrink: 0;
  transition: transform .15s ease, background .15s ease, opacity .15s;
}
.ef-chat-input button:hover { transform: scale(1.08); background: var(--brand-purple, #8B5CF6); }
.ef-chat-input button:disabled { opacity: .45; cursor: default; transform: none; }

.ef-chat-foot {
  flex-shrink: 0; text-align: center; font-size: 10px; color: #9A93B5;
  padding: 0 0 8px; background: #fff;
}

/* The chat launcher occupies the bottom-right corner — lift the theme's
   back-to-top button so it stacks above the bubble instead of under it. */
.back-to-top { bottom: 100px; right: 30px; }

@media (max-width: 480px) {
  #ef-chat-panel { right: 16px; bottom: 86px; height: 70vh; }
  #ef-chat-launcher { right: 16px; bottom: 16px; }
  .back-to-top { bottom: 92px; right: 25px; }
}
@media (prefers-reduced-motion: reduce) {
  #ef-chat-launcher, #ef-chat-panel, .ef-chat-input button { transition: none; }
  .ef-chat-header .ef-chat-dot { animation: none; }
}

/* ── Chat launcher nudge — small callout above the bubble ─────────── */
#ef-chat-nudge {
  position: fixed; right: 24px; bottom: 96px; z-index: 9997;
  width: 264px; max-width: calc(100vw - 48px);
  background: #fff; color: #1f1f2e;
  border: 1px solid rgba(139, 92, 246, .18);
  border-radius: 16px;
  box-shadow: 0 16px 40px rgba(20, 10, 50, .22);
  padding: 16px 30px 16px 16px;
  font-size: 13.5px; line-height: 1.5; cursor: pointer;
  opacity: 0; visibility: hidden; transform: translateY(10px) scale(.97);
  transform-origin: bottom right;
  transition: opacity .3s ease, transform .3s ease, visibility 0s linear .3s;
}
#ef-chat-nudge.is-visible {
  opacity: 1; visibility: visible; transform: none;
  transition: opacity .3s ease, transform .3s ease, visibility 0s;
}
#ef-chat-nudge p { margin: 0; }
#ef-chat-nudge::after {
  content: ''; position: absolute; bottom: -7px; right: 26px;
  width: 14px; height: 14px; background: #fff;
  border-right: 1px solid rgba(139, 92, 246, .18);
  border-bottom: 1px solid rgba(139, 92, 246, .18);
  transform: rotate(45deg);
}
#ef-chat-nudge-close {
  position: absolute; top: 8px; right: 8px;
  width: 22px; height: 22px; border-radius: 50%; border: 0; cursor: pointer;
  background: rgba(139, 92, 246, .08); color: #6B6485;
  display: grid; place-items: center;
  transition: background .15s ease, color .15s ease;
}
#ef-chat-nudge-close:hover { background: rgba(139, 92, 246, .18); color: #1f1f2e; }

@media (max-width: 480px) {
  #ef-chat-nudge { right: 16px; bottom: 86px; }
}
@media (prefers-reduced-motion: reduce) {
  #ef-chat-nudge { transition: none; }
}
