/* Chat-specific styles extracted from main.css to reduce bloat and improve maintainability.
   Keep selectors and variables identical to avoid regressions. */

/* Messages Area */
.messages-container {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
}

/* Custom scrollbar for messages container */
.messages-container::-webkit-scrollbar { width: 4px; }
.messages-container::-webkit-scrollbar-track { background: transparent; }
.messages-container::-webkit-scrollbar-thumb { background: rgba(255, 255, 255, 0.2); border-radius: 2px; }
.messages-container::-webkit-scrollbar-thumb:hover { background: rgba(255, 255, 255, 0.3); width: 8px; }

/* Message group wrappers */
.message-group { margin-bottom: 16px; }

/* Inline message row */
.message {
  display: flex;
  padding: 2px 16px;
  transition: background-color 0.2s ease;
  position: relative;
}
.message:hover { background: rgba(4, 4, 5, 0.07); }

.message-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  margin-right: 16px; margin-top: 2px; flex-shrink: 0;
  background: var(--chatplin-brand);
  display: flex; align-items: center; justify-content: center;
  font-weight: 600; color: white;
}

.message-content { flex: 1; min-width: 0; }
.message-header { display: flex; align-items: baseline; margin-bottom: 2px; }
.message-author { font-weight: 500; color: white; margin-right: 6px; }
.message-timestamp { font-size: 12px; color: var(--chatplin-text-muted); opacity: 0.7; transition: opacity 0.2s ease; }
.message:hover .message-timestamp { opacity: 1; }
.message-text { font-size: 15px; line-height: 1.375; color: var(--chatplin-text-normal); word-wrap: break-word; }

/* Private Message Styles */
.message-group.private-message { margin-bottom: 8px; padding: 0 16px; }
.message-group.private-message.sent { display: flex; justify-content: flex-end; }
.message-group.private-message.received { display: flex; justify-content: flex-start; }

.private-message-bubble { max-width: 70%; position: relative; margin: 2px 0; }
.private-message-bubble.sent { background: var(--chatplin-brand); color: white; border-radius: 18px 18px 4px 18px; margin-left: 20%; }
.private-message-bubble.received { background: #40444b; color: var(--chatplin-text-normal); border-radius: 18px 18px 18px 4px; margin-right: 20%; }
.private-message-content { padding: 8px 12px; position: relative; }
.private-message-author { font-size: 12px; font-weight: 600; margin-bottom: 4px; color: var(--chatplin-brand); }
.private-message-bubble.sent .private-message-author { color: rgba(255, 255, 255, 0.8); }
.private-message-time { font-size: 10px; opacity: 0.7; text-align: right; margin-top: 4px; line-height: 1; }
.private-message-bubble.received .private-message-time { color: var(--chatplin-text-muted); }
.private-message-bubble.sent .private-message-time { color: rgba(255, 255, 255, 0.7); }
.private-message-bubble .message-text { margin: 0; line-height: 1.4; }
.private-message-bubble .message-attachment { background: transparent; border: 1px solid rgba(255, 255, 255, 0.2); border-radius: 8px; margin-top: 4px; }
.private-message-bubble.received .message-attachment { border-color: rgba(255, 255, 255, 0.1); }

/* Message edited/deleted states */
.message-edited-indicator { color: var(--chatplin-text-muted); font-size: 10px; margin-left: 6px; font-style: italic; }
.message-deleted { opacity: 0.6; font-style: italic; }
.message-deleted .message-text { color: var(--chatplin-text-muted); }

/* AI message context highlight */
.message-group.ai-message {
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
  border-left: 3px solid #667eea; padding-left: 12px;
}
.ai-message-avatar { background: linear-gradient(135deg, #667eea 0%, #764ba2 100%); color: white; }

/* Jump-to-message highlight (kept local to chat) */
.jump-highlight {
  animation: jumpFlash 1.2s ease-in-out 1;
  outline: 2px solid #5865f2;
  border-radius: 6px;
}
@keyframes jumpFlash { 0% { background-color: rgba(88,101,242,0.15); } 50% { background-color: rgba(88,101,242,0.35); } 100% { background-color: rgba(88,101,242,0); } }

/* Message hover actions */
.message-actions { position: absolute; right: 16px; top: -8px; background: var(--chatplin-bg-primary); border-radius: 4px; padding: 4px; box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3); opacity: 0; transition: opacity 0.2s ease; display: flex; gap: 4px; }
.message:hover .message-actions { opacity: 1; }
.action-button { background: none; border: none; color: var(--chatplin-text-muted); padding: 4px 6px; border-radius: 3px; cursor: pointer; font-size: 14px; transition: all 0.2s ease; }
.action-button:hover { color: var(--chatplin-text-normal); background: rgba(79, 84, 92, 0.16); }

/* Edit/Delete action colors */
.message-actions .action-button.edit { color: var(--chatplin-yellow); }
.message-actions .action-button.delete { color: var(--chatplin-red); }
.message-actions .action-button.edit:hover { background: rgba(250, 166, 26, 0.2); }
.message-actions .action-button.delete:hover { background: rgba(237, 66, 69, 0.2); }

/* Reactions */
.message-reactions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 6px; }
.emoji-reaction { display: inline-flex; align-items: center; background: rgba(79, 84, 92, 0.16); border: 1px solid rgba(79, 84, 92, 0.32); border-radius: 12px; padding: 2px 6px; cursor: pointer; transition: all 0.2s ease; font-size: 12px; user-select: none; }
.emoji-reaction:hover { background: rgba(88, 101, 242, 0.2); border-color: rgba(88, 101, 242, 0.5); transform: scale(1.05); }
.emoji-reaction.reacted { background: rgba(88, 101, 242, 0.3); border-color: var(--discord-brand); color: var(--discord-brand); }
.emoji-reaction-emoji { margin-right: 3px; font-size: 14px; }
.emoji-reaction-count { font-weight: 500; font-size: 11px; }
.reaction-tooltip { display: none; position: absolute; background: var(--chatplin-bg-tertiary); border: 1px solid var(--chatplin-border); padding: 4px 6px; border-radius: 4px; font-size: 11px; color: var(--chatplin-text-muted); transform: translateY(-100%); white-space: nowrap; z-index: 5; }
.emoji-reaction:hover .reaction-tooltip { display: block; }

/* Message Edit Modal */
.message-edit-modal { position: fixed; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.8); z-index: 2000; display: none; align-items: center; justify-content: center; }
.message-edit-modal.active { display: flex; }
.message-edit-container { background: var(--chatplin-bg-primary); border-radius: 8px; width: 90%; max-width: 500px; box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5); }
.message-edit-header { padding: 16px 20px; border-bottom: 1px solid var(--chatplin-border); display: flex; align-items: center; justify-content: space-between; }
.message-edit-title { font-size: 16px; font-weight: 600; color: var(--chatplin-text-normal); }
.message-edit-close { background: none; border: none; color: var(--chatplin-text-muted); cursor: pointer; padding: 4px; border-radius: 4px; transition: all 0.2s ease; }
.message-edit-close:hover { color: var(--chatplin-text-normal); background: rgba(79, 84, 92, 0.16); }
.message-edit-body { padding: 20px; }
.message-edit-textarea { width: 100%; min-height: 80px; max-height: 200px; background: var(--chatplin-bg-secondary); border: 1px solid var(--chatplin-border); border-radius: 4px; padding: 12px; color: var(--chatplin-text-normal); font-family: inherit; font-size: 14px; resize: vertical; outline: none; }
.message-edit-textarea:focus { border-color: var(--chatplin-brand); }
.message-edit-footer { padding: 16px 20px; border-top: 1px solid var(--chatplin-border); display: flex; justify-content: flex-end; gap: 8px; }
.message-edit-btn { padding: 8px 16px; border-radius: 4px; font-size: 14px; font-weight: 500; cursor: pointer; transition: all 0.2s ease; border: none; }
.message-edit-btn.primary { background: var(--chatplin-brand); color: white; }
.message-edit-btn.primary:hover { background: #4c56d4; }
.message-edit-btn.secondary { background: transparent; color: var(--chatplin-text-normal); border: 1px solid var(--chatplin-border); }
.message-edit-btn.secondary:hover { background: rgba(79, 84, 92, 0.16); }

/* My Message Styles - Right Aligned */
.message.my-message { flex-direction: row-reverse; position: relative; }
.message.my-message .message-content { text-align: right; max-width: 70%; }
.message.my-message .message-header.right-aligned { flex-direction: row-reverse; justify-content: flex-start; gap: 8px; }
.message.my-message .message-header.right-aligned .message-timestamp { order: 1; }
.message.my-message .message-header.right-aligned .message-avatar { order: 2; margin-left: 0; margin-right: 0; }
.message.my-message .message-header.right-aligned .message-author { order: 3; }
.message.my-message .message-actions.my-message-actions { position: absolute; left: 16px; right: auto; justify-content: flex-start; transform: none; }

/* Responsive tweaks for chat area */
@media (max-width: 768px) {
  /* Reserved for future chat-specific mobile adjustments */
}
