/* =========================================================================
   Swap Assistant — floating help widget + guided tour.
   Self-contained plain CSS (the compiled Tailwind build only includes classes
   found in templates, so this widget ships its own styles). Theme matches the
   site: slate-900 surface, amber-400 accent.
   ========================================================================= */

:root {
  --sa-amber: #fbbf24;
  --sa-amber-dark: #f59e0b;
  --sa-ink: #0f172a;      /* slate-900 */
  --sa-ink-soft: #1e293b; /* slate-800 */
  --sa-line: #e2e8f0;     /* slate-200 */
  --sa-muted: #64748b;    /* slate-500 */
}

/* ---- Launcher button --------------------------------------------------- */
.sa-launcher {
  position: fixed;
  right: 18px;
  bottom: 18px;
  z-index: 2147483000;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 16px;
  border: none;
  border-radius: 9999px;
  background: var(--sa-amber);
  color: var(--sa-ink);
  font: 600 14px/1 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 10px 25px rgba(15, 23, 42, 0.35);
  cursor: grab;
  touch-action: none; /* let pointer drag work on touch without scrolling */
  transition: background 0.15s ease, box-shadow 0.15s ease;
}
.sa-launcher:active { cursor: grabbing; }
.sa-launcher:hover { background: var(--sa-amber-dark); }
.sa-launcher:focus-visible { outline: 3px solid #1d4ed8; outline-offset: 2px; }
.sa-launcher__icon { font-size: 18px; line-height: 1; }
.sa-launcher.is-hidden { display: none; }

@media (max-width: 640px) {
  .sa-launcher__label { display: none; }
  .sa-launcher { padding: 14px; }
}

/* ---- Panel ------------------------------------------------------------- */
.sa-panel {
  position: fixed;
  right: 18px;
  bottom: 84px;
  z-index: 2147483000;
  width: min(380px, calc(100vw - 32px));
  height: min(520px, calc(100vh - 120px));
  display: flex;
  flex-direction: column;
  background: #fff;
  border: 1px solid var(--sa-line);
  border-radius: 16px;
  box-shadow: 0 24px 60px rgba(15, 23, 42, 0.35);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
}
.sa-panel.is-open { opacity: 1; transform: translateY(0) scale(1); pointer-events: auto; }

@media (max-width: 480px) {
  .sa-panel {
    right: 0; left: 0; bottom: 0;
    width: 100%;
    height: 82vh;
    border-radius: 16px 16px 0 0;
  }
}

.sa-panel__head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  background: var(--sa-ink);
  color: #fff;
  flex-shrink: 0;
}
.sa-panel__avatar {
  width: 34px; height: 34px;
  border-radius: 9999px;
  background: var(--sa-amber);
  color: var(--sa-ink);
  display: grid; place-items: center;
  font-size: 18px;
  flex-shrink: 0;
}
.sa-panel__titles { line-height: 1.2; min-width: 0; }
.sa-panel__title { font-weight: 700; font-size: 15px; }
.sa-panel__status { font-size: 11px; color: #cbd5e1; }
.sa-panel__status .sa-dot {
  display: inline-block; width: 7px; height: 7px; border-radius: 9999px;
  background: #22c55e; margin-right: 4px; vertical-align: middle;
}
.sa-panel__status.is-off .sa-dot { background: #94a3b8; }
.sa-panel__close {
  margin-left: auto;
  background: transparent; border: none; color: #cbd5e1;
  font-size: 22px; line-height: 1; cursor: pointer; padding: 4px 8px;
  border-radius: 8px;
}
.sa-panel__close:hover { background: rgba(255,255,255,0.12); color: #fff; }

/* ---- Messages area ----------------------------------------------------- */
.sa-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 14px;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sa-msg {
  max-width: 85%;
  padding: 9px 12px;
  border-radius: 14px;
  font: 400 14px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  white-space: pre-wrap;
  word-wrap: break-word;
  flex-shrink: 0;
}
.sa-msg--bot {
  align-self: flex-start;
  background: #fff;
  border: 1px solid var(--sa-line);
  color: #1e293b;
  border-bottom-left-radius: 4px;
}
.sa-msg--user {
  align-self: flex-end;
  background: var(--sa-ink);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.sa-msg a { color: var(--sa-amber-dark); font-weight: 600; text-decoration: underline; }
.sa-msg--user a { color: var(--sa-amber); }

/* typing indicator */
.sa-typing { display: inline-flex; gap: 4px; align-items: center; }
.sa-typing span {
  width: 6px; height: 6px; border-radius: 9999px; background: #94a3b8;
  animation: sa-bounce 1s infinite ease-in-out;
}
.sa-typing span:nth-child(2) { animation-delay: 0.15s; }
.sa-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes sa-bounce { 0%, 80%, 100% { transform: translateY(0); opacity: 0.5; } 40% { transform: translateY(-4px); opacity: 1; } }

/* ---- Suggested question list (pinned; never shrinks with chat) ---------- */
.sa-suggests {
  flex: 0 0 auto;
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: min(200px, 32vh);
  overflow-y: auto;
  padding: 10px 12px;
  border-bottom: 1px solid var(--sa-line);
  background: #fff;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
}
.sa-suggests:empty { display: none; }
.sa-chip {
  display: block;
  width: 100%;
  box-sizing: border-box;
  text-align: left;
  background: #fff;
  border: 1px solid #fcd34d;
  color: #92400e;
  padding: 10px 12px;
  border-radius: 10px;
  font: 600 13px/1.3 system-ui, sans-serif;
  cursor: pointer;
  transition: background 0.12s ease, border-color 0.12s ease;
  flex-shrink: 0;
}
.sa-chip:hover { background: #fffbeb; }
.sa-chip:focus-visible {
  outline: 2px solid var(--sa-amber-dark);
  outline-offset: 2px;
}
.sa-chip--tour {
  border-color: var(--sa-ink);
  color: var(--sa-ink);
  background: #f1f5f9;
  font-weight: 700;
}
.sa-chip--tour:hover { background: #e2e8f0; }

/* ---- Footer / input ---------------------------------------------------- */
.sa-foot {
  flex-shrink: 0;
  border-top: 1px solid var(--sa-line);
  padding: 10px;
  background: #fff;
}
.sa-inputrow { display: flex; gap: 8px; align-items: flex-end; }
.sa-input {
  flex: 1;
  resize: none;
  max-height: 96px;
  border: 1px solid var(--sa-line);
  border-radius: 12px;
  padding: 9px 11px;
  font: 400 14px/1.4 system-ui, sans-serif;
  color: #1e293b;
}
.sa-input:focus { outline: 2px solid var(--sa-amber-dark); border-color: transparent; }
.sa-send {
  flex-shrink: 0;
  width: 40px; height: 40px;
  border: none; border-radius: 12px;
  background: var(--sa-amber); color: var(--sa-ink);
  font-size: 18px; cursor: pointer;
  display: grid; place-items: center;
}
.sa-send:hover { background: var(--sa-amber-dark); }
.sa-send:disabled { opacity: 0.5; cursor: not-allowed; }
.sa-foot__note { margin: 6px 2px 0; font-size: 11px; color: var(--sa-muted); text-align: center; }

/* =========================================================================
   Guided tour
   ========================================================================= */
/* A near-transparent, click-blocking scrim. We deliberately avoid a dark
   full-screen cutout so we never fight the stacking context of the mobile
   slide-out menu (which uses a transform and traps child z-index). */
.sa-tour-backdrop {
  position: fixed; inset: 0;
  z-index: 2147483200;
  background: rgba(15, 23, 42, 0.12);
  opacity: 0; pointer-events: none;
  transition: opacity 0.2s ease;
}
.sa-tour-backdrop.is-on { opacity: 1; pointer-events: auto; }

/* Bright highlight ring drawn around the current target using its viewport
   rect (position: fixed), so it works whether the target is in the desktop
   nav or the mobile menu overlay. */
.sa-tour-ring {
  position: fixed;
  z-index: 2147483250;
  border-radius: 12px;
  box-shadow: 0 0 0 3px var(--sa-amber), 0 0 0 6px rgba(251, 191, 36, 0.4), 0 0 22px 6px rgba(251, 191, 36, 0.55);
  pointer-events: none;
  transition: top 0.25s ease, left 0.25s ease, width 0.25s ease, height 0.25s ease;
}
.sa-tour-ring.is-center { opacity: 0; }

.sa-tour-pop {
  position: fixed;
  z-index: 2147483300;
  width: min(300px, calc(100vw - 24px));
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 18px 45px rgba(15, 23, 42, 0.4);
  padding: 14px 15px;
  transition: top 0.25s ease, left 0.25s ease;
}
.sa-tour-pop__step { font-size: 11px; font-weight: 700; letter-spacing: 0.05em; text-transform: uppercase; color: var(--sa-amber-dark); }
.sa-tour-pop__title { font-weight: 700; font-size: 15px; margin: 3px 0 5px; color: var(--sa-ink); }
.sa-tour-pop__body { font-size: 13.5px; line-height: 1.45; color: #475569; }
.sa-tour-pop__actions { display: flex; align-items: center; gap: 8px; margin-top: 12px; }
.sa-tour-pop__spacer { flex: 1; }
.sa-tour-btn {
  border: none; border-radius: 9px; padding: 7px 12px;
  font: 600 13px/1 system-ui, sans-serif; cursor: pointer;
}
.sa-tour-btn--primary { background: var(--sa-amber); color: var(--sa-ink); }
.sa-tour-btn--primary:hover { background: var(--sa-amber-dark); }
.sa-tour-btn--ghost { background: transparent; color: var(--sa-muted); }
.sa-tour-btn--ghost:hover { color: var(--sa-ink); }
.sa-tour-skip {
  background: transparent; border: none; color: var(--sa-muted);
  font-size: 12px; cursor: pointer; text-decoration: underline;
}

@media (prefers-reduced-motion: reduce) {
  .sa-panel, .sa-tour-ring, .sa-tour-pop, .sa-tour-backdrop, .sa-launcher { transition: none; }
  .sa-typing span { animation: none; }
}
