:root {
  --bg: #0f1218;
  --panel: #171b22;
  --text: #e6e6e6;
  --muted: #9aa4b2;
  --accent: #0a84ff;
  --border: #232a36;
  --danger: #e63946;
  --log-api: #0a84ff;
  --log-db: #30a46c;
  --log-ai: #f5a524;
  --log-fix: #c2508c;
  --log-error: #e63946;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  margin: 0;
  display: flex;
  flex-direction: column; /* Hoofd-as is verticaal */
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
  overflow: hidden; 
}

/* Header (blijft gelijk) */
#app-header {
  flex-shrink: 0;
  width: 100%;
  margin: 0 auto;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  border-bottom: 1px solid var(--border);
  background: var(--bg);
  z-index: 20;
}
#app-header .brand {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  text-decoration: none;
  color: var(--text);
}
.brand-logo { height: 28px; width: auto; display: block; }
.brand-title { font-weight: 700; font-size: 16px; }


/* Project Controls (blijft gelijk) */
#project-controls-container {
  flex-shrink: 0;
  width: 100%;
  background: var(--panel);
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  z-index: 10;
}
.project-controls-grid {
  display: grid;
  grid-template-columns: 1fr auto 1fr auto;
  gap: 10px;
  max-width: 1200px;
  margin: 0 auto;
}
#project-controls-container select,
#project-controls-container input,
#project-controls-container button {
  padding: 8px 12px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: var(--bg);
  color: var(--text);
  font-family: inherit;
  font-size: 14px;
  height: 40px;
}
#project-controls-container button {
  cursor: pointer;
  background: #273247;
}
#project-controls-container button:hover {
  background: #3a4862;
}
#project-controls-container input {
  min-width: 200px;
}

/* === NIEUWE CONTENT WRAPPER === */
#main-content-wrapper {
  flex: 1; /* Neemt alle resterende hoogte */
  display: flex;
  flex-direction: row; /* Verdeel chat en terminal horizontaal */
  overflow: hidden;
  width: 100%;
}


/* Hoofdcontainer (AANGEPAST) */
#chat-container {
  flex: 1 1 65%; /* Chat neemt 65% */
  /* max-width: 900px;  Verwijderd */
  /* margin: 0 auto; Verwijderd */
  width: 100%;
  padding: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden; /* Belangrijk voor layout */
  border-right: 1px solid var(--border);
}

/* === NIEUW: TERMINAL CONTAINER === */
#terminal-container {
  flex: 1 1 35%; /* Terminal neemt 35% */
  display: flex;
  flex-direction: column;
  background: #0c0e12; /* Iets donkerder dan panel */
  overflow: hidden;
}
#terminal-header {
  flex-shrink: 0;
  padding: 12px 16px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-weight: 600;
}
#clear-log-button {
  padding: 4px 8px;
  font-size: 12px;
  background: #3a4862;
  border: none;
  border-radius: 6px;
  color: var(--text);
  cursor: pointer;
}
#clear-log-button:hover { background: var(--danger); }

#terminal-log {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 12px;
  line-height: 1.6;
  white-space: pre-wrap; /* Zorgt dat lange regels afbreken */
  word-wrap: break-word;
  color: var(--muted);
}
#terminal-log .log-line {
  margin-bottom: 2px;
  display: block;
}
/* Kleurcodering voor logs */
.log-api { color: var(--log-api); }
.log-db { color: var(--log-db); }
.log-ai { color: var(--log-ai); }
.log-fix { color: var(--log-fix); }
.log-error { color: var(--log-error); font-weight: bold; }
.log-api-response, .log-ai-response { color: var(--muted); opacity: 0.8; }


/* Iframe (blijft verborgen) */
#iframe-container {
  display: none; 
}


/* Chatbox (blijft gelijk) */
#chat-box {
  flex: 1;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 16px;
  overflow-y: auto;
  margin-bottom: 12px;
}

/* Berichten (blijft gelijk) */
.message { margin: 0 0 14px 0; padding: 0; line-height: 1.55; }
.message.user { text-align: right; }
.message.user p {
  display: inline-block;
  background: #1f2733;
  border: 1px solid var(--border);
  color: var(--text);
  padding: 10px 12px;
  border-radius: 10px;
  max-width: 80%;
  word-wrap: break-word;
  text-align: left;
}
.message.user .user-image-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 8px;
  margin-bottom: 8px;
  max-width: 250px;
  display: inline-block;
  line-height: 0;
}
.message.user .user-image { display: block; max-width: 100%; max-height: 250px; }
.message.user .user-image-wrapper.scanning::after {
  content: '';
  position: absolute;
  left: 0;
  width: 100%;
  height: 3px;
  background: linear-gradient(90deg, transparent, var(--accent), transparent);
  box-shadow: 0 0 8px var(--accent);
  z-index: 1;
  animation: scan-animation-fixed 2s infinite ease-in-out;
}
@keyframes scan-animation-fixed {
  0% { top: 0; }
  50% { top: calc(100% - 3px); }
  100% { top: 0; }
}

/* AI content (blijft gelijk) */
.message.ai { max-width: 100%; }
.message.ai p { margin: 8px 0; }
.message.ai ul, .message.ai ol { margin: 8px 0 8px 22px; }
.message.ai h1, .message.ai h2, .message.ai h3 { margin: 14px 0 8px; line-height: 1.25; }
.message.ai a { color: #8ab4ff; text-decoration: none; }
.message.ai a:hover { text-decoration: underline; }
.message.ai table { border-collapse: collapse; width: 100%; margin: 10px 0; }
.message.ai table th, .message.ai table td { border: 1px solid var(--border); padding: 6px 8px; }
.message.ai blockquote {
  margin: 8px 0; padding: 6px 10px; border-left: 3px solid var(--accent);
  background: #121722; color: var(--muted);
}
.message.ai code {
  background: #1b2230; padding: 0.12rem 0.35rem; border-radius: 4px;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", monospace;
  font-size: 0.95em;
}
.message.ai pre {
  position: relative;
  background: #0f1320;
  border: 1px solid var(--border);
  padding: 12px;
  border-radius: 10px;
  overflow: auto;
  white-space: pre;
  -webkit-font-smoothing: auto;
}
.message.ai pre code { background: transparent; padding: 0; }
.copy-button {
  position: absolute;
  top: 8px;
  right: 8px;
  border: 1px solid var(--border);
  background: #202835;
  color: var(--text);
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
}
.copy-button:hover { background: #273247; }


/* Preview Container (blijft gelijk) */
#image-preview-container {
  flex-shrink: 0;
  position: relative;
  width: fit-content;
  max-width: 100%;
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 10px;
  
  opacity: 0;
  max-height: 0px;
  padding-top: 0px;
  padding-bottom: 0px;
  margin-bottom: 0px;
  border-width: 0px;
  transform: scale(0.95);
  transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}
#image-preview-container.visible {
  opacity: 1;
  max-height: 200px;
  padding-top: 8px;
  padding-bottom: 8px;
  margin-bottom: 12px;
  border-width: 1px;
  transform: scale(1);
}
#image-preview { display: block; max-width: 100%; max-height: 150px; border-radius: 6px; }
#remove-image-btn {
  position: absolute;
  top: -12px;
  right: -12px;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  font-size: 18px;
  font-weight: bold;
  cursor: pointer;
  line-height: 26px;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0,0,0,0.3);
}


/* Input-container (blijft gelijk) */
#input-container {
  flex-shrink: 0;
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: 8px;
  align-items: center;
  position: relative; 
  z-index: 10;    
}
#user-input {
  width: 100%;
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--text);
  outline: none;
  font-family: inherit;
  font-size: 100%;
  line-height: 1.5;
  resize: none;
  overflow-y: hidden;
  min-height: 48px;
  box-sizing: border-box;
}
#user-input::placeholder { color: #6b7280; }

/* Microfoonknop (blijft gelijk) */
#mic-button {
  padding: 12px 14px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--panel);
  color: var(--muted);
  cursor: pointer;
  align-self: end;
  min-height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}
#mic-button:hover { background: #273247; color: var(--text); }
#mic-button.recording {
  background: var(--danger);
  color: white;
  animation: pulse-animation 1.5s infinite;
}

/* Send knop (blijft gelijk) */
#send-button {
  padding: 12px 16px;
  border-radius: 10px;
  border: 1px solid var(--border);
  background: var(--accent);
  color: #fff;
  cursor: pointer;
  font-weight: 600;
  align-self: end;
  min-height: 48px;
  transition: filter 0.2s ease-in-out, background-color 0.2s ease-in-out;
}
#send-button:hover { filter: brightness(0.95); }
#send-button:disabled { background: var(--muted); cursor: not-allowed; filter: none; }

@keyframes pulse-animation {
  0% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0.7); }
  70% { box-shadow: 0 0 0 10px rgba(229, 57, 53, 0); }
  100% { box-shadow: 0 0 0 0 rgba(229, 57, 53, 0); }
}


/* Scrollbars (AANGEPAST: nu ook voor terminal) */
#chat-box::-webkit-scrollbar,
#terminal-log::-webkit-scrollbar { 
  height: 10px; 
  width: 10px; 
}
#chat-box::-webkit-scrollbar-thumb,
#terminal-log::-webkit-scrollbar-thumb { 
  background: #2a3344; 
  border-radius: 10px; 
}


/* Cursor (blijft gelijk) */
.blinking-cursor {
  display: inline-block;
  width: 10px;
  height: 1.1em;
  background: var(--accent);
  margin-left: 4px;
  vertical-align: middle;
  border-radius: 1px;
  animation: 
    blink 1s step-end infinite,
    trail-fade 1.5s linear infinite;
}
@keyframes blink {
  from, to { opacity: 1; }
  50% { opacity: 0; }
}
@keyframes trail-fade {
  0% { 
    box-shadow: 0 0 4px var(--accent), 0 0 8px var(--accent);
    opacity: 1;
  }
  50% {
    box-shadow: 0 0 15px 10px var(--accent), 0 0 25px 20px rgba(10, 132, 255, 0.5);
  }
  100% { 
    box-shadow: 0 0 30px 25px rgba(10, 132, 255, 0), 0 0 40px 35px rgba(10, 132, 255, 0); 
    opacity: 0;
  }
}

/* Approval Knoppen (blijft gelijk) */
.approval-buttons { 
  margin-top: 15px; 
  border-top: 1px solid var(--border); 
  padding-top: 15px; 
  background: var(--panel);
}
.approval-buttons p {
    margin: 0 0 10px 0;
    font-weight: bold;
}
.approval-buttons button {
  padding: 8px 12px; 
  margin-right: 10px; 
  cursor: pointer; 
  border-radius: 8px; 
  border: none;
  font-weight: 600;
}
button.confirm-fix { background-color: #28a745; color: white; }
button.cancel-fix { background-color: #dc3545; color: white; }
.approval-buttons em { color: var(--muted); }