/* Site chat assistant. Scoped under .lgs-chat; relies on no other stylesheet. */
.lgs-chat {
  --chat-ink: #0f172a;
  --chat-muted: #475569;
  --chat-line: #cbd5e1;
  --chat-surface: #ffffff;
  --chat-subtle: #f1f5f9;
  --chat-navy: #080f1a;
  --chat-brand: #155bd5;
  --chat-brand-hover: #114aae;
  --chat-focus: #1d72fe;
  --chat-danger: #b91c1c;
  --chat-radius: 6px;
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  z-index: 900;
  font-family: Inter, system-ui, -apple-system, 'Segoe UI', sans-serif;
  font-size: 0.9375rem;
  line-height: 1.5;
  color: var(--chat-ink);
}

.lgs-chat *,
.lgs-chat *::before,
.lgs-chat *::after { box-sizing: border-box; }

.lgs-chat [hidden] { display: none !important; }

.lgs-chat__sr {
  position: absolute;
  width: 1px;
  height: 1px;
  margin: -1px;
  padding: 0;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
  border: 0;
}

/* Launcher */
.lgs-chat__launcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  padding: 0;
  border: 1px solid var(--chat-navy);
  border-radius: var(--chat-radius);
  background: var(--chat-navy);
  color: #ffffff;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(8, 15, 26, 0.25);
  transition: transform 160ms cubic-bezier(0.34, 1.4, 0.64, 1), background-color 120ms;
}
.lgs-chat__launcher:hover { background: #1e293b; }
.lgs-chat__launcher:active { transform: scale(0.97); }
.lgs-chat.is-open .lgs-chat__launcher { display: none; }

/* Panel */
.lgs-chat__panel {
  position: absolute;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 2rem));
  height: min(600px, calc(100dvh - 2rem));
  background: var(--chat-surface);
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  box-shadow: 0 16px 48px rgba(8, 15, 26, 0.22);
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 180ms ease, transform 260ms cubic-bezier(0.34, 1.3, 0.64, 1);
}
.lgs-chat.is-open .lgs-chat__panel { opacity: 1; transform: none; }

.lgs-chat__header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.625rem 0.75rem 0.625rem 1rem;
  background: var(--chat-navy);
  color: #ffffff;
}
.lgs-chat__title { flex: 1; margin: 0; font-size: 1rem; font-weight: 700; color: #ffffff; letter-spacing: 0; }
.lgs-chat__icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  margin: -0.25rem 0;
  border: 0;
  border-radius: var(--chat-radius);
  background: transparent;
  color: #ffffff;
  cursor: pointer;
}
.lgs-chat__icon-btn:hover { background: rgba(255, 255, 255, 0.14); }

.lgs-chat__view,
.lgs-chat__demo { display: flex; flex: 1; flex-direction: column; min-height: 0; }
.lgs-chat__demo { overflow-y: auto; padding: 1rem; }

/* Messages */
.lgs-chat__log {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.lgs-chat__msg { display: flex; flex-direction: column; gap: 0.5rem; max-width: 94%; }
.lgs-chat__msg--user { align-self: flex-end; align-items: flex-end; }
.lgs-chat__msg--assistant { align-self: flex-start; align-items: flex-start; }
.lgs-chat__bubble {
  padding: 0.625rem 0.875rem;
  border-radius: var(--chat-radius);
  overflow-wrap: anywhere;
}
.lgs-chat__p { margin: 0; }
.lgs-chat__p + .lgs-chat__p,
.lgs-chat__p + .lgs-chat__list,
.lgs-chat__list + .lgs-chat__p { margin-top: 0.5rem; }
.lgs-chat__list { margin: 0; padding-left: 1.125rem; display: flex; flex-direction: column; gap: 0.25rem; }
.lgs-chat__msg--assistant .lgs-chat__bubble { background: var(--chat-subtle); color: var(--chat-ink); }
.lgs-chat__msg--user .lgs-chat__bubble { background: var(--chat-brand); color: #ffffff; }

.lgs-chat__actions { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.lgs-chat__link {
  display: inline-flex;
  align-items: center;
  min-height: 36px;
  padding: 0.25rem 0.75rem;
  border: 1px solid var(--chat-line);
  border-radius: var(--chat-radius);
  color: var(--chat-brand);
  font-weight: 600;
  text-decoration: none;
  background: #ffffff;
}
.lgs-chat__link:hover { border-color: var(--chat-brand); background: #f8fafc; }

/* Skeleton loader */
.lgs-chat__skeleton {
  width: 70%;
  gap: 0.5rem;
  padding: 0.75rem 0.875rem;
  background: var(--chat-subtle);
  border-radius: var(--chat-radius);
}
.lgs-chat__bar {
  display: block;
  height: 0.75rem;
  width: 100%;
  border-radius: 3px;
  background: linear-gradient(90deg, #dbe2ea 25%, #eef2f6 50%, #dbe2ea 75%);
  background-size: 200% 100%;
  animation: lgs-chat-shimmer 1.4s linear infinite;
}
.lgs-chat__bar--long { width: 100%; }
.lgs-chat__bar--short { width: 55%; }
@keyframes lgs-chat-shimmer { from { background-position: 200% 0; } to { background-position: -200% 0; } }

/* Suggestions and buttons */
.lgs-chat__suggestions { display: flex; flex-wrap: wrap; gap: 0.5rem; padding: 0 1rem 0.75rem; }
.lgs-chat__btn {
  min-height: 40px;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--chat-line);
  border-radius: var(--chat-radius);
  background: #ffffff;
  color: var(--chat-ink);
  font: inherit;
  font-weight: 600;
  text-align: left;
  cursor: pointer;
  transition: transform 140ms cubic-bezier(0.34, 1.4, 0.64, 1), background-color 120ms;
}
.lgs-chat__btn:hover { background: #f8fafc; border-color: #94a3b8; }
.lgs-chat__btn:active { transform: scale(0.97); }
.lgs-chat__btn:disabled { opacity: 0.6; cursor: not-allowed; }
.lgs-chat__btn--primary { background: var(--chat-brand); border-color: var(--chat-brand); color: #ffffff; }
.lgs-chat__btn--primary:hover { background: var(--chat-brand-hover); border-color: var(--chat-brand-hover); }
.lgs-chat__btn--block { width: 100%; text-align: center; min-height: 44px; }

/* Composer and form controls */
.lgs-chat__composer { padding: 0.75rem 1rem 1rem; border-top: 1px solid var(--chat-line); }
.lgs-chat__composer-row { display: flex; align-items: center; justify-content: space-between; gap: 0.75rem; margin-top: 0.5rem; }
.lgs-chat__count { font-size: 0.8125rem; color: var(--chat-muted); }
.lgs-chat__send { min-width: 88px; text-align: center; }
.lgs-chat__control {
  display: block;
  width: 100%;
  padding: 0.5rem 0.625rem;
  border: 1px solid #94a3b8;
  border-radius: var(--chat-radius);
  background: #ffffff;
  color: var(--chat-ink);
  font: inherit;
  resize: vertical;
}
.lgs-chat__input { resize: none; }
.lgs-chat__control[aria-invalid='true'] { border-color: var(--chat-danger); }

.lgs-chat__form { display: flex; flex-direction: column; gap: 0.75rem; }
.lgs-chat__form-title { margin: 0; font-size: 1.125rem; font-weight: 700; color: var(--chat-ink); }
.lgs-chat__form-note { margin: 0; color: var(--chat-muted); }
.lgs-chat__field { display: flex; flex-direction: column; gap: 0.25rem; }
.lgs-chat__label { font-weight: 600; }
.lgs-chat__error { min-height: 0; color: var(--chat-danger); font-size: 0.875rem; font-weight: 600; }
.lgs-chat__error:empty { display: none; }
.lgs-chat__trap { position: absolute; left: -9999px; width: 1px; height: 1px; overflow: hidden; }
.lgs-chat__done { display: flex; flex-direction: column; align-items: flex-start; gap: 0.75rem; outline: none; }

/* Focus */
.lgs-chat button:focus-visible,
.lgs-chat a:focus-visible,
.lgs-chat textarea:focus-visible,
.lgs-chat input:focus-visible,
.lgs-chat__log:focus-visible,
.lgs-chat__done:focus-visible {
  outline: 3px solid var(--chat-focus);
  outline-offset: 2px;
}
.lgs-chat__header button:focus-visible { outline-color: #ffffff; }

@media (max-width: 480px) {
  .lgs-chat { right: 0.5rem; bottom: 0.5rem; }
  .lgs-chat__panel { width: calc(100vw - 1rem); height: min(600px, calc(100dvh - 1rem)); }
}

@media (prefers-reduced-motion: reduce) {
  .lgs-chat__panel,
  .lgs-chat__launcher,
  .lgs-chat__btn { transition: none; }
  .lgs-chat__bar { animation: none; }
}

@media print { .lgs-chat { display: none; } }
