/* Прокрутка сообщений */
.chat-messages-scroll {
  overflow-y: auto;
  overflow-x: hidden;
}

/* Блок редактирования сообщения */
.editing-message-bar {
  background: linear-gradient(135deg, var(--bs-primary-bg-subtle) 0%, rgba(var(--bs-primary-rgb), 0.08) 100%);
  border-left: 3px solid var(--bs-primary);
  border-radius: 0 12px 12px 0;
  padding: 0.625rem 0.875rem;
  animation: slideInEditing 0.2s ease-out;
}

.editing-icon {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  background: var(--bs-primary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
  flex-shrink: 0;
}

.editing-content {
  line-height: 1.3;
}

.editing-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--bs-primary);
  margin-bottom: 1px;
}

.editing-preview {
  font-size: 0.8125rem;
  color: var(--bs-body-color);
  opacity: 0.8;
}

.editing-cancel-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--bs-secondary-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
  flex-shrink: 0;
}

.editing-cancel-btn:hover {
  background: var(--bs-danger-bg-subtle);
  color: var(--bs-danger);
}

@keyframes slideInEditing {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Стили для превью вложений */
.attachment-thumb-wrapper {
  position: relative;
}

.attachment-thumb {
  width: 60px;
  height: 60px;
  border-radius: 10px;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
}

.attachment-thumb-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.attachment-thumb-file {
  background: linear-gradient(135deg, var(--bs-primary-bg-subtle) 0%, var(--bs-secondary-bg) 100%);
  border: 1px solid var(--bs-border-color);
  color: var(--bs-primary);
  flex-direction: column;
  gap: 2px;
  padding: 6px 4px 4px;
}

.attachment-thumb-file .ti {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.attachment-thumb-name {
  font-size: 0.55rem;
  line-height: 1.1;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  color: var(--bs-body-color);
  opacity: 0.7;
  text-align: center;
}

.attachment-thumb-remove {
  position: absolute;
  top: -6px;
  right: -6px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  border: none;
  background: var(--bs-danger);
  color: white;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 0.15s ease, background-color 0.15s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

.attachment-thumb-remove:hover {
  transform: scale(1.1);
  background: var(--bs-danger);
}

/* Стили для системных сообщений */
.system-message-row {
  display: flex;
  justify-content: center;
  align-items: center;
  width: 100%;
  margin-bottom: 1rem;
}

.system-message-bubble {
  display: inline-flex;
  align-items: center;
  padding: 0.5rem 1rem;
  background-color: var(--bs-secondary-bg, #e9ecef);
  border-radius: 1rem;
  max-width: 80%;
  text-align: center;
}

.system-message-text {
  font-size: 0.875rem;
  font-style: italic;
  word-wrap: break-word;
  line-height: 1.4;
}

/* Стили для стикеров */
.sticker-message {
  font-size: 7rem !important;
  line-height: 1.2 !important;
  background: transparent !important;
  padding: 0.25rem 0.5rem !important;
  border: none !important;
  box-shadow: none !important;
}

.sticker-message .message-edited-text {
  font-size: 0.7rem !important;
  position: absolute;
  bottom: -1rem;
  right: 0;
}

.msg-reactions {
  gap: 0.35rem;
  font-size: 0.85rem;
}

.rxn-inline {
  border: 1px solid var(--bs-border-color);
  border-radius: 999px;
  background: var(--bs-body-bg);
  padding: 0.1rem 0.55rem;
  line-height: 1.2;
  cursor: pointer;
  transition: background-color 0.15s ease, border-color 0.15s ease;
  color: inherit;
}

.rxn-inline .rxn-emoji {
  font-size: 1rem;
}

.rxn-inline .rxn-count {
  font-size: 0.75rem;
}

.rxn-inline:hover {
  background-color: var(--bs-primary-bg-subtle);
  border-color: var(--bs-primary);
}

.rxn-active {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
  color: #fff;
}

.reaction-add {
  animation: reactionPop 0.3s ease;
}

.counter-update {
  animation: counterFlash 0.3s ease;
}

/* Пузырь сообщения с временем внутри */
.message-bubble {
  position: relative;
  display: inline-flex !important;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 6px 10px;
  max-width: 100%;
}

.message-bubble .message-text {
  word-break: break-word;
}

.message-bubble .message-meta {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  font-size: 0.65rem;
  color: var(--bs-secondary-color, #6c757d);
  white-space: nowrap;
  margin-left: auto;
}

.message-bubble-own .message-meta {
  color: rgba(0, 0, 0, 0.45);
}

.message-time-inline {
  font-size: 0.65rem;
}

.message-edited-label {
  font-size: 0.6rem;
  font-style: italic;
  margin-right: 2px;
}

.message-author-name {
  font-size: 0.75rem;
}

/* Галочки прочтения внутри пузыря */
.message-bubble .message-read-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.7rem;
  margin-left: 2px;
}

.message-bubble .message-read-status .ti-check {
  opacity: 0.5;
}

.message-bubble .message-read-status .ti-checks {
  opacity: 1;
}

/* Старые стили для обратной совместимости */
.message-edited-text {
  display: block;
  font-size: 0.72rem;
  text-align: right;
  color: var(--bs-secondary-color, #6c757d);
  margin-top: 0.15rem;
}

/* Галочки прочтения сообщений (для старого формата) */
.message-read-status {
  display: inline-flex;
  align-items: center;
  font-size: 0.85rem;
}

.message-read-status .ti-check {
  opacity: 0.6;
}

.message-read-status .ti-checks {
  opacity: 1;
}

/* Badge с количеством непрочитанных сообщений */
.unread-badge {
  font-size: 0.65rem;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  font-weight: 600;
}

/* Галерея изображений чата */
.chat-gallery-img-btn {
  overflow: hidden;
  border-radius: 0.375rem;
  cursor: pointer;
}

.chat-gallery-img {
  object-fit: cover;
  transition: transform 0.15s ease, opacity 0.15s ease;
}

.chat-gallery-img-btn:hover .chat-gallery-img {
  transform: scale(1.05);
  opacity: 0.9;
}

/* Индикатор "печатает" */
.typing-indicator-text {
  animation: typingPulse 1.5s ease-in-out infinite;
}

.typing-indicator-text .ti-dots {
  animation: typingDots 1s steps(3, end) infinite;
}

@keyframes typingPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.6; }
}

@keyframes typingDots {
  0% { opacity: 0.3; }
  33% { opacity: 0.6; }
  66% { opacity: 1; }
  100% { opacity: 0.3; }
}

.img-thumb {
  width: 120px;
  height: 120px;
  object-fit: cover;
  border-radius: 8px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  transition: transform 0.15s ease-in-out;
}

.img-thumb-btn {
  border-radius: 8px;
  overflow: hidden;
}

.img-thumb-btn:hover .img-thumb {
  transform: scale(1.02);
}

.img-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 2000;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
}

.img-modal-card {
  width: min(96vw, 900px);
  max-height: 92vh;
  background: var(--bs-body-bg);
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
}

.img-modal-body {
  max-height: calc(92vh - 140px);
  display: flex;
  justify-content: center;
  align-items: center;
  overflow: auto;
}

.img-modal-image {
  max-width: 100%;
  max-height: calc(92vh - 180px);
  border-radius: 12px;
  display: block;
  margin: 0 auto;
}


@keyframes reactionPop {
  0% {
    transform: scale(0.9);
  }

  60% {
    transform: scale(1.08);
  }

  100% {
    transform: scale(1);
  }
}

@keyframes counterFlash {
  0% {
    opacity: 0.4;
  }

  100% {
    opacity: 1;
  }
}

/* Мобильные стили для боковой панели вложений - только когда открыта */
@media (max-width: 991.98px) {
  .parent-chat-box.app-chat-right .app-chat-offcanvas {
    width: 100% !important;
    left: 0;
    right: 0;
  }
}

/* Предотвращение выделения текста при долгом нажатии на мобильных */
.chat-box-inner [data-message-id] {
  -webkit-touch-callout: none;
  -webkit-user-select: none;
  user-select: none;
  touch-action: pan-y;
}

/* Позволяем выделять текст внутри сообщения при необходимости */
.chat-box-inner [data-message-id] .p-2 {
  -webkit-user-select: text;
  user-select: text;
}


.popover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 1080;
}

.popover-panel {
  border-radius: 16px;
  animation: popoverSlideIn 0.2s ease-out;
}

.popover-scroll {
  max-height: 380px;
  overflow: auto;
}

.users-scroll {
  max-height: 200px;
  overflow-y: auto;
}

.user-item {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.user-item:hover {
  background-color: var(--bs-gray-100);
}

.user-item:last-child {
  border-bottom: none !important;
}

.user-item.bg-primary-subtle:hover {
  background-color: var(--bs-primary-bg-subtle) !important;
}

.form-check-input {
  width: 1.1rem;
  height: 1.1rem;
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

@keyframes popoverSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.popover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 1080;
}

.popover-panel {
  border-radius: 16px;
  animation: popoverSlideIn 0.2s ease-out;
}

.popover-scroll {
  max-height: 380px;
  overflow: auto;
}

.users-list {
  background: var(--bs-body-bg);
}

.user-item {
  transition: background-color 0.15s ease;
}

.user-item:hover {
  background-color: var(--bs-gray-100);
}

.user-item:last-child {
  border-bottom: none !important;
}

@keyframes popoverSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}








.popover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 1080;
}

.popover-panel {
  border-radius: 16px;
  overflow: hidden;
}

.users-list {
  background: var(--bs-body-bg);
}

.users-scroll {
  max-height: 240px;
  overflow-y: auto;
}

.user-item {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.user-item:hover {
  background-color: var(--bs-gray-100);
}

.user-item:last-child {
  border-bottom: none !important;
}

.user-item.bg-primary-subtle:hover {
  background-color: var(--bs-primary-bg-subtle) !important;
}

/* Скрываем стандартный чекбокс, используем как индикатор */
.form-check-input {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}

.form-check-input:checked {
  background-color: var(--bs-primary);
  border-color: var(--bs-primary);
}

/* Анимация появления */
.popover-panel {
  animation: popoverSlideIn 0.2s ease-out;
}

@keyframes popoverSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}










.popover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.02);
  z-index: 1080;
}

.popover-panel {
  border-radius: 12px;
  overflow: hidden;
}

.popover-scroll {
  max-height: 280px;
  overflow-y: auto;
  overflow-x: hidden;
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  justify-content: center; /* Добавляем центрирование */
  margin: 0 auto; /* Центрируем сетку */
  max-width: fit-content; /* Ширина по содержимому */
}

.emoji-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  border-radius: 8px;
  transition: all 0.15s ease;
  padding: 0;
}

.emoji-btn:hover {
  background-color: var(--bs-primary-bg-subtle) !important;
  transform: scale(1.1);
}

.emoji-btn:active {
  transform: scale(0.95);
}

/* Стрелочка */
.popover-arrow {
  width: 12px;
  height: 12px;
  background: var(--bs-body-bg);
  border-left: 1px solid var(--bs-border-color);
  border-top: 1px solid var(--bs-border-color);
  position: absolute;
  z-index: -1;
}










.popover-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.15);
  z-index: 1080;
}

.popover-panel {
  border-radius: 16px;
  animation: popoverSlideIn 0.2s ease-out;
}

.popover-scroll {
  max-height: 380px;
  overflow-y: auto;
  overflow-x: hidden;
}

/* Стили для аватарок */
.avatar-placeholder {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bs-secondary);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 600;
}

.avatar-placeholder.small {
  width: 24px;
  height: 24px;
  font-size: 0.6rem;
}

.reader-avatars {
  position: relative;
}

/* Стили для блока просмотров */
.views-preview {
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 6px;
  transition: background-color 0.15s ease;
}

.views-preview:hover {
  background-color: var(--bs-gray-100);
}

.readers-details {
  position: absolute;
  left: 0;
  right: 0;
  z-index: 10;
  background: white;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  animation: popoverSlideIn 0.2s ease-out;
}

/* Стили для реакций - унаследованы от emoji-grid выше */

.reaction-emoji {
  display: inline-block;
  min-width: 1.2em;
  text-align: center;
  font-size: 1.1rem;
}

/* Список реакций */
.reactions-list {
  max-height: 120px;
  overflow-y: auto;
}

.reaction-item {
  transition: background-color 0.15s ease;
}

.reaction-item:hover {
  background-color: var(--bs-gray-100);
}

.reaction-item:last-child {
  border-bottom: none !important;
}

/* Стили для блока действий */
.action-item {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.action-item:hover {
  background-color: var(--bs-gray-100);
}

.action-item:last-child {
  border-bottom: none !important;
}

.action-item:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Адаптивность */
@media (max-width: 576px) {
  .emoji-grid {
    grid-template-columns: repeat(4, 1fr);
    gap: 4px;
  }
  
  .emoji-btn {
    width: 32px;
    height: 32px;
    font-size: 1.1rem;
  }
  
  .reactions-list {
    max-height: 100px;
  }
}

@keyframes popoverSlideIn {
  from {
    opacity: 0;
    transform: translateY(-8px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}