/* ==========================================================================
   Test-chat widget
   ========================================================================== */
.test-chat-messages {
  max-height: 14rem;
  overflow-y: auto;
  overflow-x: hidden;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
  padding: 0.5rem;
  background: var(--color-surface-muted);
  border-radius: var(--radius-md);
  margin-bottom: 0.5rem;
}
.test-chat-bubble {
  max-width: 85%;
  padding: 0.4rem 0.65rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  white-space: pre-wrap;
}
.test-chat-user {
  align-self: flex-end;
  background: var(--color-primary);
  color: var(--color-on-primary);
}
.test-chat-assistant {
  align-self: flex-start;
  background: var(--color-border);
  color: var(--color-text);
}

/* --- Smart-диалоги: account picker (avatar + name + phone/username) --- */
.dialogue-account-card {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.4rem 0.9rem 0.4rem 0.4rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--color-border);
  background: var(--color-surface);
  text-decoration: none;
  color: inherit;
  max-width: 18rem;
}
.dialogue-account-card:hover { background: var(--color-surface-muted); }
.dialogue-account-card-active {
  border-color: var(--color-primary);
  background: color-mix(in srgb, var(--color-primary) 10%, var(--color-surface));
}

/* --- Smart-диалоги: two-pane inbox (dialog list + live thread) --- */
.dialogue-shell {
  display: flex;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  overflow: hidden;
  height: calc(100vh - 15rem);
  min-height: 26rem;
  background: var(--color-surface);
}
.dialogue-list-pane {
  width: 17rem;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--color-border);
  min-width: 0;
}
.dialogue-list-scroll { flex: 1; overflow-y: auto; overflow-x: hidden; }
.dialogue-row {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.65rem 0.75rem;
  text-decoration: none;
  color: inherit;
  border-bottom: 1px solid var(--color-border);
}
.dialogue-row:hover { background: var(--color-surface-muted); }
.dialogue-row-active { background: var(--color-surface-muted); box-shadow: inset 3px 0 0 var(--color-primary); }
.dialogue-thread-pane {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}
.dialogue-messages {
  flex: 1;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1.25rem 1.1rem;
  display: flex;
  flex-direction: column;
  background: var(--color-bg);
}
.dialogue-bubble-row {
  display: flex;
  align-items: flex-start; /* prevents the bubble from stretching to fill the row's cross-axis */
  margin-top: 0.85rem;
  width: 100%;
}
.dialogue-bubble-row:first-child { margin-top: 0; }
.dialogue-bubble-row-grouped { margin-top: 0.2rem; }
.dialogue-bubble-row-out { justify-content: flex-end; }
.dialogue-bubble {
  display: inline-block;
  max-width: 66%;
  width: fit-content;
  height: auto;
  padding: 0.5rem 0.8rem 0.35rem;
  border-radius: 1.1rem;
  font-size: 0.875rem;
  font-weight: 400;
  line-height: 1.48;
}
.dialogue-bubble-in {
  background: var(--color-surface);
  color: var(--color-text);
  border: 1px solid var(--color-border);
  border-bottom-left-radius: 0.3rem;
}
.dialogue-bubble-out {
  background: var(--color-primary);
  color: var(--color-on-primary);
  border-bottom-right-radius: 0.3rem;
}
.dialogue-bubble-tag {
  font-size: 0.7rem;
  font-weight: 500;
  opacity: 0.75;
  margin-bottom: 0.15rem;
}
.dialogue-bubble-text {
  line-height: 1.48;
  font-weight: 400;
  white-space: pre-wrap;
  word-break: break-word;
}
.dialogue-bubble-time {
  font-size: 0.68rem;
  font-weight: 400;
  opacity: 0.6;
  margin-top: 0.25rem;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.dialogue-input-row {
  display: flex;
  gap: 0.5rem;
  padding: 0.75rem;
  border-top: 1px solid var(--color-border);
}
.dialogue-input-row .input { flex: 1; }
.dialogue-search-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  background: var(--color-surface);
}
.dialogue-search-bar .input { flex: 1; }
.dialogue-search-mark {
  background: color-mix(in srgb, var(--color-warning) 55%, transparent);
  color: inherit;
  border-radius: 0.2rem;
  padding: 0 0.05rem;
}
.dialogue-search-mark-active {
  background: var(--color-primary);
  color: var(--color-on-primary);
}
@media (max-width: 720px) {
  .dialogue-shell { flex-direction: column; height: auto; }
  .dialogue-list-pane { width: 100%; border-right: none; border-bottom: 1px solid var(--color-border); flex: none; }
  .dialogue-list-scroll { max-height: 14rem; }
  /* .dialogue-thread-pane's base rule sets flex: 1 (i.e. flex-basis: 0%), which — once
     .dialogue-shell above loses its definite height (auto) in column mode — wins over
     this height and the pane grows to fit its content instead of scrolling within it.
     A conversation with enough history turned this into a 20000px+ page on mobile. */
  .dialogue-thread-pane { height: 28rem; flex: none; }
}
.test-chat-error { color: var(--color-danger) !important; }

