/* ============================================
   SPHERE MESSENGER - Modern Redesign
   iMessage/Messenger inspired UI
   Teal-to-Green gradient: #0891b2 → #06d6a0
   ============================================ */

:root {
  --msg-primary: #0891b2;
  --msg-secondary: #06d6a0;
  --msg-gradient: linear-gradient(135deg, #0891b2 0%, #06d6a0 100%);
  --msg-sent-bg: linear-gradient(135deg, #0891b2 0%, #06d6a0 100%);
  --msg-received-bg: var(--surface-elevated, #2d2d3a);
  --msg-online: #22c55e;
  --msg-typing: #94a3b8;
  --msg-reaction-bg: rgba(8, 145, 178, 0.15);
}

/* ============================================
   MESSENGER LAYOUT - Split View
   ============================================ */

.messenger-container {
  display: flex;
  height: calc(100vh - 60px);
  background: var(--bg-primary);
}

/* ============================================
   CONVERSATION LIST (Left Panel)
   ============================================ */

.conversations-panel {
  width: 360px;
  min-width: 320px;
  max-width: 400px;
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  background: var(--surface);
}

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

.conversations-header h2 {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin: 0;
}

.conversations-header-actions {
  display: flex;
  gap: 8px;
}

.header-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--surface-elevated);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.header-action-btn:hover {
  background: var(--msg-reaction-bg);
  color: var(--msg-primary);
}

.header-action-btn.new-chat {
  background: var(--msg-gradient);
  color: white;
}

.header-action-btn.new-chat:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.4);
}

/* Search Bar */
.conversations-search {
  padding: 12px 16px;
  position: relative;
}

.search-input-wrapper {
  position: relative;
  display: flex;
  align-items: center;
}

.search-input-wrapper svg {
  position: absolute;
  left: 14px;
  color: var(--text-muted);
  pointer-events: none;
}

.conversations-search input {
  width: 100%;
  padding: 10px 14px 10px 42px;
  border-radius: 24px;
  background: var(--surface-elevated);
  border: 1px solid transparent;
  color: var(--text-primary);
  font-size: 0.9rem;
  transition: all 0.2s;
}

.conversations-search input:focus {
  outline: none;
  border-color: var(--msg-primary);
  background: var(--bg-primary);
}

/* Conversation Tabs */
.conversation-tabs {
  display: flex;
  padding: 0 16px;
  gap: 4px;
  border-bottom: 1px solid var(--border);
}

.conv-tab {
  flex: 1;
  padding: 12px 16px;
  background: transparent;
  border: none;
  border-bottom: 2px solid transparent;
  color: var(--text-muted);
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.conv-tab:hover {
  color: var(--text-primary);
}

.conv-tab.active {
  color: var(--msg-primary);
  border-bottom-color: var(--msg-primary);
}

/* Conversations List */
.conversations-scroll {
  flex: 1;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}

.conversations-scroll::-webkit-scrollbar {
  width: 6px;
}

.conversations-scroll::-webkit-scrollbar-thumb {
  background: var(--border);
  border-radius: 3px;
}

/* Individual Conversation Item */
.conversation-item {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 18px;
  cursor: pointer;
  transition: all 0.2s ease;
  position: relative;
  border-left: 3px solid transparent;
}

.conversation-item:hover {
  background: var(--surface-elevated);
  transform: translateX(2px);
}

.conversation-item.active {
  background: var(--msg-reaction-bg);
  border-left-color: var(--msg-primary);
  transform: translateX(0);
}

.conversation-item.unread {
  background: rgba(8, 145, 178, 0.05);
}

/* Conversation Avatar */
.conv-avatar-wrapper {
  position: relative;
  flex-shrink: 0;
}

.conv-avatar {
  width: 52px;
  height: 52px;
  border-radius: 50%;
  object-fit: cover;
}

.conv-avatar.group-avatar {
  border-radius: 16px;
}

/* Online Status Indicator */
.online-indicator {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 14px;
  height: 14px;
  background: var(--msg-online);
  border: 3px solid var(--surface);
  border-radius: 50%;
  box-shadow: 0 0 0 1px rgba(0,0,0,0.1);
}

.online-indicator.away {
  background: #fbbf24;
}

.online-indicator.offline {
  display: none;
}

/* Conversation Content */
.conv-content {
  flex: 1;
  min-width: 0;
}

.conv-header-row {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  margin-bottom: 4px;
}

.conv-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  display: flex;
  align-items: center;
  gap: 6px;
}

.conv-name .verified-badge {
  color: var(--msg-primary);
}

.conv-time {
  font-size: 0.75rem;
  color: var(--text-muted);
  flex-shrink: 0;
}

.conversation-item.unread .conv-time {
  color: var(--msg-primary);
  font-weight: 600;
}

.conv-preview-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

.conv-preview {
  flex: 1;
  font-size: 0.875rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conversation-item.unread .conv-preview {
  color: var(--text-primary);
  font-weight: 500;
}

.conv-typing {
  color: var(--msg-primary);
  font-style: italic;
}

/* Unread Badge */
.unread-badge {
  min-width: 22px;
  height: 22px;
  padding: 0 7px;
  background: var(--msg-gradient);
  color: white;
  border-radius: 11px;
  font-size: 0.7rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.4);
  animation: badge-pop 0.3s ease;
}

@keyframes badge-pop {
  0% { transform: scale(0); }
  60% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Muted indicator */
.muted-indicator {
  color: var(--text-muted);
}

/* Last active status row */
.conv-status-row {
  margin-top: 2px;
}

.conv-last-active {
  font-size: 0.7rem;
  color: var(--text-muted);
}

.conv-last-active.online {
  color: var(--msg-online, #22c55e);
  font-weight: 500;
}

/* Enhanced online indicator animation */
.online-indicator {
  animation: pulse-online 2s ease-in-out infinite;
}

@keyframes pulse-online {
  0%, 100% {
    box-shadow: 0 0 0 0 rgba(34, 197, 94, 0.4);
  }
  50% {
    box-shadow: 0 0 0 6px rgba(34, 197, 94, 0);
  }
}

/* ============================================
   CHAT PANEL (Right Panel)
   ============================================ */

.chat-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  background: var(--bg-primary);
  min-width: 0;
}

/* Empty State */
.chat-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  padding: 40px;
  text-align: center;
}

.chat-empty-icon {
  width: 120px;
  height: 120px;
  margin-bottom: 24px;
  opacity: 0.4;
  background: var(--msg-gradient);
  -webkit-background-clip: text;
  background-clip: text;
}

.chat-empty-icon svg {
  width: 100%;
  height: 100%;
}

.chat-empty h3 {
  font-size: 1.5rem;
  color: var(--text-primary);
  margin-bottom: 8px;
}

.chat-empty p {
  font-size: 1rem;
  margin-bottom: 24px;
}

.chat-empty-btn {
  padding: 12px 32px;
  background: var(--msg-gradient);
  color: white;
  border: none;
  border-radius: 24px;
  font-weight: 600;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.2s;
}

.chat-empty-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 8px 20px rgba(8, 145, 178, 0.4);
}

/* Chat Header */
.chat-header {
  padding: 12px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
}

.chat-header-avatar {
  position: relative;
  flex-shrink: 0;
}

.chat-header-avatar img {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
  cursor: pointer;
  transition: transform 0.2s;
}

.chat-header-avatar img:hover {
  transform: scale(1.05);
}

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

.chat-header-name {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
}

.chat-header-name:hover {
  color: var(--msg-primary);
}

.chat-header-status {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 6px;
}

.chat-header-status.online {
  color: var(--msg-online);
}

.chat-header-status .status-dot {
  width: 8px;
  height: 8px;
  background: var(--msg-online);
  border-radius: 50%;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

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

.chat-action-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: all 0.2s;
}

.chat-action-btn:hover {
  background: var(--surface-elevated);
  color: var(--msg-primary);
}

/* ============================================
   MESSAGES AREA
   ============================================ */

.messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  scrollbar-width: thin;
  scroll-behavior: smooth;
}

/* Date Separator */
.date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px 0;
}

.date-separator span {
  padding: 6px 16px;
  background: var(--surface-elevated);
  border-radius: 16px;
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 500;
}

/* Message Group */
.message-group {
  display: flex;
  gap: 8px;
  margin-bottom: 4px;
}

.message-group.sent {
  flex-direction: row-reverse;
}

.message-group-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
  margin-top: auto;
  cursor: pointer;
}

.message-group.sent .message-group-avatar {
  display: none;
}

.message-group-content {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-width: 70%;
}

/* Individual Message */
.message-bubble {
  position: relative;
  padding: 12px 16px;
  border-radius: 20px;
  max-width: 100%;
  word-wrap: break-word;
  animation: message-appear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  backdrop-filter: blur(10px);
}

.message-bubble:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

@keyframes message-appear {
  from {
    opacity: 0;
    transform: translateY(15px) scale(0.9);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

.message-group:not(.sent) .message-bubble {
  background: var(--msg-received-bg);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.message-group:not(.sent) .message-bubble:first-child {
  border-top-left-radius: 20px;
}

.message-group:not(.sent) .message-bubble:last-child {
  border-bottom-left-radius: 20px;
}

.message-group.sent .message-bubble {
  background: var(--msg-sent-bg);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 8px rgba(8, 145, 178, 0.25);
}

.message-group.sent .message-bubble:first-child {
  border-top-right-radius: 20px;
}

.message-group.sent .message-bubble:last-child {
  border-bottom-right-radius: 20px;
}

/* Message Text */
.message-text {
  line-height: 1.45;
  font-size: 0.95rem;
}

.message-text a {
  color: inherit;
  text-decoration: underline;
}

/* Reply Quote */
.message-reply-quote {
  padding: 8px 12px;
  background: rgba(0,0,0,0.1);
  border-left: 3px solid rgba(255,255,255,0.5);
  border-radius: 8px;
  margin-bottom: 8px;
  font-size: 0.85rem;
  opacity: 0.9;
}

.message-group:not(.sent) .message-reply-quote {
  background: rgba(0,0,0,0.05);
  border-left-color: var(--msg-primary);
}

.reply-quote-name {
  font-weight: 600;
  margin-bottom: 2px;
  font-size: 0.8rem;
}

.reply-quote-text {
  opacity: 0.85;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Message Media */
.message-media {
  max-width: 300px;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
}

.message-media img,
.message-media video {
  width: 100%;
  display: block;
}

.message-media.has-text {
  margin-bottom: 8px;
}

/* Voice Message */
.voice-message {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 4px 0;
  min-width: 200px;
}

.voice-play-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: inherit;
  transition: all 0.2s;
}

.message-group:not(.sent) .voice-play-btn {
  background: var(--msg-reaction-bg);
  color: var(--msg-primary);
}

.voice-play-btn:hover {
  transform: scale(1.1);
}

.voice-waveform {
  flex: 1;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.voice-waveform .bar {
  width: 3px;
  background: currentColor;
  border-radius: 2px;
  opacity: 0.6;
}

.voice-duration {
  font-size: 0.75rem;
  opacity: 0.8;
  min-width: 35px;
}

/* Message Footer (time, status) */
.message-footer {
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 6px;
  font-size: 0.7rem;
  opacity: 0.75;
}

.message-group.sent .message-footer {
  justify-content: flex-end;
}

.message-time {
  font-weight: 500;
}

.message-status-icon {
  width: 16px;
  height: 16px;
  transition: color 0.2s ease;
}

.message-status-icon.seen {
  color: #3b82f6;
  animation: status-pop 0.3s ease;
}

@keyframes status-pop {
  0% { transform: scale(0.8); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

/* Delivered double-check */
.message-status-icon.delivered {
  color: rgba(255, 255, 255, 0.7);
}

/* Edited label styling */
.edited-label {
  font-style: italic;
  opacity: 0.6;
  font-size: 0.65rem;
}

/* Message Reactions */
.message-reactions {
  display: flex;
  gap: 4px;
  margin-top: 4px;
  flex-wrap: wrap;
}

.msg-reaction {
  display: inline-flex;
  align-items: center;
  gap: 3px;
  padding: 2px 8px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.2s;
}

.msg-reaction:hover {
  transform: scale(1.1);
}

.msg-reaction.my-reaction {
  border-color: var(--msg-primary);
  background: var(--msg-reaction-bg);
}

/* Message Actions Container - wraps bubble for extended hover area */
.message-bubble {
  position: relative;
}

/* Hover reactions bar - appears above message on hover */
.message-reactions-hover {
  position: absolute;
  bottom: calc(100% + 4px);
  left: 0;
  display: flex;
  opacity: 0;
  visibility: hidden;
  gap: 2px;
  padding: 4px 8px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  z-index: 10;
  transition: opacity 0.15s ease, visibility 0.15s ease;
}

.message-group.sent .message-reactions-hover {
  left: auto;
  right: 0;
}

/* 3-dot menu on right side of message */
.message-menu-btn {
  position: absolute;
  top: 50%;
  right: -36px;
  transform: translateY(-50%);
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: 1px solid var(--border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  opacity: 0;
  visibility: hidden;
  transition: all 0.15s ease;
  box-shadow: 0 2px 8px rgba(0,0,0,0.1);
  z-index: 10;
}

/* For sent messages, menu still on the right (outside the bubble) */
.message-group.sent .message-menu-btn {
  right: auto;
  left: -36px;
}

/* Show reactions and menu on hover - using padding trick for reliable hover */
.message-bubble::before {
  content: '';
  position: absolute;
  top: -40px;
  left: -40px;
  right: -40px;
  bottom: -10px;
  z-index: -1;
}

.message-bubble:hover .message-reactions-hover,
.message-reactions-hover:hover {
  opacity: 1;
  visibility: visible;
}

.message-bubble:hover .message-menu-btn,
.message-menu-btn:hover {
  opacity: 1;
  visibility: visible;
}

.message-menu-btn:hover {
  background: var(--surface-elevated);
  color: var(--msg-primary);
  transform: translateY(-50%) scale(1.1);
}

/* Reaction buttons in hover bar */
.reaction-hover-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.reaction-hover-btn:hover {
  transform: scale(1.3);
  background: var(--surface-elevated);
}

/* Legacy message-actions-overlay - kept for backward compatibility but hidden */
.message-actions-overlay {
  display: none !important;
}

/* Message group needs extra padding on sides to accommodate menu button */
.message-group-content {
  padding-right: 40px;
}

.message-group.sent .message-group-content {
  padding-right: 0;
  padding-left: 40px;
}

.msg-action-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 0.875rem;
  transition: all 0.2s;
}

.msg-action-btn:hover {
  background: var(--surface-elevated);
  color: var(--msg-primary);
}

/* Typing Indicator */
.typing-indicator {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 24px;
  animation: fade-in 0.3s ease;
}

.typing-indicator.hidden {
  display: none;
}

.typing-indicator-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--msg-primary);
}

.typing-dots {
  display: flex;
  gap: 4px;
  padding: 14px 18px;
  background: var(--surface-elevated);
  border-radius: 20px;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.typing-dots span {
  width: 8px;
  height: 8px;
  background: var(--msg-primary);
  border-radius: 50%;
  animation: typing-bounce 1.4s infinite;
}

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

@keyframes typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30% { transform: translateY(-8px); opacity: 1; }
}

@keyframes fade-in {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ============================================
   MESSAGE INPUT AREA
   ============================================ */

.message-input-container {
  padding: 16px 24px;
  border-top: 1px solid var(--border);
  background: var(--surface);
  transition: box-shadow 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.message-input-container:focus-within {
  box-shadow: 0 -2px 8px rgba(8, 145, 178, 0.1);
}

/* Reply Preview */
.reply-preview {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  margin-bottom: 12px;
  background: var(--surface-elevated);
  border-left: 3px solid var(--msg-primary);
  border-radius: 8px;
}

.reply-preview.hidden {
  display: none;
}

.reply-preview-content {
  flex: 1;
  min-width: 0;
}

.reply-preview-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--msg-primary);
  margin-bottom: 2px;
}

.reply-preview-text {
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-cancel-btn {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--surface);
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.reply-cancel-btn:hover {
  background: var(--surface-elevated);
  color: var(--text-primary);
}

/* Media Preview */
.media-preview-area {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}

.media-preview-area.hidden {
  display: none;
}

.media-preview-item {
  position: relative;
  width: 80px;
  height: 80px;
  border-radius: 12px;
  overflow: hidden;
  border: 1px solid var(--border);
}

.media-preview-item img,
.media-preview-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.media-preview-remove {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(0,0,0,0.6);
  color: white;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.875rem;
}

/* Input Row - Centered with room for features on both sides */
.message-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  justify-content: center;
  max-width: 800px;
  margin: 0 auto;
  width: 100%;
}

.input-actions-left {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.input-actions-right {
  display: flex;
  gap: 4px;
  flex-shrink: 0;
}

.input-action-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--msg-primary);
  transition: all 0.2s;
}

.input-action-btn:hover {
  background: var(--msg-reaction-bg);
}

/* Text Input */
.message-text-input-wrapper {
  flex: 1;
  display: flex;
  align-items: flex-end;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  position: relative;
  border-radius: 24px;
  padding: 4px;
  transition: border-color 0.2s;
}

.message-text-input-wrapper:focus-within {
  border-color: var(--msg-primary);
}

.message-text-input {
  flex: 1;
  background: transparent;
  border: none;
  padding: 10px 14px;
  color: var(--text-primary);
  font-size: 0.95rem;
  line-height: 1.4;
  resize: none;
  max-height: 120px;
  overflow-y: auto;
}

.message-text-input:focus {
  outline: none;
}

.message-text-input::placeholder {
  color: var(--text-muted);
}

.emoji-btn {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.emoji-btn:hover {
  color: var(--msg-primary);
}

/* Send/Voice Button */
.send-btn {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: var(--msg-gradient);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  transition: all 0.2s;
}

.send-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(8, 145, 178, 0.4);
}

.send-btn:active {
  transform: scale(0.95);
}

.send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* Voice Recording State */
.voice-recording-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--surface-elevated);
  border-radius: 24px;
  flex: 1;
}

.voice-recording-bar.hidden {
  display: none;
}

.recording-indicator {
  width: 12px;
  height: 12px;
  background: #ef4444;
  border-radius: 50%;
  animation: recording-pulse 1s infinite;
}

@keyframes recording-pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.8); }
}

.recording-time {
  font-weight: 600;
  color: var(--text-primary);
  min-width: 50px;
}

.recording-waveform {
  flex: 1;
  height: 32px;
  display: flex;
  align-items: center;
  gap: 2px;
}

.recording-waveform .bar {
  width: 3px;
  background: var(--msg-primary);
  border-radius: 2px;
  animation: wave-animate 0.5s ease infinite alternate;
}

@keyframes wave-animate {
  from { height: 8px; }
  to { height: 24px; }
}

.cancel-recording-btn {
  padding: 8px 16px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.875rem;
}

.cancel-recording-btn:hover {
  color: var(--text-primary);
}

/* ============================================
   GROUP CHAT SPECIFIC
   ============================================ */

.group-avatar-stack {
  position: relative;
  width: 52px;
  height: 52px;
}

.group-avatar-stack img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 2px solid var(--surface);
  position: absolute;
}

.group-avatar-stack img:nth-child(1) {
  top: 0;
  left: 0;
  z-index: 2;
}

.group-avatar-stack img:nth-child(2) {
  bottom: 0;
  right: 0;
  z-index: 1;
}

.group-member-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  background: var(--surface-elevated);
  border: 2px solid var(--surface);
  border-radius: 10px;
  padding: 2px 6px;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Group message sender name */
.message-sender-name {
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--msg-primary);
  margin-bottom: 4px;
}

/* ============================================
   MEDIA VIEWER MODAL
   ============================================ */

.media-viewer-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.95);
  z-index: 10000;
  display: flex;
  align-items: center;
  justify-content: center;
  animation: fade-in 0.2s ease;
}

.media-viewer-modal.hidden {
  display: none;
}

@keyframes fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

.media-viewer-close {
  position: absolute;
  top: 20px;
  right: 20px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: none;
  cursor: pointer;
  color: white;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  z-index: 10;
}

.media-viewer-close:hover {
  background: rgba(255,255,255,0.2);
}

.media-viewer-content {
  max-width: 90vw;
  max-height: 90vh;
}

.media-viewer-content img,
.media-viewer-content video {
  max-width: 100%;
  max-height: 90vh;
  object-fit: contain;
  border-radius: 8px;
}

.media-viewer-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(255,255,255,0.1);
  border: none;
  cursor: pointer;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.media-viewer-nav:hover {
  background: rgba(255,255,255,0.2);
}

.media-viewer-nav.prev {
  left: 20px;
}

.media-viewer-nav.next {
  right: 20px;
}

/* ============================================
   CONVERSATION INFO PANEL
   ============================================ */

.conv-info-panel {
  width: 320px;
  border-left: 1px solid var(--border);
  background: var(--surface);
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  position: relative;
}

.conv-info-panel .close-info-btn {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  cursor: pointer;
  color: var(--text-secondary);
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.conv-info-panel .close-info-btn:hover {
  background: var(--msg-reaction-bg);
  color: var(--text-primary);
}

.conv-info-panel.hidden {
  display: none;
}

.conv-info-panel.open {
  display: flex;
  animation: slide-in-right 0.3s ease;
}

@keyframes slide-in-right {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.conv-info-header {
  padding: 40px 20px 20px;
  text-align: center;
  border-bottom: 1px solid var(--border);
}

.conv-info-avatar {
  width: 80px;
  height: 80px;
  border-radius: 50%;
  margin: 0 auto 12px;
  object-fit: cover;
}

.conv-info-name {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: 4px;
}

.conv-info-status {
  font-size: 0.875rem;
  color: var(--text-muted);
}

.conv-info-actions {
  display: flex;
  justify-content: center;
  gap: 16px;
  margin-top: 16px;
}

.conv-info-action-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 12px;
  border-radius: 12px;
  background: var(--surface-elevated);
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  transition: all 0.2s;
  min-width: 70px;
}

.conv-info-action-btn:hover {
  background: var(--msg-reaction-bg);
  color: var(--msg-primary);
}

.conv-info-action-btn svg {
  width: 24px;
  height: 24px;
}

.conv-info-action-btn span {
  font-size: 0.75rem;
  font-weight: 500;
}

/* Info Sections */
.conv-info-section {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

.conv-info-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  cursor: pointer;
}

.conv-info-section-title {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 0.95rem;
}

/* Shared Media Grid */
.shared-media-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 4px;
}

.shared-media-grid.collapsed {
  display: none;
}

.shared-media-item {
  aspect-ratio: 1;
  border-radius: 8px;
  overflow: hidden;
  cursor: pointer;
  position: relative;
}

.shared-media-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.2s;
}

.shared-media-item:hover img {
  transform: scale(1.05);
}

/* Privacy & Support options */
.conv-info-option {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 0;
  cursor: pointer;
  color: var(--text-secondary);
  transition: color 0.2s;
}

.conv-info-option:hover {
  color: var(--text-primary);
}

.conv-info-option.danger {
  color: #ef4444;
}

.conv-info-option.danger:hover {
  color: #dc2626;
}

/* ============================================
   EMOJI PICKER
   ============================================ */

.emoji-picker {
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: 8px;
  width: 320px;
  max-height: 360px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.3);
  overflow: hidden;
  z-index: 100;
  animation: picker-pop 0.2s ease;
}

.emoji-picker.hidden {
  display: none;
}

@keyframes picker-pop {
  from { opacity: 0; transform: scale(0.9) translateY(10px); }
  to { opacity: 1; transform: scale(1) translateY(0); }
}

.emoji-picker-header {
  padding: 12px;
  border-bottom: 1px solid var(--border);
}

.emoji-picker-search {
  width: 100%;
  padding: 8px 12px;
  border-radius: 20px;
  background: var(--surface-elevated);
  border: 1px solid var(--border);
  color: var(--text-primary);
  font-size: 0.9rem;
}

.emoji-categories {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid var(--border);
}

.emoji-category-btn {
  flex: 1;
  padding: 8px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  font-size: 1.25rem;
  transition: background 0.2s;
}

.emoji-category-btn:hover {
  background: var(--surface-elevated);
}

.emoji-category-btn.active {
  background: var(--msg-reaction-bg);
}

.emoji-grid {
  display: grid;
  grid-template-columns: repeat(8, 1fr);
  gap: 4px;
  padding: 12px;
  max-height: 250px;
  overflow-y: auto;
}

.emoji-item {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.emoji-item:hover {
  background: var(--surface-elevated);
  transform: scale(1.2);
}

/* ============================================
   REACTION PICKER (for messages)
   ============================================ */

.reaction-picker-popup {
  position: absolute;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 24px;
  padding: 6px 10px;
  display: flex;
  gap: 4px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.2);
  animation: picker-pop 0.15s ease;
  z-index: 100;
}

.reaction-picker-popup.hidden {
  display: none;
}

.reaction-picker-btn {
  width: 36px;
  height: 36px;
  background: transparent;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.25rem;
  transition: all 0.15s;
}

.reaction-picker-btn:hover {
  transform: scale(1.3);
  background: var(--surface-elevated);
}

/* ============================================
   MOBILE RESPONSIVE
   ============================================ */

@media (max-width: 768px) {
  .messenger-container {
    flex-direction: column;
  }

  .conversations-panel {
    width: 100%;
    max-width: none;
    height: auto;
    border-right: none;
    border-bottom: 1px solid var(--border);
    position: fixed;
    top: 60px;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.3s ease;
  }

  .conversations-panel.open {
    transform: translateX(0);
  }

  .chat-panel {
    height: calc(100vh - 60px);
  }

  .conv-info-panel {
    position: fixed;
    top: 60px;
    right: 0;
    bottom: 0;
    z-index: 60;
    transform: translateX(100%);
    transition: transform 0.3s ease;
  }

  .conv-info-panel.open {
    transform: translateX(0);
  }

  .mobile-nav-btn {
    display: flex;
  }

  .message-group-content {
    max-width: 85%;
  }

  .conversations-header h2 {
    font-size: 1.25rem;
  }
}

/* ============================================
   ANIMATIONS
   ============================================ */

@keyframes send-animation {
  0% { transform: translateX(0); opacity: 1; }
  50% { transform: translateX(20px); opacity: 0.5; }
  100% { transform: translateX(0); opacity: 1; }
}

.message-sending {
  animation: send-animation 0.3s ease;
}

/* Message deletion animation */
@keyframes message-delete {
  to {
    opacity: 0;
    transform: scale(0.8);
    height: 0;
    padding: 0;
    margin: 0;
  }
}

.message-deleting {
  animation: message-delete 0.3s ease forwards;
}
