/* ===== CHAT ===== */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--nav-height) - var(--header-height));
  height: calc(100dvh - var(--nav-height) - var(--header-height));
  background: var(--bg-primary);
}

/* ===== MATCHES LIST ===== */
.matches-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px;
  border-bottom: 1px solid var(--border-color);
}

.matches-header h2 {
  font-size: var(--font-size-lg);
  font-weight: 700;
}

.matches-tabs {
  margin-bottom: 0;
}

/* New Matches - horizontal scroll */
.new-matches {
  display: flex;
  gap: 12px;
  padding: 16px;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-bottom: 1px solid var(--border-color);
}

.new-match-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
  cursor: pointer;
}

.new-match-avatar {
  width: 64px;
  height: 64px;
  border-radius: var(--radius-full);
  object-fit: cover;
  border: 3px solid var(--primary);
  padding: 2px;
  transition: transform var(--transition-fast);
}

.new-match-item:hover .new-match-avatar {
  transform: scale(1.05);
}

.new-match-name {
  font-size: var(--font-size-xs);
  color: var(--text-secondary);
  max-width: 64px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  text-align: center;
}

/* Messages List */
.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

.message-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  cursor: pointer;
  transition: background var(--transition-fast);
}

.message-item:hover {
  background: var(--bg-secondary);
}

.message-item.unread {
  background: rgba(254, 60, 114, 0.05);
}

.message-avatar {
  width: 56px;
  height: 56px;
  border-radius: var(--radius-full);
  object-fit: cover;
  flex-shrink: 0;
}

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

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

.message-name {
  font-size: var(--font-size-md);
  font-weight: 600;
}

.message-time {
  font-size: var(--font-size-xs);
  color: var(--text-tertiary);
  flex-shrink: 0;
}

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

.message-item.unread .message-preview {
  color: var(--text-primary);
  font-weight: 600;
}

.message-badge {
  width: 20px;
  height: 20px;
  background: var(--primary);
  color: white;
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

/* ===== CHAT VIEW ===== */
.chat-view {
  display: none;
  flex-direction: column;
  height: calc(100vh - var(--nav-height));
  height: calc(100dvh - var(--nav-height));
}

.chat-view.active {
  display: flex;
}

.chat-header-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-back-btn {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: 20px;
  color: var(--text-primary);
  transition: background var(--transition-fast);
}

.chat-back-btn:hover {
  background: var(--bg-tertiary);
}

.chat-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.chat-header-info {
  flex: 1;
}

.chat-header-name {
  font-size: var(--font-size-md);
  font-weight: 700;
}

.chat-header-status {
  font-size: var(--font-size-xs);
  color: var(--like-green);
}

.chat-header-actions {
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-full);
  font-size: 18px;
  color: var(--text-secondary);
}

/* Messages area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  background: var(--bg-primary);
}

.chat-bubble {
  max-width: 75%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: var(--font-size-md);
  line-height: 1.4;
  position: relative;
  animation: bubbleIn 0.2s ease;
}

@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(8px) scale(0.95); }
  to { opacity: 1; transform: translateY(0) scale(1); }
}

.chat-bubble-sent {
  align-self: flex-end;
  background: var(--primary-gradient);
  color: white;
  border-bottom-right-radius: 6px;
}

.chat-bubble-received {
  align-self: flex-start;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border-bottom-left-radius: 6px;
}

.chat-bubble-time {
  font-size: 10px;
  opacity: 0.6;
  margin-top: 4px;
  text-align: right;
}

.chat-bubble-received .chat-bubble-time {
  text-align: left;
}

.chat-bubble-status {
  position: absolute;
  bottom: -16px;
  right: 4px;
  font-size: 12px;
  opacity: 0.5;
}

/* Date separator */
.chat-date-separator {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px 0;
  color: var(--text-tertiary);
  font-size: var(--font-size-xs);
}

.chat-date-separator::before,
.chat-date-separator::after {
  content: '';
  flex: 1;
  height: 1px;
  background: var(--border-color);
}

.chat-date-separator span {
  padding: 0 12px;
}

/* Typing indicator */
.typing-indicator {
  display: none;
  align-self: flex-start;
  padding: 12px 16px;
  background: var(--bg-tertiary);
  border-radius: 18px;
  border-bottom-left-radius: 6px;
}

.typing-indicator.active {
  display: flex;
  gap: 4px;
  align-items: center;
}

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

.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* Chat input */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px;
  padding-bottom: calc(12px + var(--safe-bottom));
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  flex-shrink: 0;
}

.chat-input-wrapper {
  flex: 1;
  display: flex;
  align-items: center;
  background: var(--bg-tertiary);
  border-radius: 24px;
  padding: 4px;
  padding-left: 16px;
}

.chat-input {
  flex: 1;
  padding: 10px 0;
  max-height: 100px;
  resize: none;
  line-height: 1.4;
}

.chat-input::placeholder {
  color: var(--text-tertiary);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-full);
  background: var(--primary-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 18px;
  transition: all var(--transition-fast);
  flex-shrink: 0;
}

.chat-send-btn:hover {
  box-shadow: var(--shadow-glow);
}

.chat-send-btn:disabled {
  opacity: 0.5;
  pointer-events: none;
}

/* ===== MATCHES GRID (for discover page) ===== */
.matches-grid-header {
  padding: 16px 16px 8px;
  font-size: var(--font-size-md);
  font-weight: 700;
  color: var(--text-secondary);
}
