/* ==========================================================================
   Общая лента сообщений (public/panel/chat.js, window.APZChat): карточка заявки, «Диалоги», лента CRM.
   Только токены panel.css (светлая и тёмная темы переопределяют их через data-theme), без инлайн-стилей (CSP).
   Клиент слева, помощник слева (акцентный тон), менеджер справа, системные строки по центру без облачка.
   ========================================================================== */

.apz-chat {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-width: 0;
}

.apz-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  min-width: 0;
}
.apz-msg--client,
.apz-msg--assistant { align-self: flex-start; align-items: flex-start; }
.apz-msg--operator { align-self: flex-end; align-items: flex-end; }
.apz-msg--note { align-self: stretch; align-items: stretch; max-width: 100%; }

.apz-msg__author {
  font-size: 11.5px;
  line-height: 1.3;
  color: var(--ink-3);
  margin-bottom: 3px;
  padding: 0 4px;
  overflow-wrap: anywhere;
}

.apz-msg__bubble {
  padding: 9px 12px;
  border-radius: var(--r-md);
  font-size: 14px;
  line-height: 1.45;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  max-width: 100%;
  background: var(--surface-2);
  color: var(--ink);
}
.apz-msg--client .apz-msg__bubble { border-bottom-left-radius: 4px; }
.apz-msg--assistant .apz-msg__bubble { background: var(--accent-bg); border-bottom-left-radius: 4px; }
.apz-msg--operator .apz-msg__bubble { background: var(--ok-bg); border-bottom-right-radius: 4px; }
.apz-msg--note .apz-msg__bubble { background: var(--warn-bg); }
.apz-msg__bubble.is-empty { color: var(--ink-3); font-style: italic; }

.apz-msg__time {
  font-size: 11px;
  color: var(--ink-3);
  margin-top: 3px;
  padding: 0 4px;
}

/* Системные строки: по центру, мелким серым, без облачка */
.apz-msg--system {
  align-self: center;
  align-items: center;
  max-width: 92%;
  text-align: center;
  padding: 2px 0;
}
.apz-msg__sys-text {
  font-size: 12.5px;
  line-height: 1.4;
  color: var(--ink-3);
  overflow-wrap: anywhere;
}
.apz-msg--system .apz-msg__time { margin-top: 1px; }

/* Сообщение внутри ленты CRM (ol.crm-tl > li): облачко занимает строку целиком, выравнивание по роли */
.crm-tl-item.is-chat { flex-direction: column; min-width: 0; }

@media (max-width: 600px) {
  .apz-msg { max-width: 92%; }
}
