/* Messages tab: split list+conversation for the admin (one contact per
   student), single conversation view for everyone else — see chat-ui.js's
   renderAdminShell/renderStudentShell. Same split-pane conventions as
   bible.css's .bible-split/.bible-list/.bible-article. */

.chat-split { display: flex; gap: 0; flex: 1; min-height: 0; padding: 12px; }

.chat-list {
  flex-grow: 0;
  flex-shrink: 1;
  min-width: 10rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.chat-list-empty { color: var(--muted); font-size: 0.8125rem; padding: 8px 10px; }

.chat-list-item {
  text-align: left;
  background: transparent;
  border: none;
  color: var(--muted);
  font: inherit;
  padding: 8px 10px;
  border-radius: 5px;
  cursor: pointer;
  line-height: 1.35;
}
.chat-list-item:hover { color: var(--fg); background: rgba(128, 140, 160, 0.12); }
.chat-list-item-active {
  color: var(--fg);
  background: rgba(128, 140, 160, 0.18);
  font-weight: 600;
}

.chat-list-head { display: flex; align-items: center; gap: 6px; font-size: 0.8125rem; }
.chat-list-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

.chat-list-unread {
  background: var(--red);
  color: #1a1c22;
  font-size: 0.6875rem;
  font-weight: 700;
  line-height: 1;
  padding: 2px 6px;
  border-radius: 999px;
}

.chat-list-preview {
  margin-top: 2px;
  font-size: 0.6875rem;
  color: var(--muted);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Single-conversation view: used both as the right pane for the admin
   (.chat-convo) and as the entire screen for a student (.chat-single),
   which is why the message list / compose row styling below is shared by
   both selectors rather than duplicated. */
.chat-convo,
.chat-single {
  flex-grow: 1;
  flex-shrink: 1;
  min-width: 16.25rem;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 14px 16px;
  margin: 0 12px;
}
.chat-single { margin: 12px; }

.chat-empty-hint { color: var(--muted); margin: auto; }

.chat-header {
  font-weight: 600;
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid var(--line);
}

.chat-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 2px;
}

.chat-msg {
  max-width: 75%;
  padding: 7px 10px;
  border-radius: 8px;
  background: rgba(128, 140, 160, 0.12);
  line-height: 1.4;
}

.chat-msg-own { align-self: flex-end; background: rgba(94, 194, 126, 0.16); }
.chat-msg-other { align-self: flex-start; }

.chat-msg-text { white-space: pre-wrap; word-break: break-word; font-size: 0.8125rem; }

/* Сообщение из одного файла: текстовый узел у него всё равно есть (см.
   buildMessage в chat-ui.js — иначе порядок детей у разных сообщений был бы
   разный), но пустая строка с pre-wrap занимает целую строку впустую. */
.chat-msg-text:empty { display: none; }

/* Вложение внутри сообщения: скрепка, имя с размером и сроком, кнопка
   скачивания. Ряд, а не блок под текстом, потому что имя файла короткое, а
   кнопка должна стоять на той же строке, что и оно. */
.chat-file {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 6px;
  padding: 6px 8px;
  border: 1px solid var(--line);
  border-radius: 6px;
  background: rgba(128, 140, 160, 0.08);
}

.chat-file-clip { flex: none; font-size: 0.875rem; }
.chat-file-body { flex: 1; min-width: 0; }

.chat-file-name {
  font-size: 0.8125rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.chat-file-meta { margin-top: 2px; font-size: 0.625rem; color: var(--muted); }

.chat-file-get { flex: none; text-decoration: none; }

/* Просроченное вложение остаётся видимым — письмо-то никуда не делось, — но
   гаснет и остаётся без кнопки: сервер на такую ссылку отвечает отказом, и
   предлагать нажатие, которое заведомо ничего не даст, нечестно. */
.chat-file-gone { opacity: 0.55; }

/* Time and — on one's own messages only — the read mark, on one line under
   the text. A flex row rather than text-align, so the mark keeps its own
   gap from the clock instead of running into it. */
.chat-msg-time {
  margin-top: 3px;
  font-size: 0.625rem;
  color: var(--muted);
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
}

/* Двойная галочка узкая по замыслу: рядом со временем она должна читаться
   как один значок, а не как два символа подряд. */
.chat-msg-receipt { letter-spacing: -0.08em; }
.chat-msg-receipt-read { color: var(--green); }

/* Day heading inside a conversation: «Сегодня», «Вчера» or the date, built
   by Intl in chat-ui.js. Quiet and centred — it separates the days, it does
   not compete with what was said on them. */
.chat-day {
  align-self: center;
  margin: 4px 0 2px;
  padding: 2px 10px;
  border-radius: 999px;
  background: rgba(128, 140, 160, 0.14);
  color: var(--muted);
  font-size: 0.6875rem;
}

/* «Новые сообщения»: put in front of the first unread message the moment
   the conversation is opened, and left exactly there for the whole visit —
   see chat-ui.js's openThread/applyThread. A rule across the full width,
   because it marks a place in the list rather than labelling a message. */
.chat-new-line {
  align-self: stretch;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 6px 0 2px;
  color: var(--red);
  font-size: 0.6875rem;
}
.chat-new-line::before,
.chat-new-line::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--red);
  opacity: 0.4;
}

.chat-compose-error {
  min-height: 1rem;
  color: var(--red);
  font-size: 0.75rem;
  margin-top: 4px;
}

/* Строка ввода целиком: полоска выбранного файла, сама строка и подпись про
   срок хранения — один блок, который js/ui/chat-compose.js собирает и
   отдаёт экрану. */
.chat-compose-box { display: flex; flex-direction: column; }

.chat-compose { display: flex; gap: 8px; margin-top: 8px; align-items: flex-end; }

.chat-input {
  flex: 1;
  resize: vertical;
  background: var(--bg);
  color: var(--fg);
  border: 1px solid var(--line);
  border-radius: 5px;
  font: inherit;
  font-size: 0.8125rem;
  padding: 8px 10px;
  min-height: 2.5rem;
}

.chat-send { flex: none; }

/* Смайлики и скрепка. Квадратные и одного роста с полем ввода, чтобы
   строка не выглядела сложенной из разнокалиберных частей. Размер задан в
   rem: при крупной ступени масштаба интерфейса кнопка обязана расти вместе
   с символом на ней, а не обрезать его. */
.chat-tool {
  flex: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--fg);
  font: inherit;
  font-size: 1rem;
  line-height: 1;
  min-width: 2.5rem;
  min-height: 2.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.chat-tool:hover { background: rgba(128, 140, 160, 0.15); }

/* Настоящее поле выбора файла: спрятано, но не выброшено — кнопка со
   скрепкой открывает именно его. display:none подошёл бы тоже, но
   спрятанный так элемент в части браузеров не отвечает на .click(). */
.chat-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  pointer-events: none;
}

/* Полоска выбранного файла над строкой ввода. Пустая — не занимает ничего:
   пока файл не выбран, показывать нечего, и «файл не выбран» было бы
   строкой ради строки. */
.chat-pending {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 4px;
}
.chat-pending:empty { display: none; }

.chat-pending-clip { flex: none; }
.chat-pending-name {
  font-size: 0.75rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.chat-pending-meta { flex: 1; font-size: 0.625rem; color: var(--muted); }

.chat-pending-drop {
  flex: none;
  background: transparent;
  border: 1px solid var(--line);
  border-radius: 5px;
  color: var(--muted);
  font: inherit;
  font-size: 0.6875rem;
  padding: 3px 8px;
  cursor: pointer;
}
.chat-pending-drop:hover { color: var(--fg); background: rgba(128, 140, 160, 0.15); }

/* Честная подпись про сутки — до отправки, а не мелким шрифтом после. */
.chat-compose-note { margin-top: 4px; font-size: 0.625rem; color: var(--muted); }

@media (max-width: 900px) {
  .chat-split { flex-direction: column; }
  .chat-list { flex-direction: row; flex-wrap: wrap; }
}

/* ------------------------------------------------------------------
   Панель смайликов (js/ui/emoji-ui.js). Живёт в карточке общего окна
   LT.modal, поэтому здесь только её содержимое: заголовок, подсказка про
   клавиши, группы и сетка кнопок.
   ------------------------------------------------------------------ */

.emoji-card {
  width: 24rem;
  max-width: calc(100vw - 32px);
  margin: 16px;
  padding: 18px 20px 16px;
  border-radius: 12px;
  border: 1px solid var(--line);
  background: var(--panel);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.6);
}

.emoji-title { font-size: 1.125rem; margin-bottom: 4px; }

/* Сказано вслух, потому что панель ведёт себя не как обычный список: Tab
   по кнопкам не ходит (см. roving tabindex в emoji-ui.js), ходят стрелки. */
.emoji-hint { font-size: 0.6875rem; color: var(--muted); margin-bottom: 12px; }

.emoji-group { margin-bottom: 12px; }

.emoji-group-title {
  color: var(--muted);
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-bottom: 4px;
}

/* Восемь столбцов — то же число, что считает шаг стрелки вверх-вниз в
   js/ui/emoji-ui.js и что объявлено в js/data/emoji.js. Разойдутся — и
   стрелка вниз начнёт уводить курсор мимо соседа под ним. */
.emoji-grid { display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px; }

.emoji-cell {
  background: transparent;
  border: 1px solid transparent;
  border-radius: 5px;
  font: inherit;
  font-size: 1.25rem;
  line-height: 1;
  min-height: 2.25rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.emoji-cell:hover { background: rgba(128, 140, 160, 0.15); }
/* Обвод у выбранной клетки обязателен: ходят по панели стрелками, и без
   видимой рамки человек не знает, куда попадёт Enter. */
.emoji-cell:focus { outline: none; border-color: var(--green); background: rgba(94, 194, 126, 0.16); }

.emoji-done { margin-top: 4px; }

/* Unread signal on the «Сообщения» tab. .tab itself belongs to base.css;
   only this screen ever puts .tab-unread on, so the rules for it live
   here. chat.css is the last stylesheet index.html loads, which is what
   lets these override the plain .tab colours without !important. */

@keyframes tab-blink-gold {
  0%, 100% { color: var(--muted); background: transparent; }
  50% { color: #e8b923; background: rgba(232, 185, 35, 0.16); }
}

.tab-unread { animation: tab-blink-gold 1.2s ease-in-out infinite; }

/* Reading the conversation is the answer to the call for attention, so an
   open tab stops blinking at once — without waiting for the server's read
   marks to come back on the next poll, up to ten seconds later. */
.tab-unread.tab-active { animation: none; color: #e8b923; }

@media (prefers-reduced-motion: reduce) {
  .tab-unread { animation: none; color: #e8b923; }
}
