/* ============================================
   Bond Priori - Chat Styles
   ============================================ */

/* Chat Layout — full height */
.chat-container {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--header-height, 64px) - 40px);
  max-height: calc(100vh - var(--header-height, 64px) - 40px);
  overflow: hidden;
}

/* Chat Header Bar */
.chat-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-3) var(--space-4);
  background: rgba(0, 0, 0, 0.25);
  border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.chat-partner-info {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}

.chat-partner-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-copper, #AF8F73), var(--color-bronze, #685341));
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--font-weight-bold);
  font-size: var(--font-size-sm);
  color: white;
  position: relative;
  flex-shrink: 0;
}

.chat-partner-name {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-base);
}

.chat-partner-status {
  font-size: var(--font-size-xs);
  color: var(--color-soft-grey);
}

.chat-partner-status.online {
  color: #4ade80;
}

/* Online indicator dot */
.presence-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--color-soft-grey);
  position: absolute;
  bottom: 0;
  right: 0;
  border: 2px solid rgba(0, 0, 0, 0.4);
}

.presence-dot.online {
  background: #4ade80;
}

/* Messages Area */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--space-4);
  display: flex;
  flex-direction: column;
  gap: var(--space-2);
  background: rgba(0, 0, 0, 0.15);
}

.chat-messages::-webkit-scrollbar {
  width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
  background: transparent;
}

.chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

/* Load More */
.chat-load-more {
  text-align: center;
  padding: var(--space-2);
}

.chat-load-more button {
  font-size: var(--font-size-xs);
  padding: var(--space-1) var(--space-3);
}

/* Date separator */
.chat-date-separator {
  text-align: center;
  padding: var(--space-2) 0;
  position: relative;
}

.chat-date-separator span {
  background: rgba(0, 0, 0, 0.4);
  padding: var(--space-1) var(--space-3);
  border-radius: var(--radius-full, 9999px);
  font-size: var(--font-size-xs);
  color: var(--color-soft-grey);
}

/* Message Bubble */
.chat-bubble-row {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  max-width: 75%;
}

.chat-bubble-row.sent {
  margin-left: auto;
  flex-direction: row-reverse;
}

.chat-bubble-row.received {
  margin-right: auto;
}

.chat-bubble {
  padding: var(--space-2) var(--space-3);
  border-radius: 16px;
  max-width: 100%;
  word-wrap: break-word;
  position: relative;
  line-height: var(--line-height-relaxed, 1.6);
  font-size: var(--font-size-sm);
}

.chat-bubble-row.sent .chat-bubble {
  background: linear-gradient(135deg,
    rgba(var(--rgb-dusty-taupe, 175, 143, 115), 0.6),
    rgba(var(--rgb-ash-brown, 104, 83, 65), 0.6));
  border-bottom-right-radius: 4px;
  color: var(--color-alabaster, #DEDFE1);
}

.chat-bubble-row.received .chat-bubble {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-bottom-left-radius: 4px;
  color: var(--color-alabaster, #DEDFE1);
}

.chat-bubble-meta {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  margin-top: 2px;
  font-size: 10px;
  color: rgba(255, 255, 255, 0.4);
}

.chat-bubble-row.sent .chat-bubble-meta {
  justify-content: flex-end;
}

/* Read receipt checkmarks */
.chat-read-check {
  font-size: 12px;
  color: rgba(255, 255, 255, 0.3);
}

.chat-read-check.read {
  color: #4ade80;
}

/* Typing Indicator */
.chat-typing {
  display: none;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--font-size-xs);
  color: var(--color-soft-grey);
  flex-shrink: 0;
}

.chat-typing.visible {
  display: flex;
}

.typing-dots {
  display: flex;
  gap: 3px;
}

.typing-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--color-soft-grey);
  animation: typingBounce 1.4s ease-in-out infinite;
}

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

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

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

/* Chat Input Bar */
.chat-input-bar {
  display: flex;
  align-items: flex-end;
  gap: var(--space-2);
  padding: var(--space-3) var(--space-4);
  background: rgba(0, 0, 0, 0.3);
  border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  flex-shrink: 0;
}

.chat-input-wrapper {
  flex: 1;
  position: relative;
}

.chat-input {
  width: 100%;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 20px;
  padding: var(--space-2) var(--space-4);
  padding-right: 40px;
  color: var(--color-alabaster, #DEDFE1);
  font-family: inherit;
  font-size: var(--font-size-sm);
  resize: none;
  max-height: 120px;
  min-height: 40px;
  line-height: 1.5;
  outline: none;
  transition: border-color 0.2s;
}

.chat-input:focus {
  border-color: rgba(var(--rgb-dusty-taupe, 175, 143, 115), 0.5);
}

.chat-input::placeholder {
  color: var(--color-soft-grey);
}

.chat-emoji-btn {
  position: absolute;
  right: 8px;
  bottom: 6px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: var(--color-soft-grey);
  font-size: 18px;
  line-height: 1;
  transition: color 0.2s;
}

.chat-emoji-btn:hover {
  color: var(--color-dusty-taupe, #AF8F73);
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg,
    rgba(var(--rgb-dusty-taupe, 175, 143, 115), 0.8),
    rgba(var(--rgb-ash-brown, 104, 83, 65), 0.8));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  flex-shrink: 0;
  transition: opacity 0.2s, transform 0.2s;
}

.chat-send-btn:hover {
  opacity: 0.9;
  transform: scale(1.05);
}

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

.chat-send-btn svg {
  width: 18px;
  height: 18px;
}

/* Emoji Picker Popup */
.chat-emoji-picker {
  display: none;
  position: absolute;
  bottom: 100%;
  right: 0;
  margin-bottom: var(--space-2);
  background: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg);
  padding: var(--space-3);
  z-index: 100;
  width: 280px;
}

.chat-emoji-picker.visible {
  display: block;
}

.chat-emoji-picker-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.chat-emoji-picker-grid button {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 22px;
  padding: 6px;
  border-radius: var(--radius-md, 8px);
  transition: background 0.15s;
  line-height: 1;
}

.chat-emoji-picker-grid button:hover {
  background: rgba(255, 255, 255, 0.1);
}

/* Empty state */
.chat-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  text-align: center;
  color: var(--color-soft-grey);
  gap: var(--space-3);
  padding: var(--space-6);
}

.chat-empty-icon {
  font-size: 48px;
  opacity: 0.5;
}

.chat-empty h3 {
  font-weight: var(--font-weight-semibold);
  font-size: var(--font-size-lg);
  color: var(--color-warm-grey, #A39A92);
}

.chat-empty p {
  font-size: var(--font-size-sm);
  max-width: 300px;
}

/* Connection status bar */
.chat-connection-status {
  display: none;
  align-items: center;
  justify-content: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-3);
  font-size: var(--font-size-xs);
  text-align: center;
  flex-shrink: 0;
}

.chat-connection-status.disconnected {
  display: flex;
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.chat-connection-status.reconnecting {
  display: flex;
  background: rgba(234, 179, 8, 0.2);
  color: #fde047;
}

/* Responsive */
@media (max-width: 768px) {
  .chat-container {
    height: calc(100vh - 56px - 20px);
    max-height: calc(100vh - 56px - 20px);
  }

  .chat-bubble-row {
    max-width: 85%;
  }

  .chat-emoji-picker {
    width: 250px;
    right: -40px;
  }
}
