/* ==========================================================================
   Fitness Black Belt — chatbot.css
   Floating chat widget. Self-contained: this file plus js/chatbot.js are the
   only two things the widget needs. Remove both <link>/<script> tags from a
   page and the widget disappears cleanly.
   Depends on the design tokens declared in base.css, which loads first.
   ========================================================================== */

.fbb-chat {
  position: fixed;
  right: clamp(1rem, 3vw, 1.75rem);
  bottom: clamp(1rem, 3vw, 1.75rem);
  z-index: 950;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: .9rem;
  font-family: var(--font-body);
  /* The closed panel is only visibility:hidden, so this container still
     measures ~384×630px. Without this it silently swallows every click in
     the bottom-right of the viewport — footer links included. Children
     switch pointer events back on individually. */
  pointer-events: none;
}
/* Clear the mobile conversion bar, which occupies the same corner below 1024px */
@media (max-width: 1023px) { .fbb-chat { bottom: 5.5rem; } }

/* The nav drawer owns the screen while it is open */
body.nav-open .fbb-chat { opacity: 0; pointer-events: none; }

/* --------------------------------------------------------------------------
   Launcher
   -------------------------------------------------------------------------- */
.fbb-chat__launcher {
  position: relative;
  pointer-events: auto;
  display: grid;
  place-items: center;
  width: 60px;
  height: 60px;
  padding: 0;
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  color: #FFFFFF;
  background:
    radial-gradient(130% 130% at 30% 20%, #A855F7 0%, var(--brand-500) 45%, var(--brand) 100%);
  box-shadow:
    0 0 0 1px rgba(196,181,253,.28),
    0 18px 40px -12px rgba(91,33,182,.95),
    0 0 46px -8px rgba(139,92,246,.75);
  transition:
    transform var(--dur) var(--ease-spring),
    box-shadow var(--dur) var(--ease-out);
}
.fbb-chat__launcher:hover { transform: translateY(-3px) scale(1.05); }
.fbb-chat__launcher:active { transform: scale(.95); }
.fbb-chat__launcher:focus-visible { outline: 2px solid var(--brand-200); outline-offset: 4px; }

.fbb-chat__launcher svg { width: 26px; height: 26px; }

/* Chat glyph and close glyph cross-fade in place */
.fbb-chat__icon {
  grid-area: 1 / 1;
  display: grid;
  place-items: center;
  transition: opacity 240ms var(--ease-out), rotate 320ms var(--ease-out);
}
.fbb-chat__icon--close { opacity: 0; rotate: -90deg; }
.fbb-chat.is-open .fbb-chat__icon--chat  { opacity: 0; rotate: 90deg; }
.fbb-chat.is-open .fbb-chat__icon--close { opacity: 1; rotate: 0deg; }

/* Halo that pulses until the widget has been opened once */
.fbb-chat__launcher::after {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: 50%;
  border: 2px solid rgba(167,139,250,.6);
  opacity: 0;
  pointer-events: none;
}
.fbb-chat:not(.is-seen) .fbb-chat__launcher::after { animation: fbb-ping 2.8s var(--ease-out) infinite; }
@keyframes fbb-ping {
  0%   { transform: scale(1);    opacity: .75; }
  70%  { transform: scale(1.65); opacity: 0; }
  100% { transform: scale(1.65); opacity: 0; }
}

.fbb-chat__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  display: grid;
  place-items: center;
  border-radius: var(--r-pill);
  font-family: var(--font-mono);
  font-size: 10px;
  font-weight: 600;
  color: #1A0B2E;
  background: var(--gold);
  box-shadow: 0 0 0 2px var(--bg);
}

/* --------------------------------------------------------------------------
   Panel
   -------------------------------------------------------------------------- */
.fbb-chat__panel {
  display: flex;
  flex-direction: column;
  width: min(384px, calc(100vw - 2rem));
  height: min(560px, calc(100vh - 9rem));
  overflow: hidden;
  border-radius: var(--r-lg);
  background: linear-gradient(180deg, var(--surface) 0%, var(--bg-2) 100%);
  border: 1px solid var(--line-strong);
  box-shadow: 0 40px 90px -30px rgba(0,0,0,.95), 0 0 0 1px rgba(139,92,246,.12);
  transform-origin: bottom right;
  opacity: 0;
  transform: translateY(14px) scale(.96);
  pointer-events: none;
  transition:
    opacity 260ms var(--ease-out),
    transform 320ms var(--ease-out),
    visibility 0s linear 320ms;
  visibility: hidden;
}
.fbb-chat.is-open .fbb-chat__panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
  visibility: visible;
  transition-delay: 0s;
}
@media (max-width: 480px) {
  .fbb-chat__panel { height: min(70vh, calc(100vh - 11rem)); }
}

/* --- Header --- */
.fbb-chat__head {
  display: flex;
  align-items: center;
  gap: .8rem;
  flex: none;
  padding: 1rem 1.1rem;
  background:
    radial-gradient(120% 160% at 0% 0%, rgba(124,58,237,.45), transparent 62%),
    linear-gradient(180deg, rgba(255,255,255,.05), transparent);
  border-bottom: 1px solid var(--line);
}
.fbb-chat__avatar {
  flex: none;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  overflow: hidden;
  border: 1px solid rgba(139,92,246,.4);
  background: #000000;
}
.fbb-chat__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  mix-blend-mode: screen;   /* drops the black box out of logo-2.jpg */
  filter: contrast(1.15);
}
.fbb-chat__id { flex: 1; min-width: 0; }
.fbb-chat__id strong {
  display: block;
  font-family: var(--font-display);
  font-size: var(--fs-sm);
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--text);
}
.fbb-chat__id span {
  display: flex;
  align-items: center;
  gap: .4rem;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .05em;
  color: var(--muted);
}
.fbb-chat__status {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px rgba(52,211,153,.9);
}

.fbb-chat__close {
  flex: none;
  display: grid;
  place-items: center;
  width: 32px;
  height: 32px;
  padding: 0;
  color: var(--muted);
  background: transparent;
  border: 1px solid transparent;
  border-radius: 50%;
  cursor: pointer;
  transition: color var(--dur), background var(--dur), border-color var(--dur);
}
.fbb-chat__close svg { width: 16px; height: 16px; }
.fbb-chat__close:hover { color: #FFFFFF; background: rgba(255,255,255,.06); border-color: var(--line-strong); }

/* --- Message log --- */
.fbb-chat__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  display: flex;
  flex-direction: column;
  gap: .7rem;
  padding: 1.1rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(139,92,246,.4) transparent;
}
.fbb-chat__log::-webkit-scrollbar { width: 6px; }
.fbb-chat__log::-webkit-scrollbar-thumb { background: rgba(139,92,246,.35); border-radius: 99px; }

.fbb-msg {
  max-width: 84%;
  padding: .7rem .9rem;
  font-size: var(--fs-sm);
  line-height: 1.6;
  border-radius: 16px;
  animation: fbb-pop 380ms var(--ease-out) backwards;
  overflow-wrap: anywhere;
}
@keyframes fbb-pop {
  from { opacity: 0; transform: translateY(8px); }
}
.fbb-msg--bot {
  align-self: flex-start;
  color: var(--text-soft);
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
}
.fbb-msg--user {
  align-self: flex-end;
  color: #FFFFFF;
  background: linear-gradient(150deg, var(--brand-500), var(--brand));
  border-bottom-right-radius: 5px;
  box-shadow: 0 8px 20px -10px rgba(91,33,182,.9);
}
.fbb-msg--error {
  align-self: flex-start;
  color: var(--warn);
  background: rgba(251,191,36,.08);
  border: 1px solid rgba(251,191,36,.25);
  border-bottom-left-radius: 5px;
}
.fbb-msg a { color: var(--brand-200); text-decoration: underline; text-underline-offset: 2px; }
.fbb-msg--user a { color: #FFFFFF; }

/* Typing indicator */
.fbb-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: .85rem .9rem;
  background: rgba(255,255,255,.045);
  border: 1px solid var(--line);
  border-radius: 16px;
  border-bottom-left-radius: 5px;
}
.fbb-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--brand-300);
  animation: fbb-blink 1.3s var(--ease-in-out) infinite;
}
.fbb-typing i:nth-child(2) { animation-delay: .18s; }
.fbb-typing i:nth-child(3) { animation-delay: .36s; }
@keyframes fbb-blink {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* --- Quick replies --- */
.fbb-chat__quick {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: 0 1.1rem .9rem;
}
.fbb-chat__quick:empty { display: none; }
.fbb-chat__quick button {
  padding: .42rem .75rem;
  font-family: var(--font-mono);
  font-size: 10px;
  letter-spacing: .04em;
  color: var(--brand-200);
  background: rgba(139,92,246,.1);
  border: 1px solid rgba(139,92,246,.26);
  border-radius: var(--r-pill);
  cursor: pointer;
  transition: background var(--dur), border-color var(--dur), color var(--dur);
}
.fbb-chat__quick button:hover {
  color: #FFFFFF;
  background: rgba(124,58,237,.28);
  border-color: rgba(139,92,246,.55);
}

/* --- Composer --- */
.fbb-chat__bar {
  flex: none;
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .8rem;
  border-top: 1px solid var(--line);
  background: rgba(255,255,255,.02);
}
.fbb-chat__bar input {
  flex: 1;
  min-width: 0;
  padding: .75rem .95rem;
  font-family: inherit;
  font-size: var(--fs-sm);
  color: var(--text);
  background: rgba(255,255,255,.04);
  border: 1px solid var(--line-strong);
  border-radius: var(--r-pill);
  transition: border-color var(--dur), background var(--dur);
}
.fbb-chat__bar input::placeholder { color: var(--dim); }
.fbb-chat__bar input:focus {
  outline: none;
  border-color: rgba(139,92,246,.6);
  background: rgba(139,92,246,.07);
}

.fbb-chat__send {
  flex: none;
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  padding: 0;
  color: #FFFFFF;
  background: var(--grad-brand);
  border: 0;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 10px 24px -10px rgba(91,33,182,.95);
  transition: transform var(--dur) var(--ease-spring), opacity var(--dur);
}
.fbb-chat__send svg { width: 17px; height: 17px; }
.fbb-chat__send:hover:not(:disabled) { transform: scale(1.07); }
.fbb-chat__send:disabled { opacity: .4; cursor: not-allowed; }

.fbb-chat__legal {
  flex: none;
  padding: 0 1.1rem .8rem;
  font-size: 10px;
  line-height: 1.5;
  color: var(--dim);
  text-align: center;
}

@media (prefers-reduced-motion: reduce) {
  .fbb-chat__launcher::after,
  .fbb-typing i { animation: none; }
  .fbb-msg { animation: none; }
  .fbb-chat__panel { transition: opacity 160ms linear, visibility 0s linear 160ms; transform: none; }
  .fbb-chat.is-open .fbb-chat__panel { transform: none; }
}
