/* ============================================================
   LaminPack Chat — Web/PC Version
   Стили соответствуют планшетной версии (sw600dp)
   ============================================================ */

/* ─── Общий контейнер ─────────────────────────────────────── */
.chat-container {
  display: flex;
  height: calc(100vh - 180px);
  background: linear-gradient(135deg, #F8F9FA 0%, #E3F2FD 100%);
  border-radius: 8px;
  overflow: hidden;
  position: relative;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

/* ─── Левая панель (Sidebar) ─────────────────────────────── */
.chat-sidebar {
  width: 320px;
  min-width: 320px;
  background: #FFFFFF;
  border-right: 1px solid #E0E0E0;
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  box-shadow: 4px 0px 10px rgba(0, 0, 0, 0.05);
  z-index: 10;
}

.chat-sidebar-header {
  padding: 14px 16px;
  font-size: 18px;
  font-weight: 700;
  color: #244A7B;
  border-bottom: 1px solid #F0F0F0;
}

.chat-section-label {
  font-size: 11px;
  font-weight: 700;
  color: #888888;
  text-transform: uppercase;
  padding: 6px 16px;
}

.chat-room-item {
  height: 52px;
  padding: 0 16px;
  margin: 4px 8px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}

.chat-room-item:hover { background: #F5F5F5; }
.chat-room-item.active { background: #E3F2FD; }

.chat-room-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #244A7B;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  font-weight: 600;
  flex-shrink: 0;
  position: relative;
}

.chat-room-info {
  flex: 1;
  margin-left: 12px;
  overflow: hidden;
}

.chat-room-name {
  font-size: 13px;
  font-weight: 600;
  color: #333333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-room-subtitle {
  font-size: 11px;
  color: #888888;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 2px;
}

.chat-room-badge {
  background: #244A7B;
  color: white;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 700;
  min-width: 20px;
  text-align: center;
}

/* Точка онлайна */
.online-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #4CAF50;
  position: absolute;
  bottom: 0;
  right: 0;
  border: 2px solid white;
}

.offline-dot {
  background: #BDBDBD;
}

/* ─── Правая панель (Main Chat) ──────────────────────────── */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: linear-gradient(135deg, #F8F9FA 0%, #E3F2FD 100%);
  min-width: 0;
}

/* Placeholder */
.chat-placeholder {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  color: #888888;
}

.chat-placeholder-icon { font-size: 64px; }
.chat-placeholder-title { font-size: 20px; font-weight: 700; color: #244A7B; }
.chat-placeholder-subtitle { font-size: 14px; }

/* ─── Хедер чата ─────────────────────────────────────────── */
.chat-header {
  background-color: #244A7B;
  color: #FFFFFF;
  height: 72px;
  min-height: 72px;
  padding: 0 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.chat-header-info { min-width: 0; }

.chat-header-info h2 {
  font-size: 20px;
  font-weight: 700;
  color: white;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-subtitle {
  font-size: 14px;
  opacity: 0.8;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-header-actions {
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-header-btn {
  width: 48px;
  height: 48px;
  border: none;
  background: transparent;
  color: white;
  font-size: 22px;
  cursor: pointer;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
}

.chat-header-btn:hover { background: rgba(255, 255, 255, 0.15); }

/* Поиск в хедере */
.chat-search-bar {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 24px;
  padding: 0 16px;
  height: 44px;
}

.chat-search-bar input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: white;
  font-size: 15px;
}

.chat-search-bar input::placeholder { color: rgba(255, 255, 255, 0.7); }

.chat-search-count {
  font-size: 13px;
  color: rgba(255, 255, 255, 0.9);
  white-space: nowrap;
}

/* ─── Панель закрепов ────────────────────────────────────── */
.chat-pinned-panel {
  background: #FFFFFF;
  border-bottom: 1px solid #E0E0E0;
  padding: 8px 16px;
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.chat-pinned-panel:hover { background: #F5F5F5; }

.chat-pinned-icon { font-size: 16px; }
.chat-pinned-text {
  flex: 1;
  font-size: 13px;
  color: #244A7B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-pinned-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}

.chat-pinned-nav button {
  border: none;
  background: transparent;
  cursor: pointer;
  color: #244A7B;
  font-size: 16px;
  padding: 4px 8px;
  border-radius: 4px;
}

.chat-pinned-nav button:hover { background: #E3F2FD; }

.chat-pinned-counter {
  font-size: 12px;
  color: #888888;
  font-weight: 600;
}

/* ─── Область сообщений ──────────────────────────────────── */
.chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
}

.chat-empty {
  text-align: center;
  padding: 60px 20px;
  color: #888888;
}

.chat-empty-icon { font-size: 64px; margin-bottom: 16px; }

/* Разделитель даты */
.chat-date-separator {
  text-align: center;
  margin: 16px 0;
}

.chat-date-separator span {
  background-color: #244A7B;
  border-radius: 8px;
  color: #FFFFFF;
  padding: 4px 12px;
  font-size: 12px;
  font-weight: 700;
}

/* Разделитель непрочитанных */
.unread-divider {
  text-align: center;
  margin: 16px 0;
}

.unread-divider span {
  background: #FFE0B2;
  color: #E65100;
  padding: 4px 12px;
  border-radius: 10px;
  font-size: 12px;
  font-weight: 500;
}

/* ─── Сообщения ──────────────────────────────────────────── */
.chat-message-wrapper {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  margin-bottom: 3px;
  animation: messageIn 0.2s ease-out;
}

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

.message-own { flex-direction: row-reverse; }
.message-same-author { margin-top: -2px; }

.chat-avatar-small {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #244A7B;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  flex-shrink: 0;
  align-self: flex-end;
  margin-bottom: 2px;
}

.message-own .chat-avatar-small { display: none; }
.chat-avatar-hidden { visibility: hidden; }

.chat-message-content {
  max-width: 75%;
  position: relative;
}

.message-own .chat-message-content {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.chat-message-author {
  font-size: 12px;
  font-weight: 700;
  margin-bottom: 1px;
  padding-left: 8px;
  color: #244A7B;
  text-align: left;
}

.message-own .chat-message-author {
  text-align: right;
  padding-left: 0;
  padding-right: 8px;
}

/* Бабл */
.chat-bubble {
  background: #FFFFFF;
  padding: 6px 10px;
  border-radius: 12px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
  position: relative;
}

.bubble-own {
  background: #DEE9F2;
  border-radius: 12px 0 12px 12px;
}

.chat-text {
  font-size: 15px;
  line-height: 1.4;
  word-wrap: break-word;
  white-space: pre-wrap;
  color: #333333;
}

.chat-text a { color: #244A7B; text-decoration: none; }

/* Reply внутри бабла */
.chat-message-reply {
  background: #F5F5F5;
  border-left: 3px solid #244A7B;
  border-radius: 4px;
  padding: 4px 8px;
  margin-bottom: 4px;
  display: flex;
  gap: 6px;
  cursor: pointer;
  font-size: 12px;
}

.reply-line {
  width: 3px;
  background: #244A7B;
  border-radius: 2px;
  flex-shrink: 0;
}

.reply-content { overflow: hidden; }
.reply-author { color: #244A7B; font-weight: 600; }
.reply-text {
  color: #666666;
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Изображения */
.chat-image {
  max-width: 240px;
  border-radius: 4px;
  cursor: pointer;
  display: block;
  margin-bottom: 4px;
}

/* Карточка файла */
.chat-file-card {
  background: rgba(36, 74, 123, 0.1);
  border-radius: 8px;
  padding: 8px;
  width: 240px;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.chat-file-icon { font-size: 24px; }

.chat-file-info { flex: 1; min-width: 0; }

.chat-file-name {
  font-size: 12px;
  font-weight: 600;
  color: #244A7B;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-file-size { font-size: 10px; color: #888888; }

/* Метаданные */
.chat-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 4px;
  margin-top: 2px;
}

.chat-time { font-size: 10px; color: #888888; font-style: italic; }
.bubble-own .chat-time { color: #244A7B; }

.chat-edited {
  font-size: 10px;
  color: #888888;
  margin-left: 4px;
  font-style: italic;
}

/* Статусы сообщений */
.chat-status-icon {
  font-size: 14px;
  color: #244A7B;
}

/* Reply кнопка */
.chat-reply-btn {
  display: none;
  position: absolute;
  top: -8px;
  right: 8px;
  background: white;
  border: 1px solid #BDBDBD;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  font-size: 12px;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  align-items: center;
  justify-content: center;
}

.chat-message-content:hover .chat-reply-btn {
  display: flex;
}

/* Highlight */
@keyframes highlight {
  0% { background: rgba(36, 74, 123, 0.25); }
  100% { background: transparent; }
}

.chat-highlight {
  animation: highlight 2s ease-out;
}

/* ─── Typing индикатор ───────────────────────────────────── */
.chat-typing {
  font-size: 12px;
  color: #888888;
  padding: 4px 20px;
  min-height: 20px;
  font-style: italic;
}

.typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #888888;
  animation: typingBlink 1.4s infinite;
}

.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBlink {
  0%, 60%, 100% { opacity: 0.3; }
  30% { opacity: 1; }
}

/* ─── Reply preview ──────────────────────────────────────── */
.chat-reply-preview {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #FFFFFF;
  padding: 8px 16px;
  margin: 0 16px;
  border-radius: 8px 8px 0 0;
  border-left: 3px solid #244A7B;
}

.reply-preview-label {
  font-size: 11px;
  color: #244A7B;
  font-weight: 600;
}

.reply-preview-text {
  font-size: 13px;
  color: #333333;
  margin-left: 8px;
}

.reply-preview-close {
  background: none;
  border: none;
  color: #BDBDBD;
  cursor: pointer;
  font-size: 16px;
  padding: 0 4px;
}

/* ─── Панель ввода ───────────────────────────────────────── */
.chat-footer {
  background: #FFFFFF;
  border-top: 1px solid #E0E0E0;
}

/* Markdown Toolbar */
.md-toolbar {
  background: #F9F9F9;
  border-bottom: 1px solid #EEEEEE;
  height: 40px;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 0 8px;
}

.md-btn {
  border: none;
  background: transparent;
  color: #444444;
  font-size: 16px;
  cursor: pointer;
  padding: 6px 10px;
  border-radius: 4px;
  transition: background 0.15s;
}

.md-btn:hover { background: #E0E0E0; }

.chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 16px;
}

.chat-input-wrapper {
  flex: 1;
  background: #F0F0F0;
  border-radius: 8px;
  border: 1px solid #E0E0E0;
  min-height: 48px;
  padding: 0 12px;
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.chat-input-icon-btn {
  border: none;
  background: transparent;
  cursor: pointer;
  font-size: 20px;
  padding: 12px 4px;
  color: #888888;
}

.chat-input {
  flex: 1;
  border: none;
  background: transparent;
  padding: 12px 0;
  font-size: 18px;
  outline: none;
  resize: none;
  min-height: 48px;
  max-height: 150px;
  line-height: 1.4;
  font-family: inherit;
  color: #333333;
}

.chat-input::placeholder { color: #888888; }

.chat-send-btn {
  background: #244A7B;
  border: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(36, 74, 123, 0.3);
  transition: background 0.15s;
}

.chat-send-btn:hover { background: #1B3A62; }

/* ─── FAB Scroll to Bottom ───────────────────────────────── */
.chat-fab {
  position: absolute;
  bottom: 100px;
  right: 24px;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: #FFFFFF;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  z-index: 100;
}

.chat-fab-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #F44336;
  color: white;
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 10px;
  font-weight: 700;
}

/* ─── Контекстное меню ───────────────────────────────────── */
.context-menu {
  position: fixed;
  background: #FFFFFF;
  border-radius: 24px;
  border: 1px solid #DDDDDD;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15);
  z-index: 10001;
  min-width: 220px;
  overflow: hidden;
  padding: 8px 0;
}

.ctx-item {
  height: 40px;
  padding: 0 24px;
  display: flex;
  align-items: center;
  font-size: 14px;
  color: #333333;
  cursor: pointer;
  transition: background 0.15s;
}

.ctx-item:hover { background: #F0F0F0; }
.ctx-delete { color: #F44336; }

.ctx-divider {
  height: 1px;
  background: #EEEEEE;
  margin: 8px 0;
}

/* Панель реакций */
.reaction-panel {
  position: fixed;
  background: #FFFFFF;
  border-radius: 24px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15);
  z-index: 10002;
  padding: 8px 12px;
  display: flex;
  gap: 12px;
}

.reaction-emoji {
  font-size: 28px;
  cursor: pointer;
  transition: transform 0.15s;
}

.reaction-emoji:hover { transform: scale(1.3); }

/* Реакции под сообщением */
.chat-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
}

.chat-reaction-badge {
  background: #F0F0F0;
  border-radius: 12px;
  padding: 2px 8px;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 4px;
}

.chat-reaction-badge.active {
  background: #E3F2FD;
  border: 1px solid #244A7B;
}

/* ─── Select Mode ────────────────────────────────────────── */
.chat-select-checkbox {
  display: flex;
  align-items: center;
  margin-right: 4px;
}

.chat-select-checkbox input {
  width: 16px;
  height: 16px;
  cursor: pointer;
}

.bulk-panel {
  display: flex;
  justify-content: center;
  padding: 8px 16px;
  background: #FFFFFF;
  border-top: 1px solid #E0E0E0;
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}

.bulk-panel-content {
  display: flex;
  align-items: center;
  gap: 16px;
}

.bulk-count { font-weight: 600; color: #333333; font-size: 14px; }

/* ─── Модалки ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.5);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-content {
  background: #FFFFFF;
  border-radius: 12px;
  padding: 24px;
  width: 420px;
  max-height: 80vh;
  overflow-y: auto;
  position: relative;
}

.modal-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 16px;
}

.modal-search {
  width: 100%;
  padding: 10px 14px;
  border: 1px solid #DDDDDD;
  border-radius: 8px;
  font-size: 14px;
  margin-bottom: 12px;
  outline: none;
}

.modal-user-list { max-height: 300px; overflow-y: auto; }

.modal-user-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px;
  border-radius: 8px;
  cursor: pointer;
}

.modal-user-item:hover { background: #F0F5FF; }

.modal-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #244A7B;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

.modal-user-info { flex: 1; }
.modal-user-name { font-size: 14px; font-weight: 500; }
.modal-user-role { font-size: 12px; color: #888888; }

.modal-close {
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  position: absolute;
  top: 12px;
  right: 12px;
  color: #888888;
}

/* ─── Lightbox ───────────────────────────────────────────── */
.lightbox {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0,0,0,0.95);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-direction: column;
}

.lightbox img {
  max-width: 90%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
}

.lightbox-top { position: absolute; top: 20px; right: 20px; }
.lightbox-bottom { position: absolute; bottom: 20px; }

.lightbox-close, .lightbox-download {
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  padding: 10px 20px;
  border-radius: 8px;
  font-size: 18px;
  cursor: pointer;
}

.lightbox-close:hover, .lightbox-download:hover {
  background: rgba(255,255,255,0.4);
}

/* ─── Адаптивность ───────────────────────────────────────── */
@media (max-width: 768px) {
  .chat-sidebar {
    width: 100%;
    min-width: 100%;
    position: absolute;
    top: 0;
    left: 0;
    height: 100%;
    z-index: 50;
    display: none;
  }
  
  .chat-sidebar.mobile-open {
    display: flex;
  }
  
  .chat-main {
    width: 100%;
  }
}

/* Минипревью в закрепе */
.chat-pinned-thumb {
  width: 32px;
  height: 32px;
  border-radius: 4px;
  object-fit: cover;
  flex-shrink: 0;
}

/* Панель эмодзи */
.emoji-panel {
  position: absolute;
  bottom: 80px;
  left: 16px;
  background: #FFFFFF;
  border-radius: 12px;
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.15);
  padding: 8px;
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  max-width: 360px;
  z-index: 1000;
}

/* Drag & Drop Overlay */
.drop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(36, 74, 123, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.drop-overlay-content {
  text-align: center;
}

.drop-overlay-icon { font-size: 48px; }
.drop-overlay-text { font-size: 16px; color: #244A7B; font-weight: 600; margin-top: 8px; }

/* Lightbox навигация */
.lightbox-nav {
  background: rgba(255,255,255,0.2);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  margin: 0 4px;
}

.lightbox-counter {
  color: white;
  font-size: 14px;
  margin: 0 8px;
}

/* Увеличение изображения */
.chat-image-wrapper {
  position: relative;
  display: inline-block;
}

.chat-image-zoom {
  position: absolute;
  bottom: 8px;
  right: 8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  cursor: pointer;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.2s;
}

.chat-image-wrapper:hover .chat-image-zoom {
  opacity: 1;
}

/* Светбокс */
.lightbox img {
  max-width: 90%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: 4px;
  cursor: zoom-in;
}