/* ==========================================================================
   NEARBY CHAT — CHAT & MESSAGING STYLES
   ========================================================================== */

/* Conversation List / Inbox */
.inbox-container {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}

.inbox-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-2);
}

.conversation-item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  text-decoration: none;
  color: inherit;
  transition: all var(--transition-fast);
}

.conversation-item:hover {
  background-color: var(--bg-subtle);
  border-color: #cbd5e1;
  transform: translateY(-1px);
}

.conversation-item.has-unread {
  background-color: #f8fafc;
  border-left: 4px solid var(--primary);
}

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

.conv-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 2px;
}

.conv-name {
  font-weight: 600;
  font-size: var(--text-sm);
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.conv-time {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.conv-bottom {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.conv-preview {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* 1-on-1 & Private Chat Room Container */
.chat-window {
  display: flex;
  flex-direction: column;
  width: 100%;
  height: 100%;
  flex: 1 1 0%;
  min-height: 0;
  background-color: var(--bg-surface);
  overflow: hidden;
  position: relative;
}

@media (min-width: 768px) {
  .chat-window {
    height: calc(100vh - var(--header-height) - var(--space-8));
    height: calc(100dvh - var(--header-height) - var(--space-8));
    max-height: 850px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-md);
  }
}

@media (max-width: 767px) {
  .chat-window {
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
    box-shadow: none;
  }
}

.chat-header {
  flex-shrink: 0;
  position: sticky;
  top: 0;
  padding: var(--space-3) var(--space-4);
  background-color: var(--bg-surface);
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  z-index: 50;
  box-sizing: border-box;
}

.chat-partner-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  text-decoration: none;
  color: inherit;
  min-width: 0;
}

.chat-partner-details {
  min-width: 0;
}

.chat-partner-details h3 {
  font-size: var(--text-base);
  margin-bottom: 1px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chat-partner-details span {
  font-size: var(--text-xs);
  color: var(--text-muted);
}

.chat-partner-details span.online-text {
  color: var(--online);
  font-weight: 500;
}

/* Message Stream */
.message-stream {
  flex: 1 1 0%;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior-y: contain;
  padding: var(--space-3) var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-3);
  background-color: #f8fafc;
  -webkit-overflow-scrolling: touch;
}

.load-more-btn {
  align-self: center;
  font-size: var(--text-xs);
  color: var(--primary);
  background: var(--bg-surface);
  border: 1px solid var(--border-color);
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: var(--space-2);
}

.message-bubble-row {
  display: flex;
  gap: var(--space-2);
  max-width: 80%;
}

.message-bubble-row.outgoing {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.message-bubble-row.incoming {
  align-self: flex-start;
}

.message-bubble {
  padding: var(--space-3) var(--space-4);
  border-radius: var(--radius-lg);
  font-size: var(--text-sm);
  line-height: 1.4;
  word-break: break-word;
  position: relative;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.outgoing .message-bubble {
  background-color: var(--primary);
  color: var(--text-inverse);
  border-bottom-right-radius: 4px;
}

.incoming .message-bubble {
  background-color: var(--bg-surface);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
  border-bottom-left-radius: 4px;
}

.message-meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: 10px;
  margin-top: 4px;
  opacity: 0.85;
}

.outgoing .message-meta {
  color: rgba(255, 255, 255, 0.9);
}

.incoming .message-meta {
  color: var(--text-muted);
}

.status-tick {
  display: inline-flex;
  align-items: center;
}

/* Typing Indicator */
.typing-indicator {
  display: none;
  align-items: center;
  gap: 4px;
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-xs);
  color: var(--text-muted);
  font-style: italic;
}

.typing-indicator.active {
  display: flex;
}

.typing-dot {
  width: 5px;
  height: 5px;
  background-color: var(--text-muted);
  border-radius: var(--radius-full);
  animation: typingBounce 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) { animation-delay: -0.32s; }
.typing-dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
  0%, 80%, 100% { transform: scale(0); }
  40% { transform: scale(1); }
}

/* Sticky Chat Composer */
.chat-composer {
  flex-shrink: 0;
  position: sticky;
  bottom: 0;
  padding: var(--space-2) var(--space-3);
  padding-bottom: calc(var(--space-2) + env(safe-area-inset-bottom, 0px));
  background-color: var(--bg-surface);
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  gap: var(--space-2);
  z-index: 40;
  box-sizing: border-box;
}

.chat-input {
  flex: 1;
  min-width: 0;
  padding: 0.65rem 1rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-color);
  background-color: var(--bg-subtle);
  font-size: var(--text-sm);
  outline: none;
  transition: all var(--transition-fast);
  box-sizing: border-box;
}

.chat-input:focus {
  background-color: var(--bg-surface);
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary-glow);
}

.btn-send {
  width: 42px;
  height: 42px;
  border-radius: var(--radius-full);
  background-color: var(--primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color var(--transition-fast), transform var(--transition-fast);
}

.btn-send:hover {
  background-color: var(--primary-hover);
  transform: scale(1.05);
}

/* ==========================================================================
   RANDOM CHAT RADAR ANIMATION
   ========================================================================== */
.radar-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--space-12) var(--space-4);
  text-align: center;
}

.radar-circle-wrap {
  position: relative;
  width: 200px;
  height: 200px;
  margin-bottom: var(--space-6);
  display: flex;
  align-items: center;
  justify-content: center;
}

.radar-wave {
  position: absolute;
  width: 100%;
  height: 100%;
  border-radius: var(--radius-full);
  border: 2px solid var(--primary);
  opacity: 0;
  animation: radarPulse 2s infinite cubic-bezier(0.36, 0.11, 0.89, 0.32);
}

.radar-wave:nth-child(2) { animation-delay: 0.6s; }
.radar-wave:nth-child(3) { animation-delay: 1.2s; }

.radar-center-icon {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  background: var(--primary);
  color: var(--text-inverse);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 20px var(--primary-glow);
  z-index: 5;
}

@keyframes radarPulse {
  0% { transform: scale(0.3); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}
