/* =========================
   Контейнер чата
   ========================= */
.chat-wrap{
  max-width: 1200px;
  margin: 10px auto;
  padding: 0 10px;
}

/* =========================
   Шапка
   ========================= */
.chat-head{
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin: 8px 0 12px;
}
.chat-head .back{
  font-size: 14px;
  opacity: .8;
}
.chat-title{
  font-size: 18px;
  margin: 0;
}

/* =========================
   Лента сообщений
   ========================= */
.chat-thread{
  background: #fff;
  border-radius: 14px;
  padding: 12px 8px;
  box-shadow: 0 1px 6px rgba(0,0,0,.05);
  min-height: 260px;
  max-height: 60vh;
  overflow: auto;
}

/* =========================
   Сообщения
   ========================= */
.msg{
  display: flex;
  margin: 6px 0;
}

.msg--mine{
  justify-content: flex-end;
}

.msg--peer{
  justify-content: flex-start;
}

/* =========================
   Пузырь сообщения
   ========================= */
.msg__bubble{
  max-width: 80%;
  width: fit-content;

  /* чтобы мета не ломалась у коротких сообщений */
  min-width: 180px;

  border-radius: 12px;
  padding: 4px 10px;
  font-size: 14px;
  line-height: 1.25;
  box-shadow: 0 1px 2px rgba(0,0,0,0.04);

  /* переносы текста */
  white-space: normal;
  word-break: break-word;
  overflow-wrap: anywhere;
  hyphens: auto;
}

/* Текст внутри пузыря */
.msg__text{
  display: block;
}

/* Цвета пузырей */
.msg--mine .msg__bubble{
  background: #e8f5e9;
}

.msg--peer .msg__bubble{
  background: #f2f2f2;
}

/* =========================
   Метаданные (имя + дата)
   ========================= */
.msg__meta{
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  opacity: .6;
  margin-top: 4px;
  line-height: 1.2;

  /* ВСЕГДА в одну строку */
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* Выравнивание меты */
.msg--mine .msg__meta{
  justify-content: flex-end;
  text-align: right;
}

.msg--peer .msg__meta{
  justify-content: flex-start;
  text-align: left;
}

/* =========================
   Пустой чат
   ========================= */
.chat-empty{
  text-align: center;
  padding: 20px;
  color: #777;
}

/* =========================
   Форма ввода
   ========================= */
.chat-form{
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.chat-form textarea{
  flex: 1;
  min-height: 80px;
  padding: 8px;
  border-radius: 10px;
  border: 1px solid #ddd;
  resize: vertical;
}

.chat-form button{
  padding: 8px 14px;
  border-radius: 10px;
  border: 0;
  cursor: pointer;
  background: #1f8c68;
  color: #fff;
  font-weight: 500;
}

.chat-form button:hover{
  filter: brightness(.95);
}

/* =========================
   Мобилка / планшет
   ========================= */
@media (max-width: 768px){
  .msg__bubble{
    max-width: 92%;
    min-width: 0;        /* важно, иначе ломает узкие экраны */
    padding: 4px 8px;
    line-height: 1.2;
  }
}
