/* Бело-синий фирменный стиль. Цвета — в переменных: правятся здесь.
   Тёмной темы намеренно нет — чат выглядит одинаково у всех, как часть сайта. */
:root {
  --blue: #1554c0;
  --blue-dark: #0f3f94;
  --blue-soft: #eef4ff;
  --blue-line: #d6e3fb;
  --white: #ffffff;
  --text: #0f1f3d;
  --muted: #5b6b86;
  --error: #c62828;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  background: var(--blue-soft);
  color: var(--text);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.chat {
  display: flex;
  flex-direction: column;
  height: 100%;
  max-width: 760px;
  margin: 0 auto;
  background: var(--white);
  box-shadow: 0 0 0 1px var(--blue-line);
}
.embed .chat { box-shadow: none; max-width: none; }

/* Шапка */
.chat__head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  background: linear-gradient(135deg, var(--blue), var(--blue-dark));
  color: var(--white);
}
.chat__avatar {
  flex: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  background: rgba(255, 255, 255, .16);
  border: 1px solid rgba(255, 255, 255, .35);
}
.chat__title { font-weight: 700; font-size: 17px; letter-spacing: .2px; }
.chat__subtitle { font-size: 13px; opacity: .85; }

/* Лента сообщений */
.chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--blue-soft);
}

.msg { max-width: 88%; }
.msg--user { align-self: flex-end; }
.msg--bot { align-self: flex-start; }
.msg__text {
  padding: 10px 14px;
  border-radius: 16px;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
.msg--bot .msg__text {
  background: var(--white);
  border: 1px solid var(--blue-line);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 2px rgba(21, 84, 192, .06);
}
.msg--user .msg__text {
  background: var(--blue);
  color: var(--white);
  border-bottom-right-radius: 4px;
}
.msg--error .msg__text { color: var(--error); border-color: #f5c6c6; }

/* Строка «откуда ответ» под сообщением ассистента */
.msg__trust {
  margin-top: 6px;
  padding-left: 6px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--blue-dark);
}
.msg__trust div { margin-top: 2px; font-weight: 400; color: var(--muted); }
.msg__trust a { color: var(--blue); text-decoration: none; }
.msg__trust a:hover { text-decoration: underline; }

.typing .msg__text { color: var(--muted); }
.typing .msg__text::after { content: "…"; animation: blink 1s steps(2) infinite; }
@keyframes blink { 50% { opacity: 0; } }

/* Поле ввода */
.chat__form {
  display: flex;
  gap: 8px;
  padding: 12px;
  background: var(--white);
  border-top: 1px solid var(--blue-line);
}
.chat__form textarea {
  flex: 1;
  resize: none;
  max-height: 140px;
  padding: 10px 14px;
  border: 1px solid var(--blue-line);
  border-radius: 12px;
  background: var(--white);
  color: var(--text);
  font: inherit;
}
.chat__form textarea::placeholder { color: #8a98b3; }
.chat__form textarea:focus, .escalate input:focus {
  outline: none;
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(21, 84, 192, .15);
}

button {
  border: 0;
  border-radius: 12px;
  background: var(--blue);
  color: var(--white);
  font: inherit;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
button:hover:not(:disabled) { background: var(--blue-dark); }
button:disabled { opacity: .5; cursor: default; }
.chat__form button { width: 46px; display: grid; place-items: center; }

/* Форма передачи инженеру */
.escalate {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 14px;
  border: 1px solid var(--blue-line);
  border-left: 4px solid var(--blue);
  border-radius: 12px;
  background: var(--white);
}
.escalate__title { font-weight: 700; color: var(--blue-dark); }
.escalate input {
  padding: 9px 12px;
  border: 1px solid var(--blue-line);
  border-radius: 10px;
  background: var(--white);
  color: var(--text);
  font: inherit;
}
.escalate button { padding: 10px; }
