:root {
  --headerkleur: #007bff;
  --headertekstkleur: #ffffff;
  --achtergrondkleur: #f9f9f9;
  --tekstkleur: #222222;
  --botkleur: #eeeeee;
  --bottekstkleur: #222222;
  --userkleur: #007bff;
  --usertekstkleur: #ffffff;
  --chatkleur: #007bff;
  --usertekst: #ffffff;
}

/* Alleen in de iframe zelf: scroll/zoom niet doorlekken */
html,
body {
  overscroll-behavior: none;
  touch-action: none;
}

body {
  margin: 0;
  font-family: Arial, sans-serif;
}

body.chat-open {
  position: fixed;
  width: 100%;
  overflow: hidden;
}

/* widget vult de hele iframe */
#chat-widget {
  position: absolute;
  inset: 0;
  z-index: 10001;
  opacity: 1;
  transform: translateY(0);
  transition: all 0.5s ease-in-out;
}

#chat-widget.visible {
  opacity: 1;
  transform: translateY(0);
}

#chat-toggle {
  display: none;
}

/* box volgt de afmeting van de widget/iframe */
#chat-box {
  width: 100%;
  height: 100%;
  background: var(--achtergrondkleur);
  color: var(--tekstkleur);
  border-radius: 16px;
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.2);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  margin-top: 0;
  position: relative;
}

#chat-box.chat-expanded {
  width: 100%;
  height: 100%;
}

.hidden {
  display: none;
}

/* ⭐ BASIS (desktop / alle grotere schermen): GROTE HEADER */
.chat-header {
  background: var(--headerkleur);
  color: var(--headertekstkleur);
  padding: 40px 12px 18px 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  gap: 10px;
  text-align: left;
  position: relative;
}

/* standaard: knop zichtbaar */
.header-expand {
  position: absolute;
  top: 6px;
  left: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: #ffffff;
  font-size: 0;
  line-height: 1;
  cursor: pointer;
  padding: 0;
}

.header-expand:hover {
  background: rgba(255, 255, 255, 0.25);
}

/* SVG icoon in de fullscreen-knop */
.header-expand-icon {
  width: 14px;
  height: 14px;
  display: block;
  transform: rotate(90deg);
  filter: invert(1); /* icoontje wit op donkere header */
}

/* logo links */
.chat-header-logo {
  width: 44px;
  height: 44px;
  object-fit: cover;
  border-radius: 50%;
  background: var(--headerkleur);
  display: block;
  margin-left: 4px;
}

.chat-header-text {
  flex: 1;
  font-size: 16px;
  font-weight: bold;
  color: var(--headertekstkleur);
  display: inline-block;
}

/* hier mag je wél scrollen */
.chat-messages {
  flex: 1;
  padding: 12px;
  padding-bottom: 20px;
  overflow-y: auto;
  background: var(--achtergrondkleur); /* ← hier aangepast zodat het thema volgt */
  display: flex;
  flex-direction: column;
  gap: 8px;
  touch-action: pan-y;
}

.message {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  position: relative;
  transition: background-color 0.3s ease, color 0.3s ease;
  white-space: pre-line; /* ✅ NEW: \n wordt echte nieuwe regel */
}

.message.bot {
  background: var(--botkleur);
  color: var(--bottekstkleur);
  align-self: flex-start;
}

.message.user {
  background: var(--userkleur);
  color: var(--usertekstkleur);
  align-self: flex-end;
}

.message.user::after {
  content: "";
  position: absolute;
  right: -8px;
  bottom: 8px;
  width: 12px;
  height: 12px;
  background: var(--userkleur);
  clip-path: polygon(0 0, 100% 50%, 0 100%);
}

.message.bot::after {
  content: "";
  position: absolute;
  left: -8px;
  bottom: 8px;
  width: 12px;
  height: 12px;
  background: var(--botkleur);
  clip-path: polygon(100% 0, 0% 50%, 100% 100%);
}

.chat-input {
  display: flex;
  align-items: center;
  gap: 8px;
  border-top: 1px solid #f0f0f0;
  position: sticky;
  bottom: 0;
  padding: 10px 10px 12px;
  background: #f8f8f8;
  z-index: 10;
}

.chat-input input,
.chat-input textarea {
  flex: 1;
  border: 1px solid rgba(0, 0, 0, 0.06);
  padding: 6px 12px;
  font-size: 16px; /* tegen auto-zoom */
  outline: none;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.95);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  resize: none;
  overflow-y: hidden;
  max-height: 120px;
  line-height: 1.35;
  scrollbar-width: thin;
  scrollbar-color: rgba(0, 0, 0, 0.35) transparent;
  transition: border-radius 0.2s ease;
}

.chat-input input {
  transition: border-radius 0.2s ease;
}

.chat-input textarea.is-multiline {
  border-radius: 18px;
}

.chat-input textarea::-webkit-scrollbar {
  width: 6px;
}

.chat-input textarea::-webkit-scrollbar-track {
  background: transparent;
}

.chat-input textarea::-webkit-scrollbar-thumb {
  background-color: rgba(0, 0, 0, 0.35);
  border-radius: 999px;
}

.chat-input textarea::-webkit-scrollbar-thumb:hover {
  background-color: rgba(0, 0, 0, 0.5);
}

.chat-input textarea {
  touch-action: pan-y;
}

.chat-input button {
  background: var(--headerkleur);
  color: var(--headertekstkleur);
  border: none;
  padding: 8px 14px;
  font-size: 14px;
  cursor: pointer;
  border-radius: 999px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.18);
  white-space: nowrap;
}

.chat-input button:hover {
  filter: brightness(1.05);
}

.chat-input button:active {
  transform: scale(0.96);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.close-button {
  position: absolute;
  top: 10px;
  right: 12px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 10000;
  padding: 0;
  background-color: transparent;
  background-image: url("icons/naar-beneden.svg");
  background-repeat: no-repeat;
  background-position: center;
  background-size: 16px 16px;
  font-size: 0;
  color: transparent;
  filter: invert(1); /* icoontje wit op donkere header */
}

.close-button::before {
  content: none;
  font-size: 18px;
  line-height: 28px;
  color: #ffffff;
}

.close-button:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

/* 📱 layout op smalle schermen – GEEN header-verkleining hier, alleen layout */
@media (max-width: 768px) {
  #chat-box {
    width: 100vw;
    height: 100dvh;
    border-radius: 0;
    box-shadow: none;
    margin-top: 0;
  }

  #taalkeuze-popup {
    max-width: 90%;
    font-size: 16px;
    border-radius: 16px;
  }

  #taalkeuze-popup select#taal-select {
    width: 70%;
  }
}

/* 🖥️ desktop-box */
@media (min-width: 769px) {
  #chat-box {
    width: 100%;
    height: 100%;
    border-radius: 20px;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(0, 0, 0, 0.05);
  }
}

/* 👉 Alleen op 'echte telefoon fullscreen':
      header kleiner + knop weg */
@media (max-width: 500px) and (min-height: 600px) {
  .chat-header {
    padding: 18px 10px 10px 10px;  /* kleiner dan desktop */
    gap: 8px;
  }

  .chat-header-logo {
    width: 34px;
    height: 34px;
  }

  .chat-header-text {
    font-size: 14px;
  }

  .header-expand {
    display: none;
  }
}

.typing {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 16px;
}

.typing span {
  width: 6px;
  height: 6px;
  background: #999;
  border-radius: 50%;
  display: inline-block;
  animation: blink 1.4s infinite ease-in-out both;
}

.typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%, 80%, 100% { opacity: 0; transform: scale(0.8); }
  40% { opacity: 1; transform: scale(1.2); }
}

#taalkeuze-popup {
  /* ✅ FIX: voorkom "shrink-to-fit" (inline-block) waardoor het klein blijft */
  display: block;

  /* ✅ FIX: weer "oude grote maat" */
  width: 80%;
  max-width: 520px;
  min-width: 260px;

  background: #ffffff;
  color: #222222;
  border-radius: 18px;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.08);
  padding: 16px 20px;
  margin: 10px auto;
  font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
  line-height: 1.6;
  font-size: 15px;
  font-weight: 500;
  text-align: center;
  transition: all 0.3s ease;
  box-sizing: border-box;
}

#taalkeuze-popup::after {
  content: none !important;
}

#taalkeuze-popup > div:first-child {
  margin-bottom: 10px;
  font-weight: 600;
}

#taalkeuze-popup select#taal-select {
  padding: 8px 14px;
  border-radius: 12px;
  border: 1px solid #ccc;
  font-size: 15px;
  font-family: inherit;
  font-weight: 500;
  background: #f9f9f9;
  color: #222;
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;

  /* ✅ FIX: select vult de hele bubble */
  display: block;
  width: 100%;
  box-sizing: border-box;
}

#taalkeuze-popup select#taal-select:focus {
  border-color: #007bff;
  background: #ffffff;
}

#taalkeuze-popup button#bevestig-taal {
  margin-left: 0 !important;
  margin-top: 10px;
  padding: 8px 18px;
  border-radius: 50px;
  background: #ffffff;
  color: #222222;
  font-size: 14px;
  font-weight: 600;
  border: 1px solid rgba(0, 0, 0, 0.08);
  cursor: pointer;
  transition: background 0.3s ease, transform 0.1s ease, box-shadow 0.2s ease;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.15);
  display: inline-block;
}

#taalkeuze-popup button#bevestig-taal:hover {
  background: #f5f5f5;
  box-shadow: 0 8px 22px rgba(0, 0, 0, 0.18);
}

#taalkeuze-popup button#bevestig-taal:active {
  transform: scale(0.96);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}
