/* CRM SOURCE MAP:
 * Стили master-only чата и панели инструментов агента.
 * Комментарии описывают назначение слоя оформления.
 */
.agent-chat-view { max-width: none !important; padding-bottom: 0; }
.agent-chat-view > .heading { margin-bottom: 14px; }
.agent-chat-shell {
  display: grid;
  grid-template-columns: minmax(220px, 270px) minmax(0, 1fr);
  min-height: min(740px, calc(100vh - 190px));
  border: 1px solid var(--line);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 8px 30px rgba(23, 38, 66, .06);
}
.agent-chat-side {
  display: flex;
  min-height: 0;
  flex-direction: column;
  border-right: 1px solid var(--line);
  background: #f8f9fc;
}
.agent-chat-side-head { padding: 16px; border-bottom: 1px solid var(--line); }
.agent-chat-side-head .primary { width: 100%; }
.agent-chat-tabs { display: flex; gap: 6px; margin-top: 12px; }
.agent-chat-tabs button { flex: 1; min-width: 0; padding: 8px 5px; }
.agent-chat-tabs button.active { color: var(--blue); background: var(--pale); border-color: #cbd7fb; }
.agent-chat-side-content { min-height: 0; flex: 1; overflow: auto; padding: 10px; }
.agent-history-item, .agent-tool-item {
  display: block; width: 100%; margin: 0 0 7px; padding: 11px 12px;
  border: 1px solid transparent; border-radius: 10px; background: transparent;
  color: var(--ink); text-align: left; cursor: pointer;
}
.agent-history-item:hover, .agent-history-item.active { border-color: #d7e0fa; background: #fff; }
.agent-history-item strong, .agent-history-item small, .agent-tool-item strong, .agent-tool-item small { display: block; }
.agent-history-item strong, .agent-tool-item strong { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 13px; }
.agent-history-item small, .agent-tool-item small { margin-top: 5px; color: var(--muted); line-height: 1.4; }
.agent-tool-item { cursor: default; border-bottom: 1px solid var(--line); border-radius: 0; }
.agent-tool-state { float: right; color: #16804a; font-size: 12px; }
.agent-chat-main { display: flex; min-width: 0; min-height: 0; flex-direction: column; }
.agent-chat-header { display: flex; align-items: center; justify-content: space-between; gap: 12px; padding: 14px 18px; border-bottom: 1px solid var(--line); }
.agent-chat-header h2 { margin: 0; font-size: 17px; }
.agent-chat-header-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; justify-content: flex-end; }
.agent-model-badge, .agent-service-state { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border-radius: 999px; color: #3454a5; background: var(--pale); font-size: 12px; }
.agent-service-state.offline { color: #9a3d35; background: #fff0ef; }
.agent-message-list { flex: 1; min-height: 280px; overflow: auto; padding: 20px clamp(14px, 4vw, 42px); background: linear-gradient(#fff, #fcfdff); }
.agent-empty { max-width: 560px; margin: 11vh auto 0; color: var(--muted); text-align: center; }
.agent-empty h3 { color: var(--ink); }
.agent-message { width: fit-content; max-width: min(82%, 780px); margin: 0 0 14px; padding: 11px 14px; border: 1px solid var(--line); border-radius: 14px 14px 14px 4px; background: #fff; box-shadow: 0 2px 8px rgba(23, 38, 66, .035); }
.agent-message.user { margin-left: auto; border-color: #d5def9; border-radius: 14px 14px 4px 14px; background: #eef2ff; }
.agent-message-role { margin-bottom: 5px; color: var(--muted); font-size: 11px; }
.agent-message-text { overflow-wrap: anywhere; white-space: pre-wrap; line-height: 1.55; }
.agent-message-time { margin-top: 7px; color: var(--muted); font-size: 10px; text-align: right; }
.agent-attachments { display: grid; gap: 6px; margin-top: 9px; }
.agent-attachment-row { display: flex; min-width: 0; align-items: stretch; gap: 6px; }
.agent-attachment { display: flex; min-width: 0; flex: 1; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px; background: rgba(255,255,255,.7); color: var(--ink); text-decoration: none; }
.agent-attachment:hover { border-color: #aebff5; }
.agent-attachment-name { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-attachment-note { display: block; margin-top: 2px; color: var(--muted); font-size: 11px; }
.agent-convert-button { flex: 0 0 auto; padding: 6px 9px; font-size: 11px; }
.agent-approval { margin: 0 18px 10px; padding: 14px 16px; border: 1px solid #e7cf8b; border-radius: 12px; background: #fff9e9; }
.agent-approval h3 { margin: 0 0 7px; font-size: 15px; }
.agent-approval pre { max-height: 180px; overflow: auto; white-space: pre-wrap; overflow-wrap: anywhere; font: 12px/1.5 ui-monospace, Consolas, monospace; }
.agent-approval-actions { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 10px; }
.agent-approval-actions .danger { color: #a12d28; }
.agent-run-status { padding: 8px 18px; color: var(--muted); font-size: 12px; }
.agent-composer { padding: 14px 18px 16px; border-top: 1px solid var(--line); background: #fff; }
.agent-composer-row { display: flex; align-items: flex-end; gap: 8px; }
.agent-composer textarea { min-height: 48px; max-height: 180px; flex: 1; resize: vertical; }
.agent-attach-button { flex: 0 0 auto; width: 44px; min-width: 44px; height: 44px; padding: 0; font-size: 20px; }
.agent-send-button { flex: 0 0 auto; min-height: 44px; }
.agent-file-list { display: flex; flex-wrap: wrap; gap: 6px; margin: 0 0 9px; }
.agent-file-chip { display: inline-flex; align-items: center; gap: 7px; max-width: 100%; padding: 5px 8px; border: 1px solid var(--line); border-radius: 999px; color: var(--muted); font-size: 12px; }
.agent-file-chip span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.agent-file-chip button { min-width: 22px; padding: 0; border: 0; background: transparent; color: #9a3d35; }
.agent-chat-note { margin: 8px 0 0; color: var(--muted); font-size: 11px; line-height: 1.45; }
.agent-error { color: #9a3d35; }
@media (max-width: 820px) {
  .agent-chat-shell { grid-template-columns: 1fr; min-height: calc(100vh - 220px); }
  .agent-chat-side { order: 2; max-height: 190px; border-top: 1px solid var(--line); border-right: 0; }
  .agent-chat-side-head { padding: 9px 12px; }
  .agent-chat-side-head .primary { padding: 8px 10px; }
  .agent-chat-tabs { margin-top: 7px; }
  .agent-chat-side-content { display: flex; gap: 6px; overflow-x: auto; overflow-y: hidden; }
  .agent-history-item, .agent-tool-item { min-width: 190px; max-width: 250px; align-self: flex-start; }
  .agent-chat-main { min-height: 440px; }
  .agent-message { max-width: 94%; }
}
