/* MKI-Techniek chatbot widget. Huisstijl oranje #E8701C -> #CC5C0A.
   Vanilla CSS, scoped onder .mki-chat zodat het niet botst met de site.
   Mobile-first, clean. Geen externe afhankelijkheden. */

.mki-chat {
  --mki-orange: #e8701c;
  --mki-orange-dark: #cc5c0a;
  --mki-orange-deep: #b5520a;
  --mki-ink: #1f2937;
  --mki-ink-soft: #475569;
  --mki-muted: #64748b;
  --mki-line: rgba(15, 23, 42, 0.1);
  --mki-bg-soft: #f6f7f9;
  --mki-green: #25d366;
  /* Neutrale basis (slate) voor header en gebruikersberichten; oranje is accent. */
  --mki-header: #273340;
  --mki-header-2: #1c2630;
  --mki-user: #3a4654;
  --mki-radius: 16px;
  --mki-shadow: 0 18px 50px rgba(15, 23, 42, 0.18);
  position: fixed;
  right: clamp(14px, 4vw, 28px);
  bottom: clamp(14px, 4vw, 28px);
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--mki-ink);
}

.mki-chat *,
.mki-chat *::before,
.mki-chat *::after {
  box-sizing: border-box;
}

/* ---- Launcher bubbel ---- */
.mki-launcher {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 60px;
  height: 60px;
  border: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--mki-orange) 0%, var(--mki-orange-dark) 100%);
  color: #fff;
  cursor: pointer;
  box-shadow: 0 10px 26px rgba(200, 80, 14, 0.32);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.mki-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 32px rgba(200, 80, 14, 0.4);
}
.mki-launcher:focus-visible {
  outline: 3px solid rgba(232, 112, 28, 0.5);
  outline-offset: 3px;
}
.mki-launcher svg {
  width: 28px;
  height: 28px;
}
.mki-launcher .mki-icon-close {
  display: none;
}
.mki-chat[data-open="true"] .mki-launcher .mki-icon-open {
  display: none;
}
.mki-chat[data-open="true"] .mki-launcher .mki-icon-close {
  display: block;
}

/* Pulsende attentie-stip op de bubbel (eenmalig) */
.mki-launcher::after {
  content: "";
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--mki-green);
  border: 2px solid #fff;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.3s ease, transform 0.3s ease;
}
.mki-chat[data-unread="true"] .mki-launcher::after {
  opacity: 1;
  transform: scale(1);
}

/* ---- Paneel ---- */
.mki-panel {
  position: absolute;
  right: 0;
  bottom: 74px;
  width: min(380px, calc(100vw - 28px));
  max-height: min(620px, calc(100vh - 110px));
  background: #fff;
  border: 1px solid var(--mki-line);
  border-radius: var(--mki-radius);
  box-shadow: var(--mki-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  transform-origin: bottom right;
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.mki-chat[data-open="true"] .mki-panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ---- Header ---- */
.mki-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 16px 14px;
  background: linear-gradient(135deg, var(--mki-header) 0%, var(--mki-header-2) 100%);
  color: #fff;
  border-bottom: 2px solid var(--mki-orange);
}
.mki-avatar {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #fff;
  display: grid;
  place-items: center;
  box-shadow: 0 1px 4px rgba(0, 0, 0, 0.2);
}
.mki-avatar img {
  display: block;
  width: 26px;
  height: 26px;
}
.mki-header-text {
  line-height: 1.25;
  min-width: 0;
}
.mki-header-title {
  font-weight: 700;
  font-size: 0.98rem;
}
.mki-header-sub {
  font-size: 0.76rem;
  opacity: 0.9;
  display: flex;
  align-items: center;
  gap: 6px;
  margin-top: 2px;
}
.mki-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--mki-green);
  box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.25);
}
.mki-header-close {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.16);
  border: 0;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 9px;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 0.18s ease;
}
.mki-header-close:hover {
  background: rgba(255, 255, 255, 0.28);
}
.mki-header-close:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}
.mki-header-close svg {
  width: 18px;
  height: 18px;
}

/* ---- Berichtenlijst ---- */
.mki-log {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  background: #f7f8fa;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.mki-msg {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
  animation: mki-pop 0.25s ease;
}
@keyframes mki-pop {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}
.mki-msg-bot {
  align-self: flex-start;
  background: #fff;
  color: var(--mki-ink);
  border: 1px solid var(--mki-line);
  border-bottom-left-radius: 5px;
}
.mki-msg-user {
  align-self: flex-end;
  background: var(--mki-user);
  color: #fff;
  border-bottom-right-radius: 5px;
}

/* Typ-indicator */
.mki-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 12px 14px;
  background: #fff;
  border: 1px solid var(--mki-line);
  border-radius: 14px;
  border-bottom-left-radius: 5px;
}
.mki-typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--mki-muted);
  animation: mki-blink 1.2s infinite ease-in-out;
}
.mki-typing span:nth-child(2) { animation-delay: 0.18s; }
.mki-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes mki-blink {
  0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-3px); }
}

/* ---- Chips (snelkeuze) ---- */
.mki-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 2px 2px 10px;
  align-self: stretch;
}
.mki-chip {
  border: 1px solid var(--mki-line);
  background: #fff;
  color: var(--mki-ink-soft);
  font-size: 0.82rem;
  font-weight: 600;
  padding: 8px 13px;
  border-radius: 999px;
  cursor: pointer;
  transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease, transform 0.16s ease;
}
.mki-chip:hover {
  background: #fff6ef;
  border-color: var(--mki-orange);
  color: var(--mki-orange-deep);
  transform: translateY(-1px);
}
.mki-chip:focus-visible {
  outline: 2px solid var(--mki-orange);
  outline-offset: 2px;
}

/* Actie-chips (bel/whatsapp/mail) krijgen accent */
.mki-chip-action {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  color: #fff;
  border-color: transparent;
  background: linear-gradient(135deg, var(--mki-orange) 0%, var(--mki-orange-dark) 100%);
}
.mki-chip-action:hover {
  background: linear-gradient(135deg, #f07d2a 0%, var(--mki-orange-dark) 100%);
  filter: brightness(1.06);
}
.mki-chip-action svg {
  width: 15px;
  height: 15px;
  flex-shrink: 0;
}
.mki-chip-wa {
  background: var(--mki-green);
}
.mki-chip-wa:hover {
  background: #2ecc6a;
  filter: brightness(1.05);
}
.mki-chip-back {
  color: var(--mki-muted);
  border-color: var(--mki-line);
  background: var(--mki-bg-soft);
}
.mki-chip-back:hover {
  background: #eef1f4;
  border-color: var(--mki-muted);
}

/* ---- Invoerbalk ---- */
.mki-input {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--mki-line);
  background: #fff;
}
.mki-input input {
  flex: 1;
  min-width: 0;
  border: 1px solid var(--mki-line);
  background: var(--mki-bg-soft);
  border-radius: 11px;
  padding: 11px 13px;
  font: inherit;
  font-size: 0.9rem;
  color: var(--mki-ink);
}
.mki-input input::placeholder {
  color: rgba(100, 116, 139, 0.7);
}
.mki-input input:focus {
  outline: none;
  background: #fff;
  border-color: rgba(232, 112, 28, 0.6);
  box-shadow: 0 0 0 2px rgba(232, 112, 28, 0.13);
}
.mki-send {
  flex-shrink: 0;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: 11px;
  background: linear-gradient(135deg, var(--mki-orange) 0%, var(--mki-orange-dark) 100%);
  color: #fff;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: transform 0.16s ease, box-shadow 0.16s ease;
}
.mki-send:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 14px rgba(200, 80, 14, 0.25);
}
.mki-send:focus-visible {
  outline: 2px solid var(--mki-orange);
  outline-offset: 2px;
}
.mki-send svg {
  width: 18px;
  height: 18px;
}

.mki-footnote {
  text-align: center;
  font-size: 0.68rem;
  color: var(--mki-muted);
  padding: 0 12px 9px;
  background: #fff;
}
.mki-footnote a {
  color: var(--mki-orange-deep);
  text-decoration: none;
}
.mki-footnote a:hover {
  text-decoration: underline;
}

/* ---- Screenreader-only ---- */
.mki-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ---- Mobiel: paneel vult het scherm ---- */
@media (max-width: 480px) {
  .mki-panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    max-height: 100vh;
    height: 100vh;
    border-radius: 0;
    bottom: 0;
    right: 0;
  }
  .mki-chat[data-open="true"] .mki-launcher {
    display: none;
  }
}

/* ---- Reduced motion ---- */
@media (prefers-reduced-motion: reduce) {
  .mki-panel,
  .mki-launcher,
  .mki-chip,
  .mki-send,
  .mki-msg {
    transition: none;
    animation: none;
  }
  .mki-typing span {
    animation: none;
    opacity: 0.6;
  }
}
