/* Private Chat Component Styles */
/* Following Domain-Driven OOP pattern */

.private-chat-component {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  height: 100%;
  background: linear-gradient(135deg, #00091E 0%, rgba(85, 93, 255, 0.05) 100%);
  color: #FFFFFF;
  z-index: 1000; /* Ensure it appears on top */
  opacity: 0;
  transform: translateX(100%);
  animation: slideInPrivateChat 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);
}

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

/* Header Styles */
.private-chat-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 */
}

.private-chat-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;
  margin-right: 6px; /* More condensed */
  border: 1px solid rgba(85, 93, 255, 0.2);
}

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

.private-chat-back i {
  font-size: 1.2rem;
}

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

.recipient-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(85, 93, 255, 0.1);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.recipient-avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* ===== AVATAR FALLBACK GRADIENTS ===== */

.avatar-fallback {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  display: flex !important;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #ffffff;
  box-shadow: 0 4px 12px rgb(0 0 0 / 30%);
  border: 2px solid rgba(85, 93, 255, 0.1);
}

.avatar-fallback-blue {
  background: linear-gradient(135deg, #3b82f6 0%, #1e3a8a 100%);
}

.avatar-fallback-purple {
  background: linear-gradient(135deg, #ab9ff2 0%, #6c5ce7 100%);
}

.avatar-fallback-green {
  background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

/* Message avatar fallbacks */
.message-avatar.avatar-fallback {
  width: 24px;
  height: 24px;
  font-size: 12px;
  margin-right: 8px;
  display: flex !important;
  align-items: center;
  justify-content: center;
}

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

/* ✅ UX POLISH: Header title/subtitle styles */
.recipient-info .chat-title {
  font-family: 'Montserrat', sans-serif !important; /* 🔥 BUG FIX: Force Montserrat */
  font-weight: 600;
  font-size: 16px;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 2px;
}

.recipient-info .chat-subtitle {
  font-family: 'Montserrat', sans-serif !important; /* 🔥 BUG FIX: Force Montserrat instead of Monaco */
  font-weight: 400;
  font-size: 12px;
  color: rgba(255, 255, 255, 0.6);
}

.recipient-name {
  font-weight: 600;
  font-size: 1rem;
  color: #ffffff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.125rem;
}

.recipient-wallet {
  font-size: 0.85rem;
  color: #a0aec0;
  font-family: 'Archivo', monospace;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 0.25rem;
  opacity: 0.8;
}

.recipient-status {
  display: flex;
  align-items: center;
  font-size: 0.85rem;
  color: rgba(255, 255, 255, 0.7);
}

.status-indicator {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 0.5rem;
}

.status-online {
  background: #28a745;
  box-shadow: 0 0 6px rgba(40, 167, 69, 0.5);
}

.status-text {
  font-size: 0.8rem;
}

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

.private-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;
}

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

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

.private-chat-messages-area {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Custom Scrollbar for Messages */
.private-chat-messages-area::-webkit-scrollbar {
  width: 6px;
}

.private-chat-messages-area::-webkit-scrollbar-track {
  background: rgba(85, 93, 255, 0.05);
  border-radius: 3px;
}

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

.private-chat-messages-area::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.3);
}

/* Message Styles */
.private-chat-message {
  display: flex;
  margin-bottom: 8px;
  animation: messageSlideIn 0.3s ease-out;
  flex-direction: column;
}

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

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

.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 */
}

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

.private-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%;
  
  /* 🔥 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 */
.private-chat-message.own .message-time {
  justify-content: flex-end;
  align-self: flex-end;
  max-width: min(75%, 400px);
}

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

/* Input Area */
/* Agent #3 - Match Figma design */
.private-chat-input-area {
  padding: 6px 24px; /* Figma spec */
  border-top: none; /* No border in Figma */
  background: #00091E; /* Figma spec: darker background */
  height: 56px; /* Figma spec */
  display: flex;
  align-items: center;
}

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

/* Agent #3 - Icon buttons match Figma design */
.private-chat-attach-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  color: #536285;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease;
  flex-shrink: 0;
  padding: 0;
}

.private-chat-attach-btn:hover {
  opacity: 0.7;
}

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

.private-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);
}

.private-chat-e2ee-status:hover {
  background: linear-gradient(135deg, #059669 0%, #047857 100%);
  transform: scale(1.02);
  box-shadow: 0 4px 12px rgba(16, 185, 129, 0.3);
}

.private-chat-e2ee-status i {
  font-size: 12px;
  color: #ffffff;
}

.private-e2ee-status-text {
  color: #ffffff;
  font-weight: 600;
  letter-spacing: 0.5px;
}

/* Agent #3 - Input wrapper with rounded background (Figma design) */
.private-chat-message-input-wrapper {
  display: flex;
  align-items: center;
  padding: 12px 6px; /* 🔥 BUG FIX (Agent #9 - Oct 26): Reduced horizontal padding for more space */
  gap: 2px;
  background: #0D1529; /* Figma spec: darker rounded background */
  border-radius: 16px;
  flex: 1;
  height: 44px;
}

.private-chat-message-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #EBEBEB;
  font-size: 16px; /* 🔥 BUG FIX (Agent #6 - Oct 26): Increased from 14px to prevent iOS zoom */
  font-family: 'Montserrat', sans-serif;
  font-weight: 400;
  line-height: 20px;
  outline: none;
}

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

/* Agent #3 - Send button matches Figma design */
.private-chat-send-btn {
  width: 32px;
  height: 32px;
  background: transparent;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, opacity 0.2s ease;
  padding: 0;
  flex-shrink: 0;
}

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

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

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

/* Loading Indicator */
.private-chat-loading {
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 1rem;
}

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

.spinner {
  width: 24px;
  height: 24px;
  border: 2px solid rgba(85, 93, 255, 0.2);
  border-top: 2px solid #667eea;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

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

/* Mobile Responsive */
@media (max-width: 768px) {
  /* 🔥 BUG #1 FIX: Hide "CHAT" header on mobile private chats (matches group chat behavior) */
  .mobile-private-chat .private-chat-header {
    display: none !important;
  }
  
  .private-chat-header {
    padding: 12px 16px;
    min-height: 60px;
    background: rgba(14, 20, 41, 0.95) !important; /* 🔥 MATCH GROUP CHAT: Solid background! */
    border-bottom: 1px solid rgba(255, 255, 255, 0.1) !important;
  }

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

  .recipient-name {
    font-size: 0.9rem;
  }

  .recipient-wallet {
    font-size: 0.75rem;
  }

  .private-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;
  }

  .private-chat-input-area {
    padding: 12px;
  }

  .private-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 */
  .private-chat-send-btn,
  .private-chat-attach-btn,
  .chat-input-icon,
  .chat-send-button {
    width: 24px !important;
    height: 24px !important;
  }
  
  /* 🔥 Send button img 24px on mobile */
  .private-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;
  }

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

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

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

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

/* ===== IMMORTAL MESSAGE STYLES ===== */
/* These styles are shared with chat-interface-component.css - kept consistent */

/* ===== NOTIFICATION STYLES ===== */
.private-chat-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 10001;
  max-width: 300px;
  animation: slideInFromRight 0.3s ease;
  font-size: 0.875rem;
}

.private-chat-notification.private-chat-success {
  background: rgba(40, 167, 69, 0.9);
  border: 1px solid rgba(40, 167, 69, 0.5);
  color: white;
}

.private-chat-notification.private-chat-error {
  background: rgba(220, 53, 69, 0.9);
  border: 1px solid rgba(220, 53, 69, 0.5);
  color: white;
}

.private-chat-notification.private-chat-warning {
  background: rgba(255, 193, 7, 0.9);
  border: 1px solid rgba(255, 193, 7, 0.5);
  color: #212529;
}

.private-chat-notification.private-chat-info {
  background: rgba(23, 162, 184, 0.9);
  border: 1px solid rgba(23, 162, 184, 0.5);
  color: white;
}

.private-chat-notification i {
  font-size: 0.875rem;
}

.private-chat-notification span {
  font-size: 0.875rem;
  font-weight: 500;
}

/* ===== NOTIFICATION ANIMATION ===== */
@keyframes slideInFromRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* ===== MOBILE RESPONSIVENESS FOR NEW ELEMENTS ===== */
@media (max-width: 480px) {
  .private-chat-e2ee-status {
    padding: 3px 6px;
    font-size: 0.7rem;
  }

  .private-chat-notification {
    left: 10px;
    right: 10px;
    max-width: none;
  }
}

/* ===================================
   SOLIUS_SEEDS ENCRYPTION ANIMATION
   =================================== */

/* Lock icon animation for encrypted messages */
.seed-encrypting .message-e2ee-indicator {
  animation: lockFloatInOut 4s ease-in-out forwards;
}

@keyframes lockFloatInOut {
  0% {
    opacity: 0;
    transform: translateY(20px);
  }
  25% {
    opacity: 1;
    transform: translateY(0);
  }
  75% {
    opacity: 1;
    transform: translateY(0);
  }
  100% {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* Encryption indicator styling */
.message-e2ee-indicator {
  font-size: 14px;
  margin-left: 6px;
  position: relative;
  z-index: 10;
}

.message-e2ee-locked-green {
  background: linear-gradient(135deg, rgba(34, 197, 94, 0.2), rgba(34, 197, 94, 0.05));
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.3);
}

.message-e2ee-locked-red {
  background: linear-gradient(135deg, rgba(239, 68, 68, 0.2), rgba(239, 68, 68, 0.05));
  padding: 2px 6px;
  border-radius: 4px;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.3);
}

/* Payment Error Toast */
.payment-error-toast {
  position: fixed;
  top: 80px;
  left: 50%;
  transform: translateX(-50%) translateY(-20px);
  background: rgba(255, 71, 87, 0.95);
  color: white;
  padding: 12px 24px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  z-index: 10000;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 8px 24px rgba(255, 71, 87, 0.4);
}

.payment-error-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}