/* ===== CHAT INTERFACE COMPONENT - SOLIUS Domain-Driven OOP ===== */

.chat-interface {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(135deg, #00091E 0%, rgba(85, 93, 255, 0.2) 100%);
  color: #FFFFFF;
  display: flex;
  flex-direction: column;
  z-index: 10;
  opacity: 0;
  transform: translateX(100%);
  animation: slideInChat 0.3s ease-out forwards;
  border-radius: 12px 0 0 12px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(85, 93, 255, 0.1);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
}

@keyframes slideInChat {
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===== CHAT INTERFACE HEADER ===== */

.chat-interface-header {
  display: flex;
  align-items: center;
  padding: 10px 14px; /* More condensed */
  border-bottom: 1px solid rgba(85, 93, 255, 0.2);
  background: linear-gradient(135deg, #00091E 0%, rgba(85, 93, 255, 0.03) 100%);
  min-height: 50px; /* More condensed */
}

.chat-interface-back {
  cursor: pointer;
  padding: 6px; /* More condensed */
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.7);
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; /* More condensed */
  height: 32px;
  border: 1px solid rgba(85, 93, 255, 0.2);
}

.chat-interface-back:hover {
  background: rgba(85, 93, 255, 0.1);
  color: #555DFF;
  border-color: rgba(85, 93, 255, 0.4);
}

.chat-interface-recipient {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: 8px;
}

/* ✅ UX POLISH: Header title/subtitle styles (matches private chat!) */
.recipient-info .chat-title {
  font-family: 'Montserrat', sans-serif !important;
  font-weight: 600;
  font-size: 16px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.recipient-info .chat-subtitle {
  font-family: 'Montserrat', sans-serif !important;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.chat-interface-actions {
  display: flex;
  gap: 8px;
}

.chat-action-btn {
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: #a0aec0;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
}

.chat-action-btn:hover {
  background: rgba(85, 93, 255, 0.1);
  color: #ffffff;
}

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

.chat-messages-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden; /* Keep scrolling container behavior */
}

.chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 12px; /* More condensed */
  display: flex;
  flex-direction: column;
  gap: 10px; /* Consistent spacing */
}

.chat-message {
  position: relative; /* Required for E2EE indicator positioning */
  display: flex;
  margin-bottom: 8px;
  animation: messageSlideIn 0.3s ease-out;
  flex-direction: column;
}

/* ===== CLICKABLE USER ELEMENTS ===== */

.message-user-clickable {
  display: flex;
  align-items: center;
  cursor: pointer;
  padding: 0.25rem;
  border-radius: 8px;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  user-select: none;
}

.message-user-clickable:hover {
  background: rgba(85, 93, 255, 0.1);
  transform: translateY(-1px);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.message-user-clickable:active {
  transform: translateY(0);
  background: rgba(85, 93, 255, 0.05);
}

.chat-message.own {
  align-items: flex-end;
}

.chat-message.other {
  align-items: flex-start;
}

/* ===== MESSAGE HEADER FOR OTHER USERS ===== */
.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(85, 93, 255, 0.2);
}

.message-avatar-placeholder {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(85, 93, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 2px solid rgba(85, 93, 255, 0.2);
}

.message-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message-nickname {
  font-size: 12px;
  font-weight: 600;
  color: #ab9ff2;
  line-height: 1;
}

.message-wallet {
  font-size: 10px;
  color: #a0aec0;
  line-height: 1;
  font-family: 'Archivo', monospace;
}

.message-content {
  display: inline-block;
  min-width: 60px;
  max-width: min(75%, 400px);
  padding: 12px 16px;
  border-radius: 16px;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
  
  /* 🔥 iOS FIX: Prevent text selection on long-press */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  -webkit-touch-callout: none; /* Disable iOS callout menu */
  touch-action: manipulation; /* Prevent default touch behaviors */
}

.chat-message.own .message-content {
  background: #313578;
  color: #FFFFFF;
  border-radius: 16px 16px 0px 16px;
}

.chat-message.other .message-content {
  background: #38394F;
  color: #EBEBEB;
  border-radius: 0px 16px 16px 16px;
}

.message-text {
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  line-height: 20px;
  margin: 0;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  display: block;
  width: 100%;
  
  /* 🔥 iOS FIX: Prevent text selection on long-press */
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}

/* Time + status tick - OUTSIDE the bubble */
.message-time {
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  line-height: 16px;
  color: #536285;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 0px;
  margin-top: 4px;
  width: 100%;
}

/* Own messages - time aligned right */
.chat-message.own .message-time {
  justify-content: flex-end;
  align-self: flex-end;
  max-width: min(75%, 400px);
}

/* Other messages - time aligned left */
.chat-message.other .message-time {
  justify-content: flex-start;
  align-self: flex-start;
  max-width: min(75%, 400px);
}

/* Read receipt (check marks) in messages */
.message-receipt {
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.message-receipt svg {
  width: 16px;
  height: 16px;
}

/* Date divider */
.date-divider {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 8px 0;
  margin: 8px 0;
}

.date-divider-badge {
  padding: 4px 8px;
  background: #1E273C;
  border-radius: 20px;
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  line-height: 16px;
  font-weight: 400;
  color: #EBEBEB;
}

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

/* ===== INPUT AREA (EXACT MATCH TO PRIVATE CHAT!) ===== */

.chat-interface-input-area {
  padding: 6px 24px; /* 🔥 EXACT: Figma spec from private chat */
  border-top: none; /* 🔥 EXACT: No border in Figma */
  background: #00091E; /* 🔥 EXACT: Darker background from private chat */
  height: 56px; /* 🔥 EXACT: Figma spec */
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.chat-interface-input-container {
  display: flex;
  align-items: center;
  gap: 4px; /* 🔥 EXACT: Tighter spacing from private chat */
  width: 100%;
  height: 44px;
  padding: 0; /* 🔥 EXACT: No padding */
}

.chat-interface-message-input-wrapper {
  display: flex;
  align-items: center;
  padding: 12px 16px; /* 🔥 EXACT: From private chat */
  gap: 2px; /* 🔥 EXACT: From private chat */
  background: #0D1529; /* 🔥 EXACT: Darker rounded background from private chat */
  border-radius: 16px; /* 🔥 EXACT: 16px not 22px! */
  flex: 1;
  height: 44px;
}

.chat-interface-message-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: #EBEBEB; /* 🔥 EXACT: From private chat */
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  font-weight: 400; /* 🔥 EXACT: From private chat */
  line-height: 20px; /* 🔥 EXACT: From private chat */
  padding: 0; /* 🔥 No padding on input itself */
}

.chat-interface-message-input::placeholder {
  color: #536285; /* 🔥 EXACT: From private chat */
}

.chat-interface-attach-btn,
.chat-interface-send-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px; /* 🔥 EXACT: From private chat */
  height: 32px; /* 🔥 EXACT: From private chat */
  background: transparent;
  border: none;
  color: #536285;
  cursor: pointer;
  padding: 0;
  flex-shrink: 0;
  transition: opacity 0.2s ease;
}

.chat-interface-attach-btn:hover,
.chat-interface-send-btn:hover:not(:disabled) {
  opacity: 0.7; /* 🔥 EXACT: From private chat */
}

.chat-interface-send-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.chat-attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(85, 93, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #a0aec0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-attach-btn:hover {
  background: rgba(85, 93, 255, 0.1);
  border-color: #ab9ff2;
  color: #ffffff;
  transform: scale(1.05);
}

/* ===== E2EE STATUS INDICATOR ===== */

.chat-e2ee-status {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border: 1px solid rgba(16, 185, 129, 0.3);
  border-radius: 16px;
  color: #ffffff;
  font-size: 11px;
  font-weight: 600;
  cursor: help;
  transition: all 0.2s ease;
  flex-shrink: 0;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.chat-e2ee-status:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: scale(1.02);
}

/* ===== E2EE STATUS INDICATOR (ALWAYS VISIBLE) ===== */

.chat-e2ee-status.e2ee-connected {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
  border-color: rgba(16, 185, 129, 0.3);
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.2);
}

.chat-e2ee-status.e2ee-connecting {
  background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
  border-color: rgba(245, 158, 11, 0.3);
  animation: e2eePulse 1.5s ease-in-out infinite;
}

.chat-e2ee-status.e2ee-error {
  background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
  border-color: rgba(239, 68, 68, 0.3);
  box-shadow: 0 2px 8px rgba(239, 68, 68, 0.2);
}

.chat-e2ee-status.e2ee-disabled {
  background: linear-gradient(135deg, #6b7280 0%, #4b5563 100%);
  border-color: rgba(107, 114, 128, 0.3);
  box-shadow: 0 2px 8px rgba(107, 114, 128, 0.2);
}

@keyframes e2eePulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.7;
  }
}

.chat-message-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  background: rgba(85, 93, 255, 0.05);
  color: #ffffff;
  font-size: 14px;
  font-family: 'Archivo', sans-serif;
  outline: none;
  transition: all 0.2s ease;
}

.chat-message-input:focus {
  border-color: #ab9ff2;
  background: rgba(85, 93, 255, 0.1);
}

.chat-message-input::placeholder {
  color: #a0aec0;
}

.chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ab9ff2 0%, #6c5ce7 100%);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(171, 159, 242, 0.3);
  flex-shrink: 0;
}

.chat-send-btn:hover:not(:disabled) {
  transform: scale(1.05);
  box-shadow: 0 6px 16px rgba(171, 159, 242, 0.4);
}

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

.chat-send-btn i {
  font-size: 14px;
}

.chat-input-actions {
  display: flex;
  gap: 8px;
  justify-content: center;
}

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

@media (max-width: 768px) {
  .chat-interface-header {
    padding: 10px 12px;
    min-height: 50px;
  }

  .chat-interface-back,
  .chat-action-btn {
    width: 32px;
    height: 32px;
  }

  .chat-messages-area {
    padding: 12px;
    gap: 8px;
  }

  .message-header {
    padding: 0;
  }

  .message-avatar,
  .message-avatar-placeholder {
    width: 20px;
    height: 20px;
    font-size: 10px;
  }

  .message-nickname {
    font-size: 11px;
  }

  .message-wallet {
    font-size: 9px;
  }

  .message-content {
    max-width: 85%;
    padding: 10px 14px;
  }

  .message-text {
    font-size: 13px;
  }

  .message-time {
    font-size: 10px;
  }

  .chat-input-area {
    padding: 12px;
  }
  
  /* 🔥 Tighter input container spacing on mobile */
  .chat-input-container {
    gap: 4px;
    padding: 0;
  }

  .chat-message-input {
    padding: 10px 14px;
    font-size: 16px; /* 🔥 BUG FIX (Agent #6 - Oct 26): Increased from 13px to prevent iOS zoom */
  }

  /* 🔥 All input buttons 24px on mobile */
  .chat-send-btn,
  .chat-attach-btn,
  .chat-input-icon {
    width: 24px !important;
    height: 24px !important;
  }
  
  /* 🔥 Send button img 24px on mobile */
  .chat-send-btn > img,
  .chat-send-button > img {
    width: 24px !important;
    height: 24px !important;
  }
  
  /* 🔥 Hide emoji button on mobile */
  .chat-input-icon[alt="Emoji"],
  img.chat-input-icon[title*="emoji" i] {
    display: none !important;
  }

  .chat-send-btn i,
  .chat-attach-btn i {
    font-size: 12px;
  }
}

/* ===== ACCESSIBILITY ===== */

.chat-interface-back:focus,
.chat-action-btn:focus,
.chat-attach-btn:focus {
  outline: 2px solid #ab9ff2;
  outline-offset: 2px;
}

.chat-message-input:focus {
  outline: 2px solid #ab9ff2;
  outline-offset: 2px;
}

/* ===== INFINITE SCROLL LOADING INDICATOR ===== */

.infinite-scroll-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 16px;
}

.loading-spinner {
  display: flex;
  justify-content: center;
  align-items: center;
}

.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(171, 159, 242, 0.2);
  border-top: 2px solid #ab9ff2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* ===== RESPONSIVE DESIGN ===== */

@media (max-width: 768px) {
  .infinite-scroll-loading {
    padding: 12px;
  }

  .spinner {
    width: 16px;
    height: 16px;
  }
}

@media (prefers-reduced-motion: reduce) {
  .chat-interface,
  .chat-message {
    animation: none;
  }

  .chat-interface-back,
  .chat-action-btn,
  .chat-attach-btn,
  .chat-send-btn {
    transition: none;
  }

  .chat-message-input {
    transition: none;
  }

  .spinner {
    animation: none;
  }
}

/* ===== IMMORTAL MESSAGE STYLES ===== */

.message-immortal {
  position: relative;
  /* Removed border, background, and box-shadow - keeping only positioning for indicator */
}

.message-immortal-indicator {
  position: absolute;
  top: -8px;
  background: linear-gradient(135deg, #fbbf24, #f59e0b);
  color: #1a1a2e;
  border-radius: 50%;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: bold;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
  border: 2px solid rgba(85, 93, 255, 0.9);
  z-index: 10;
  animation: immortalGlow 2s ease-in-out infinite alternate;
}

/* Position indicator based on message ownership in community chat */
.chat-message.other .message-immortal-indicator {
  left: -8px; /* Top-left for other user's messages */
}

.chat-message.own .message-immortal-indicator {
  right: -8px; /* Top-right for own messages */
}

.message-immortal .message-immortal-indicator {
  animation: immortalGlow 2s ease-in-out infinite alternate;
}

@keyframes immortalGlow {
  from {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 6px rgba(251, 191, 36, 0.4);
    transform: scale(1);
  }
  to {
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2), 0 0 12px rgba(251, 191, 36, 0.8);
    transform: scale(1.05);
  }
}

/* Mobile adjustments for immortal messages */
@media (max-width: 768px) {
  .message-immortal-indicator {
    width: 18px;
    height: 18px;
    font-size: 11px;
    top: -6px;
    right: -6px;
  }
}

/* ===== ADDITIONAL INTERFACE STYLES MOVED FROM CHAT-COMPONENT.CSS ===== */

.chat-interface {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%);
  color: #ffffff;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
}

/* Header Styles */
.chat-interface-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: rgba(85, 93, 255, 0.05);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  flex-shrink: 0;
}

.chat-interface-back {
  background: none;
  border: none;
  font-size: 18px;
  color: #a0aec0;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.chat-interface-back:hover {
  background: rgba(85, 93, 255, 0.1);
  color: #ffffff;
}

.chat-interface-contact {
  display: flex;
  align-items: center;
  flex: 1;
  margin: 0 16px;
}

.contact-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ab9ff2 0%, #6c5ce7 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-weight: bold;
  font-size: 16px;
  margin-right: 12px;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(171, 159, 242, 0.3);
}

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

.contact-name {
  font-weight: 600;
  font-size: 16px;
  color: #ffffff;
  margin: 0 0 2px 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.contact-status {
  display: flex;
  align-items: center;
  font-size: 13px;
  color: #a0aec0;
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 6px;
  flex-shrink: 0;
}

.status-indicator.status-online {
  background: #48bb78;
}

.status-indicator.status-offline {
  background: #a0aec0;
}

.chat-interface-actions {
  display: flex;
  gap: 8px;
}

.chat-action-btn {
  background: none;
  border: none;
  font-size: 16px;
  color: #6c757d;
  cursor: pointer;
  padding: 8px;
  border-radius: 8px;
  transition: all 0.2s ease;
}

.chat-action-btn:hover {
  background: rgba(0, 0, 0, 0.05);
  color: #495057;
}

/* Messages Area */
.chat-messages-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  position: relative;
}

.chat-messages-area {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

/* Input Area */
.chat-input-area,
.private-chat-input-area {
  flex-shrink: 0;
  background: rgba(255, 255, 255, 0.02);
  backdrop-filter: blur(10px);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
  position: relative;
}

.chat-input-container,
.private-chat-input-container {
  display: flex;
  align-items: center;
  padding: 16px 20px;
  gap: 12px;
}

.chat-attach-btn,
.chat-send-btn,
.chat-e2ee-toggle-btn,
.private-chat-attach-btn,
.private-chat-send-btn,
.private-chat-e2ee-toggle-btn {
  background: none;
  border: none;
  font-size: 16px;
  cursor: pointer;
  padding: 10px;
  border-radius: 8px;
  transition: all 0.2s ease;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
}

.chat-attach-btn,
.private-chat-attach-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(85, 93, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.2);
  color: #a0aec0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  flex-shrink: 0;
}

.chat-attach-btn:hover,
.private-chat-attach-btn:hover {
  background: rgba(85, 93, 255, 0.1);
  border-color: #ab9ff2;
  color: #ffffff;
  transform: scale(1.05);
}

.chat-send-btn,
.private-chat-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #ab9ff2 0%, #6c5ce7 100%);
  border: none;
  color: #ffffff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
  box-shadow: 0 4px 12px rgba(171, 159, 242, 0.3);
  flex-shrink: 0;
  opacity: 0.6;
  pointer-events: none;
}

.chat-send-btn:not(:disabled),
.private-chat-send-btn:not(:disabled) {
  opacity: 1;
  pointer-events: auto;
}

.chat-send-btn:not(:disabled):hover,
.private-chat-send-btn:not(:disabled):hover {
  background: linear-gradient(135deg, #9b94f2 0%, #7c69f2 100%);
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(171, 159, 242, 0.4);
}

.chat-send-btn:disabled,
.private-chat-send-btn:disabled {
  cursor: not-allowed;
}

.chat-message-input,
.private-chat-message-input {
  flex: 1;
  padding: 12px 16px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  font-size: 14px;
  background: rgba(85, 93, 255, 0.05);
  color: #ffffff;
  font-family: 'Archivo', sans-serif;
  transition: all 0.2s ease;
  outline: none;
  min-height: 20px;
  max-height: 120px;
  resize: none;
}

.chat-message-input:focus,
.private-chat-message-input:focus {
  border-color: #ab9ff2;
  background: rgba(85, 93, 255, 0.1);
}

.chat-message-input::placeholder,
.private-chat-message-input::placeholder {
  color: #a0aec0;
}

/* E2EE Toggle Button Styles */
.chat-e2ee-toggle-btn,
.private-chat-e2ee-toggle-btn {
  color: #a0aec0;
  position: relative;
}

.chat-e2ee-toggle-btn:hover,
.private-chat-e2ee-toggle-btn:hover {
  background: rgba(85, 93, 255, 0.1);
  color: #ffffff;
}

.chat-e2ee-toggle-btn.e2ee-connected,
.private-chat-e2ee-toggle-btn.e2ee-connected {
  color: #48bb78;
  background: rgba(72, 187, 120, 0.1);
}

.chat-e2ee-toggle-btn.e2ee-connected:hover,
.private-chat-e2ee-toggle-btn.e2ee-connected:hover {
  background: rgba(72, 187, 120, 0.2);
}

.chat-e2ee-toggle-btn.e2ee-connecting,
.private-chat-e2ee-toggle-btn.e2ee-connecting {
  color: #667eea;
  cursor: not-allowed;
}

.chat-e2ee-toggle-btn.e2ee-error,
.private-chat-e2ee-toggle-btn.e2ee-error {
  color: #f56565;
  background: rgba(245, 101, 101, 0.1);
}

.chat-e2ee-toggle-btn.e2ee-error:hover,
.private-chat-e2ee-toggle-btn.e2ee-error:hover {
  background: rgba(245, 101, 101, 0.2);
}

.chat-e2ee-toggle-btn.e2ee-disabled,
.private-chat-e2ee-toggle-btn.e2ee-disabled {
  color: #a0aec0;
}

/* E2EE Notification Styles */
.e2ee-notification {
  position: absolute;
  bottom: 100%;
  left: 20px;
  right: 20px;
  padding: 12px 16px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
  animation: slideUp 0.3s ease;
  z-index: 1000;
}

.e2ee-notification.e2ee-success {
  background: rgba(72, 187, 120, 0.95);
  color: white;
  border: 1px solid rgba(72, 187, 120, 0.3);
}

.e2ee-notification.e2ee-error {
  background: rgba(245, 101, 101, 0.95);
  color: white;
  border: 1px solid rgba(245, 101, 101, 0.3);
}

.e2ee-notification.e2ee-warning {
  background: rgba(237, 137, 54, 0.95);
  color: white;
  border: 1px solid rgba(237, 137, 54, 0.3);
}

.e2ee-notification.e2ee-info {
  background: rgba(102, 126, 234, 0.95);
  color: white;
  border: 1px solid rgba(102, 126, 234, 0.3);
}

.e2ee-notification i {
  font-size: 16px;
  flex-shrink: 0;
}

/* Message Styles */
.chat-message {
  margin-bottom: 16px;
  animation: fadeIn 0.3s ease;
  display: flex;
  flex-direction: column;
}

.chat-message.own {
  align-items: flex-end;
}

.chat-message.other {
  align-items: flex-start;
}

.message-content {
  display: inline-block;
  min-width: 60px;
  max-width: min(75%, 400px);
  padding: 12px 16px;
  border-radius: 16px;
  position: relative;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.chat-message.own .message-content {
  background: #313578;
  color: #FFFFFF;
  border-radius: 16px 16px 0px 16px;
  margin-left: auto;
}

.chat-message.other .message-content {
  background: #38394F;
  color: #EBEBEB;
  border-radius: 0px 16px 16px 16px;
  margin-right: auto;
}

.message-text {
  font-family: 'Montserrat', sans-serif;
  font-size: 14px;
  line-height: 20px;
  margin: 0;
  white-space: normal;
  word-break: normal;
  overflow-wrap: break-word;
  display: block;
  width: 100%;
}

/* Time + status tick - OUTSIDE the bubble */
.message-time {
  font-family: 'Montserrat', sans-serif;
  font-size: 12px;
  line-height: 16px;
  color: #536285;
  display: flex;
  align-items: center;
  gap: 2px;
  padding: 4px 0px;
  margin-top: 4px;
  width: 100%;
}

/* Own messages - time aligned right */
.chat-message.own .message-time {
  justify-content: flex-end;
  align-self: flex-end;
  max-width: min(75%, 400px);
}

/* Other messages - time aligned left */
.chat-message.other .message-time {
  justify-content: flex-start;
  align-self: flex-start;
  max-width: min(75%, 400px);
}

.message-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(85, 93, 255, 0.2);
}

.message-avatar-placeholder {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(85, 93, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  border: 2px solid rgba(85, 93, 255, 0.2);
}

.message-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.message-user-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.message-nickname {
  font-size: 12px;
  font-weight: 600;
  color: #ab9ff2;
  line-height: 1;
}

.message-wallet {
  font-size: 10px;
  color: #a0aec0;
  line-height: 1;
  font-family: 'Archivo', monospace;
}

/* Immortal Message Styles */
.message-immortal {
  position: relative;
}

.message-immortal-indicator {
  position: absolute;
  top: -8px;
  right: -8px;
  background: linear-gradient(135deg, #ffd700 0%, #ffb347 100%);
  color: #FFFFFF;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(255, 215, 0, 0.3);
  z-index: 10;
}

/* E2EE Message Styles */
.message-encrypted {
  position: relative;
}

.message-e2ee-indicator {
  position: absolute;
  top: -8px;
  left: -8px;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 10px;
  font-weight: bold;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
  z-index: 10;
}

/* Green background - encrypted and can decrypt */
.message-e2ee-indicator.message-e2ee-locked-green {
  background: linear-gradient(135deg, #48bb78 0%, #38a169 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(72, 187, 120, 0.3);
}

/* Red background - encrypted but can't decrypt (no seed committed) */
.message-e2ee-indicator.message-e2ee-locked-red {
  background: linear-gradient(135deg, #f56565 0%, #e53e3e 100%);
  color: white;
  box-shadow: 0 2px 8px rgba(245, 101, 101, 0.3);
}

/* Adjust positioning for own messages */
.chat-message.own .message-e2ee-indicator {
  left: auto;
  right: -8px;
}

.chat-message.own .message-immortal-indicator {
  right: -8px;
}

/* Adjust positioning when both indicators are present */
.chat-message.own.message-immortal .message-e2ee-indicator {
  right: 20px; /* Leave space for immortal indicator */
}

.chat-message.other.message-immortal .message-e2ee-indicator {
  left: 20px; /* Leave space for immortal indicator */
}

/* Image Message Styles */
.image-message-placeholder {
  height: 150px;
  background: rgba(85, 93, 255, 0.05);
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #a0aec0;
  cursor: pointer;
  transition: all 0.2s ease;
}

.image-message-placeholder:hover {
  background: rgba(85, 93, 255, 0.1);
  border-color: #ab9ff2;
}

/* Context Menu Styles */
.context-menu {
  position: absolute;
  background: rgba(26, 26, 46, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 8px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
  border: 1px solid rgba(85, 93, 255, 0.1);
  min-width: 160px;
  z-index: 10000;
  animation: fadeIn 0.2s ease;
}

.context-menu-item {
  display: flex;
  align-items: center;
  padding: 12px 16px;
  cursor: pointer;
  transition: all 0.2s ease;
  border-radius: 6px;
  margin: 2px 4px;
  color: #ffffff;
}

.context-menu-item:hover {
  background: rgba(85, 93, 255, 0.1);
}

.context-menu-item.destructive {
  color: #f56565;
}

.context-menu-item.destructive:hover {
  background: rgba(245, 101, 101, 0.1);
}

.context-menu-item i {
  margin-right: 8px;
  width: 16px;
  text-align: center;
}

/* Infinite Scroll Loading */
.infinite-scroll-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
  color: #a0aec0;
  font-size: 14px;
}

.loading-spinner {
  width: 20px;
  height: 20px;
  border: 2px solid rgba(255, 255, 255, 0.1);
  border-top: 2px solid #ab9ff2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 8px;
}

/* File Upload Modal */
.file-upload-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  animation: fadeIn 0.3s ease;
}

.file-upload-modal-overlay {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.file-upload-modal-content {
  background: rgba(26, 26, 46, 0.95);
  border-radius: 12px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow: hidden;
  animation: slideUp 0.3s ease;
  border: 1px solid rgba(85, 93, 255, 0.1);
}

.file-upload-modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.file-upload-modal-header h3 {
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: #ffffff;
}

.file-upload-modal-close {
  background: none;
  border: none;
  font-size: 20px;
  color: #a0aec0;
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.file-upload-modal-close:hover {
  background: rgba(85, 93, 255, 0.1);
  color: #ffffff;
}

.file-upload-modal-body {
  padding: 20px;
  max-height: 60vh;
  overflow-y: auto;
}

/* Animations */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Responsive Design */
@media (max-width: 768px) {
  .chat-interface-header {
    padding: 12px 16px;
  }

  .chat-input-container {
    padding: 12px 16px;
  }

  .contact-avatar {
    width: 32px;
    height: 32px;
    font-size: 14px;
  }

  .contact-name {
    font-size: 14px;
  }

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

  .chat-attach-btn,
  .chat-send-btn,
  .chat-e2ee-toggle-btn {
    width: 36px;
    height: 36px;
    font-size: 14px;
  }

  .chat-message-input {
    font-size: 16px; /* Prevents zoom on iOS */
  }

  .context-menu {
    min-width: 140px;
  }

  .context-menu-item {
    padding: 10px 12px;
    font-size: 14px;
  }
}

/* Dark Mode Support - REMOVED: App is always dark themed, using Figma solid colors */

/* Loading States */
.chat-interface.loading .chat-messages-area {
  opacity: 0.7;
  pointer-events: none;
}

.chat-interface.loading::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 4px solid rgba(255, 255, 255, 0.1);
  border-top: 4px solid #ab9ff2;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  z-index: 1000;
}

/* ===== ENCRYPTED IMAGE MESSAGES ===== */

/* Image message bubbles have tighter padding than text */
.message-content.image-content {
  padding: 8px 10px;
  max-width: min(75%, 320px);
  border-radius: 16px;
  overflow: hidden;
}

.chat-image {
  width: 100%;
  max-width: 283px;
  max-height: 255px;
  object-fit: contain;
  border-radius: 12px;
  cursor: pointer;
  transition: transform 0.2s ease;
  display: block;
}

.chat-image:hover {
  transform: scale(1.02);
}

.image-placeholder {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 150px;
  background: rgba(85, 93, 255, 0.1);
  border-radius: 12px;
  gap: 12px;
  padding: 20px;
}

.image-placeholder .spinner {
  width: 40px;
  height: 40px;
  border: 4px solid rgba(85, 93, 255, 0.3);
  border-top-color: #555DFF;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

.image-placeholder span {
  color: rgba(255, 255, 255, 0.7);
  font-size: 14px;
}

.image-error {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100px;
  background: rgba(255, 85, 85, 0.1);
  border-radius: 12px;
  padding: 20px;
}

.image-error span {
  color: rgba(255, 85, 85, 0.9);
  font-size: 14px;
}

/* Attach button styling */
.chat-attach-btn {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background: rgba(85, 93, 255, 0.2);
  border: 1px solid rgba(85, 93, 255, 0.4);
  color: #FFFFFF;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.chat-attach-btn:hover {
  background: rgba(85, 93, 255, 0.4);
  transform: scale(1.05);
}

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

/* ===== END ENCRYPTED IMAGE MESSAGES ===== */

/* ========================================
   📱 MOBILE STYLES (MATCH PRIVATE CHAT)
   ======================================== */

@media (max-width: 768px) {
  /* 🔥 CONTAINER - Full screen on mobile (matches private chat!) */
  .chat-interface,
  .chat-interface-component {
    position: fixed !important;
    top: 60px !important; /* Below mobile header */
    left: 0 !important;
    right: 0 !important;
    bottom: 80px !important; /* 🔥 FIX: Account for bottom nav (64px + 16px padding = 80px total) */
    display: flex !important;
    flex-direction: column !important;
    background: rgba(10, 15, 35, 0.6) !important;
    z-index: 100 !important;
    overflow: hidden !important;
    border-radius: 0 !important; /* No rounded corners on mobile */
  }
  
  /* 🔥 HEADER - Same as private chat */
  .chat-interface-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: rgba(14, 20, 41, 0.95);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    min-height: 60px;
    flex-shrink: 0;
  }
  
  /* 🔥 BACK BUTTON - Visible on mobile */
  .chat-interface-back {
    display: flex !important;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
  }
  
  /* 🔥 HEADER RECIPIENT INFO (matches private chat class names!) */
  .chat-interface-recipient {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
  }
  
  .recipient-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
  }
  
  .recipient-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
  }
  
  .recipient-info .chat-title {
    font-family: 'Montserrat', sans-serif !important;
    font-weight: 600;
    font-size: 16px;
    color: #ffffff;
  }
  
  .recipient-info .chat-subtitle {
    font-family: 'Montserrat', sans-serif !important;
    font-size: 12px;
    color: rgba(255, 255, 255, 0.6);
  }
  
  /* 🔥 MESSAGES CONTAINER - Scrollable area (matches private chat!) */
  .chat-messages-container,
  #chat-messages-area {
    flex: 1 !important;
    overflow-y: auto !important;
    -webkit-overflow-scrolling: touch !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 12px !important;
  }
  
  /* 🔥 INPUT AREA - EXACT MATCH TO PRIVATE CHAT MOBILE */
  .chat-interface-input-area {
    padding: 12px; /* 🔥 EXACT: From private chat mobile */
    background: #00091E; /* Keep same background */
    border-top: none;
    height: 56px;
  }
  
  /* 🔥 INPUT CONTAINER - Same as private chat */
  .chat-interface-input-container {
    display: flex;
    align-items: center;
    gap: 4px; /* 🔥 EXACT: Tight spacing */
    width: 100%;
    height: 44px;
    padding: 0;
  }
  
  /* 🔥 INPUT WRAPPER - Same as desktop, no changes needed on mobile */
  .chat-interface-message-input-wrapper {
    /* Inherits from desktop styles - no override needed */
  }
  
  .chat-interface-message-input {
    padding: 10px 14px; /* 🔥 EXACT: From private chat mobile */
    font-size: 13px; /* 🔥 EXACT: From private chat mobile */
  }
  
  /* 🔥 ALL INPUT BUTTONS - 24px on mobile (EXACT MATCH) */
  .chat-interface-send-btn,
  .chat-interface-attach-btn,
  .chat-send-button,
  .chat-input-icon {
    width: 24px !important; /* 🔥 EXACT: From private chat mobile */
    height: 24px !important; /* 🔥 EXACT: From private chat mobile */
  }
  
  /* 🔥 Send button img 24px on mobile (EXACT MATCH) */
  .chat-interface-send-btn > img,
  .chat-send-button > img {
    width: 24px !important;
    height: 24px !important;
  }
  
  /* 🔥 HIDE EMOJI BUTTON ON MOBILE */
  .chat-input-icon[alt="Emoji"],
  img[alt="Emoji"],
  button[title*="emoji" i] {
    display: none !important;
  }
  
  /* 🔥 HIDE MOBILE MESSAGE INPUT WRAPPER (obsolete from ChatComponent mobile rendering) */
  .mobile-message-input-wrapper {
    display: none !important;
  }
  
  /* 🔥 E2EE INDICATOR */
  .e2ee-status-indicator {
    display: none; /* Hidden by default, shown when E2EE active */
    align-items: center;
    gap: 4px;
    font-size: 11px;
    color: rgba(85, 93, 255, 0.8);
    font-weight: 600;
  }
  
  .e2ee-lock {
    font-size: 12px;
  }
  
  /* 🔥 MESSAGE BUBBLES - Responsive on mobile */
  .message-content {
    max-width: 85% !important;
    padding: 10px 14px !important;
  }
  
  .message-text {
    font-size: 13px !important;
  }
  
  .message-time {
    font-size: 10px !important;
  }
}