/* ========================================
   CHAT SELECTION MODE & THREADING
   ======================================== */

/* Selection mode overlay */
.selection-mode-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  z-index: 10000;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.selection-mode-overlay.visible {
  opacity: 1;
}

/* Selection controls */
.selection-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 40px;
  background: rgba(255, 255, 255, 0.05);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  gap: 20px;
  flex-wrap: wrap;
}

.selection-controls-left,
.selection-controls-right {
  display: flex;
  align-items: center;
  gap: 12px;
}

.selection-counter {
  font-size: 16px;
  font-weight: 600;
  color: white;
  padding: 8px 16px;
  background: rgba(145, 70, 255, 0.3);
  border-radius: var(--radius);
}

.selection-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius);
  color: white;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.selection-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.4);
  transform: translateY(-1px);
}

.selection-btn span {
  font-size: 16px;
}

/* Selected message container */
.selected-message-container {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  overflow-y: auto;
}

.selected-message-container .chat-message {
  max-width: 800px;
  width: 100%;
  background: var(--panel);
  border: 2px solid var(--accent);
  border-radius: var(--radius-lg);
  padding: 24px 32px;
  box-shadow: 0 10px 50px rgba(145, 70, 255, 0.3);
  line-height: 1.6;
}

.selected-enlarged {
  animation: slideIn 0.3s ease;
}

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

.selected-message-container .username {
  font-size: 1.2em;
  font-weight: 700;
  margin-bottom: 8px;
}

.selected-message-container .message-text {
  font-size: inherit;
  line-height: 1.8;
}

/* Reply button */
.reply-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-left: 6px;
  padding: 0;
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 12px;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s ease;
}

.reply-btn:hover {
  opacity: 1;
  background: var(--panel2);
  border-color: var(--accent);
}

/* Reply indicator */
.reply-indicator {
  display: none;
  padding: 12px 16px;
  background: var(--panel2);
  border-left: 3px solid var(--accent);
  border-radius: var(--radius-sm);
  margin-bottom: 8px;
  animation: slideDown 0.3s ease;
}

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

.reply-indicator-content {
  display: flex;
  align-items: center;
  gap: 12px;
}

.reply-icon {
  font-size: 20px;
  flex-shrink: 0;
}

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

.reply-to {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 2px;
}

.reply-to strong {
  color: var(--accent);
}

.reply-preview {
  font-size: 13px;
  color: var(--text);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.reply-cancel {
  width: 24px;
  height: 24px;
  padding: 0;
  background: transparent;
  border: none;
  color: var(--muted);
  font-size: 18px;
  cursor: pointer;
  flex-shrink: 0;
  transition: color 0.2s ease;
}

.reply-cancel:hover {
  color: var(--text);
}

/* Thread indicator */
.thread-indicator {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  background: rgba(145, 70, 255, 0.1);
  border: 1px solid rgba(145, 70, 255, 0.3);
  border-radius: var(--radius-full);
  font-size: 11px;
  font-weight: 600;
  color: var(--accent);
  margin-left: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.thread-indicator:hover {
  background: rgba(145, 70, 255, 0.2);
  border-color: rgba(145, 70, 255, 0.5);
}

/* Thread modal */
.thread-modal-content {
  max-width: 700px;
  width: 90%;
  max-height: 80vh;
}

.thread-messages {
  max-height: 60vh;
  overflow-y: auto;
  padding: 0;
}

.thread-message {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  position: relative;
}

.thread-message:last-child {
  border-bottom: none;
}

.thread-message.thread-root {
  background: rgba(145, 70, 255, 0.05);
  border-left: 3px solid var(--accent);
}

.thread-message:not(.thread-root) {
  padding-left: 40px;
}

.thread-indent {
  position: absolute;
  left: 20px;
  top: 0;
  bottom: 0;
  width: 2px;
  background: var(--border);
}

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

.thread-username {
  font-weight: 700;
  font-size: 14px;
}

.thread-timestamp {
  font-size: 11px;
  color: var(--muted);
}

.thread-message-text {
  color: var(--text);
  line-height: 1.6;
  font-size: 14px;
}

/* Mobile responsive */
@media (max-width: 768px) {
  .selection-controls {
    padding: 12px 16px;
  }
  
  .selection-controls-left,
  .selection-controls-right {
    gap: 8px;
  }
  
  .selection-btn {
    padding: 8px 12px;
    font-size: 12px;
  }
  
  .selection-btn span {
    font-size: 14px;
  }
  
  .selected-message-container {
    padding: 20px 16px;
  }
  
  .selected-message-container .chat-message {
    padding: 16px 20px;
  }
  
  .thread-message:not(.thread-root) {
    padding-left: 30px;
  }
  
  .thread-indent {
    left: 15px;
  }
}

/* Smooth scrolling for navigation */
.selected-message-container {
  scroll-behavior: smooth;
}

/* Highlight effect when navigating */
.selected-enlarged {
  position: relative;
}

.selected-enlarged::before {
  content: '';
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  background: linear-gradient(45deg, transparent, rgba(145, 70, 255, 0.2), transparent);
  border-radius: var(--radius-lg);
  z-index: -1;
  animation: pulse 2s ease infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 0.5;
  }
  50% {
    opacity: 1;
  }
}

/* Chat message hover effect to show reply button */
.chat-message {
  position: relative;
  transition: background 0.2s ease;
}

.chat-message:hover {
  background: rgba(255, 255, 255, 0.02);
}

.chat-message:hover .reply-btn {
  opacity: 0.8;
}

/* Selection mode active cursor */
.selection-mode-overlay .selected-message-container {
  cursor: default;
}
