/*
 * Grawlix Chat — widget styles
 * Colors inherit the active template theme via CSS custom properties
 * (--accent, --accent-2, --panel, --ink, --paper, --line, --muted) with
 * safe fallbacks so the widget also works dropped onto any page.
 */
.gx-chat {
  --gx-accent: var(--accent, var(--hi, var(--arc, #2563eb)));
  --gx-accent-2: var(--accent-2, var(--hi-deep, var(--arc-deep, #60a5fa)));
  /* The panel uses a deliberately self-contained light surface. Inheriting a dark template's
     white --ink token while falling back to a white panel made the entire conversation vanish. */
  --gx-surface: #f8fafc;
  --gx-ink: #Example827;
  --gx-text: #Example827;
  --gx-muted: #475569;
  --gx-line: rgba(15, 23, 42, 0.16);
  --gx-on-accent: #fff;
  /* Typography follows the host page for the same reason colour does: this widget is injected
     into client templates and should not impose a face of its own. Hardcoding one made it
     clash, since these templates set their own body font. A template can override this. */
  --gx-font: inherit;
  --gx-radius: 16px;
  --gx-gap: 20px;
  /* Desktop has no sticky CTA, so sit close to the corner. The mobile query below raises
     this to clear the sticky call bar; a large offset here just floated the panel mid-page. */
  --gx-bottom: calc(env(safe-area-inset-bottom, 0px) + 24px);

  position: fixed;
  right: var(--gx-gap);
  bottom: var(--gx-bottom);
  z-index: 40;
  font-family: var(--gx-font);
  line-height: 1.45;
}

/* ---- Launcher (collapsed state) ---- */
.gx-chat__launcher {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-direction: row-reverse;
}
.gx-chat[data-floating-call="true"] { --gx-bottom: calc(env(safe-area-inset-bottom, 0px) + 96px); }
.gx-chat__button {
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  flex: 0 0 auto;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  color: var(--gx-on-accent);
  background: linear-gradient(135deg, var(--gx-accent), var(--gx-accent-2));
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.28);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.gx-chat__button:hover { transform: translateY(-2px); box-shadow: 0 14px 32px rgba(0, 0, 0, 0.34); }
.gx-chat__button:focus-visible { outline: 3px solid var(--gx-accent-2); outline-offset: 2px; }
.gx-chat__button svg { width: 26px; height: 26px; }

/* Subtle text teaser next to the icon on load. Never blocks the screen. */
.gx-chat__teaser {
  max-width: 200px;
  padding: 9px 13px;
  border-radius: 12px 12px 2px 12px;
  background: var(--gx-surface);
  color: var(--gx-text);
  border: 1px solid var(--gx-line);
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.16);
  font-size: 0.82rem;
  font-weight: 600;
  cursor: pointer;
  animation: gx-rise 0.35s ease both;
}
.gx-chat__teaser-close {
  margin-left: 6px;
  color: var(--gx-muted);
  font-weight: 800;
  opacity: 0.7;
}
.gx-chat__teaser-close:hover { opacity: 1; }

/* ---- Panel (expanded state) ---- */
.gx-chat__panel {
  position: absolute;
  right: 0;
  bottom: 70px;
  width: min(360px, calc(100vw - 2 * var(--gx-gap)));
  max-height: min(560px, calc(100vh - var(--gx-bottom) - 90px));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border-radius: var(--gx-radius);
  background: var(--gx-surface);
  color: var(--gx-text);
  border: 1px solid var(--gx-line);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.32);
  animation: gx-rise 0.22s ease both;
}
.gx-chat__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  color: var(--gx-on-accent);
  background: linear-gradient(135deg, var(--gx-accent), var(--gx-accent-2));
}
.gx-chat__avatar {
  display: grid; place-items: center;
  width: 34px; height: 34px; flex: 0 0 auto;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.22);
  font-weight: 900;
}
.gx-chat__title { font-size: 0.92rem; font-weight: 800; }
.gx-chat__subtitle { font-size: 0.72rem; opacity: 0.85; }
.gx-chat__close {
  margin-left: auto;
  display: grid; place-items: center;
  width: 30px; height: 30px;
  border: none; border-radius: 8px;
  color: var(--gx-on-accent);
  background: rgba(255, 255, 255, 0.12);
  cursor: pointer;
  font-size: 1.1rem;
}
.gx-chat__close:hover { background: rgba(255, 255, 255, 0.24); }

.gx-chat__log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: color-mix(in srgb, var(--gx-surface) 88%, var(--gx-ink) 12%);
}
.gx-chat__msg {
  max-width: 82%;
  padding: 9px 12px;
  border-radius: 14px;
  font-size: 0.86rem;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: gx-rise 0.2s ease both;
}
.gx-chat__msg--bot {
  align-self: flex-start;
  background: var(--gx-surface);
  border: 1px solid var(--gx-line);
  border-bottom-left-radius: 4px;
}
.gx-chat__msg--user {
  align-self: flex-end;
  color: var(--gx-on-accent);
  background: var(--gx-accent);
  border-bottom-right-radius: 4px;
}
.gx-chat__typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.gx-chat__typing i {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--gx-muted);
  animation: gx-blink 1.2s infinite both;
}
.gx-chat__typing i:nth-child(2) { animation-delay: 0.2s; }
.gx-chat__typing i:nth-child(3) { animation-delay: 0.4s; }

.gx-chat__quick {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 0 16px 10px;
  background: color-mix(in srgb, var(--gx-surface) 88%, var(--gx-ink) 12%);
}
.gx-chat__chip {
  padding: 7px 12px;
  border-radius: 999px;
  border: 1px solid var(--gx-accent);
  background: transparent;
  color: var(--gx-accent);
  font-size: 0.78rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 0.15s ease, color 0.15s ease;
}
.gx-chat__chip:hover { background: var(--gx-accent); color: var(--gx-on-accent); }

.gx-chat__form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--gx-line);
  background: var(--gx-surface);
}
.gx-chat__input {
  flex: 1 1 auto;
  min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--gx-line);
  border-radius: 10px;
  background: color-mix(in srgb, var(--gx-surface) 92%, var(--gx-ink) 8%);
  color: var(--gx-text);
  font: inherit;
  font-size: 0.86rem;
}
.gx-chat__input:focus { outline: 2px solid var(--gx-accent); outline-offset: -1px; }
.gx-chat__send {
  display: grid; place-items: center;
  width: 42px; flex: 0 0 auto;
  border: none; border-radius: 10px;
  color: var(--gx-on-accent);
  background: var(--gx-accent);
  cursor: pointer;
}
.gx-chat__send:disabled { opacity: 0.5; cursor: default; }
.gx-chat__send svg { width: 18px; height: 18px; }

.gx-chat__badge {
  padding: 8px 16px 12px;
  font-size: 0.72rem;
  color: var(--gx-muted);
  text-align: center;
  background: color-mix(in srgb, var(--gx-surface) 88%, var(--gx-ink) 12%);
}

.gx-chat[hidden] { display: none; }
.gx-chat.gx-chat--open .gx-chat__launcher { display: none; }
.gx-chat:not(.gx-chat--open) .gx-chat__panel { display: none; }

@keyframes gx-rise { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
@keyframes gx-blink { 0%, 100% { opacity: 0.25; } 50% { opacity: 1; } }

/* Mobile: keep it tucked; the panel is a bounded card, never a full-screen block. */
@media (max-width: 760px) {
  /* Raised here so the launcher clears the template's sticky mobile call bar. */
  .gx-chat { --gx-gap: 12px; --gx-bottom: calc(env(safe-area-inset-bottom, 0px) + 84px); }
  .gx-chat[data-floating-call="true"] { --gx-bottom: calc(env(safe-area-inset-bottom, 0px) + 142px); }
  .gx-chat__teaser { max-width: 160px; }
  .gx-chat__panel { width: calc(100vw - 2 * var(--gx-gap)); max-height: min(70vh, 520px); }
}
@media (prefers-reduced-motion: reduce) {
  .gx-chat *, .gx-chat { animation: none !important; transition: none !important; }
}

/* Northline Arbor &amp; Tree Co. theme: the page gold against its near-black panels. */
.gx-chat {
  --gx-accent: var(--gold, #d9a521);
  --gx-accent-2: var(--gold-2, #f6dc8f);
  --gx-on-accent: var(--ink, #0a0908);
  --gx-font: var(--sans, system-ui, sans-serif);
}
