/* Стили для чатов */

/* Дизайн-токены: цвета статусов и «моих» чатов.
   Меняются в одном месте и работают и с dev-CDN Tailwind, и с prod-сборкой. */
:root {
  --status-pending-bg: #fef3c7;
  --status-pending-fg: #92400e;
  --status-active-bg: #dbeafe;
  --status-active-fg: #1e40af;
  --status-closed-bg: #dcfce7;
  --status-closed-fg: #166534;

  --mine-accent: #6366f1;          /* индиго — theme-color приложения */
  --mine-tint: rgba(99, 102, 241, 0.06);
  --avatar-other-bg: #e5e7eb;
  --avatar-other-fg: #4b5563;
}

/* Анимация мигания для "зависших" чатов */
@keyframes pending-pulse {
  0%, 100% { background-color: rgba(251, 191, 36, 0.05); }
  50%      { background-color: rgba(251, 191, 36, 0.18); }
}

/* Класс для "зависших" чатов (pending > 1 мин или active > 5 мин) */
.chat-pending-urgent {
  animation: pending-pulse 2s ease-in-out infinite;
}

/* Янтарная точка рядом со временем у «зависших» чатов */
.chat-urgent-dot {
  display: inline-block;
  width: 6px;
  height: 6px;
  border-radius: 9999px;
  background-color: #f59e0b;
  margin-right: 4px;
  vertical-align: middle;
}

/* Класс для своих чатов (назначенных текущему оператору) */
.chat-assigned-to-me {
  background-color: var(--mine-tint);
}
/* повышенная специфичность: .chat-list-item ниже по файлу сбрасывает border-left */
.chat-list-item.chat-assigned-to-me {
  border-left-color: var(--mine-accent);
}

/* Базовый класс для элементов списка чатов */
.chat-list-item {
  display: block;
  padding: 12px;
  border-bottom: 1px solid #e5e7eb;
  border-left: 3px solid transparent;
  transition: background-color 0.2s ease, border-left-color 0.2s ease;
}

.chat-list-item:hover {
  background-color: #f9fafb;
}

/* Выбранный (открытый) чат: заметный фон, толстая полоса слева, жирное имя.
   Идёт после .chat-assigned-to-me и :hover с той же специфичностью, поэтому перекрывает их. */
.chat-list-item[aria-current="true"],
.chat-list-item[aria-current="true"]:hover {
  background-color: #dbeafe;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.25);
  border-left: 4px solid #2563eb;
  padding-left: 11px; /* 12px − 1px: контент не сдвигается при выделении */
}
.chat-list-item[aria-current="true"] .chat-item-name {
  font-weight: 700;
}

/* Аватар клиента (фото из Telegram или инициалы) */
.client-avatar {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  object-fit: cover;
  color: #fff;
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1;
  user-select: none;
}
.client-avatar-md { width: 36px; height: 36px; font-size: 13px; }

/* Пульсирующий счётчик непрочитанных */
@keyframes unread-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.6); }
  70%  { box-shadow: 0 0 0 7px rgba(59, 130, 246, 0); }
  100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}
.unread-badge {
  animation: unread-pulse 1.6s ease-out infinite;
}
@media (prefers-reduced-motion: reduce) {
  .unread-badge { animation: none; }
}

/* Badge стилей для статусов */
.status-badge {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
}

.status-badge-pending {
  background-color: var(--status-pending-bg);
  color: var(--status-pending-fg);
}

.status-badge-active {
  background-color: var(--status-active-bg);
  color: var(--status-active-fg);
}

.status-badge-closed {
  background-color: var(--status-closed-bg);
  color: var(--status-closed-fg);
}

/* Badge статуса смены оператора */
.duty-badge {
  display: inline-block;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
}

.duty-badge-on {
  background-color: #22c55e; /* зеленый */
  color: white;
}

.duty-badge-off {
  background-color: #ef4444; /* красный */
  color: white;
}

/* Правый сайдбар transitions */
.chat-sidebar {
  transition: width 0.3s ease-in-out;
}

/* Скрытие текста в компактном режиме */
@media (min-width: 1024px) {
  .chat-sidebar.compact .sidebar-action-text {
    display: none;
  }
}

/* Highlight для найденных сообщений */
mark {
  background-color: #fef3c7; /* светло-желтый */
  color: #92400e; /* темно-коричневый */
  padding: 2px 4px;
  border-radius: 2px;
  font-weight: 500;
}

/* Line clamp для результатов поиска */
.line-clamp-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Smooth scroll */
html {
  scroll-behavior: smooth;
}

/* Анимация подсветки для найденного сообщения */
@keyframes highlight-message {
  0% {
    background-color: #fef3c7;
  }
  100% {
    background-color: transparent;
  }
}

/* Transition для плавного появления/скрытия элементов сайдбара */
.sidebar-content {
  transition: opacity 0.2s ease-in-out, transform 0.2s ease-in-out;
}

/* Стили для результатов поиска по сообщениям */
.message-search-result {
  transition: background-color 0.2s ease, transform 0.1s ease;
}

.message-search-result:hover {
  transform: translateX(4px);
}

/* Аватар оператора (инициалы в круге) */
.operator-avatar {
  display: inline-flex;
  flex-shrink: 0;
  align-items: center;
  justify-content: center;
  border-radius: 9999px;
  font-weight: 600;
  text-transform: uppercase;
  line-height: 1;
  background-color: var(--avatar-other-bg);
  color: var(--avatar-other-fg);
}
.operator-avatar-sm { width: 20px; height: 20px; font-size: 9px; }
.operator-avatar-md { width: 28px; height: 28px; font-size: 11px; }
.operator-avatar-lg { width: 64px; height: 64px; font-size: 22px; }
.operator-avatar-image { object-fit: cover; }
.operator-avatar-mine { background-color: var(--mine-accent); color: #fff; }
.operator-avatar-empty { background: transparent; border: 1.5px dashed #9ca3af; color: transparent; }

/* Вкладки «Мои / Свободные / Все» */
.assignment-tab {
  display: flex;
  flex: 1 1 0;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 4px 6px;
  border-radius: 6px;
  font-size: 12px;
  color: #4b5563;
  transition: background-color 0.15s ease;
}
.assignment-tab:hover { background-color: #f3f4f6; }
.assignment-tab.is-active { background-color: #fff; color: #111827; font-weight: 600; box-shadow: 0 1px 2px rgba(0,0,0,.08); }
.assignment-tab-count { font-size: 10px; padding: 0 5px; border-radius: 9999px; background: #e5e7eb; color: #374151; }
.assignment-tab.is-active .assignment-tab-count { background: var(--mine-accent); color: #fff; }

/* Подсветка найденного сообщения (пузырь, а не вся строка) */
.message-highlight > div {
  box-shadow: 0 0 0 3px #facc15;
  transition: box-shadow 0.3s ease;
}

/* Правый сайдбар чата: свёрнутое состояние задаётся атрибутом <html data-chat-sidebar>,
   который сервер ставит из cookie при первом рендере — без мигания развёрнутым видом. */
@media (min-width: 1024px) {
  html[data-chat-sidebar="compact"] #chat_sidebar { width: 4rem; }
  html[data-chat-sidebar="compact"] #chat_sidebar [data-chat-sidebar-target="content"],
  html[data-chat-sidebar="compact"] #chat_sidebar [data-chat-sidebar-target="title"] { display: none; }
  html[data-chat-sidebar="compact"] #chat_sidebar [data-chat-sidebar-target="compact"] { display: flex; }
  html[data-chat-sidebar="compact"] #chat_sidebar .sidebar-icon-expanded { display: none; }
  html[data-chat-sidebar="compact"] #chat_sidebar .sidebar-icon-compact { display: block; }
}

/* Короткая подсветка чата, который «поднялся» в списке из-за нового сообщения */
@keyframes chat-bump {
  0%   { box-shadow: inset 0 0 0 100px rgba(251, 191, 36, 0.35); }
  100% { box-shadow: inset 0 0 0 100px rgba(251, 191, 36, 0); }
}
.chat-bumped {
  animation: chat-bump 2s ease-out;
}

/* Панель шаблонов над полем ввода: тонкая горизонтальная прокрутка */
.template-chips {
  scrollbar-width: thin;
}

/* Оформление текста сообщений: **жирный**, __курсив__, ||спойлер||, `код`, [ссылка](url).
   Разметку в HTML переводит MessageFormatter. */
.message-text code,
.template-tooltip code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.9em;
  padding: 0 0.25em;
  border-radius: 0.25rem;
  background: rgba(0, 0, 0, 0.15);
}
.message-text a { text-decoration: underline; }

/* Спойлер размыт и раскрывается при наведении, как в Telegram */
tg-spoiler {
  filter: blur(4px);
  cursor: pointer;
  transition: filter 0.15s;
}
tg-spoiler:hover { filter: none; }
/* В подсказке шаблона спойлер не прячем, иначе его не прочитать */
.template-tooltip tg-spoiler { filter: none; border-bottom: 1px dotted currentColor; }

/* ---- Левая панель: поиск, переключатель режима, фильтры, результаты сквозного поиска ---- */

/* Поле поиска (иконка слева, ✕ справа; родной крестик type=search прячем) */
.list-search-input {
  width: 100%;
  padding: 7px 28px 7px 32px;
  font-size: 14px;
  color: #111827;
  background: #fff;
  border: 1px solid #d1d5db;
  border-radius: 6px;
}
.list-search-input:focus {
  outline: none;
  border-color: var(--mine-accent);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25);
}
.list-search-input::-webkit-search-cancel-button { display: none; }
.list-search-clear {
  position: absolute;
  top: 50%;
  right: 6px;
  transform: translateY(-50%);
  padding: 4px;
  color: #9ca3af;
  border-radius: 9999px;
}
.list-search-clear:hover { color: #4b5563; background: #f3f4f6; }

/* Сегментный переключатель «Чаты | Сообщения» (тот же вид, что у вкладок .assignment-tab) */
.segmented { display: flex; gap: 2px; padding: 2px; background: #f3f4f6; border-radius: 8px; }
.segmented-option { position: relative; flex: 1 1 0; cursor: pointer; }
.segmented-option span {
  display: block;
  padding: 4px 6px;
  text-align: center;
  font-size: 12px;
  color: #4b5563;
  border-radius: 6px;
  transition: background-color 0.15s ease;
}
.segmented-option:hover span { background-color: #e5e7eb; }
.segmented-option input:checked + span {
  background-color: #fff;
  color: #111827;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, .08);
}
.segmented-option input:focus-visible + span { outline: 2px solid var(--mine-accent); outline-offset: 1px; }

/* Компактные фильтры-«пилюли»: нативный select/date; значение не по умолчанию подсвечено */
.filter-pill {
  width: 100%;
  min-width: 0;
  height: 28px;
  padding: 0 4px 0 8px;
  font-size: 12px;
  color: #4b5563;
  background-color: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
  text-overflow: ellipsis;
}
.filter-pill:hover { border-color: #d1d5db; }
.filter-pill:focus { outline: none; box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.25); }
.filter-pill.is-active {
  color: #4338ca;
  font-weight: 500;
  background-color: rgba(99, 102, 241, 0.08);
  border-color: rgba(99, 102, 241, 0.45);
}

/* Карточка результата поиска (строка = сообщение). Выбранная — как открытый чат в списке */
.search-result {
  display: block;
  padding: 10px 12px;
  border-bottom: 1px solid #e5e7eb;
  border-left: 3px solid transparent;
  transition: background-color 0.2s ease;
}
.search-result:hover { background-color: #f9fafb; }
.search-result[aria-current="true"],
.search-result[aria-current="true"]:hover {
  background-color: #dbeafe;
  box-shadow: inset 0 0 0 1px rgba(59, 130, 246, 0.25);
  border-left: 4px solid #2563eb;
  padding-left: 11px;
}
.search-result[aria-current="true"] .search-result-name { font-weight: 700; }
.result-snippet {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  overflow-wrap: anywhere;
}

/* Совпадения с запросом (в результатах и в найденном сообщении) */
mark {
  padding: 0 1px;
  color: #111827;
  background-color: #fef08a;
  border-radius: 2px;
}

/* Меню «⋯» в пузыре сообщения оператора (изменить / удалить): появляется при наведении на пузырь.
   На тач-экранах наведения нет, поэтому кнопка видна всегда. Задано обычным CSS (не классами Tailwind),
   чтобы работало и с dev-CDN, и с prod-сборкой. */
.message-bubble .message-menu-button { opacity: 0; transition: opacity 0.15s; }
.message-bubble:hover .message-menu-button,
.message-bubble:focus-within .message-menu-button,
.message-menu-button[aria-expanded="true"] { opacity: 1; }
@media (hover: none) {
  .message-bubble .message-menu-button { opacity: 1; }
}
/*
 * This is a manifest file that'll be compiled into application.css, which will include all the files
 * listed below.
 *
 * Any CSS (and SCSS, if configured) file within this directory, lib/assets/stylesheets, or any plugin's
 * vendor/assets/stylesheets directory can be referenced here using a relative path.
 *
 * You're free to add application-wide styles to this file and they'll appear at the bottom of the
 * compiled file so the styles you add here take precedence over styles defined in any other CSS
 * files in this directory. Styles in this file should be added after the last require_* statement.
 * It is generally better to create a new file per style scope.
 *


 */
