/* Thinking Mode Phase 1 — Unified Reasoning Card
 *
 * One card per user turn. Streams the `reasoning` value extracted
 * from the agent's JSON output char-by-char (the backend does the
 * partial-JSON extraction; here we just append deltas).  Each
 * decider step becomes its own segment inside the card.
 */

.reasoning-card {
  background: transparent;
  border: none;
  border-radius: 10px;
  margin: 8px 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #d6dee8;
  box-shadow: none;
  overflow:visible;
  transition: border-color 0.25s ease;
}

.reasoning-card[data-streaming="true"] {
  border-color: rgba(120, 170, 255, 0.5);
}

.reasoning-card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  cursor: pointer;
  user-select: none;
}

.reasoning-card-header .r-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: rgba(120, 170, 255, 0.12);
  color: #9ec1ff;
  font-size: 13px;
}

.reasoning-card[data-streaming="true"] .r-icon {
  background: rgba(120, 170, 255, 0.22);
  animation: r-pulse 1.4s ease-in-out infinite;
}

@keyframes r-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50%      { transform: scale(1.08); opacity: 0.78; }
}

.reasoning-card-header .r-title {
  font-size: 13px;
  font-weight: 600;
  color: rgb(69 83 103);
  flex: 0 0 auto;
}

.reasoning-card-header .r-preview {
  flex: 1 1 auto;
  font-size: 12px;
  color: rgb(21 62 121);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  font-style: italic;
}

.reasoning-card-header .r-chevron {
  font-size: 11px;
  color: #6a7897;
  transition: transform 0.25s ease;
}

.reasoning-card[data-open="true"] .r-chevron {
  transform: rotate(180deg);
}

.reasoning-card-body {
  display: none;
  padding: 0 14px 12px 14px;
  max-height: 420px;
  overflow-y: auto;
  border-top: 1px solid rgba(255, 255, 255, 0.04);
}

.reasoning-card[data-open="true"] .reasoning-card-body {
  display: block;
}

.reasoning-segment {
  padding: 10px 0 8px 0;
  border-bottom: 1px dashed rgba(255, 255, 255, 0.06);
}

.reasoning-segment:last-child {
  border-bottom: none;
}

.reasoning-segment-meta {
  font-size: 11px;
  color: #6a7897;
  margin-bottom: 4px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.reasoning-segment-meta .r-agent {
  padding: 1px 6px;
  border-radius: 3px;
  background: rgba(120, 170, 255, 0.08);
  color: #9ec1ff;
  font-weight: 600;
}

.reasoning-segment-meta .r-step {
  color: #8a98b2;
}

.reasoning-segment-meta .r-tool {
  color: #d6ae5f;
}

.reasoning-segment-text {
  font-size: 13px;
  line-height: 1.5;
  color: rgb(69 83 103);
  white-space: pre-wrap;
  word-break: break-word;
}

.reasoning-segment[data-streaming="true"] .reasoning-segment-text::after {
  content: "▍";
  margin-left: 1px;
  color: #9ec1ff;
  animation: r-caret 0.85s steps(2) infinite;
}

@keyframes r-caret {
  50% { opacity: 0; }
}

/* RTL */
[dir="rtl"] .reasoning-card-header {
  flex-direction: row-reverse;
}
[dir="rtl"] .reasoning-segment-meta {
  flex-direction: row-reverse;
}



/* --------------------------------------------------------------
   Thinking Mode Phase 2 - Interleaved bot segments
   Each bot bubble's `.bot-segments-container` lays out chronological
   text segments and reasoning cards in a single vertical column.
   -------------------------------------------------------------- */
.bot-segments-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.bot-segment {
  display: block;
}

.bot-segment-text > .message-text {
  /* Inherit existing message-text typography. The wrapper is a
     pure layout slot so multiple text segments stack cleanly. */
}

.bot-segment-text + .bot-segment-text {
  margin-top: 4px;
}

.bot-segment-reasoning,
.bot-segments-container > .reasoning-card {
  margin: 0;
}

[dir="rtl"] .bot-segments-container {
  text-align: right;
}
