/* Современный многоязычный чат */
.chat-container {
  display: flex;
  height: 600px;
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-size: 18px;
}

/* Боковая панель */
.chat-sidebar {
  width: 320px;
  background: #f8f9fa;
  border-right: 1px solid #e9ecef;
  display: flex;
  flex-direction: column;
  font-size: 18px;
}

.chat-sidebar .sidebar-header {
  padding: 15px 20px;
  border-bottom: 1px solid #e9ecef;
  background: #fff;
  height: 60px;
  display: flex;
  align-items: center;
}

.chat-sidebar .search-box {
  position: relative;
  width: 135%;
  display: flex;
  align-items: center;
}

.chat-sidebar .search-box input {
  flex: 1;
  padding: 8px 25px 8px 12px;
  border: 1px solid #dee2e6;
  border-radius: 8px;
  font-size: 14px;
  background: #f8f9fa;
}

.chat-sidebar .search-box input:focus {
  outline: none;
  border-color: #007bff;
  background: #fff;
}

.chat-sidebar .search-box svg {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 10;
  pointer-events: none;
}

.chat-sidebar .users-list {
  flex: 1;
  overflow-y: auto;
  padding: 0;
}

.chat-sidebar .user-item {
  display: flex;
  align-items: center;
  padding: 15px 20px;
  cursor: pointer;
  transition: background-color 0.2s;
  border-bottom: 1px solid #f1f3f4;
  position: relative;
}

.chat-sidebar .user-item:hover {
  background: #f8f9fa;
}

.chat-sidebar .user-item.active {
  background: #e3f2fd;
  border-left: 3px solid #2196f3;
}

.chat-sidebar .user-info {
  flex: 1;
  min-width: 0;
  display: flex;
  align-items: center;
  gap: 12px;
}

.chat-sidebar .user-info .user-name {
  font-weight: 700;
  font-size: 14px;
  color: #212529;
  margin-bottom: 0;
  flex: 1;
}

.chat-sidebar .user-info .last-message {
  font-size: 16px;
  color: #adb5bd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
  position: absolute;
  bottom: 8px;
  left: 44px;
}

.chat-sidebar .avatar-circle {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 14px;
  color: white;
  flex-shrink: 0;
}

.chat-sidebar .user-name {
  font-weight: 700;
  font-size: 18px;
  color: #212529;
  margin-bottom: 4px;
  flex: 1;
}

.chat-sidebar .last-message {
  font-size: 16px;
  color: #adb5bd;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 200px;
}

.chat-sidebar .message-time {
  display: none;
}

.chat-sidebar .user-status {
  display: none;
}

.chat-sidebar .unread-badge {
  background: #dc3545;
  color: white;
  border-radius: 10px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  min-width: 18px;
  text-align: center;
  display: none;
}

.chat-sidebar .unread-badge.has-unread {
  display: block;
}

.chat-sidebar .message-counter {
  position: absolute !important;
  right: 5px !important;
  top: 50% !important;
  transform: translateY(-50%) !important;
  width: 30px !important;
  height: 30px !important;
  border-radius: 50% !important;
  display: flex !important;
  align-items: center !important;
  justify-content: center !important;
  font-size: 12px !important;
  font-weight: 600 !important;
  color: white !important;
  border: 2px solid #fff !important;
  box-shadow: 0 0 0 2px #f8f9fa !important;
  z-index: 10 !important;
}

.chat-sidebar .user-item .message-counter.has-new,
.users-list .user-item .message-counter.has-new {
  background: #28a745 !important;
  display: flex !important;
}

.chat-sidebar .user-item .message-counter.no-new,
.users-list .user-item .message-counter.no-new {
  background: #6c757d !important;
  display: flex !important;
}

/* Скрываем пустые счетчики */
.chat-sidebar .user-item .message-counter:empty,
.users-list .user-item .message-counter:empty {
  display: none !important;
}

/* Базовые стили для счетчика сообщений */
.users-list .user-item {
  position: relative;
}

.users-list .user-item .message-counter {
  position: absolute;
  top: 5px;
  right: 5px;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  color: white;
  font-size: 12px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid white;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* Основная область чата */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: #fff;
}

.chat-main .chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 15px 20px;
  border-bottom: 1px solid #e9ecef;
  background: #fff;
  height: 60px;
}

.chat-main .header-user {
  display: flex;
  align-items: center;
}

.chat-main .user-details .user-name-container {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 2px;
}

.chat-main .user-details .user-name {
  font-weight: 600;
  font-size: 20px;
  color: #212529;
  margin-bottom: 0;
}

.chat-main .user-details .status-indicator {
  display: inline-block !important;
  width: 12px !important;
  height: 12px !important;
  border-radius: 50% !important;
  background: #28a745 !important;
  border: 2px solid #fff !important;
  box-shadow: 0 0 0 1px #28a745 !important;
  flex-shrink: 0 !important;
  position: static !important;
  bottom: auto !important;
  right: auto !important;
}

.chat-main .user-details .user-status {
  font-size: 12px;
  color: #28a745;
  margin-bottom: 0;
}

.chat-main .user-details .user-status.offline {
  color: #6c757d;
}

.chat-main .user-details .status-indicator.offline {
  background: #6c757d !important;
  box-shadow: 0 0 0 1px #6c757d !important;
}

/* Скрываем статус когда чат не выбран */
.chat-main .user-details .user-status.hidden {
  display: none !important;
}

/* Скрываем имя пользователя когда чат не выбран */
.chat-main .user-details .user-name.username.hidden {
  display: none !important;
}

.chat-main .header-actions {
  display: flex;
  gap: 8px;
}

.chat-main .action-btn {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.chat-main .action-btn:hover {
  background: #f8f9fa;
}

/* Стили для сообщений чата - современный дизайн */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  background: #f8f9fa;
  font-size: 14px;
  min-height: 500px; /* Фиксированная минимальная высота для предотвращения мерцания */
  contain: layout style; /* Оптимизация перерисовки */
}

/* Контейнер сообщений */
#messages-items {
  display: flex;
  flex-direction: column;
  gap: 8px;
  scroll-behavior: auto;
  min-height: 400px; /* Фиксированная минимальная высота для предотвращения мерцания */
  height: 100%;
  contain: layout style; /* Оптимизация перерисовки */
}

/* Принудительная прокрутка к последнему сообщению */
#messages-items.scroll-to-bottom {
  scroll-behavior: auto;
}

/* Общие стили для сообщений */
.item {
  display: flex;
  flex-direction: column;
  margin-bottom: 8px;
  max-width: 70%;
}

/* Сообщения получателя (слева) */
.item.you {
  align-self: flex-start;
  align-items: flex-start;
}

.item.you .message {
  background: #e9ecef;
  color: #212529;
  padding: 12px 16px;
  border-radius: 18px 18px 18px 4px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
}

.item.you .bold {
  font-weight: 600;
  font-size: 13px;
  color: #212529;
}

/* Сообщения отправителя (справа) */
.item.right {
  align-self: flex-end;
  align-items: flex-end;
}

.item.right .message {
  background: #007bff;
  color: white;
  padding: 12px 16px;
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
}

.item.right .name {
  font-weight: 600;
  font-size: 13px;
  color: #007bff;
}

/* Стили для времени сообщений */
.item .datetime,
.item .date {
  font-size: 12px;
  color: #6c757d;
  margin-top: 4px;
  display: block;
}

.item.you .datetime {
  text-align: left;
}

.item.right .date {
  text-align: right;
}

/* Стили для файловых вложений */
.file-attachment {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px;
  background: rgba(255, 255, 255, 0.8);
  border-radius: 8px;
  margin-top: 4px;
  font-size: 18px;
}

.file-icon {
  font-size: 20px;
}

.file-name {
  flex: 1;
  font-size: 16px;
  color: #1565c0;
  word-break: break-word;
}

.file-size {
  font-size: 15px;
  color: #90a4ae;
}

.file-download,
.file-delete {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  font-size: 14px;
  transition: background-color 0.2s;
}

.file-download:hover {
  background: rgba(21, 101, 192, 0.1);
}

.file-delete:hover {
  background: rgba(244, 67, 54, 0.1);
}

/* Скрываем старые элементы времени */
.item .datetime[title*="You"] {
  display: none;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
  .item {
    max-width: 85%;
  }

  .item.you .message,
  .item.right .message {
    padding: 10px 14px;
    font-size: 14px;
  }
}

.chat-main .chat-input {
  padding: 20px;
  border-top: 1px solid #e9ecef;
  background: #fff;
}

.chat-main .input-container {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.chat-main .input-actions {
  display: flex;
  gap: 8px;
}

.chat-main .input-actions button {
  background: none;
  border: none;
  padding: 8px;
  border-radius: 6px;
  cursor: pointer;
  transition: background-color 0.2s;
}

.chat-main .input-actions button:hover {
  background: #f8f9fa;
}

.chat-main .message-input {
  flex: 1;
}

.chat-main .message-input textarea {
  width: 100%;
  border: 1px solid #dee2e6;
  border-radius: 20px;
  padding: 12px 16px;
  font-size: 14px;
  resize: none;
  min-height: 44px;
  max-height: 120px;
  font-family: inherit;
}

.chat-main .message-input textarea:focus {
  outline: none;
  border-color: #007bff;
}

.chat-main .send-btn button {
  background: #007bff;
  border: none;
  border-radius: 50%;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background-color 0.2s;
}

.chat-main .send-btn button:hover {
  background: #0056b3;
}

/* Анимации для переключения языков */
[data-lang],
[data-lang-placeholder],
[data-lang-title] {
  transition: opacity 0.3s ease;
}

.chat-container.changing-language [data-lang],
.chat-container.changing-language [data-lang-placeholder],
.chat-container.changing-language [data-lang-title] {
  opacity: 0.7;
}

/* Адаптивность */
@media (max-width: 768px) {
  .chat-container {
    height: 100vh;
    border-radius: 0;
  }

  .chat-sidebar {
    width: 100%;
    display: none;
  }

  .chat-sidebar.show {
    display: flex;
  }

  .chat-main .chat-messages .message-item .message-content {
    max-width: 85%;
  }
}

/* Кнопка прикрепления файла */
.attach-btn {
  background: none;
  border: none;
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: background-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
}

.attach-btn:hover {
  background: #f8f9fa;
}

.attach-btn svg {
  width: 24px;
  height: 24px;
}

/* Модальные окна для кнопок чата */
.emoji-modal,
.user-info-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
}

.emoji-content,
.file-preview-content,
.user-info-content {
  background: white;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
  max-width: 90%;
  max-height: 90%;
  overflow: hidden;
}

.emoji-header,
.file-preview-header,
.user-info-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid #e9ecef;
}

.emoji-header h4,
.file-preview-header h4,
.user-info-header h4 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  color: #212529;
}

.close-btn {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #6c757d;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.close-btn:hover {
  background: #f8f9fa;
}

/* Эмодзи пикер */
.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 10px;
  padding: 20px;
  max-height: 300px;
  overflow-y: auto;
}

.emoji-item {
  font-size: 32px;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  text-align: center;
  transition: background-color 0.2s;
}

.emoji-item:hover {
  background: #f8f9fa;
}

/* Информация о пользователе */
.user-info-body {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}

.user-avatar-large {
  position: relative;
}

.user-avatar-large .avatar-circle {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 24px;
}

.user-avatar-large .status-indicator {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  border: 3px solid #fff;
  background: #28a745;
}

.user-details h5 {
  margin: 0 0 8px 0;
  font-size: 24px;
  font-weight: 600;
  color: #212529;
}

.user-details p {
  margin: 4px 0;
  font-size: 18px;
  color: #6c757d;
}

.user-info-actions {
  display: flex;
  gap: 10px;
  padding: 20px;
  border-top: 1px solid #e9ecef;
}

.send-message-btn,
.block-user-btn {
  padding: 10px 20px;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: background-color 0.2s;
}

.send-message-btn {
  background: #007bff;
  color: white;
}

.send-message-btn:hover {
  background: #0056b3;
}

.block-user-btn {
  background: #dc3545;
  color: white;
}

.block-user-btn:hover {
  background: #c82333;
}

/* Меню дополнительных опций */
.more-options-menu {
  background: white;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  border: 1px solid #e9ecef;
  min-width: 200px;
}

.menu-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background-color 0.2s;
  border-bottom: 1px solid #f1f3f4;
}

.menu-item:last-child {
  border-bottom: none;
}

.menu-item:hover {
  background: #f8f9fa;
}

.menu-item svg {
  flex-shrink: 0;
}

.menu-item span {
  font-size: 18px;
  color: #212529;
}

/* Стили для режима списка */
.items-list.--list {
  display: inline-block;
}

.items-list.--list > .item {
  width: 100%;
  max-width: 100%;
  height: 151px;
  display: flex;
  flex-direction: row;
}

.items-list.--list > .item:not(:nth-child(4n)) {
  margin-right: 0;
  margin-bottom: 0.6rem;
}

.items-list.--list > .item > .image {
  min-width: 150px;
  max-width: 150px;
  width: 150px;
  height: 151px;
  border-top: 1px solid #ccc;
  border-left: 1px solid #ccc;
  border-right: none;
  border-bottom: 1px solid #ccc;
  border-radius: 4px 0 0 4px;
  overflow: hidden;
}

.items-list.--list > .item > .content {
  flex: 1;
  width: auto;
  height: 151px;
  border-left: none;
  border-top: 1px solid #ccc;
  border-right: 1px solid #ccc;
  border-bottom: 1px solid #ccc;
  border-radius: 0 4px 4px 0;
  padding: 0.6rem;
}

.items-list.--list > .item > .content > .link {
  height: auto;
  max-height: 30px;
}

.items-list.--list > .item > .content > .link > svg {
  margin-right: 0.2rem;
}

.items-list.--list > .item > .content > .link > a {
  font-size: 1rem;
  line-height: 15px;
}

.items-list.--list > .item > .content > .price {
  font-size: 1rem;
  margin-top: 0.4rem;
}

.items-list.--list > .item > .content > .description {
  font-size: 0.8rem;
  color: #666;
  max-height: 42px;
  overflow: hidden;
}

/* Специальные стили для fotorama в режиме списка */
.items-list.--list .item .image .fotorama {
  .fotorama__img {
    object-fit: cover !important;
    object-position: center !important;
    width: 100% !important;
    height: 151px !important;
  }

  .fotorama__stage {
    height: 151px !important;
  }

  .fotorama__stage__frame {
    height: 151px !important;
  }

  .fotorama__stage__shaft {
    height: 151px !important;
  }
}

/* Стили для свойств в detail компоненте */
.properties {
  width: 100% !important;
  padding-left: 1rem !important;
  padding-right: 1rem !important;
}

.properties > .item {
  display: flex !important;
  flex-direction: row !important;
  align-items: flex-start !important;
  font-size: 0.95rem !important;
  width: 100% !important;
}

.properties > .item:not(:last-child) {
  margin-bottom: 0.8rem !important;
}

.properties > .item > .name {
  width: 20% !important;
  min-width: 20% !important;
  color: #666 !important;
  flex-shrink: 0 !important;
  display: inline-block !important;
  margin-right: 1rem !important;
}

.properties > .item > .value {
  width: 80% !important;
  color: #333 !important;
  flex: 1 !important;
  display: inline-block !important;
}

/* Дополнительные специфичные стили для свойств */
.properties .item .name,
.properties .item .value {
  display: inline !important;
  float: none !important;
  clear: none !important;
}

.properties .item {
  white-space: nowrap !important;
  overflow: hidden !important;
}

.properties .item .name {
  white-space: nowrap !important;
  overflow: hidden !important;
  text-overflow: ellipsis !important;
}

.properties .item .value {
  white-space: normal !important;
  word-wrap: break-word !important;
}

/* Стили для индикаторов фильтра */
#input-ind-*,
#dropdown-ind-* {
  display: inline-block !important;
}

[id^="input-ind-"],
[id^="dropdown-ind-"] {
  display: inline-block !important;
}

#input-ind-* .active,
#dropdown-ind-* .active {
  display: inline-block !important;
  position: relative !important;
  width: 6px !important;
  height: 6px !important;
  background: #007bff !important;
  border-radius: 50% !important;
  margin-left: 5px !important;
  top: -5px !important;
  vertical-align: middle !important;
}

/* Альтернативный селектор для всех индикаторов */
[id^="input-ind-"] .active,
[id^="dropdown-ind-"] .active {
  display: inline-block !important;
  position: relative !important;
  width: 6px !important;
  height: 6px !important;
  background: #007bff !important;
  border-radius: 50% !important;
  margin-left: 5px !important;
  top: -5px !important;
  vertical-align: middle !important;
}
