/* ========== RESET ========== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}
/* BODY font-family is normaal gesproken door het thema gezet */
.chat-input.disabled textarea,
.chat-input.disabled button {
  background: #eaeaea;
  cursor: not-allowed;
  color: #999;
  pointer-events: none;
}
/* ===== DRAGGABLE LAUNCHER KNOP ===== */
#chatLauncher {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: linear-gradient(to bottom right, #ff8000, #c83200);
  color: #fff;
  font-size: 24px;
  display: flex; /* Zorg dat het initieel zichtbaar is om te testen */
  align-items: center;
  justify-content: center;
  cursor: move;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.2);
  z-index: 9999;
  user-select: none;
  transition: width 0.3s ease, height 0.3s ease, bottom 0.3s ease, right 0.3s ease;
}
/* ===== CHAT-CONTAINER ===== */
.chat-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  width: 420px;
  height: 575px;
  background: #fff;
  border-radius: 10px;
  border: 1px solid #ccc;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 9998;
}
.chat-container.hidden {
  display: none;
}
.chat-container.fullscreen {
  width: 95vw;
  height: 95vh;
  bottom: 2.5vh;
  right: 2.5vw;
}
/* ===== HEADER ===== */
.chat-header {
  background: #ff8000;
  color: #fff;
  padding: 6px 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top-left-radius: 10px;
  border-top-right-radius: 10px;
}
.chat-header-left {
  display: flex;
  align-items: center;
}
.chat-header-right i {
  color: white;
  font-size: 18px;
  transition: color 0.2s;
  margin-left: 8px;
  cursor: pointer; /* Maak iconen klikbaar */
}
.chat-header-right i:hover {
  color: #4682b2;
}
.chat-header-left img {
  width: 28px;
  height: 28px;
  margin-right: 8px;
}
.chat-text-block {
  display: flex;
  flex-direction: column;
  justify-content: center;
  line-height: normal;
}
.chat-caption {
  font-size: 16px;
  font-weight: bold;
}
.chat-title {
  font-size: 13px;
  margin-top: 2px;
  color: #ffe4c2;
}
/* Span wrappers voor iconen, als je specifieke styling per knop wilt toevoegen */
.chat-help, .chat-reset, .chat-maximize, .chat-minimize, .chat-close {
  cursor: pointer;
  user-select: none;
}
.chat-minimize i { font-size: 22px; } /* Voorbeeld van specifieke aanpassing */
.chat-reset i { font-size: 20px; }
/* ===== MESSAGES SCROLL PANEL ===== */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  background: #f8f8f8;
  padding: 10px;
}
/* ===== INPUTBALK ===== */
.chat-input {
  border-top: 1px solid #ddd;
  display: flex;
}
.chat-input textarea {
  flex: 1;
  border: none;
  padding: 10px;
  font-size: 14px;
  outline: none;
  resize: none;
  height: auto; /* Past zich aan, tot max 3 regels is goed idee */
  line-height: 1.4;
  /* min-height: calc(1.4em * 3 + 20px); /* 3 regels + padding */
}
.chat-input textarea::placeholder {
  color: #999;
}
.chat-input button {
  border: none;
  background: #ff8000;
  color: #fff;
  padding: 0 20px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  user-select: none;
}
/* ===== MESSAGES IN BUBBLES ===== */
.message-row {
  display: flex;
  align-items: flex-start; /* Avatar en bubble op één lijn boven */
  margin-bottom: 10px;
}
.message-row.user {
  justify-content: flex-end;
}
.message-bubble {
  max-width: 85%;
  padding: 8px 12px; /* Iets meer padding */
  border-radius: 8px;
  line-height: 1.45; /* Iets meer ruimte */
  white-space: normal; 
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1); /* Subtielere shadow */
  font-size: 14px;
  background: #e9e9eb; /* Iets lichter grijs */
}
.message-bubble pre {
  position: relative;
  background: #2d2d2d; /* Donkerder voor code blocks */
  color: #f8f8f2;     /* Lichte tekst voor code blocks */
  padding: 12px 15px;
  border-radius: 6px;
  font-size: 0.9em; /* Iets kleiner voor code */
  overflow-x: auto;
  margin: 10px 0;
  white-space: pre-wrap; /* behoudt structuur van codeblocks */
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace; /* Betere monospace fonts */
}
.message-bubble pre code {
  font-family: inherit; /* Gebruik font van pre */
  background: none; /* Geen extra achtergrond voor code in pre */
  padding: 0;       /* Geen extra padding */
  font-size: inherit; /* Gebruik grootte van pre */
  color: inherit;     /* Gebruik kleur van pre */
}
.copy-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: #555;
  border: none;
  color: white;
  font-size: 10px; /* Kleiner */
  padding: 3px 6px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0.7;
  transition: opacity 0.2s;
}
.message-bubble pre:hover .copy-btn {
  opacity: 1;
}
.copy-btn:hover {
  background: #777;
}
.message-row.user .message-bubble {
  background: linear-gradient(to right, #f8ce6e, #ff8000);
  color: #fff;
  border-bottom-right-radius: 0;
  margin-right: 5px; /* Consistentie met avatar margin */
}


/* ====== Systeem bericht ====== */
.message-row.system .message-bubble {
  background: #f5f5f5; /* Neutraal grijs */
  color: #555;
  font-style: italic;
  font-size: 0.9em; /* Iets kleiner */
  border: 1px dashed #ccc;
  margin: 0 auto 10px auto; /* Gecentreerd, volledige breedte (min avatar) */
  width: calc(100% - 44px); /* Ruimte voor avatar als die er zou zijn, of aanpassen */
  max-width: 90%; /* Of een andere max-width */
  box-shadow: none;
}
.message-row.system .message-bubble strong { font-style: normal; } /* Commands niet italic */
.message-row.system .message-bubble button {
  margin: 8px 4px 0 4px; /* Iets meer ruimte */
  padding: 6px 12px;
  border: none;
  border-radius: 4px;
  background-color: #ff8000;
  color: white;
  cursor: pointer;
  font-size: 13px; /* Consistent met tekst */
  font-style: normal;
}
.message-row.system .message-bubble button:hover {
  background-color: #c83200;
}
/* ===== AVATARS ===== */
.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-right: 8px;
  object-fit: cover;
  flex-shrink: 0; /* Voorkom dat avatar krimpt */
}
.message-row.user .avatar {
  display: none; /* Geen avatar voor gebruiker */
}
.message-row.bot .avatar,
.message-row.system .avatar { /* Avatar voor bot en systeem */
  display: block;
}
/* ===== TYPING INDICATOR ===== */
.typing-indicator { /* Ziet eruit als een bot message bubble */
  display: inline-block;
  background: #e9e9eb;
  color: #333;
  border-radius: 8px;
  padding: 8px 12px;
  margin-bottom: 0; /* Is al onderdeel van message-row die margin-bottom heeft */
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  border-bottom-left-radius: 0;
}
/* message-row.bot #typingId .message-bubble (als je het in een bubble wilt) */
/* of een aparte .typing-row */
.dot {
  display: inline-block;
  width: 7px; /* Iets groter */
  height: 7px;
  margin: 0 2.5px;
  border-radius: 50%;
  background: #777; /* Donkerder grijs */
  animation: blink 1.2s infinite alternate;
}
.dot:nth-child(2) {
  animation-delay: 0.25s;
}
.dot:nth-child(3) {
  animation-delay: 0.5s;
}
@keyframes blink {
  to {
    opacity: 0.3;
  }
}
.chat-disclaimer {
  font-size: 11px; /* Kleiner */
  color: #777; /* Gedempter */
  padding: 8px 10px;
  text-align: center;
  background-color: #f8f8f8; /* Achtergrond passend bij messages */
  border-top: 1px solid #ddd;
}
/* ========== Markdown styling (in message-bubble) ========== */
.message-bubble h1,
.message-bubble h2,
.message-bubble h3,
.message-bubble h4,
.message-bubble h5,
.message-bubble h6 {
  font-weight: bold;
  margin: 12px 0 6px 0; /* Meer margin boven */
  line-height: 1.3;
}
.message-bubble h1 { font-size: 1.4em; }
.message-bubble h2 { font-size: 1.3em; }
.message-bubble h3 { font-size: 1.2em; }
.message-bubble h4 { font-size: 1.1em; }
.message-bubble ul,
.message-bubble ol {
  margin: 10px 0px 10px 20px; /* Standaard browser indent */
  padding-left: 15px; /* Extra padding voor markers binnen de bubble */
  list-style-position: outside; /* Markers buiten de tekstflow */
}
.message-bubble ul li::marker { color: #ff8000; font-weight: bold; } /* Kleur voor ul markers */
.message-bubble ol li::marker { color: #c83200; font-weight: bold; } /* Kleur voor ol markers */
.message-bubble li {
  margin: 4px 0;
  padding-left: 0; /* Geen extra padding hier als list-style-position outside is */
}
.message-bubble blockquote {
  border-left: 3px solid #ff8000; /* Oranje accent */
  padding: 8px 12px;
  margin: 10px 0;
  color: #555;
  background: #f9f9f9; /* Lichte achtergrond voor quote */
  font-style: italic;
}
.message-bubble code:not(pre code) { /* Inline code */
  background-color: rgba(255, 128, 0, 0.1); /* Zeer lichte oranje achtergrond */
  color: #c83200; /* Donkeroranje tekst */
  padding: 2px 5px;
  border-radius: 4px;
  font-family: 'SFMono-Regular', Consolas, 'Liberation Mono', Menlo, Courier, monospace;
  font-size: 0.9em;
}
.message-bubble table {
  border-collapse: collapse;
  margin: 15px 0;
  width: 100%;
  font-size: 0.95em;
}
.message-bubble th,
.message-bubble td {
  border: 1px solid #ddd;
  padding: 8px 10px;
  text-align: left;
}
.message-bubble th {
  background-color: #f2f2f2; /* Lichte header voor tabel */
  font-weight: bold;
}
.message-bubble img {
  max-width: 100%;
  height: auto;
  border-radius: 6px; /* Iets rondere hoeken */
  margin: 10px 0;
  border: 1px solid #eee; /* Subtiele rand */
}
.message-bubble a {
  color: #0066cc; /* Standaard link kleur */
  text-decoration: underline;
}
.message-bubble a:hover {
  text-decoration: none;
}
.message-bubble hr {
  border: none;
  border-top: 1px solid #ddd;
  margin: 15px 0;
}
.chat-container .message-bubble p,
.chat-container .message-bubble ul,
.chat-container .message-bubble ol,
.chat-container .message-bubble dl {
  margin-top: 0 !important;
  margin-bottom: 0 !important;
}
