/* Ask-the-course FAQ widget — floating avatar + chat panel.
   Seeds its answers from the page's own FAQPage JSON-LD, no backend. */

.faqw-launcher {
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 950;
  width: 76px;
  height: 76px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  padding: 0;
  background: transparent;
  box-shadow: none;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: faqw-float 3.2s ease-in-out infinite;
  transition: transform 160ms ease;
}
.faqw-launcher:hover { transform: scale(1.06); }
.faqw-launcher:active { transform: scale(0.96); }
.faqw-launcher img,
.faqw-launcher .faqw-fallback-icon {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 8px 14px rgba(2, 6, 23, 0.35));
}
.faqw-launcher .faqw-fallback-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--brand-blue, #1e3a8a);
  font-size: 2.2rem;
  background: transparent;
}
.faqw-launcher .faqw-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: #22c55e;
  border: 2px solid #fff;
}

@keyframes faqw-float {
  0%, 100% { transform: translateY(0); }
  50% { transform: translateY(-6px); }
}
.faqw-launcher.is-talking img,
.faqw-launcher.is-talking .faqw-fallback-icon {
  animation: faqw-pulse 0.9s ease-in-out infinite;
}
@keyframes faqw-pulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.08); }
}

.faqw-panel {
  position: fixed;
  right: 20px;
  bottom: 96px;
  z-index: 951;
  width: min(360px, calc(100vw - 32px));
  max-height: min(520px, calc(100vh - 140px));
  background: var(--surface, #fff);
  border-radius: var(--radius-lg, 24px);
  border: 1px solid var(--line, rgba(148,163,184,0.34));
  box-shadow: var(--shadow-lg, 0 24px 40px rgba(2,6,23,0.12));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 180ms ease, transform 180ms ease;
}
.faqw-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.faqw-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--brand-navy, #0f172a), var(--brand-blue, #1e3a8a));
  color: #fff;
}
.faqw-header img, .faqw-header .faqw-fallback-icon {
  width: 42px; height: 42px; border-radius: 50%; object-fit: contain; flex-shrink: 0;
  display: flex; align-items: center; justify-content: center; font-size: 1.1rem;
  background: transparent;
}
.faqw-header-text { flex: 1; min-width: 0; }
.faqw-header-text strong { display: block; font-size: 0.88rem; }
.faqw-header-text span { display: block; font-size: 0.72rem; opacity: 0.78; }
.faqw-close {
  background: rgba(255,255,255,0.14);
  border: none;
  color: #fff;
  width: 28px; height: 28px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.9rem;
  flex-shrink: 0;
}
.faqw-close:hover { background: rgba(255,255,255,0.24); }

.faqw-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--surface-soft, #f8fbff);
}
.faqw-msg {
  max-width: 88%;
  font-size: 0.84rem;
  line-height: 1.5;
  padding: 10px 13px;
  border-radius: 14px;
}
.faqw-msg.from-bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--line-light, rgba(148,163,184,0.24));
  color: var(--ink-muted, #334155);
  border-bottom-left-radius: 4px;
}
.faqw-msg.from-user {
  align-self: flex-end;
  background: var(--brand-blue, #1e3a8a);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.faqw-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-top: 2px;
}
.faqw-suggestion-btn {
  text-align: left;
  font-size: 0.78rem;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--line, rgba(148,163,184,0.34));
  background: #fff;
  color: var(--brand-blue, #1e3a8a);
  cursor: pointer;
  transition: background 120ms ease, border-color 120ms ease;
}
.faqw-suggestion-btn:hover { background: var(--surface-soft, #f8fbff); border-color: var(--brand-blue, #1e3a8a); }

.faqw-inputrow {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--line-light, rgba(148,163,184,0.24));
  background: #fff;
}
.faqw-input {
  flex: 1;
  font-size: 0.85rem;
  padding: 10px 12px;
  border-radius: 10px;
  border: 1px solid var(--line, rgba(148,163,184,0.34));
  outline: none;
  font-family: inherit;
}
.faqw-input:focus { border-color: var(--brand-blue, #1e3a8a); }
.faqw-send {
  width: 38px; height: 38px;
  border-radius: 10px;
  border: none;
  background: var(--brand-blue, #1e3a8a);
  color: #fff;
  cursor: pointer;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}
.faqw-send:hover { background: var(--brand-gold, #a16207); }
.faqw-send:disabled { opacity: 0.5; cursor: default; }

.faqw-fineprint {
  font-size: 0.65rem;
  color: var(--ink-soft, #475569);
  text-align: center;
  padding: 0 12px 10px;
  background: #fff;
}

@media (max-width: 480px) {
  .faqw-launcher { right: 14px; bottom: 14px; width: 56px; height: 56px; }
  .faqw-panel { right: 12px; left: 12px; width: auto; bottom: 82px; }
}
