/* ================================================================
   WayToGrow Services — ai-agent.css
   Styles for the floating AI assistant. Mobile-first.

   Every class is namespaced .wtg-ai- so nothing here can collide
   with styles.css. This file does not modify a single existing rule.

   z-index 1200 — above cookie banner (800), sticky CTA (850),
   marquee (890) and nav (900); below the work lightbox (2000).
================================================================ */

.wtg-ai {
  --wa-brand:      #2563EB;
  --wa-brand-dark: #1D4ED8;
  --wa-ink:        #172B4D;
  --wa-muted:      rgba(23, 43, 77, 0.62);
  --wa-faint:      rgba(23, 43, 77, 0.38);
  --wa-line:       rgba(23, 43, 77, 0.12);
  --wa-surface:    #FFFFFF;
  --wa-canvas:     #F6F8FC;
  --wa-r:          16px;
  --wa-gap:        18px;   /* distance from the viewport edges */
  --wa-lift:       0px;    /* raised when other fixed bars appear */

  font-family: 'Jost', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--wa-ink);
  -webkit-font-smoothing: antialiased;
}

.wtg-ai *,
.wtg-ai *::before,
.wtg-ai *::after { box-sizing: border-box; }

/* Raise the launcher clear of the sticky CTA / cookie banner */
.wtg-ai[data-lift="1"] { --wa-lift: 68px; }
.wtg-ai[data-lift="2"] { --wa-lift: 150px; }


/* ============================================================
   LAUNCHER
============================================================ */
.wtg-ai-launcher {
  position: fixed;
  right: var(--wa-gap);
  bottom: calc(var(--wa-gap) + var(--wa-lift) + env(safe-area-inset-bottom, 0px));
  z-index: 1200;
  display: flex;
  align-items: center;
  gap: 10px;
  transition: bottom 0.28s ease, opacity 0.22s ease, transform 0.22s ease;
}

.wtg-ai.is-open .wtg-ai-launcher { pointer-events: none; }

.wtg-ai-fab {
  position: relative;
  width: 58px;
  height: 58px;
  flex: 0 0 58px;
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  color: #fff;
  background: linear-gradient(140deg, #3B82F6 0%, var(--wa-brand) 46%, #1E40AF 100%);
  box-shadow: 0 10px 26px rgba(37, 99, 235, 0.42), 0 2px 8px rgba(15, 30, 61, 0.18);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  -webkit-tap-highlight-color: transparent;
}
.wtg-ai-fab:hover  { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 32px rgba(37, 99, 235, 0.5); }
.wtg-ai-fab:active { transform: translateY(0) scale(0.97); }
.wtg-ai-fab:focus-visible { outline: 3px solid rgba(37, 99, 235, 0.45); outline-offset: 3px; }

.wtg-ai-fab-ico {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.25s ease;
}
.wtg-ai-fab-ico svg { width: 26px; height: 26px; }

.wtg-ai-fab-close { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.wtg-ai.is-open .wtg-ai-fab-chat  { opacity: 0; transform: rotate(90deg) scale(0.6); }
.wtg-ai.is-open .wtg-ai-fab-close { opacity: 1; transform: none; }

/* Live dot */
.wtg-ai-dot {
  position: absolute;
  top: 3px; right: 3px;
  width: 13px; height: 13px;
  border-radius: 50%;
  background: #22C55E;
  border: 2.5px solid #fff;
}
.wtg-ai.is-open .wtg-ai-dot { display: none; }

/* Pulse ring */
.wtg-ai-fab::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(37, 99, 235, 0.5);
  opacity: 0;
  pointer-events: none;
}
.wtg-ai.hint-on .wtg-ai-fab::after { animation: wtgAiPulse 2.4s ease-out infinite; }
@keyframes wtgAiPulse {
  0%   { opacity: 0.7; transform: scale(0.9); }
  70%  { opacity: 0;   transform: scale(1.35); }
  100% { opacity: 0;   transform: scale(1.35); }
}

/* "Ask your queries here" prompt */
.wtg-ai-hint {
  position: relative;
  border: 1px solid var(--wa-line);
  background: var(--wa-surface);
  color: var(--wa-ink);
  font-family: inherit;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  line-height: 1.2;
  padding: 10px 15px;
  border-radius: 100px;
  white-space: nowrap;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(15, 30, 61, 0.14);
  opacity: 0;
  transform: translateX(10px) scale(0.94);
  pointer-events: none;
  transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.4, 0.64, 1);
}
.wtg-ai-hint::after {
  content: '';
  position: absolute;
  right: -5px;
  top: 50%;
  width: 9px; height: 9px;
  background: var(--wa-surface);
  border-right: 1px solid var(--wa-line);
  border-top: 1px solid var(--wa-line);
  transform: translateY(-50%) rotate(45deg);
}
.wtg-ai.hint-on .wtg-ai-hint {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}
.wtg-ai.hint-off .wtg-ai-hint,
.wtg-ai.is-open  .wtg-ai-hint { opacity: 0; pointer-events: none; }


/* ============================================================
   PANEL — full screen on mobile
============================================================ */
.wtg-ai-panel {
  position: fixed;
  inset: 0;
  z-index: 1201;
  background: var(--wa-surface);
  display: flex;
  flex-direction: column;
  opacity: 0;
  visibility: hidden;
  transform: translateY(14px);
  transition: opacity 0.24s ease, transform 0.28s cubic-bezier(0.22, 1, 0.36, 1), visibility 0.24s;
}
.wtg-ai.is-open .wtg-ai-panel {
  opacity: 1;
  visibility: visible;
  transform: none;
}

/* ---- Header ---- */
.wtg-ai-head {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 14px 16px;
  padding-top: calc(14px + env(safe-area-inset-top, 0px));
  color: #fff;
  background: linear-gradient(120deg, #0F1E3D 0%, #1E3A8A 55%, var(--wa-brand) 100%);
}
.wtg-ai-avatar {
  flex: 0 0 38px;
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.15);
  border: 1px solid rgba(255, 255, 255, 0.26);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
}
.wtg-ai-avatar svg { width: 21px; height: 21px; }

.wtg-ai-head-txt { display: flex; flex-direction: column; min-width: 0; }
.wtg-ai-title {
  font-size: 0.94rem;
  font-weight: 700;
  letter-spacing: -0.015em;
  line-height: 1.25;
}
.wtg-ai-status {
  font-size: 0.7rem;
  color: #A7F3D0;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}
.wtg-ai-status i {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #22C55E;
  flex: 0 0 6px;
}

.wtg-ai-min {
  margin-left: auto;
  width: 34px; height: 34px;
  flex: 0 0 34px;
  border: none;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 9px;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease;
}
.wtg-ai-min:hover { background: rgba(255, 255, 255, 0.2); }
.wtg-ai-min svg { width: 17px; height: 17px; }

/* ---- Message area ---- */
.wtg-ai-body {
  flex: 1 1 auto;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  overscroll-behavior: contain;
  background: var(--wa-canvas);
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.wtg-ai-body::-webkit-scrollbar { width: 6px; }
.wtg-ai-body::-webkit-scrollbar-thumb {
  background: rgba(23, 43, 77, 0.18);
  border-radius: 3px;
}

.wtg-ai-msg { display: flex; }
.wtg-ai-msg--bot { justify-content: flex-start; }
.wtg-ai-msg--me  { justify-content: flex-end; }

.wtg-ai-bub {
  max-width: 85%;
  font-size: 0.875rem;
  line-height: 1.6;
  padding: 11px 14px;
  border-radius: 15px;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  animation: wtgAiIn 0.26s ease both;
}
@keyframes wtgAiIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: none; }
}

.wtg-ai-msg--bot .wtg-ai-bub {
  background: var(--wa-surface);
  border: 1px solid var(--wa-line);
  border-bottom-left-radius: 5px;
  color: var(--wa-ink);
  box-shadow: 0 1px 2px rgba(15, 30, 61, 0.04);
}
.wtg-ai-msg--me .wtg-ai-bub {
  background: var(--wa-brand);
  border-bottom-right-radius: 5px;
  color: #fff;
}
.wtg-ai-bub strong { font-weight: 700; }

.wtg-ai-link {
  color: var(--wa-brand);
  font-weight: 600;
  text-decoration: underline;
  text-underline-offset: 2px;
}
.wtg-ai-link:hover { color: var(--wa-brand-dark); }

/* ---- Typing indicator ---- */
.wtg-ai-typing .wtg-ai-bub {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 14px 15px;
}
.wtg-ai-typing .wtg-ai-bub span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--wa-faint);
  animation: wtgAiBlink 1.3s infinite ease-in-out;
}
.wtg-ai-typing .wtg-ai-bub span:nth-child(2) { animation-delay: 0.18s; }
.wtg-ai-typing .wtg-ai-bub span:nth-child(3) { animation-delay: 0.36s; }
@keyframes wtgAiBlink {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30%           { opacity: 1;    transform: translateY(-3px); }
}

/* ---- Suggested follow-ups ---- */
.wtg-ai-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding-left: 2px;
  animation: wtgAiIn 0.3s ease both;
}
.wtg-ai-chip {
  font-family: inherit;
  font-size: 0.775rem;
  font-weight: 600;
  line-height: 1.2;
  color: var(--wa-brand);
  background: rgba(37, 99, 235, 0.07);
  border: 1px solid rgba(37, 99, 235, 0.24);
  border-radius: 100px;
  padding: 8px 13px;
  cursor: pointer;
  transition: background 0.16s ease, transform 0.12s ease;
  -webkit-tap-highlight-color: transparent;
}
.wtg-ai-chip:hover  { background: rgba(37, 99, 235, 0.14); }
.wtg-ai-chip:active { transform: scale(0.96); }

/* ---- Inline lead capture ---- */
.wtg-ai-lead {
  background: var(--wa-surface);
  border: 1px solid rgba(37, 99, 235, 0.28);
  border-radius: 14px;
  padding: 15px 15px 13px;
  animation: wtgAiIn 0.3s ease both;
  box-shadow: 0 4px 18px rgba(37, 99, 235, 0.08);
}
.wtg-ai-lead-l {
  display: block;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--wa-faint);
  margin-bottom: 5px;
}
.wtg-ai-lead-i {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  color: var(--wa-ink);
  background: #fff;
  border: 1.5px solid var(--wa-line);
  border-radius: 9px;
  padding: 11px 12px;
  margin-bottom: 12px;
  outline: none;
  transition: border-color 0.18s ease, box-shadow 0.18s ease;
}
.wtg-ai-lead-i:focus {
  border-color: var(--wa-brand);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.13);
}
.wtg-ai-lead-i::placeholder { color: var(--wa-faint); }

.wtg-ai-lead-err {
  display: none;
  font-size: 0.78rem;
  font-weight: 600;
  color: #DC2626;
  margin: -6px 0 10px;
}
.wtg-ai-lead-err.is-on { display: block; }

.wtg-ai-lead-btn {
  width: 100%;
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 700;
  color: #fff;
  background: var(--wa-brand);
  border: none;
  border-radius: 9px;
  padding: 12px;
  cursor: pointer;
  transition: background 0.18s ease, transform 0.12s ease;
}
.wtg-ai-lead-btn:hover:not(:disabled)  { background: var(--wa-brand-dark); }
.wtg-ai-lead-btn:active:not(:disabled) { transform: scale(0.985); }
.wtg-ai-lead-btn:disabled { opacity: 0.6; cursor: not-allowed; }

.wtg-ai-lead-note {
  font-size: 0.72rem;
  color: var(--wa-faint);
  text-align: center;
  margin: 9px 0 0;
  line-height: 1.4;
}

/* ---- Composer ---- */
.wtg-ai-foot {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 11px 12px 8px;
  background: var(--wa-surface);
  border-top: 1px solid var(--wa-line);
}
.wtg-ai-input {
  flex: 1 1 auto;
  min-width: 0;
  font-family: inherit;
  font-size: 16px;          /* 16px stops iOS zooming on focus */
  color: var(--wa-ink);
  background: #F1F4F9;
  border: 1px solid var(--wa-line);
  border-radius: 100px;
  padding: 11px 16px;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease;
}
.wtg-ai-input:focus { border-color: var(--wa-brand); background: #fff; }
.wtg-ai-input::placeholder { color: var(--wa-faint); }

.wtg-ai-send {
  flex: 0 0 42px;
  width: 42px; height: 42px;
  border: none;
  border-radius: 50%;
  background: var(--wa-brand);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.18s ease, transform 0.12s ease;
}
.wtg-ai-send:hover  { background: var(--wa-brand-dark); }
.wtg-ai-send:active { transform: scale(0.93); }
.wtg-ai-send svg { width: 17px; height: 17px; }

.wtg-ai-disc {
  flex: 0 0 auto;
  margin: 0;
  padding: 0 14px 10px;
  padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  background: var(--wa-surface);
  font-size: 0.68rem;
  color: var(--wa-faint);
  text-align: center;
  line-height: 1.4;
}


/* ============================================================
   DESKTOP / TABLET — dock the panel instead of full screen
============================================================ */
@media (min-width: 641px) {
  .wtg-ai-panel {
    inset: auto;
    right: var(--wa-gap);
    bottom: calc(var(--wa-gap) + 74px);
    width: 380px;
    height: min(620px, calc(100vh - 140px));
    border-radius: var(--wa-r);
    border: 1px solid var(--wa-line);
    overflow: hidden;
    box-shadow: 0 24px 60px rgba(15, 30, 61, 0.22), 0 4px 14px rgba(15, 30, 61, 0.1);
    transform: translateY(16px) scale(0.98);
    transform-origin: bottom right;
  }
  .wtg-ai.is-open .wtg-ai-panel { transform: none; }

  .wtg-ai-head    { padding-top: 14px; }
  .wtg-ai-disc    { padding-bottom: 10px; }
  .wtg-ai-bub     { max-width: 88%; }
  .wtg-ai.is-open .wtg-ai-launcher { pointer-events: auto; }
}

/* Short viewports — keep the composer reachable */
@media (min-width: 641px) and (max-height: 620px) {
  .wtg-ai-panel { height: calc(100vh - 120px); }
}


/* ============================================================
   ACCESSIBILITY / MOTION
============================================================ */
@media (prefers-reduced-motion: reduce) {
  .wtg-ai *,
  .wtg-ai *::before,
  .wtg-ai *::after {
    animation-duration: 0.001ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.001ms !important;
  }
  .wtg-ai-fab::after { display: none; }
}

.wtg-ai button:focus-visible,
.wtg-ai input:focus-visible,
.wtg-ai a:focus-visible {
  outline: 3px solid rgba(37, 99, 235, 0.45);
  outline-offset: 2px;
}

/* Never print the widget */
@media print { .wtg-ai { display: none !important; } }
