/* ===== MESSAGES PAGE ===== */

.navbar {
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 1px 3px rgba(0,0,0,0.06);
}

.nav-link {
  font-size: 0.9rem; font-weight: 500; color: var(--text-2);
  text-decoration: none; transition: color 0.18s;
}
.nav-link:hover { color: var(--text); }

.user-dropdown { position: relative; }
.user-dropdown-trigger {
  display: flex; align-items: center; gap: 8px; cursor: pointer;
  background: none; border: none; font-family: inherit;
  padding: 4px 8px; border-radius: 8px; transition: background 0.18s;
}
.user-dropdown-trigger:hover { background: #f5f5f5; }
.user-avatar-sm {
  width: 34px; height: 34px; border-radius: 50%;
  background: linear-gradient(135deg, var(--accent), #ff6b5b);
  color: #fff; font-weight: 800; font-size: 0.78rem;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.user-name-sm { font-size: 0.88rem; font-weight: 600; color: var(--text); }
.user-dropdown-trigger svg { color: var(--text-2); transition: transform 0.2s; }
.user-dropdown.open .user-dropdown-trigger svg { transform: rotate(180deg); }
.user-dropdown-menu {
  position: absolute; top: calc(100% + 8px); right: 0; min-width: 210px;
  background: var(--bg); border: 1.5px solid var(--border); border-radius: 14px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.12); padding: 6px; z-index: 300;
  opacity: 0; visibility: hidden; transform: translateY(-6px);
  transition: opacity 0.2s, visibility 0.2s, transform 0.2s;
}
.user-dropdown.open .user-dropdown-menu { opacity: 1; visibility: visible; transform: translateY(0); }
.user-dropdown-item {
  display: flex; align-items: center; gap: 10px; padding: 9px 12px;
  border-radius: 8px; font-size: 0.88rem; font-weight: 500; color: var(--text);
  text-decoration: none; transition: background 0.15s;
}
.user-dropdown-item:hover { background: #f5f5f5; }
.user-dropdown-item.active { background: rgba(232,68,58,0.06); color: var(--accent); font-weight: 600; }
.user-dropdown-item svg { color: var(--text-2); flex-shrink: 0; }
.user-dropdown-divider { height: 1px; background: var(--border); margin: 6px 0; }
.user-dropdown-logout { color: var(--accent) !important; }
.user-dropdown-logout svg { color: var(--accent) !important; }
.mob-divider { height: 1px; background: var(--border); margin: 8px 16px; }

/* ===== MESSENGER LAYOUT ===== */
.msg-page {
  height: calc(100vh - 64px);
  display: flex;
  overflow: hidden;
  background: var(--bg-2);
}

/* ===== LEFT: CONVERSATIONS LIST ===== */
.msg-sidebar {
  width: 340px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  background: var(--bg);
  border-right: 1.5px solid var(--border);
}

.msg-sidebar-head {
  padding: 18px 18px 0;
  flex-shrink: 0;
}

.msg-sidebar-title {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -0.03em;
  margin-bottom: 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.msg-count-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  background: var(--accent);
  color: #fff;
  border-radius: 11px;
  font-size: 0.72rem;
  font-weight: 700;
}

.msg-search {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 9px 12px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  margin-bottom: 14px;
}
.msg-search svg { color: var(--text-2); flex-shrink: 0; }
.msg-search input {
  border: none; outline: none; background: transparent;
  font-family: inherit; font-size: 0.88rem; color: var(--text); width: 100%;
}
.msg-search input::placeholder { color: var(--text-2); }

/* Filter tabs */
.msg-tabs {
  display: flex;
  gap: 4px;
  margin-bottom: 10px;
}
.msg-tab {
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--text-2);
  cursor: pointer;
  background: none;
  border: none;
  font-family: inherit;
  transition: background 0.15s, color 0.15s;
}
.msg-tab:hover { background: var(--bg-2); color: var(--text); }
.msg-tab.active { background: rgba(232,68,58,0.08); color: var(--accent); font-weight: 600; }

/* Conversations list */
.msg-list {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
}
.msg-list::-webkit-scrollbar { width: 4px; }
.msg-list::-webkit-scrollbar-track { background: transparent; }
.msg-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

.msg-conv {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 12px 10px;
  border-radius: 12px;
  cursor: pointer;
  transition: background 0.15s;
  position: relative;
}
.msg-conv:hover { background: var(--bg-2); }
.msg-conv.active { background: rgba(232,68,58,0.07); }
.msg-conv.unread .msg-conv-name { font-weight: 700; }
.msg-conv.unread .msg-conv-preview { color: var(--text); font-weight: 500; }

.msg-conv-avatar {
  width: 46px; height: 46px; border-radius: 50%;
  color: #fff; font-size: 0.95rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; letter-spacing: -0.03em;
}
.msg-conv-avatar.green  { background: linear-gradient(135deg, #10b981, #059669); }
.msg-conv-avatar.blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.msg-conv-avatar.purple { background: linear-gradient(135deg, #6366f1, #4f46e5); }
.msg-conv-avatar.orange { background: linear-gradient(135deg, #f59e0b, #d97706); }
.msg-conv-avatar.red    { background: linear-gradient(135deg, var(--accent), #c0392b); }

.msg-conv-body { flex: 1; min-width: 0; }
.msg-conv-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 3px;
}
.msg-conv-name {
  font-size: 0.9rem;
  font-weight: 600;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-conv-time { font-size: 0.75rem; color: var(--text-2); flex-shrink: 0; }
.msg-conv-sub {
  font-size: 0.78rem;
  color: var(--text-2);
  margin-bottom: 3px;
}
.msg-conv-preview {
  font-size: 0.82rem;
  color: var(--text-2);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.msg-unread-dot {
  position: absolute;
  right: 10px;
  top: 50%;
  transform: translateY(-50%);
  width: 8px; height: 8px;
  border-radius: 50%;
  background: var(--accent);
}

/* ===== RIGHT: CHAT AREA ===== */
.msg-chat {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
}

/* Chat header */
.msg-chat-head {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 24px;
  background: var(--bg);
  border-bottom: 1.5px solid var(--border);
  flex-shrink: 0;
}

.msg-chat-avatar {
  width: 42px; height: 42px; border-radius: 50%;
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff; font-size: 0.9rem; font-weight: 800;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}

.msg-chat-info { flex: 1; min-width: 0; }
.msg-chat-name {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text);
}
.msg-chat-meta {
  font-size: 0.78rem;
  color: var(--text-2);
  display: flex;
  align-items: center;
  gap: 6px;
}
.msg-online-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #10b981;
  flex-shrink: 0;
}

.msg-chat-actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.msg-chat-btn {
  width: 36px; height: 36px;
  border: 1.5px solid var(--border);
  border-radius: 9px;
  background: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: var(--text-2);
  transition: all 0.15s;
  text-decoration: none;
}
.msg-chat-btn:hover { border-color: var(--accent); color: var(--accent); }

/* Invitation card (pinned) */
.msg-invite-card {
  margin: 16px 24px 0;
  padding: 14px 18px;
  background: #ecfdf5;
  border: 1.5px solid #6ee7b7;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}
.msg-invite-icon {
  width: 38px; height: 38px; border-radius: 9px;
  background: #10b981; color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.msg-invite-body { flex: 1; min-width: 0; }
.msg-invite-label { font-size: 0.72rem; font-weight: 600; text-transform: uppercase; letter-spacing: 0.06em; color: #059669; margin-bottom: 2px; }
.msg-invite-title { font-size: 0.9rem; font-weight: 700; color: var(--text); }
.msg-invite-meta  { font-size: 0.78rem; color: var(--text-2); }
.msg-invite-actions { display: flex; gap: 8px; flex-shrink: 0; }
.msg-invite-accept {
  padding: 7px 16px; background: #10b981; color: #fff;
  border: none; border-radius: 8px; font-family: inherit;
  font-size: 0.83rem; font-weight: 600; cursor: pointer; transition: background 0.18s;
}
.msg-invite-accept:hover { background: #059669; }
.msg-invite-decline {
  padding: 7px 14px; background: none; color: var(--text-2);
  border: 1.5px solid var(--border); border-radius: 8px; font-family: inherit;
  font-size: 0.83rem; font-weight: 500; cursor: pointer; transition: all 0.18s;
}
.msg-invite-decline:hover { border-color: var(--accent); color: var(--accent); }

/* Messages area */
.msg-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.msg-messages::-webkit-scrollbar { width: 4px; }
.msg-messages::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }

/* Date separator */
.msg-date-sep {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-2);
  font-weight: 500;
  margin: 12px 0 8px;
  position: relative;
}
.msg-date-sep::before,
.msg-date-sep::after {
  content: '';
  position: absolute;
  top: 50%;
  width: calc(50% - 50px);
  height: 1px;
  background: var(--border);
}
.msg-date-sep::before { left: 0; }
.msg-date-sep::after  { right: 0; }

/* Message bubble */
.msg-bubble-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  margin-bottom: 2px;
}
.msg-bubble-wrap.mine { flex-direction: row-reverse; }

.msg-bubble-av {
  width: 30px; height: 30px; border-radius: 50%;
  font-size: 0.7rem; font-weight: 800; color: #fff;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
  background: linear-gradient(135deg, #10b981, #059669);
  align-self: flex-end;
}
.msg-bubble-wrap.mine .msg-bubble-av {
  background: linear-gradient(135deg, var(--accent), #ff6b5b);
}

.msg-bubble {
  max-width: 68%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.55;
  position: relative;
}

/* Theirs */
.msg-bubble-wrap:not(.mine) .msg-bubble {
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-bottom-left-radius: 4px;
  color: var(--text);
}

/* Mine */
.msg-bubble-wrap.mine .msg-bubble {
  background: var(--accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.msg-bubble-time {
  font-size: 0.68rem;
  opacity: 0.65;
  margin-top: 4px;
  display: block;
  text-align: right;
}
.msg-bubble-wrap:not(.mine) .msg-bubble-time { text-align: left; color: var(--text-2); opacity: 1; }

/* Consecutive messages (no avatar for middle ones) */
.msg-bubble-wrap.same-sender .msg-bubble-av { visibility: hidden; }
.msg-bubble-wrap.same-sender:not(.mine) .msg-bubble { border-bottom-left-radius: 16px; border-top-left-radius: 4px; }
.msg-bubble-wrap.same-sender.mine .msg-bubble { border-bottom-right-radius: 16px; border-top-right-radius: 4px; }

/* Status (read receipt) */
.msg-status {
  font-size: 0.7rem;
  color: rgba(255,255,255,0.7);
  display: flex;
  align-items: center;
  gap: 3px;
  justify-content: flex-end;
  margin-top: 2px;
}

/* Typing indicator */
.msg-typing {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 0 0;
}
.msg-typing-dots {
  display: flex;
  gap: 3px;
  padding: 10px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
}
.msg-typing-dots span {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--text-2);
  animation: typing 1.2s infinite;
}
.msg-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.msg-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* Input area */
.msg-input-area {
  padding: 14px 24px 18px;
  background: var(--bg);
  border-top: 1.5px solid var(--border);
  flex-shrink: 0;
}

.msg-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 10px 14px;
  background: var(--bg-2);
  border: 1.5px solid var(--border);
  border-radius: 14px;
  transition: border-color 0.18s;
}
.msg-input-wrap:focus-within { border-color: var(--accent); }

.msg-input {
  flex: 1;
  border: none; outline: none;
  background: transparent;
  font-family: inherit;
  font-size: 0.92rem;
  color: var(--text);
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  padding: 2px 0;
}
.msg-input::placeholder { color: var(--text-2); }

.msg-attach-btn {
  width: 32px; height: 32px; border: none; background: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  color: var(--text-2); border-radius: 8px; transition: all 0.15s; flex-shrink: 0;
}
.msg-attach-btn:hover { background: var(--border); color: var(--text); }

.msg-send-btn {
  width: 36px; height: 36px;
  background: var(--accent); color: #fff;
  border: none; border-radius: 9px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.18s, transform 0.15s;
  flex-shrink: 0;
}
.msg-send-btn:hover { background: #c0392b; transform: scale(1.05); }

.msg-input-hint {
  font-size: 0.75rem;
  color: var(--text-2);
  margin-top: 8px;
  text-align: center;
}

/* ===== EMPTY STATE ===== */
.msg-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  color: var(--text-2);
  text-align: center;
  padding: 40px;
}
.msg-empty-icon {
  width: 72px; height: 72px;
  border-radius: 50%;
  background: var(--bg-3);
  display: flex; align-items: center; justify-content: center;
  margin-bottom: 8px;
  color: var(--text-2);
}
.msg-empty-title { font-size: 1.05rem; font-weight: 700; color: var(--text); }
.msg-empty-sub   { font-size: 0.87rem; max-width: 280px; }

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .msg-sidebar { width: 100%; }
  .msg-chat    { display: none; }
  .msg-sidebar.hidden { display: none; }
  .msg-chat.visible   { display: flex; }
}
