/* ==========================================================================
   AI2GO - website-chatbot (widget)
   Alle klassen zijn genamespaced met .ai2c- zodat er niets op de bestaande
   pagina's geraakt wordt. Kleuren staan hard in dit bestand (huisstijl), zodat
   de widget er op elke pagina identiek uitziet, los van de CSS-variabelen
   die per pagina gedefinieerd zijn.

   z-index: 900 voor knop en paneel.
     - header (sticky) = 10
     - dropdownmenu    = 200
     - .ig-overlay (interesse-modal) = 1000  -> modal blijft boven de chat
     - cookiebanner    = 99999               -> banner blijft boven de chat
   ========================================================================== */

.ai2c-wrap {
  --ai2c-blauw: #1e5a7d;
  --ai2c-groen: #4fb06d;
  --ai2c-verloop: linear-gradient(135deg, #1e5a7d, #4fb06d);
  --ai2c-tekst: #2c3e50;
  --ai2c-grijs: #6b7a8c;
  --ai2c-lijn: #dbe4ec;
  --ai2c-vlak: #f4f8fb;
  --ai2c-font: 'Outfit', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --ai2c-kopfont: 'Space Grotesk', 'Outfit', system-ui, -apple-system, sans-serif;

  /* Afstand tot de onderrand. Deze waarden worden hieronder overschreven voor
     zelfscan.php, voor mobiel, en voor een zichtbare cookiebanner. */
  --ai2c-knop-onder: 24px;
  --ai2c-teaser-onder: 34px;
  --ai2c-paneel-onder: 100px;          /* 24 (rand) + 60 (knop) + 16 (lucht) */
  --ai2c-paneel-marge: 124px;          /* paneel-onder + 24 lucht bovenaan */
  --ai2c-banner: 0px;                  /* hoogte van de cookiebanner */

  font-family: var(--ai2c-font);
  color: var(--ai2c-tekst);
  line-height: 1.5;
}

.ai2c-wrap *,
.ai2c-wrap *::before,
.ai2c-wrap *::after { box-sizing: border-box; }

/* ==========================================================================
   1. Knop rechtsonder
   ========================================================================== */

.ai2c-knop {
  position: fixed;
  right: 24px;
  bottom: calc(var(--ai2c-knop-onder) + var(--ai2c-banner));
  z-index: 900;
  width: 60px;
  height: 60px;
  border: none;
  border-radius: 50%;
  padding: 0;
  cursor: pointer;
  background: var(--ai2c-verloop);
  color: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 10px 28px rgba(30, 90, 125, .38);
  transition: transform .18s ease, box-shadow .18s ease;
  -webkit-appearance: none;
  appearance: none;
}
.ai2c-knop:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 14px 34px rgba(30, 90, 125, .45); }
.ai2c-knop:focus-visible { outline: 3px solid rgba(79, 176, 109, .55); outline-offset: 3px; }
.ai2c-knop svg { width: 28px; height: 28px; display: block; fill: currentColor; }

/* Twee iconen in dezelfde knop: chat (dicht) en kruis (open) */
.ai2c-knop .ai2c-icoon-sluit { display: none; }
.ai2c-wrap.ai2c-open .ai2c-knop .ai2c-icoon-chat { display: none; }
.ai2c-wrap.ai2c-open .ai2c-knop .ai2c-icoon-sluit { display: block; }

/* Op zelfscan.php staat alles hoger, zodat de voortgangsbalk en de
   wizardknoppen onderin vrij blijven. Een cookiebanner stapelt daar bovenop. */
body.ai2c-zelfscan .ai2c-wrap {
  --ai2c-knop-onder: 96px;
  --ai2c-teaser-onder: 106px;
  --ai2c-paneel-onder: 172px;
  --ai2c-paneel-marge: 196px;
}

/* Zolang de cookiebanner (z-index 99999) onderaan staat, schuift de widget
   precies de bannerhoogte omhoog. chatbot.js zet de klasse en de hoogte. */
body.ai2c-banner-actief .ai2c-wrap {
  --ai2c-banner: var(--ai2c-banner-hoogte, 0px);
}

/* Badge ("1") na begeleide navigatie op mobiel */
.ai2c-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: #d4574e;
  color: #fff;
  font-family: var(--ai2c-font);
  font-size: .78rem;
  font-weight: 700;
  line-height: 22px;
  text-align: center;
  border: 2px solid #fff;
  display: none;
}
.ai2c-knop.ai2c-heeft-badge .ai2c-badge { display: block; }

/* ==========================================================================
   2. Teaser-ballon
   ========================================================================== */

.ai2c-teaser {
  position: fixed;
  right: 96px;
  bottom: calc(var(--ai2c-teaser-onder) + var(--ai2c-banner));
  z-index: 900;
  max-width: 220px;
  padding: .7rem 2rem .7rem .95rem;
  border-radius: 14px 14px 2px 14px;
  background: #fff;
  color: var(--ai2c-tekst);
  font-family: var(--ai2c-font);
  font-size: .92rem;
  box-shadow: 0 10px 30px rgba(20, 36, 48, .18);
  border: 1px solid var(--ai2c-lijn);
  cursor: pointer;
  opacity: 0;
  transform: translateY(6px);
  pointer-events: none;
  transition: opacity .3s ease, transform .3s ease;
}
.ai2c-teaser.ai2c-zichtbaar { opacity: 1; transform: translateY(0); pointer-events: auto; }

.ai2c-teaser-sluit {
  position: absolute;
  top: 2px;
  right: 4px;
  border: none;
  background: none;
  color: #9aa8b4;
  font-size: 1.15rem;
  line-height: 1;
  padding: .25rem .35rem;
  cursor: pointer;
}
.ai2c-teaser-sluit:hover { color: var(--ai2c-tekst); }

/* ==========================================================================
   3. Paneel
   ========================================================================== */

.ai2c-paneel {
  position: fixed;
  right: 24px;
  bottom: calc(var(--ai2c-paneel-onder) + var(--ai2c-banner));
  z-index: 900;
  width: 380px;
  height: 560px;
  max-height: calc(100vh - var(--ai2c-paneel-marge) - var(--ai2c-banner));
  display: none;
  flex-direction: column;
  overflow: hidden;
  background: #fff;
  border-radius: 18px;
  border: 1px solid var(--ai2c-lijn);
  box-shadow: 0 24px 60px rgba(20, 36, 48, .28);
  opacity: 0;
  transform: translateY(12px) scale(.98);
  transform-origin: bottom right;
  transition: opacity .22s ease, transform .22s ease;
}
.ai2c-wrap.ai2c-open .ai2c-paneel { display: flex; }
.ai2c-wrap.ai2c-open.ai2c-getoond .ai2c-paneel { opacity: 1; transform: translateY(0) scale(1); }

/* Kop */
.ai2c-kop {
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: .7rem;
  padding: .85rem 1rem;
  background: var(--ai2c-verloop);
  color: #fff;
}
.ai2c-kop-tekst { flex: 1 1 auto; min-width: 0; }
.ai2c-kop-titel {
  font-family: var(--ai2c-kopfont);
  font-weight: 700;
  font-size: 1.02rem;
  margin: 0;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.ai2c-status {
  display: flex;
  align-items: center;
  gap: .38rem;
  font-size: .8rem;
  opacity: .92;
  margin-top: .1rem;
}
.ai2c-status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  background: #cfd9e1;
  flex: 0 0 auto;
}
.ai2c-status[data-status="bezig"] .ai2c-status-dot { background: #f0c14b; animation: ai2c-puls 1.4s ease-in-out infinite; }
.ai2c-status[data-status="online"] .ai2c-status-dot { background: #7ee0a0; box-shadow: 0 0 0 3px rgba(126, 224, 160, .28); }
.ai2c-status[data-status="fout"]   .ai2c-status-dot { background: #ff8b7d; }

@keyframes ai2c-puls { 0%, 100% { opacity: .35; } 50% { opacity: 1; } }

.ai2c-icoonknop {
  flex: 0 0 auto;
  width: 32px; height: 32px;
  border: none;
  border-radius: 8px;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: rgba(255, 255, 255, .16);
  color: #fff;
  transition: background .18s ease;
}
.ai2c-icoonknop:hover { background: rgba(255, 255, 255, .3); }
.ai2c-icoonknop:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.ai2c-icoonknop svg { width: 16px; height: 16px; display: block; fill: currentColor; }

/* ==========================================================================
   4. Berichtenlijst
   ========================================================================== */

.ai2c-lijst {
  flex: 1 1 auto;
  overflow-y: auto;
  overscroll-behavior: contain;
  -webkit-overflow-scrolling: touch;
  padding: 1rem .9rem .4rem;
  background: var(--ai2c-vlak);
  display: flex;
  flex-direction: column;
  gap: .7rem;
}

.ai2c-bericht { display: flex; flex-direction: column; max-width: 88%; }
.ai2c-bericht--bot  { align-self: flex-start; }
.ai2c-bericht--user { align-self: flex-end; align-items: flex-end; }

.ai2c-bubbel {
  padding: .65rem .85rem;
  border-radius: 14px;
  font-size: .94rem;
  word-wrap: break-word;
  overflow-wrap: anywhere;
  white-space: normal;
}
.ai2c-bericht--bot .ai2c-bubbel {
  background: #fff;
  border: 1px solid var(--ai2c-lijn);
  border-bottom-left-radius: 4px;
  color: var(--ai2c-tekst);
}
.ai2c-bericht--user .ai2c-bubbel {
  background: var(--ai2c-verloop);
  border-bottom-right-radius: 4px;
  color: #fff;
}
.ai2c-bericht--fout .ai2c-bubbel {
  background: #fdf1ef;
  border: 1px solid #f3c9c3;
  color: #a8342a;
}
.ai2c-bubbel a { color: var(--ai2c-blauw); text-decoration: underline; font-weight: 600; }
.ai2c-bericht--user .ai2c-bubbel a { color: #fff; }
.ai2c-bubbel strong { font-weight: 700; }

/* Navigatieknoppen onder een botbericht */
.ai2c-nav {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin-top: .45rem;
}
.ai2c-nav-knop {
  border: 1.5px solid var(--ai2c-groen);
  background: #fff;
  color: var(--ai2c-blauw);
  font-family: var(--ai2c-font);
  font-size: .85rem;
  font-weight: 600;
  padding: .38rem .8rem;
  border-radius: 999px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  transition: background .16s ease, color .16s ease, transform .16s ease;
  text-align: left;
}
.ai2c-nav-knop:hover { background: var(--ai2c-groen); color: #fff; transform: translateY(-1px); }
.ai2c-nav-knop:focus-visible { outline: 2px solid var(--ai2c-blauw); outline-offset: 2px; }
.ai2c-nav-knop svg { width: 13px; height: 13px; fill: currentColor; flex: 0 0 auto; }

/* Typ-indicator */
.ai2c-typ {
  align-self: flex-start;
  display: inline-flex;
  gap: 5px;
  align-items: center;
  padding: .8rem .9rem;
  background: #fff;
  border: 1px solid var(--ai2c-lijn);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}
.ai2c-typ span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #a7b6c4;
  animation: ai2c-stip 1.2s ease-in-out infinite;
}
.ai2c-typ span:nth-child(2) { animation-delay: .18s; }
.ai2c-typ span:nth-child(3) { animation-delay: .36s; }

@keyframes ai2c-stip {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* Suggestie-chips: staan in de berichtenlijst, direct onder het welkomstbericht */
.ai2c-chips {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  margin: -.15rem 0 .1rem;
  flex: 0 0 auto;
}
.ai2c-chips[hidden] { display: none; }
.ai2c-chip {
  border: 1px solid var(--ai2c-lijn);
  background: #fff;
  color: var(--ai2c-blauw);
  font-family: var(--ai2c-font);
  font-size: .84rem;
  font-weight: 500;
  padding: .35rem .75rem;
  border-radius: 999px;
  cursor: pointer;
  transition: border-color .16s ease, background .16s ease;
}
.ai2c-chip:hover { border-color: var(--ai2c-groen); background: #f0faf3; }
.ai2c-chip:focus-visible { outline: 2px solid var(--ai2c-blauw); outline-offset: 2px; }

/* ==========================================================================
   5. Invoer
   ========================================================================== */

.ai2c-voet {
  flex: 0 0 auto;
  padding: .7rem .9rem .8rem;
  background: #fff;
  border-top: 1px solid var(--ai2c-lijn);
}

.ai2c-invoer {
  display: flex;
  align-items: flex-end;
  gap: .5rem;
}

.ai2c-textarea {
  flex: 1 1 auto;
  min-width: 0;
  resize: none;
  overflow-y: hidden;             /* JS zet dit op auto zodra de max bereikt is */
  max-height: 132px;              /* circa 6 regels */
  padding: .55rem .75rem;
  border: 1.5px solid var(--ai2c-lijn);
  border-radius: 12px;
  font-family: var(--ai2c-font);
  font-size: .94rem;
  line-height: 1.45;
  color: var(--ai2c-tekst);
  background: #fff;
  transition: border-color .18s ease, box-shadow .18s ease;
}
.ai2c-textarea::placeholder { color: #9aa8b4; }
.ai2c-textarea:focus {
  outline: none;
  border-color: var(--ai2c-groen);
  box-shadow: 0 0 0 3px rgba(79, 176, 109, .18);
}

.ai2c-verzend {
  flex: 0 0 auto;
  width: 40px; height: 40px;
  border: none;
  border-radius: 50%;
  padding: 0;
  display: grid;
  place-items: center;
  cursor: pointer;
  background: var(--ai2c-verloop);
  color: #fff;
  transition: transform .16s ease, opacity .16s ease, box-shadow .16s ease;
}
.ai2c-verzend:hover:not(:disabled) { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(30, 90, 125, .3); }
.ai2c-verzend:disabled { opacity: .4; cursor: default; transform: none; box-shadow: none; }
.ai2c-verzend:focus-visible { outline: 2px solid var(--ai2c-blauw); outline-offset: 2px; }
.ai2c-verzend svg { width: 18px; height: 18px; display: block; fill: currentColor; }

.ai2c-avg {
  margin: .5rem 0 0;
  font-size: .72rem;
  line-height: 1.4;
  color: #90a0ad;
}
.ai2c-avg a { color: var(--ai2c-grijs); text-decoration: underline; }

/* ==========================================================================
   6. Highlight van een doelsectie na begeleide navigatie
   ========================================================================== */

.ai2c-scroll-doel { scroll-margin-top: 90px; }

.ai2c-highlight {
  animation: ai2c-oplichten 2s ease-out forwards;
  border-radius: 10px;
}

@keyframes ai2c-oplichten {
  0%   { outline: 3px solid rgba(79, 176, 109, .95); outline-offset: 6px; background-color: rgba(79, 176, 109, .16); }
  70%  { outline: 3px solid rgba(79, 176, 109, .55); outline-offset: 6px; background-color: rgba(79, 176, 109, .09); }
  100% { outline: 3px solid rgba(79, 176, 109, 0);   outline-offset: 6px; background-color: rgba(79, 176, 109, 0); }
}

/* ==========================================================================
   7. Mobiel: schermvullend paneel
   ========================================================================== */

@media (max-width: 639px) {
  /* Kleinere marges onderin; de zelfscan-regel staat hierna zodat die wint. */
  .ai2c-wrap {
    --ai2c-knop-onder: 16px;
    --ai2c-teaser-onder: 26px;
  }
  body.ai2c-zelfscan .ai2c-wrap {
    --ai2c-knop-onder: 88px;
    --ai2c-teaser-onder: 98px;
  }

  /* Schermvullend, maar nooit onder de cookiebanner: anders valt de banner
     over het invoerveld. */
  .ai2c-paneel,
  body.ai2c-zelfscan .ai2c-paneel {
    right: 0;
    bottom: var(--ai2c-banner);
    left: 0;
    top: 0;
    width: auto;
    height: auto;
    max-height: none;
    border-radius: 0;
    border: none;
    transform: translateY(16px);
  }
  .ai2c-wrap.ai2c-open.ai2c-getoond .ai2c-paneel { transform: translateY(0); }

  /* Knop en teaser verdwijnen zolang het paneel schermvullend openstaat */
  .ai2c-wrap.ai2c-open .ai2c-knop,
  .ai2c-wrap.ai2c-open .ai2c-teaser { display: none; }

  .ai2c-knop { right: 16px; }
  .ai2c-teaser { right: 88px; max-width: 180px; }
  .ai2c-bericht { max-width: 92%; }
}

/* ==========================================================================
   8. Bewegingsvoorkeur en print
   ========================================================================== */

@media (prefers-reduced-motion: reduce) {
  .ai2c-knop,
  .ai2c-paneel,
  .ai2c-teaser,
  .ai2c-nav-knop,
  .ai2c-verzend,
  .ai2c-icoonknop { transition: none !important; }
  .ai2c-knop:hover { transform: none; }
  .ai2c-paneel { transform: none !important; }
  .ai2c-typ span,
  .ai2c-status-dot { animation: none !important; }
  .ai2c-highlight { animation: none !important; outline: 3px solid rgba(79, 176, 109, .9); outline-offset: 6px; background-color: rgba(79, 176, 109, .14); }
}

@media print {
  .ai2c-wrap { display: none !important; }
}
