/* Messages Page */
.messages-page {
  display: flex;
  height: calc(100vh - var(--nav-height, 57px) - 48px);
  min-height: 560px;
  max-height: 820px;
  margin: 24px 0;
  background: var(--surface);
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.messages-sidebar {
  width: 250px;
  border-right: 1px solid var(--border);
  background: rgba(255,255,255,0.02);
  display: flex;
  flex-direction: column;
}

.messages-sidebar__title {
  padding: 16px;
  font-size: 1rem;
  border-bottom: 1px solid var(--border);
  margin: 0;
}

.messages-friend-list {
  list-style: none;
  padding: 0;
  margin: 0;
  overflow-y: auto;
}

.messages-friend-item {
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

.messages-friend-item.active {
  background: rgba(255,255,255,0.05);
  border-left: 3px solid var(--primary);
}

.messages-friend-link {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  text-decoration: none;
  color: var(--text);
  transition: background 0.2s;
}

.messages-friend-link:hover {
  background: rgba(255,255,255,0.08);
}

.messages-friend-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  margin-right: 12px;
}

.messages-friend-avatar--default {
  background: var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: var(--text-muted);
}

.messages-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  position: relative;
}

.messages-header {
  padding: 16px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.messages-header__title {
  margin: 0;
  font-size: 1.25rem;
}

.messages-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  text-align: center;
  padding: 24px;
}

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

.messages-input-area {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
}

.call-container {
  background: #000;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-bottom: 1px solid var(--border);
}

.call-video-wrapper {
  display: flex;
  gap: 16px;
  margin-bottom: 16px;
  justify-content: center;
  width: 100%;
}

.call-video-wrapper video {
  max-height: 300px;
  border-radius: 8px;
  background: #222;
}

#remoteVideo {
  flex: 1;
  max-width: 600px;
}

#localVideo {
  width: 150px;
}

/* ─── Chat / Messages Area Styles ─── */
.chat-form {
  display: flex;
  gap: 12px;
  align-items: center;
}

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

.chat-send-btn {
  white-space: nowrap;
  flex-shrink: 0;
  border-radius: var(--radius) !important;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 10px 16px;
}

.chat-msg {
  display: flex;
  gap: 12px;
  align-items: flex-end;
  max-width: 80%;
  animation: fadeIn 0.2s ease;
}

.chat-msg--mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  object-fit: cover;
}

.chat-msg__avatar--default {
  background: var(--border);
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: bold;
  font-size: 0.8rem;
}

.chat-msg__content {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.chat-msg__header {
  display: flex;
  align-items: baseline;
  gap: 8px;
  font-size: 0.8rem;
  margin: 0 4px;
}

.chat-msg--mine .chat-msg__header {
  flex-direction: row-reverse;
}

.chat-msg__name {
  font-weight: 600;
  color: var(--text-muted);
}

.chat-msg__time {
  color: var(--text-dim);
  font-size: 0.7rem;
}

.chat-msg__bubble {
  background: var(--bg-card);
  border: 1px solid var(--border);
  padding: 10px 14px;
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  color: var(--text);
  word-break: break-word;
}

.chat-msg--mine .chat-msg__bubble {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--bg);
  border-bottom-left-radius: 14px;
  border-bottom-right-radius: 4px;
}

/* Свои сообщения: без аватарки, ровное выравнивание вправо */
.chat-msg--mine .chat-msg__avatar {
  display: none;
}
.chat-msg--mine .chat-msg__content {
  align-items: flex-end;
}

.chat-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-muted);
  opacity: 0.6;
  text-align: center;
}

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