/* CNCware Chatbot Widget */
:root {
  --cnc-primary: #3DAA7A;
  --cnc-primary-dark: #2d8a60;
  --cnc-bg: #ffffff;
  --cnc-text: #1a1a1a;
  --cnc-text-muted: #666666;
  --cnc-border: #e0e0e0;
  --cnc-user-bubble: #3DAA7A;
  --cnc-bot-bubble: #f5f5f5;
  --cnc-shadow: 0 8px 32px rgba(0,0,0,0.18);
  --cnc-radius: 16px;
  --cnc-font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

#cncware-chatbot-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: var(--cnc-font);
}

/* Toggle knop */
#cncware-chatbot-toggle {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--cnc-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  box-shadow: var(--cnc-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.2s;
  outline: none;
}

#cncware-chatbot-toggle:hover {
  background: var(--cnc-primary-dark);
  transform: scale(1.07);
}

#cncware-chatbot-toggle svg {
  width: 26px;
  height: 26px;
  pointer-events: none;
}

/* Chat venster */
#cncware-chatbot-window {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: 420px;
  height: 700px;
  background: var(--cnc-bg);
  border-radius: var(--cnc-radius);
  box-shadow: var(--cnc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: cncSlideIn 0.22s ease;
}

@keyframes cncSlideIn {
  from { opacity: 0; transform: translateY(16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* Header */
#cncware-chatbot-header {
  background: #1a1a1a;
  color: #fff;
  padding: 22px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-weight: 600;
  font-size: 15px;
  letter-spacing: 0.01em;
  flex-shrink: 0;
}

#cncware-chatbot-header .cnc-logo {
  height: 34px;
  width: auto;
  display: block;
}

.cnc-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}

.cnc-header-actions button {
  background: rgba(255,255,255,0.1);
  border: none;
  color: rgba(255,255,255,0.85);
  cursor: pointer;
  width: 32px;
  height: 32px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
}

.cnc-header-actions button:hover {
  background: rgba(255,255,255,0.2);
  color: #fff;
}

.cnc-header-actions button svg {
  width: 15px;
  height: 15px;
  pointer-events: none;
}

#cncware-chatbot-close {
  font-size: 18px;
  line-height: 1;
}

/* Berichten */
#cncware-chatbot-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
}

#cncware-chatbot-messages::-webkit-scrollbar { width: 4px; }
#cncware-chatbot-messages::-webkit-scrollbar-thumb { background: var(--cnc-border); border-radius: 2px; }

/* Wrapper per bericht */
.cnc-message-wrapper {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cnc-message-wrapper.user { align-items: flex-end; }
.cnc-message-wrapper.bot  { align-items: flex-start; }

/* Naam + tijd */
.cnc-message-meta {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 4px;
}

.cnc-message-wrapper.user .cnc-message-meta { flex-direction: row-reverse; }

.cnc-sender {
  font-size: 12px;
  font-weight: 600;
  color: #555;
}

.cnc-time {
  font-size: 11px;
  color: #aaa;
}

.cnc-message {
  max-width: 72%;
  padding: 12px 16px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.cnc-message.user {
  background: var(--cnc-user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cnc-message.bot {
  background: var(--cnc-bot-bubble);
  color: var(--cnc-text);
  border-bottom-left-radius: 4px;
}

.cnc-message.bot a {
  color: var(--cnc-primary);
  text-decoration: underline;
}

/* Markdown opmaak in berichten */
.cnc-h1, .cnc-h2, .cnc-h3 {
  display: block;
  font-weight: 700;
  margin: 10px 0 2px;
  line-height: 1.3;
}

.cnc-h1 { font-size: 15px; }
.cnc-h2 { font-size: 14.5px; }
.cnc-h3 { font-size: 14px; }

.cnc-h1:first-child,
.cnc-h2:first-child,
.cnc-h3:first-child { margin-top: 0; }

.cnc-li {
  display: block;
  padding-left: 14px;
  position: relative;
  line-height: 1.5;
  margin: 1px 0;
}

.cnc-li::before {
  content: '·';
  position: absolute;
  left: 4px;
  color: var(--cnc-primary);
  font-weight: 700;
}

/* Bronnen */
.cnc-sources {
  margin-top: 10px;
  padding-top: 10px;
  border-top: 1px solid rgba(0,0,0,0.08);
}

.cnc-sources-label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: #999;
  margin-bottom: 6px;
}

.cnc-sources-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.cnc-sources-list li a {
  display: block;
  font-size: 12px;
  color: var(--cnc-primary) !important;
  text-decoration: none !important;
  font-weight: 500;
  padding: 4px 8px;
  border-radius: 6px;
  background: rgba(61, 170, 122, 0.08);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.15s;
}

.cnc-sources-list li a:hover {
  background: rgba(61, 170, 122, 0.18) !important;
  text-decoration: none !important;
}

/* Suggestievragen */
.cnc-suggestions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 4px 0;
}

.cnc-suggestion-btn {
  background: #fff;
  border: 1.5px solid var(--cnc-primary);
  color: var(--cnc-primary);
  border-radius: 10px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  text-align: left;
  transition: background 0.15s, color 0.15s;
  font-family: var(--cnc-font);
}

.cnc-suggestion-btn:hover {
  background: var(--cnc-primary);
  color: #fff;
}

/* Contactknop in bot-antwoord */
.cnc-contact-btn {
  display: inline-block;
  margin-top: 10px;
  padding: 7px 14px;
  background: var(--cnc-primary);
  color: #fff !important;
  text-decoration: none !important;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  transition: background 0.15s;
}

.cnc-contact-btn:hover {
  background: var(--cnc-primary-dark) !important;
}

/* Typing indicator */
.cnc-typing {
  align-self: flex-start;
  display: flex;
  gap: 5px;
  padding: 12px 16px;
  background: var(--cnc-bot-bubble);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
}

.cnc-typing span {
  width: 8px;
  height: 8px;
  background: #aaa;
  border-radius: 50%;
  animation: cncBounce 1.2s infinite ease-in-out;
}

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

@keyframes cncBounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* Reply knop */
.cnc-message-wrapper {
  position: relative;
}

/* Bubbel + knop naast elkaar */
.cnc-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  width: 100%;
}

.cnc-message-wrapper.user .cnc-bubble-row {
  flex-direction: row-reverse;
  justify-content: flex-start;
}

.cnc-reply-btn {
  opacity: 0;
  pointer-events: none;
  background: none;
  border: none;
  width: 20px;
  height: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.15s;
  padding: 0;
  flex-shrink: 0;
}

.cnc-message-wrapper:hover .cnc-reply-btn {
  opacity: 1;
  pointer-events: auto;
}

.cnc-reply-btn svg { width: 14px; height: 14px; stroke: #aaa; pointer-events: none; }

/* Nieuwe sessie bevestiging */
.cnc-confirm-banner {
  margin: 4px 0;
  padding: 12px 14px;
  background: #fff8e1;
  border: 1px solid #ffe082;
  border-radius: 12px;
  align-self: center;
  width: 90%;
  text-align: center;
}

.cnc-confirm-banner p {
  font-size: 13px;
  color: #555;
  margin: 0 0 10px;
}

.cnc-confirm-banner .cnc-confirm-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

.cnc-confirm-banner button {
  flex: 1;
  padding: 7px 10px;
  border-radius: 8px;
  border: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
}

.cnc-confirm-banner .btn-confirm {
  background: var(--cnc-primary);
  color: #fff;
}

.cnc-confirm-banner .btn-confirm:hover { background: var(--cnc-primary-dark); }

.cnc-confirm-banner .btn-cancel {
  background: #f0f0f0;
  color: #444;
}

.cnc-confirm-banner .btn-cancel:hover { background: #e0e0e0; }

/* Reply preview boven invoerveld */
.cnc-reply-preview {
  display: none;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  background: #f7f7f7;
  border-top: 1px solid var(--cnc-border);
}

.cnc-reply-bar {
  width: 3px;
  min-width: 3px;
  height: 36px;
  background: var(--cnc-primary);
  border-radius: 3px;
  flex-shrink: 0;
}

.cnc-reply-content {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.cnc-reply-sender {
  font-size: 12px;
  font-weight: 700;
  color: var(--cnc-primary);
}

.cnc-reply-text {
  font-size: 12px;
  color: #888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.cnc-reply-cancel {
  background: none;
  border: none;
  cursor: pointer;
  color: #bbb;
  font-size: 20px;
  line-height: 1;
  padding: 0;
  flex-shrink: 0;
  transition: color 0.15s;
}

.cnc-reply-cancel:hover { color: #555; }

/* Invoerveld */
#cncware-chatbot-input-area {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 14px 16px;
  border-top: 1px solid var(--cnc-border);
  background: var(--cnc-bg);
  flex-shrink: 0;
}

#cncware-chatbot-input {
  flex: 1;
  border: 1.5px solid var(--cnc-border);
  border-radius: 14px;
  padding: 11px 16px;
  font-size: 14px;
  font-family: var(--cnc-font);
  resize: none;
  outline: none;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.2s;
  line-height: 1.5;
  background: #fafafa;
  scrollbar-width: none;
}

#cncware-chatbot-input::-webkit-scrollbar {
  display: none;
}

#cncware-chatbot-input:focus {
  border-color: var(--cnc-primary);
  background: #fff;
}

#cncware-chatbot-send {
  width: 44px;
  height: 44px;
  min-width: 44px;
  border-radius: 14px;
  background: var(--cnc-primary);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
  outline: none;
  box-shadow: none;
}

#cncware-chatbot-send:hover { background: var(--cnc-primary-dark); transform: scale(1.04); }
#cncware-chatbot-send:disabled { background: #ccc; cursor: not-allowed; box-shadow: none; transform: none; }

#cncware-chatbot-send svg {
  width: 18px;
  height: 18px;
}

/* Uitgevouwen modus */
#cncware-chatbot-window.cnc-expanded {
  position: fixed;
  bottom: 0;
  right: 0;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  border-radius: 0;
  z-index: 99999;
}

/* Mobiel */
@media (max-width: 480px) {
  #cncware-chatbot-container {
    bottom: 16px;
    right: 16px;
  }

  #cncware-chatbot-window {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 85vh;
    border-radius: var(--cnc-radius) var(--cnc-radius) 0 0;
  }
}
