/* Quote assistant chat widget. Tokens come from design-system.css. */

.floating-contact__brand--chat {
  background: transparent;
  box-shadow: none;
}

.floating-contact__brand--chat .floating-contact__icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-linejoin: round;
  stroke-width: 1.8;
}

.floating-contact__link--chat[aria-expanded="true"]::before {
  opacity: 0;
  transform: translateX(6px);
}

.quote-chat {
  position: fixed;
  right: 84px;
  bottom: 24px;
  z-index: 70;
  display: flex;
  flex-direction: column;
  width: min(380px, calc(100vw - 108px));
  max-height: min(580px, calc(100vh - 48px));
  border: 1px solid var(--line);
  border-radius: var(--radius-md);
  background: var(--panel);
  color: var(--ink);
  font-family: var(--font-sans);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.quote-chat[hidden] {
  display: none;
}

.quote-chat__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: var(--space-3);
  padding: var(--space-4) var(--space-4) var(--space-3);
  border-bottom: 1px solid var(--line);
  border-top: 3px solid var(--moss);
}

.quote-chat__title {
  margin: 0;
  font-size: 1rem;
  font-weight: 600;
  line-height: 1.35;
}

.quote-chat__subtitle {
  margin: 2px 0 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.45;
}

.quote-chat__close {
  display: grid;
  place-items: center;
  flex: none;
  width: 36px;
  height: 36px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 0;
  background: transparent;
  color: var(--ink);
  cursor: pointer;
}

.quote-chat__close:hover,
.quote-chat__close:focus-visible {
  border-color: var(--moss);
}

.quote-chat__close svg {
  width: 18px;
  height: 18px;
  stroke: currentColor;
  stroke-linecap: round;
  stroke-width: 1.8;
}

.quote-chat__log {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  gap: var(--space-3);
  min-height: 180px;
  padding: var(--space-4);
  overflow-y: auto;
  background: var(--paper);
}

.quote-chat__bubble {
  max-width: 88%;
  margin: 0;
  border-radius: var(--radius-md);
  padding: 10px 12px;
  font-size: 0.9375rem;
  line-height: 1.55;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.quote-chat__bubble--assistant {
  align-self: flex-start;
  border: 1px solid var(--line);
  background: var(--panel);
}

.quote-chat__bubble--user {
  align-self: flex-end;
  background: var(--moss-dark);
  color: var(--color-white);
}

.quote-chat__bubble--pending {
  color: var(--muted);
}

.quote-chat__notice {
  align-self: center;
  margin: 0;
  color: var(--muted);
  font-size: 0.8125rem;
  line-height: 1.45;
  text-align: center;
}

.quote-chat__sources,
.quote-chat__mode {
  margin: 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.quote-chat__draft {
  display: grid;
  gap: var(--space-2);
  border: 1px solid var(--moss);
  border-radius: var(--radius-md);
  padding: var(--space-3);
  background: var(--panel);
}

.quote-chat__draft-title {
  font-size: 0.8125rem;
  font-weight: 600;
}

.quote-chat__draft-list {
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px var(--space-3);
  margin: 0;
  font-size: 0.875rem;
  line-height: 1.45;
}

.quote-chat__draft-list dt {
  color: var(--muted);
}

.quote-chat__draft-list dd {
  margin: 0;
  overflow-wrap: anywhere;
}

.quote-chat__use {
  width: 100%;
}

.quote-chat__privacy {
  margin: 0;
  padding: var(--space-2) var(--space-4) 0;
  color: var(--muted);
  font-size: 0.75rem;
  line-height: 1.45;
}

.quote-chat__form {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4) var(--space-4);
}

.quote-chat__input {
  flex: 1 1 auto;
  min-height: 48px;
  max-height: 120px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  background: var(--color-white);
  color: var(--ink);
  font: inherit;
  font-size: 0.9375rem;
  line-height: 1.45;
  resize: vertical;
}

.quote-chat__input:focus-visible {
  border-color: var(--moss);
  outline: 2px solid var(--color-focus);
  outline-offset: 1px;
}

.quote-chat__send {
  flex: none;
  min-height: 48px;
}

.quote-chat__turnstile:empty {
  display: none;
}

.quote-chat__turnstile {
  padding: 0 var(--space-4) var(--space-4);
}

@media (max-width: 720px) {
  .quote-chat {
    right: 12px;
    bottom: max(12px, env(safe-area-inset-bottom));
    left: 12px;
    width: auto;
    max-height: calc(100dvh - 24px);
  }

  /* Let the log shrink so the input stays visible with the keyboard open. */
  .quote-chat__log {
    min-height: 0;
  }

  body.quote-chat-open .floating-contact {
    visibility: hidden;
  }
}

/* The mobile launcher lives in the header; hide it while chat is open. */
@media (max-width: 720px) {
  body.quote-chat-open .site-header .floating-contact { visibility: hidden; }
}
