/* CTA button (buiten chat) */
.afchat-cta {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background-color: #95C11F; 
  color: #fff;
  border: none;
  border-radius: 3px;
  padding: 12px 20px;
  font-weight: 600;
  font-size: 15px;
  cursor: pointer;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
  line-height: 1.2;
  text-decoration: none;
  width: 100%;
  box-sizing: border-box;
}
.afchat-cta:hover {
  background-color: #2D5D6E;
}
.afchat-cta__icon::before {
  content: "";
  display: inline-block;
  width: 18px;
  height: 18px;
  -webkit-mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="%23fff" viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2z"/></svg>') no-repeat center / contain;
  mask: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" fill="%23fff" viewBox="0 0 24 24"><path d="M20 2H4a2 2 0 0 0-2 2v18l4-4h14a2 2 0 0 0 2-2V4a2 2 0 0 0-2-2z"/></svg>') no-repeat center / contain;
  background: #fff;
}


/* Overlay & modal */
.afchat-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.35);
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
}
.afchat-modal {
  width: min(920px, 96vw);
  background: #fff;
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  min-height: 580px;
  max-height: 680px;
  height: 100%;
}

@media (max-width: 768px) {
  .afchat-modal {
    max-height: 20vh;
    height: 20vh;
  }

  .afchat-wrap {
    flex-direction: column;
    position: relative;
  }

  .afchat-menu-toggle {
    display: block;
    margin-right: 8px;
    position: relative;
  }

  .afchat-menu-toggle.has-unread::after {
    content: "!";
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: #00AFEF;
    border-radius: 50%;
    box-shadow: 0 0 0 2px #f8fafc;
  }

  .afchat-left {
    position: absolute;
    top: 0;
    left: 0;
    width: 80%;
    height: 100%;
    max-height: 100%;
    background: #fafafa;
    z-index: 10;
    transition: transform 0.3s ease;
    transform: translateX(-100%);
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    border-right: 1px solid #e5e7eb;
  }

  .afchat-left.open {
    transform: translateX(0);
  }

  .afchat-right {
    display: flex;
    flex-direction: column;
    min-height: 0;
    height: 100%;
  }

  .afchat-messages {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 0;
  }

  .afchat-composer {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    padding: 16px;
    background: #fff;
    border-top: 1px solid #e5e7eb;
    box-sizing: border-box;
    flex-shrink: 0;
  }

  .afchat-textarea {
    min-height: 50px !important;
    max-height: 110px;
    font-size: 15px;
    resize: none;
    padding: 10px 12px;
    line-height: 1.4;
    width: 100%;
    box-sizing: border-box;
  }

  .afchat-send,
  .afchat-upload-btn {
    height: 44px;
    font-size: 15px;
    padding: 0 16px;
    border-radius: 10px;
    width: 100%;
  }
}


.afchat-upload-btn {
  background: #00AFEF;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 12px;
  font-weight: 600;
  cursor: pointer;
  font-size: 14px;
  height: 100%;
}
.afchat-upload-btn:hover {
  background: #008ecf;
}

/* De rest van je CSS blijft ongewijzigd... */

/* Header */
.afchat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
}
.afchat-title {
  font-weight: 700;
  font-size: 16px;
}
.afchat-close {
  background: transparent;
  border: none;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
}

/* Main wrap */
.afchat-wrap {
  display: flex;
  flex: 1;
  min-height: 0;
  overflow: hidden;
  position: relative;
}

/* Left panel: threads */
.afchat-left {
  width: 280px;
  border-right: 1px solid #e5e7eb;
  background: #fafafa;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.afchat-thread-list {
  padding: 8px;
  overflow-y: auto;
  flex: 1 1 auto;
  min-height: 100px;
}
.afchat-thread-item {
  display: flex;
  align-items: center;
  padding: 10px;
  border-radius: 10px;
  cursor: pointer;
}
.afchat-thread-item:hover {
  background: #eef2f7;
}
.afchat-thread-item.active {
  background: #e6f4ea;
}

/* Avatar styling */
.afchat-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50% !important; /* altijd rond */
  object-fit: cover;
  margin-right: 10px;
  background-color: #e2e8f0;
  background-size: cover;
  background-position: center;
  display: block;
}

/* fallback als er geen src is */
.afchat-avatar[src=""] {
  background-image: url('https://www.gravatar.com/avatar/?d=mp');
}

.afchat-thread-title {
  font-weight: 600;
  font-size: 14px;
  color: #111827;
  flex: 1;                /* neemt alle ruimte in het midden */
  white-space: nowrap;    /* voorkomt dat de tekst op 2 regels komt */
  overflow: hidden;
  text-overflow: ellipsis; /* toont "..." bij lange titels */
}

/* Ongelezen indicator helemaal rechts */
.afchat-unread {
  display: inline-block;
  margin-left: auto;
  background-color: #00AFEF;
  color: #fff;
  font-weight: bold;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
}

.afchat-empty {
  padding: 20px;
  color: #6b7280;
  font-size: 14px;
}

/* Right panel: messages */
.afchat-right {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.afchat-subheader {
  padding: 12px 16px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
}
.afchat-subheader-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.afchat-subheader-content {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  row-gap: 8px;
}
.afchat-proposal-btn {
  background-color: #3b82f6;
  color: white;
  padding: 6px 12px;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
}
.afchat-messages {
  flex: 1 1 auto;
  padding: 16px;
  overflow-y: auto;
  min-height: 0;
  background: #f5f7fb;
  background-image: radial-gradient(#e5e7eb 1px, transparent 1px);
  background-size: 20px 20px;
}

/* Berichtballonnen */
.afchat-msg {
  max-width: 70%;
  margin: 8px 0;
  padding: 10px 12px;
  border-radius: 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  transition: background 0.2s ease;
  position: relative;
}
.afchat-msg.own-msg {
  margin-left: auto;
  background: #e8f5e9;
  border-color: #a5d6a7;
}
.afchat-msg.other-msg {
  margin-right: auto;
  background: #fff;
  border-color: #e5e7eb;
}
.afchat-msg-meta {
  font-size: 11px;
  color: #6b7280;
  margin-bottom: 4px;
}
.afchat-msg-text {
  font-size: 14px;
  white-space: pre-wrap;
}

/* Vinkje zichtbaar bij eigen berichten */
.afchat-msg.own-msg::after {
  content: "";
  position: absolute;
  bottom: 6px;
  right: 10px;
  width: 20px;
  height: 20px;
  background-size: contain;
  background-repeat: no-repeat;
}

/* Grijs vinkje als niet gelezen */
.afchat-msg.own-msg:not(.is-read)::after {
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.5 8.5L7 10L10.5 6.5' stroke='%23999' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Groen vinkje als gelezen */
.afchat-msg.own-msg.is-read::after {
  background-image: url("data:image/svg+xml,%3Csvg width='20' height='20' viewBox='0 0 16 16' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M5.5 8.5L7 10L10.5 6.5' stroke='%2300b37d' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
}

/* Verberg vinkjes bij ontvangen berichten */
.afchat-msg.other-msg::after {
  display: none !important;
}

/* Composer */
.afchat-composer {
  display: flex;
  align-items: stretch;
  gap: 8px;
  padding: 10px 14px;
  border-top: 1px solid #e5e7eb;
  background: #fff;
  box-sizing: border-box;
  flex-shrink: 0;
}
.afchat-textarea {
  flex: 1;
  border: 1px solid #d1d5db;
  border-radius: 12px;
  padding: 8px 10px;
  resize: vertical;
  min-height: 40px;
  max-height: 96px;
  overflow-y: auto;
}
.afchat-send {
  background: #95C11F;
  color: #fff;
  border: none;
  border-radius: 10px;
  padding: 0 16px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
}
.afchat-send:hover {
  background: #43a047;
}

/* Animatie voor nieuwe berichten */
.afchat-msg.just-added {
  opacity: 0;
  transform: translateY(10px);
  animation: fadeInUp 0.3s ease forwards;
}
@keyframes fadeInUp {
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Verberg hamburger op desktop */
.afchat-menu-toggle {
  display: none;
  background: transparent;
  border: none;
  font-size: 22px;
  cursor: pointer;
}

/* Mobiel: hamburger tonen en threadmenu als overlay binnen modal */
@media (max-width: 768px) {
  .afchat-modal {
    max-height: 90vh; /* was: 680px */
    height: 90vh;
  }

  .afchat-menu-toggle {
    display: block;
    margin-right: 8px;
  }

  .afchat-wrap {
    flex-direction: column;
    position: relative;
  }

  .afchat-left {
    position: absolute;
    top: 0;
    left: 0;
    width: 80%;
    height: 100%;
    max-height: 100%;
    background: #fafafa;
    z-index: 10;
    transition: transform 0.3s ease;
    transform: translateX(-100%);
    box-shadow: 4px 0 10px rgba(0,0,0,0.1);
    border-right: 1px solid #e5e7eb;
  }

  .afchat-left.open {
    transform: translateX(0);
  }
}

/* Badge op hamburger-menu bij ongelezen – alleen mobiel */
@media (max-width: 768px) {
  .afchat-menu-toggle {
    position: relative;
  }
  .afchat-menu-toggle.has-unread::after {
    content: "!";
    position: absolute;
    top: -4px;
    right: -4px;
    width: 18px;
    height: 18px;
    line-height: 18px;
    text-align: center;
    font-size: 12px;
    font-weight: 700;
    color: #fff;
    background: #00AFEF; /* jouw blauw */
    border-radius: 50%;
    box-shadow: 0 0 0 2px #f8fafc; /* kleine rand zodat het zichtbaar blijft */
  }
}

/* ✅ Badge op de knop zelf */
.afchat-badge {
  margin-left: auto;
  background-color: #00AFEF; /* blauw */
  color: #fff;
  font-weight: bold;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  line-height: 20px;
  text-align: center;
  font-size: 13px;
  flex-shrink: 0;
  display: none;
}
.afchat-badge.has-unread {
  display: inline-block;
}
/* ✅ Alleen de badge op de chatknop groter maken */
/* ✅ Alleen de badge op de chatknop groter maken */
.afchat-cta .afchat-badge {
  width: 34px;
  height: 34px;
  font-size: 30px;
  line-height: 28px;
	animation: bouncePause 2.0s ease-in-out infinite;
  transform-origin: center bottom;
}

@keyframes bouncePause {
  0%, 100% { transform: translateY(0) scale(1); }
  10% { transform: translateY(-4px) scale(1.1); }
  20% { transform: translateY(0) scale(0.95); }
  30% { transform: translateY(-2px) scale(1.05); }
  40% { transform: translateY(0) scale(1); }
  /* 40% - 100% = pauze */
}
.afchat-msg-image {
  display: block;
  max-width: 220px;
  max-height: 220px;
  width: auto;
  height: auto;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
  object-fit: cover;
  cursor: zoom-in;
}

/* Fullscreen image lightbox boven chat */
.afchat-imglightbox {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.8);
  z-index: 100001; /* hoger dan .afchat-overlay (99999) */
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}
.afchat-imglightbox__inner {
  max-width: 95vw;
  max-height: 95vh;
}
.afchat-imglightbox__img {
  max-width: 95vw;
  max-height: 95vh;
  width: auto;
  height: auto;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,.4);
}
.afchat-imglightbox__close {
  position: absolute;
  top: 14px;
  right: 16px;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  background: rgba(255,255,255,.9);
  color: #111;
  font-size: 28px;
  line-height: 40px;
  cursor: pointer;
}
/* Spinner op uploadknop */
.afchat-upload-btn { position: relative; }
.afchat-upload-btn.is-loading { opacity: .8; pointer-events: none; }
.afchat-upload-btn.is-loading::after {
  content: "";
  position: absolute;
  right: 10px;
  top: 50%;
  width: 16px; height: 16px;
  border: 2px solid rgba(255,255,255,.8);
  border-top-color: transparent;
  border-radius: 50%;
  transform: translateY(-50%);
  animation: afchat-spin .8s linear infinite;
}
@keyframes afchat-spin { to { transform: translateY(-50%) rotate(360deg); } }

/* Tijdelijke upload-bubbel */
.afchat-msg.uploading {
  background: #eef6ff;
  border-color: #bcd7ff;
  opacity: .9;
}
.afchat-msg .afchat-inline-spinner {
  display: inline-block;
  width: 14px; height: 14px;
  border: 2px solid #6aa7ff;
  border-top-color: transparent;
  border-radius: 50%;
  vertical-align: -2px;
  margin-right: 6px;
  animation: afchat-spin .8s linear infinite;
}

.afchat-consent-modal {
  width: 100%;
  max-width: 480px;
  min-height: auto !important;
  max-height: none;
  height: auto;
  padding: 32px;
  border-radius: 14px;
  background: #fff;
  box-shadow: 0 10px 30px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 15px;
  font-family: inherit;
}


.afchat-consent-title {
  font-size: 22px;
  font-weight: 700;
  margin: 0 0 16px 0;
  color: #3A4F66;
}

.afchat-consent-text {
  font-size: 15px;
  line-height: 1.6;
  color: #374151;
  margin-bottom: 10px;
}

.afchat-consent-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.afchat-consent-cancel {
  background: #fef2f2;
  color: #b91c1c;
  border: 1px solid #fca5a5;
  border-radius: 8px;
  padding: 10px 16px;
  font-size: 14px;
  cursor: pointer;
  font-weight: 600;
}

.afchat-consent-cancel:hover {
  background: #fee2e2;
}

.afchat-consent-accept {
  border-radius: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
}

@media (max-width: 480px) {
  .afchat-consent-modal {
    max-width: 92vw;
    padding: 20px 16px;
    font-size: 14px;
  }

  .afchat-consent-buttons {
    flex-direction: column;
    gap: 8px;
  }

  .afchat-consent-buttons button {
    width: 100%;
  }
}
.afchat-send:disabled {
  background-color: #e5e7eb !important;
  color: #9ca3af !important;
  cursor: not-allowed !important;
  border-color: #d1d5db !important;
}
