/* Website chat assistant widget. Uses the site's design tokens from main.css. */
.cw-launcher {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--cw-offset, 0px));
  z-index: 55;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  height: 3.25rem;
  padding: 0 1.25rem 0 1rem;
  border: 0;
  border-radius: 999px;
  background: var(--primary);
  color: #fff;
  font: inherit;
  font-size: 0.9375rem;
  font-weight: 500;
  box-shadow: 0 8px 24px rgb(16 32 31 / 0.25);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease, bottom 0.25s ease, opacity 0.2s ease;
}
.cw-launcher:hover { transform: translateY(-2px); box-shadow: 0 12px 28px rgb(16 32 31 / 0.3); }
.cw-launcher:focus-visible { outline: 3px solid var(--ring); outline-offset: 3px; }
.cw-launcher svg { width: 1.375rem; height: 1.375rem; flex-shrink: 0; }
.cw-launcher[aria-expanded="true"] { opacity: 0; pointer-events: none; transform: scale(0.9); }
html.menu-open .cw-launcher, html.menu-open .cw-panel { display: none; }

.cw-panel {
  position: fixed;
  right: 20px;
  bottom: calc(20px + var(--cw-offset, 0px));
  z-index: 56;
  width: min(390px, calc(100vw - 40px));
  height: min(620px, calc(100dvh - 40px - var(--cw-offset, 0px)));
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--border);
  border-radius: calc(var(--radius) * 2);
  background: var(--card);
  color: var(--card-foreground);
  box-shadow: 0 24px 60px rgb(16 32 31 / 0.28);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, transform 0.2s cubic-bezier(0.22, 1, 0.36, 1), bottom 0.25s ease;
}
.cw-panel[hidden] { display: none; }
.cw-panel.cw-entering { opacity: 0; transform: translateY(12px) scale(0.97); }

.cw-head {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 0.75rem 0.875rem 1rem;
  background: var(--foreground);
  color: #fff;
}
.cw-avatar {
  width: 2.25rem; height: 2.25rem; flex-shrink: 0;
  display: grid; place-items: center;
  border-radius: 999px;
  background: rgb(255 255 255 / 0.12);
}
.cw-avatar svg { width: 1.25rem; height: 1.25rem; color: var(--btn-bg, #e8b94a); }
.cw-title { flex: 1; min-width: 0; line-height: 1.25; }
.cw-title strong { display: block; font-size: 0.9375rem; font-weight: 600; }
.cw-title span { font-size: 0.75rem; color: rgb(255 255 255 / 0.7); }
.cw-icon-btn {
  display: inline-grid; place-items: center;
  width: 2rem; height: 2rem;
  border: 0; border-radius: var(--radius);
  background: transparent; color: rgb(255 255 255 / 0.85);
  cursor: pointer;
}
.cw-icon-btn:hover { background: rgb(255 255 255 / 0.12); color: #fff; }
.cw-icon-btn:focus-visible { outline: 2px solid var(--btn-bg, #fff); outline-offset: 1px; }
.cw-icon-btn svg { width: 1.125rem; height: 1.125rem; }

.cw-log {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  background: var(--surface, var(--background));
  font-size: 0.875rem;
  line-height: 1.55;
}
.cw-msg { max-width: 86%; padding: 0.625rem 0.875rem; border-radius: 1rem; overflow-wrap: anywhere; }
.cw-msg p { margin: 0; }
.cw-msg p + p, .cw-msg p + ul, .cw-msg ul + p { margin-top: 0.5rem; }
.cw-msg ul { margin: 0.25rem 0 0; padding-inline-start: 1.1rem; list-style: disc; }
.cw-msg a { color: var(--primary); text-decoration: underline; text-underline-offset: 2px; }
.cw-bot { align-self: flex-start; background: var(--card); color: var(--card-foreground); border: 1px solid var(--border); border-end-start-radius: 0.25rem; }
.cw-user { align-self: flex-end; background: var(--primary); color: #fff; border-end-end-radius: 0.25rem; white-space: pre-wrap; }
.cw-error { align-self: flex-start; color: var(--destructive); font-size: 0.8125rem; }
.cw-error button { margin-inline-start: 0.25rem; border: 0; background: none; color: var(--primary); text-decoration: underline; cursor: pointer; font: inherit; }

.cw-chips { display: flex; flex-wrap: wrap; gap: 0.5rem; }
.cw-chip {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--foreground);
  padding: 0.375rem 0.75rem;
  font: inherit;
  font-size: 0.8125rem;
  cursor: pointer;
  text-align: start;
}
.cw-chip:hover { border-color: var(--primary); color: var(--primary); }
.cw-chip:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

.cw-feedback {
  align-self: flex-start;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 0.375rem;
  margin-top: -0.25rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}
.cw-feedback span { margin-inline-end: 0.25rem; }
.cw-feedback button {
  border: 1px solid var(--border);
  border-radius: 999px;
  background: var(--card);
  color: var(--foreground);
  padding: 0.125rem 0.75rem;
  font: inherit;
  cursor: pointer;
}
.cw-feedback button:hover { border-color: var(--primary); color: var(--primary); }
.cw-feedback button:focus-visible { outline: 2px solid var(--ring); outline-offset: 1px; }

.cw-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 0.875rem 1rem; }
.cw-typing i { width: 6px; height: 6px; border-radius: 50%; background: var(--muted-foreground); animation: cw-bounce 1.2s infinite ease-in-out; }
.cw-typing i:nth-child(2) { animation-delay: 0.15s; }
.cw-typing i:nth-child(3) { animation-delay: 0.3s; }
@keyframes cw-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-4px); opacity: 1; } }

/* Lead form card inside the conversation */
.cw-lead {
  align-self: stretch;
  border: 1px solid var(--border);
  border-radius: 0.875rem;
  background: var(--card);
  padding: 0.875rem;
}
.cw-lead h3 { margin: 0 0 0.125rem; font-size: 0.875rem; font-weight: 600; color: var(--foreground); }
.cw-lead > p { margin: 0 0 0.75rem; font-size: 0.8125rem; color: var(--muted-foreground); }
.cw-field { display: flex; flex-direction: column; gap: 0.25rem; margin-bottom: 0.625rem; }
.cw-field label { font-size: 0.75rem; font-weight: 500; color: var(--foreground); }
.cw-field input, .cw-field textarea {
  width: 100%;
  border: 1px solid var(--input);
  border-radius: calc(var(--radius) - 2px);
  background: var(--background);
  color: var(--foreground);
  padding: 0.5rem 0.625rem;
  font: inherit;
  font-size: 0.875rem;
}
.cw-field textarea { resize: vertical; min-height: 4.5rem; }
.cw-field input:focus-visible, .cw-field textarea:focus-visible, .cw-input:focus-visible {
  outline: none; border-color: var(--ring); box-shadow: 0 0 0 3px color-mix(in oklab, var(--ring) 25%, transparent);
}
.cw-field [aria-invalid="true"] { border-color: var(--destructive); }
.cw-field-error { font-size: 0.75rem; color: var(--destructive); }
.cw-consent { display: flex; gap: 0.5rem; align-items: flex-start; font-size: 0.75rem; color: var(--muted-foreground); margin-bottom: 0.75rem; }
.cw-consent input { margin-top: 0.15rem; accent-color: var(--primary); width: 0.9rem; height: 0.9rem; flex-shrink: 0; }
.cw-hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }
.cw-btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 0.5rem;
  min-height: 2.25rem; padding: 0 1rem;
  border: 0; border-radius: calc(var(--radius) - 2px);
  background: var(--btn-bg, var(--primary)); color: var(--btn-fg, #fff);
  font: inherit; font-size: 0.875rem; font-weight: 500;
  cursor: pointer;
}
.cw-btn:hover { background: var(--btn-hover-bg, var(--btn-bg)); filter: brightness(0.97); }
.cw-btn:disabled { opacity: 0.6; cursor: default; }
.cw-btn:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }

.cw-compose { border-top: 1px solid var(--border); background: var(--card); padding: 0.625rem 0.75rem 0.5rem; }
.cw-row { display: flex; align-items: flex-end; gap: 0.5rem; }
.cw-input {
  flex: 1;
  max-height: 7.5rem;
  min-height: 2.5rem;
  resize: none;
  border: 1px solid var(--input);
  border-radius: 1.25rem;
  background: var(--background);
  color: var(--foreground);
  padding: 0.55rem 0.875rem;
  font: inherit;
  font-size: 0.875rem;
  line-height: 1.4;
}
.cw-send {
  width: 2.5rem; height: 2.5rem; flex-shrink: 0;
  display: grid; place-items: center;
  border: 0; border-radius: 999px;
  background: var(--primary); color: #fff;
  cursor: pointer;
}
.cw-send:disabled { opacity: 0.45; cursor: default; }
.cw-send:focus-visible { outline: 3px solid var(--ring); outline-offset: 2px; }
.cw-send svg { width: 1.125rem; height: 1.125rem; }
.cw-note { margin: 0.375rem 0.25rem 0; font-size: 0.6875rem; color: var(--muted-foreground); }
.cw-note a { color: inherit; text-decoration: underline; }
.cw-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

@media (max-width: 639px) {
  .cw-launcher { right: 16px; bottom: calc(16px + var(--cw-offset, 0px)); padding: 0; width: 3.25rem; justify-content: center; }
  .cw-launcher .cw-label { display: none; }
  .cw-panel { inset: 0; width: 100%; height: 100dvh; border-radius: 0; border: 0; }
  .cw-input { font-size: 1rem; } /* stops iOS zooming into the field */
}
@media (prefers-reduced-motion: reduce) {
  .cw-launcher, .cw-panel { transition: none; }
  .cw-typing i { animation: none; opacity: 0.7; }
}
