/* ==========================================================================
   Chat Interface & Timeline Styling
   ========================================================================== */

/* Hauptcontainer für die Chat-Ansicht */
.chat_main_container {
  display: flex;
  flex-direction: column;
  height: 100%;
  box-sizing: border-box;
  background-color: #ffffff;
}

/* Header-Bereich */
.chat_header {
  padding: 12px 16px;
  border-bottom: 1px solid #e1e4e8;
  background-color: #f6f8fa;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.chat_title {
  font-size: 16px;
  font-weight: 600;
  color: #24292e;
}

/* Scrollbare Message-Timeline */
.timeline_scroll {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background-color: #fafbfc;
}

/* Nachrichten-Bubbles (Basis) */
.chat_bubble {
  max-width: 80%;
  padding: 12px 16px;
  border-radius: 8px;
  box-sizing: border-box;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
  text-align: left;
}

/* User-Nachricht (rechts ausgerichtet oder farblich abgesetzt) */
.bubble_user {
  align-self: flex-end;
  background-color: #0366d6;
  color: #ffffff;
  border-bottom-right-radius: 2px;
}

.bubble_user .msg_sender {
  color: #c8e1ff;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 12px;
  text-align: left;
}

.bubble_user .msg_body {
  color: #ffffff;
}

/* Assistant / Navigator-Nachricht (links) */
.bubble_assistant {
  align-self: flex-start;
  background-color: #ffffff;
  color: #24292e;
  border: 1px solid #e1e4e8;
  border-bottom-left-radius: 2px;
}

.bubble_assistant .msg_sender {
  color: #586069;
  font-weight: 600;
  margin-bottom: 4px;
  font-size: 12px;
  text-align: left;
}

.bubble_assistant .msg_body {
  color: #24292e;
}

/* Tool Output (neutral / dezent) */
.bubble_tool {
  align-self: center;
  background-color: #f1f8ff;
  color: #0366d6;
  border: 1px solid #c8e1ff;
  font-family: monospace;
  font-size: 13px;
  width: 90%;
}

/* Thought Process / Reasoning Block (für LLM-Gedanken) */
.thought_block {
  background-color: #fffbdd;
  border-left: 3px solid #f1e05a;
  padding: 8px 12px;
  margin-bottom: 8px;
  font-size: 12px;
  color: #555555;
  border-radius: 4px;
  font-style: italic;
  white-space: pre-wrap;
  text-align: left;
}

/* Untere Eingabeleiste (UIForm Container) */
.chat_input_bar {
  padding: 12px 16px;
  border-top: 1px solid #e1e4e8;
  background-color: #f6f8fa;
  display: flex;
  gap: 10px;
  align-items: flex-end;
}

.chat_input_bar textarea {
  flex: 1;
  resize: none;
  padding: 8px 12px;
  border: 1px solid #d1d5da;
  border-radius: 4px;
  font-family: inherit;
  font-size: 14px;
  outline: none;
  background-color: #ffffff;
}

.chat_input_bar textarea:focus {
  border-color: #0366d6;
  box-shadow: 0 0 0 3px rgba(3, 102, 214, 0.3);
}

.chat_input_bar button {
  padding: 8px 16px;
  font-weight: 600;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid #d1d5da;
}

/* ==========================================================================
   Markdown Content Styling inside Bubbles (Overrides p { color: green; })
   ========================================================================== */

/* Überschreibt das globale grüne p aus slui.css und hält den Text linksbündig */
.chat_bubble p,
.msg_body p {
  color: inherit !important;
  text-align: left;
  margin-top: 0;
  margin-bottom: 8px;
  line-height: 1.5;
}

.chat_bubble p:last-child,
.msg_body p:last-child {
  margin-bottom: 0;
}

/* Inline Markdown Formatting */
.chat_bubble b,
.chat_bubble strong {
  font-weight: 700;
  color: inherit;
}

.chat_bubble i,
.chat_bubble em {
  font-style: italic;
  color: inherit;
}

.bubble_user code {
  background-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
}

.chat_bubble a {
  color: inherit;
  text-decoration: underline;
}

.bubble_assistant a {
  color: #0366d6;
}

/* Block Markdown Elements */
.chat_bubble ul,
.chat_bubble ol {
  margin: 6px 0 6px 20px;
  padding: 0;
  color: inherit;
  text-align: left;
}

.chat_bubble li {
  margin-bottom: 3px;
  line-height: 1.4;
}

.chat_bubble h1,
.chat_bubble h2,
.chat_bubble h3 {
  margin: 8px 0 4px 0;
  color: inherit;
  font-weight: 600;
  text-align: left;
}

.chat_bubble h1 { font-size: 1.3em; }
.chat_bubble h2 { font-size: 1.2em; }
.chat_bubble h3 { font-size: 1.1em; }

/* ==========================================================================
   Markdown Tables inside Chat Bubbles
   ========================================================================== */

.chat_bubble table {
  border-collapse: collapse;
  width: 100%;
  margin: 10px 0;
  font-size: 13px;
  background-color: transparent;
}

.chat_bubble th,
.chat_bubble td {
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
  border: 1px solid #d1d5da;
}

/* Tabellen-Header */
.bubble_assistant th {
  background-color: #f1f3f5;
  color: #24292e;
  font-weight: 600;
  border-bottom: 2px solid #cbd5e1;
}

.bubble_user th {
  background-color: rgba(255, 255, 255, 0.15);
  color: #ffffff;
  font-weight: 600;
  border-color: rgba(255, 255, 255, 0.3);
}

/* Zeilen & Hover */
.bubble_assistant tr:nth-child(even) {
  background-color: #f8f9fa;
}

.bubble_assistant tr:hover {
  background-color: #eef2f6;
}

.bubble_user td {
  border-color: rgba(255, 255, 255, 0.25);
}

.bubble_user tr:nth-child(even) {
  background-color: rgba(255, 255, 255, 0.08);
}

/* ==========================================================================
   Code & Preformatted Blocks inside Chat Bubbles
   ========================================================================== */

/* 1. Mehrzeilige Code-Blöcke (<pre>) */
.chat_bubble pre {
  margin: 10px 0;
  padding: 12px 14px;
  border-radius: 6px;
  overflow-x: auto; /* Horizontales Scrollen bei sehr langen Zeilen */
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 12.5px;
  line-height: 1.45;
  tab-size: 2;
  box-sizing: border-box;
}

/* Assistant-Bubble: Dunkler oder dezent grauer Editor-Look */
.bubble_assistant pre {
  background-color: #1e1e1e !important; /* VS Code / Dark Style */
  color: #d4d4d4 !important;
  border: 1px solid #333333;
}

/* User-Bubble: Subtiler transparenter Look passend zum Bubble-Theme */
.bubble_user pre {
  background-color: rgba(0, 0, 0, 0.25) !important;
  color: #f8f9fa !important;
  border: 1px solid rgba(255, 255, 255, 0.2);
}

/* <code> innerhalb von <pre> neutralisieren */
.chat_bubble pre code {
  background-color: transparent !important;
  color: inherit !important;
  padding: 0 !important;
  border: none !important;
  border-radius: 0 !important;
  font-size: inherit !important;
  white-space: pre; /* Behält Einrückungen und Zeilenumbrüche exakt bei */
  word-break: normal;
}

/* 2. Inline-Code (nur einfaches `code` im Fließtext) */
.chat_bubble :not(pre) > code {
  font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, "Liberation Mono", monospace;
  font-size: 0.88em;
  padding: 2px 5px;
  border-radius: 4px;
  word-break: break-word;
}

/* Inline-Code für Assistant */
.bubble_assistant :not(pre) > code {
  background-color: #eef2f6;
  color: #b83052; /* Dezentes Bordeaux/Rot für schnelles Scannen */
  border: 1px solid #e1e4e8;
}

/* Inline-Code für User */
.bubble_user :not(pre) > code {
  background-color: rgba(255, 255, 255, 0.2);
  color: #ffffff;
  border: 1px solid rgba(255, 255, 255, 0.3);
}

/* 3. Dezenter Scrollbalken für lange Codezeilen */
.chat_bubble pre::-webkit-scrollbar {
  height: 6px;
}

.chat_bubble pre::-webkit-scrollbar-track {
  background: transparent;
}

.bubble_assistant pre::-webkit-scrollbar-thumb {
  background: #4a4a4a;
  border-radius: 3px;
}

.bubble_assistant pre::-webkit-scrollbar-thumb:hover {
  background: #6a6a6a;
}


/* ==========================================================================
   Chat Header Live-Status & Step Telemetry
   ========================================================================== */

/*
.chat_header {
  display: flex !important;
  flex-direction: column !important;
  padding: 8px 16px !important;
  background-color: #f8f9fa !important;
  border-bottom: 1px solid #e1e4e8 !important;
  box-sizing: border-box !important;
}
*/

.chat_header {
  position: -webkit-sticky !important;
  position: sticky !important;
  top: 0 !important;
  z-index: 10 !important;
  display: flex !important;
  flex-direction: column !important;
  padding: 8px 16px !important;
  background-color: #f8f9fa !important;
  border-bottom: 1px solid #e1e4e8 !important;
  box-sizing: border-box !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.08);
}

.chat_header_top {
  display: flex;
  flex-direction: row;
  justify-content: space-between;
  align-items: center;
  width: 100%;
}

.chat_status_container {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

/* Status-Badges */
.status_badge {
  display: inline-block;
  padding: 3px 8px;
  font-size: 11px;
  font-weight: bold;
  border-radius: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.status_idle {
  background-color: #e9ecef;
  color: #495057;
  border: 1px solid #ced4da;
}

.status_wait {
  background-color: #fff3cd;
  color: #856404;
  border: 1px solid #ffeeba;
  animation: pulse_wait 1.5s infinite;
}

.status_running {
  background-color: #cce5ff !important;
  color: #004085 !important;
  border: 1px solid #70b0ff !important;
  animation: pulse_running 1.2s ease-in-out infinite !important;
}

@keyframes pulse_running {
  0% {
    opacity: 0.6;
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4);
  }
  50% {
    opacity: 1.0;
    box-shadow: 0 0 8px 2px rgba(0, 123, 255, 0.5);
  }
  100% {
    opacity: 0.6;
    box-shadow: 0 0 0 0 rgba(0, 123, 255, 0.4);
  }
}

.status_cancelled {
  background-color: #ffe8d6;
  color: #d9480f;
  border: 1px solid #ffd8a8;
}

.status_error {
  background-color: #f8d7da;
  color: #721c24;
  border: 1px solid #f5c6cb;
}

@keyframes pulse_wait {
  0% { opacity: 0.6; }
  50% { opacity: 1.0; }
  100% { opacity: 0.6; }
}

/* Step-Activity Bar */
.chat_step_bar {
  display: flex;
  align-items: center;
  width: 100%;
  margin-top: 4px;
}

.step_activity_text {
  font-size: 12px !important;
  color: #6c757d !important;
  font-family: Consolas, "Courier New", monospace;
}

/* Details Toggle Button */
.btn_header_toggle {
  background: transparent !important;
  border: 1px solid #ced4da !important;
  color: #495057 !important;
  padding: 2px 8px !important;
  font-size: 11px !important;
  border-radius: 3px !important;
  cursor: pointer;
}

.btn_header_toggle:hover {
  background-color: #e2e6ea !important;
}

/* Details Drawer */
.chat_details_drawer {
  width: 100%;
  max-height: 120px;
  overflow-y: auto;
  margin-top: 6px;
  padding: 6px 10px;
  background-color: #ffffff;
  border: 1px solid #dcdcdc;
  border-radius: 4px;
  box-sizing: border-box;
}

.details_raw_text {
  font-family: Consolas, monospace !important;
  font-size: 11px !important;
  color: #333333 !important;
  white-space: pre-wrap;
  word-break: break-all;
}

