.messages-page {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.messages-page .page-title {
  font-size: 1.5rem;
  font-weight: 700;
  margin-bottom: var(--spacing-md);
}

/* Search */
.search-container {
  margin-bottom: var(--spacing-lg);
  max-width: 400px;
}

@media (min-width: 768px) {
  .search-container {
    max-width: 100%;
  }
}

.search-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid #e5e5e5;
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  font-family: inherit;
  background: white;
  transition: border-color 0.2s ease;
}

.search-input:focus {
  outline: none;
  border-color: var(--primary-purple);
}

.search-input::placeholder {
  color: var(--text-grey);
}

/* Messages List */
.messages-list {
  display: flex;
  flex-direction: column;
  gap: var(--spacing-md);
}

.message-item {
  display: flex;
  align-items: flex-start;
  gap: var(--spacing-md);
  padding: var(--spacing-sm) 0;
  cursor: pointer;
  transition: background 0.2s ease;
  border-radius: var(--radius-md);
}

@media (min-width: 768px) {
  .message-item {
    background: white;
    padding: var(--spacing-md);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-sm);
  }

}


.msg-avatar img {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.msg-avatar-initials {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--primary-purple, #7c3aed), #a855f7);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.9rem;
  flex-shrink: 0;
}

.msg-content {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.msg-top {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.125rem;
}

.msg-top h3 {
  font-size: 0.95rem;
  font-weight: 700;
}

.msg-top .dots-btn {
  margin-left: auto;
  color: var(--text-grey);
  background: none;
  border: none;
  padding: 0.25rem;
  cursor: pointer;
  border-radius: var(--radius-sm);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
}

.msg-top .dots-btn:hover {
  background: var(--bg-body);
  color: var(--primary-purple);
}

/* Message Dropdown */
.msg-dropdown {
  background: white;
  border: 1px solid #eee;
  border-radius: var(--radius-md);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
  z-index: 100;
  padding: 0.25rem;
}

.msg-dropdown [role="menuitem"] {
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: background 0.15s ease;
}

.msg-dropdown [role="menuitem"]:hover {
  background: var(--bg-body);
}

.msg-dropdown [role="menuitem"]:focus {
  background: var(--bg-body);
  outline: none;
}

.msg-role {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--primary-purple);
  margin-bottom: 0.25rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-preview {
  font-size: 0.75rem;
  color: var(--text-grey);
  display: flex;
  align-items: center;
  gap: 0.375rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.blue-dot {
  color: var(--primary-purple);
  font-size: 0.6rem;
  flex-shrink: 0;
}

/* ── Real-time: unread & new message highlight ── */

.message-item.has-unread {
  border-left: 3px solid var(--primary-purple, #7c3aed);
}

@media (min-width: 768px) {
  .message-item.has-unread {
    border-left: 3px solid var(--primary-purple, #7c3aed);
  }
}

/* Flash animation when a new message arrives via Firebase real-time */
@keyframes newMessageFlash {
  0%   { background-color: inherit; }
  20%  { background-color: color-mix(in srgb, var(--primary-purple, #7c3aed) 15%, white); }
  80%  { background-color: color-mix(in srgb, var(--primary-purple, #7c3aed) 10%, white); }
  100% { background-color: inherit; }
}

.message-item.new-message-flash {
  animation: newMessageFlash 1.5s ease-out forwards;
}

