/* AVM chatwidget: hergebruikt bestaande designtokens uit main.css (--ink, --green, --paper, --soft, --line). */
.avm-chat-toggle {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(20px + env(safe-area-inset-bottom));
  z-index: 59;
  display: grid;
  place-items: center;
  width: 58px;
  height: 58px;
  border-radius: 50%;
  border: 2px solid var(--green);
  background: var(--ink);
  color: var(--green);
  box-shadow: 0 5px 20px #06121c40;
  cursor: pointer;
  transition: transform .15s, background .15s;
}
.avm-chat-toggle:hover { background: #1d3a49; }
.avm-chat-toggle:focus-visible { outline: 3px solid var(--green); outline-offset: 3px; }
.avm-chat-toggle svg { width: 26px; height: 26px; }
.avm-chat-toggle .avm-chat-icon-close { display: none; }
.avm-chat-toggle[aria-expanded="true"] .avm-chat-icon-open { display: none; }
.avm-chat-toggle[aria-expanded="true"] .avm-chat-icon-close { display: block; }
.avm-chat-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--ink);
}
/* De chatwidget is de primaire floating contactknop op elke pagina waar hij actief is
   (overal behalve /verkoopformulier/, waar de widget bewust niet laadt en de losse
   WhatsApp-knop dus gewoon zichtbaar blijft). WhatsApp blijft binnen de widget bereikbaar
   via de header-knop en de contactkeuzes. */
body.avm-chat-active .floating-whatsapp { display: none !important; }
.avm-chat-header-whatsapp svg { width: 17px; height: 17px; }

.avm-chat-attention {
  position: fixed;
  right: max(20px, env(safe-area-inset-right));
  bottom: calc(86px + env(safe-area-inset-bottom));
  z-index: 58;
  max-width: 240px;
  background: var(--paper);
  color: var(--ink);
  border: 1px solid var(--line);
  border-radius: 14px 14px 4px 14px;
  padding: 14px 16px;
  font-size: .875rem;
  line-height: 1.4;
  box-shadow: 0 8px 24px #142c3924;
}
.avm-chat-attention button {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 22px;
  height: 22px;
  border: 0;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  font-size: .9rem;
  line-height: 1;
}
.avm-chat-attention button:focus-visible { outline: 2px solid #527d22; }

.avm-chat-panel {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(16px + env(safe-area-inset-bottom));
  z-index: 65;
  width: min(392px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 100px));
  max-height: calc(var(--avm-vh, 100vh) - 32px);
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border-radius: 20px;
  overflow: hidden;
  box-shadow: 0 20px 50px #06121c40;
  border: 1px solid var(--line);
}
.avm-chat-panel[hidden] { display: none; }

.avm-chat-header {
  flex: 0 0 auto;
  background: var(--ink);
  color: white;
  padding: 16px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.avm-chat-header-title { display: flex; align-items: center; gap: 10px; min-width: 0; }
.avm-chat-header-title strong { font-size: .9375rem; display: block; }
.avm-chat-header-title span { font-size: .75rem; color: #b7cdd6; display: flex; align-items: center; gap: 5px; }
.avm-chat-status-dot { width: 7px; height: 7px; border-radius: 50%; background: var(--green); flex-shrink: 0; }
.avm-chat-header-actions { display: flex; gap: 4px; flex-shrink: 0; }
.avm-chat-header-actions button {
  width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent; color: white;
  display: grid; place-items: center; cursor: pointer;
}
.avm-chat-header-actions button:hover { background: #ffffff22; }
.avm-chat-header-actions button:focus-visible { outline: 2px solid var(--green); outline-offset: 1px; }
/* WhatsApp-knop krijgt de AVM-groene vulling (--green), net als .button-green elders op de site;
   het icoon gebruikt daarom var(--ink) i.p.v. wit voor voldoende contrast op de lichte groentint. */
.avm-chat-header-actions button.avm-chat-header-whatsapp { background: var(--green); color: var(--ink); }
.avm-chat-header-actions button.avm-chat-header-whatsapp:hover { background: var(--green); filter: brightness(0.92); }
.avm-chat-header-actions button.avm-chat-header-whatsapp:focus-visible { outline: 2px solid var(--ink); outline-offset: 1px; }
.avm-chat-header-actions svg { width: 18px; height: 18px; }

.avm-chat-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  padding: 18px;
  background: var(--soft);
  display: flex;
  flex-direction: column;
  gap: 10px;
  overscroll-behavior: contain;
}
.avm-chat-body > * { flex-shrink: 0; }
.avm-chat-row { display: flex; }
.avm-chat-row.avm-chat-row-user { justify-content: flex-end; }
.avm-chat-bubble {
  max-width: 84%;
  padding: 11px 14px;
  border-radius: 16px;
  font-size: .9rem;
  line-height: 1.45;
  white-space: pre-wrap;
}
.avm-chat-row-bot .avm-chat-bubble { background: var(--paper); color: var(--ink); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.avm-chat-row-user .avm-chat-bubble { background: var(--green); color: var(--ink); border-bottom-right-radius: 4px; font-weight: 600; }
.avm-chat-typing { display: inline-flex; gap: 4px; padding: 4px 2px; }
.avm-chat-typing span { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); opacity: .5; animation: avm-chat-blink 1.1s infinite; }
.avm-chat-typing span:nth-child(2) { animation-delay: .15s; }
.avm-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes avm-chat-blink { 0%, 80%, 100% { opacity: .3; } 40% { opacity: 1; } }

.avm-chat-choices { display: flex; flex-direction: column; gap: 8px; margin-top: 2px; }
.avm-chat-choice-btn {
  display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  padding: 13px 16px; border-radius: 14px; border: 1px solid var(--line); background: var(--paper);
  color: var(--ink); font: inherit; font-size: .9rem; font-weight: 600; cursor: pointer;
}
.avm-chat-choice-btn:hover { border-color: var(--green); background: #f5fbe9; }
.avm-chat-choice-primary { background: var(--green); border-color: var(--green); font-weight: 700; }
.avm-chat-choice-primary:hover { background: #ddf6b5; }
.avm-chat-input-error { font-size: .8rem; color: var(--ink); font-weight: 600; margin: 8px 2px 0; }
.avm-chat-trust { padding: 10px 12px; margin-top: 12px; border-radius: 12px; background: #f5fbe9; font-size: .78rem; line-height: 1.4; }
.avm-chat-trust strong { display: block; margin-bottom: 6px; }
.avm-chat-trust ul { list-style: none; padding: 0; margin: 0 0 8px; }
.avm-chat-trust li { position: relative; padding-left: 18px; margin-bottom: 5px; }
.avm-chat-trust li::before { content: '✓'; position: absolute; left: 0; font-weight: 700; color: #527d22; }
.avm-chat-trust a { font-size: .72rem; }
.avm-chat-sale-summary .avm-chat-body { padding: 12px; }
.avm-chat-sale-summary .avm-chat-summary-list { margin-top: 10px; }
.avm-chat-summary-title { font-size: 1rem; letter-spacing: 0; margin: 0 0 8px; }
.avm-chat-field-label { display: block; font-size: .875rem; font-weight: 700; margin: 0 2px 8px; }
.avm-chat-choice-btn:focus-visible { outline: 3px solid #527d22; outline-offset: 1px; }
.avm-chat-choice-btn .avm-chat-emoji { font-size: 1.15rem; flex-shrink: 0; }

.avm-chat-skip {
  align-self: flex-start;
  border: 0; background: none; color: var(--muted); font-size: .8125rem; text-decoration: underline;
  text-underline-offset: 3px; cursor: pointer; padding: 2px 0;
}
.avm-chat-skip:focus-visible { outline: 2px solid #527d22; }

.avm-chat-footer { flex: 0 0 auto; border-top: 1px solid var(--line); background: var(--paper); padding: 10px 12px; }
.avm-chat-back {
  display: inline-flex; align-items: center; gap: 6px; border: 0; background: none; color: var(--muted);
  font-size: .8125rem; cursor: pointer; padding: 4px 2px; margin-bottom: 6px;
}
.avm-chat-back:hover { color: var(--ink); }
.avm-chat-back:focus-visible { outline: 2px solid #527d22; }
.avm-chat-form-row { display: flex; gap: 8px; align-items: flex-end; }
.avm-chat-form-row textarea,
.avm-chat-form-row input {
  flex: 1 1 auto; min-width: 0; border: 1px solid var(--line); border-radius: 12px; padding: 11px 14px;
  font: inherit; font-size: .9375rem; color: var(--ink); background: var(--paper); resize: none;
}
.avm-chat-form-row textarea { max-height: 90px; }
.avm-chat-form-row input:focus-visible,
.avm-chat-form-row textarea:focus-visible { outline: 3px solid #527d22; outline-offset: 1px; }
.avm-chat-send {
  flex: 0 0 auto; width: 44px; height: 44px; border-radius: 50%; border: 0; background: var(--ink); color: var(--green);
  display: grid; place-items: center; cursor: pointer;
}
.avm-chat-send:hover { background: #1d3a49; }
.avm-chat-send:focus-visible { outline: 3px solid var(--green); outline-offset: 2px; }
.avm-chat-send:disabled { opacity: .4; cursor: not-allowed; }
.avm-chat-send svg { width: 19px; height: 19px; }
.avm-chat-hint { font-size: .75rem; color: var(--muted); margin: 6px 2px 0; }
.avm-chat-privacy { font-size: .7rem; color: var(--muted); margin: 8px 2px 0; line-height: 1.4; }
.avm-chat-privacy a { color: var(--ink); }

.avm-chat-summary-list { border: 1px solid var(--line); border-radius: 12px; background: var(--paper); padding: 12px 14px; margin: 4px 0; }
.avm-chat-summary-list div { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; font-size: .85rem; border-bottom: 1px solid var(--soft); }
.avm-chat-summary-list div:last-child { border-bottom: 0; }
.avm-chat-summary-list dt { color: var(--muted); font-weight: 600; }
.avm-chat-summary-list dd { margin: 0; text-align: right; font-weight: 600; overflow-wrap: anywhere; }

.avm-chat-action-primary {
  width: 100%; padding: 13px 16px; border-radius: 14px; border: 0; background: var(--green); color: var(--ink);
  font: inherit; font-weight: 700; font-size: .9375rem; cursor: pointer;
}
.avm-chat-action-primary:hover { background: #ddf6b5; }
.avm-chat-action-primary:focus-visible { outline: 3px solid #527d22; outline-offset: 2px; }
@media (max-width: 640px) {
  .avm-chat-panel {
    right: max(8px, env(safe-area-inset-right)); left: max(8px, env(safe-area-inset-left));
    bottom: calc(var(--avm-keyboard-bottom, 0px) + 8px + env(safe-area-inset-bottom));
    width: auto; height: auto;
    max-height: min(560px, calc(var(--avm-vh, 100dvh) - 16px - env(safe-area-inset-bottom)));
    border-radius: 20px 20px 16px 16px;
  }
  .avm-chat-header { padding: 10px 12px; }
  .avm-chat-body { flex: 0 1 auto; padding: 12px; -webkit-overflow-scrolling: touch; }
  .avm-chat-footer { min-height: 0; max-height: calc(var(--avm-vh, 100dvh) * .65); overflow-y: auto; overscroll-behavior: contain; padding: 8px 10px; }
  .avm-chat-form-row input, .avm-chat-form-row textarea { font-size: 16px; }
  .avm-chat-field-label { margin-bottom: 5px; }
  .avm-chat-back { margin-bottom: 3px; }
  .avm-chat-choice-btn { padding: 10px 12px; min-height: 44px; }
  .avm-chat-action-primary { min-height: 48px; }
  .avm-chat-attention { right: 12px; max-width: calc(100vw - 24px); bottom: calc(86px + env(safe-area-inset-bottom)); }
}

@media (prefers-reduced-motion: reduce) {
  .avm-chat-toggle, .avm-chat-choice-btn, .avm-chat-send, .avm-chat-action-primary { transition: none !important; }
  .avm-chat-typing span { animation: none !important; opacity: .6; }
}
/* RDW confirmation actions each have a separate, accessible tap target. */
.avm-chat-rdw .avm-chat-footer .avm-chat-skip {
  display: block;
  width: 100%;
  text-align: left;
  margin-top: 8px;
}
