/* ============================================================
   chat.css — стили для мессенджера
   ============================================================ */

/* Общий каркас чата */
.chat-layout {
  display: flex;
  height: calc(100vh - var(--topbar-h) - var(--content-pad) * 2);
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow-sm);
}

/* ---------- Левая колонка (контакты) ---------- */
.chat-sidebar {
  width: 280px;
  flex-shrink: 0;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--bg-elevated);
}

.chat-sidebar-header {
  padding: 16px 18px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
}

.chat-users-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.chat-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background var(--t-fast);
}

.chat-user:hover {
  background: var(--bg-hover);
}

.chat-user.is-active {
  background: var(--accent-soft);
}

.chat-user.is-active .chat-user-name {
  color: var(--accent);
}

.chat-user-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--bg-sunken);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 13px;
  flex-shrink: 0;
  text-transform: uppercase;
}

.chat-user.is-active .chat-user-avatar {
  background: var(--accent);
  color: #fff;
}

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

.chat-user-name {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-user-role {
  font-size: 11.5px;
  color: var(--text-muted);
}

/* ---------- Правая колонка (сообщения) ---------- */
.chat-main {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  background: var(--bg);
}

.chat-main-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 15px;
  background: var(--bg-elevated);
  flex-shrink: 0;
}

.chat-messages {
  flex: 1;
  padding: 24px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

/* ---------- Пузыри сообщений ---------- */
.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 70%;
}

.chat-msg.is-out {
  align-self: flex-end;
  align-items: flex-end;
}

.chat-msg.is-in {
  align-self: flex-start;
  align-items: flex-start;
}

.chat-msg-bubble {
  padding: 10px 14px;
  border-radius: var(--radius-lg);
  font-size: 14px;
  line-height: 1.4;
  word-break: break-word;
}

.chat-msg.is-in .chat-msg-bubble {
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

.chat-msg.is-out .chat-msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.chat-msg-time {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 4px;
  padding: 0 4px;
}

/* ---------- Поле ввода ---------- */
.chat-input-area {
  padding: 16px 24px;
  background: var(--bg-elevated);
  border-top: 1px solid var(--border);
  display: flex;
  gap: 12px;
  flex-shrink: 0;
}

.chat-input {
  flex: 1;
  height: 40px;
  padding: 0 16px;
  border: 1px solid var(--border-strong);
  border-radius: var(--radius-pill);
  background: var(--bg-elevated);
  color: var(--text);
  font-size: 14px;
  transition: border-color var(--t-fast), box-shadow var(--t-fast);
}

.chat-input:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
  outline: none;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background var(--t-fast), transform var(--t-fast);
}

.chat-send-btn:hover:not(:disabled) {
  background: var(--accent-hover);
}
.chat-send-btn:active:not(:disabled) {
  transform: scale(0.95);
}
.chat-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Мобильная адаптация */
@media (max-width: 768px) {
  .chat-layout {
    flex-direction: column;
    height: calc(100vh - var(--topbar-h) - var(--content-pad) * 2);
  }
  .chat-sidebar {
    width: 100%;
    height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--border);
  }
}