/* ========================================
   CHAT SELECTION POPUP (Mini-Profile Style)
   ======================================== */

/* Highlight selected message in chat */
.chat-message-selected,
.chat-line.chat-message-selected {
  position: relative;
  background: rgba(145, 70, 255, 0.15) !important;
  border-left: 4px solid rgba(145, 70, 255, 0.8) !important;
  padding-left: 12px !important;
  animation: pulseHighlight 2s ease-in-out infinite;
  box-shadow: 0 0 20px rgba(145, 70, 255, 0.3);
}

@keyframes pulseHighlight {
  0%, 100% {
    background: rgba(145, 70, 255, 0.15);
    box-shadow: 0 0 20px rgba(145, 70, 255, 0.3);
  }
  50% {
    background: rgba(145, 70, 255, 0.25);
    box-shadow: 0 0 30px rgba(145, 70, 255, 0.5);
  }
}

/* Selection mode popup (mini-profile style) */
.selection-mode-popup {
  position: fixed;
  z-index: 10003;
  width: min(520px, calc(100vw - 16px));
  max-height: calc(100vh - 40px);
  background: linear-gradient(145deg, rgba(28, 28, 32, 0.98), rgba(20, 20, 24, 0.98));
  border: 1px solid rgba(145, 70, 255, 0.2);
  border-radius: 12px;
  box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7), 0 0 0 1px rgba(145, 70, 255, 0.15);
  backdrop-filter: blur(20px);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  opacity: 0;
  transform: translateY(8px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s cubic-bezier(0.4, 0, 0.2, 1), transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.selection-mode-popup.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* Popup header */
.selection-popup-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 14px 18px;
  gap: 12px;
  border-bottom: 1px solid rgba(145, 70, 255, 0.15);
  background: linear-gradient(135deg, rgba(145, 70, 255, 0.12), rgba(145, 70, 255, 0.05));
  cursor: move;
  cursor: grab;
  user-select: none;
  box-shadow: 0 2px 10px rgba(145, 70, 255, 0.1);
}

.selection-popup-header:active {
  cursor: grabbing;
}

.selection-popup-header .selection-counter {
  font-size: 13px;
  font-weight: 900;
  color: #ffffff;
  padding: 7px 14px;
  background: linear-gradient(135deg, rgba(145, 70, 255, 0.35), rgba(145, 70, 255, 0.25));
  border-radius: 6px;
  border: 1px solid rgba(145, 70, 255, 0.4);
  box-shadow: 0 2px 8px rgba(145, 70, 255, 0.2), inset 0 1px 0 rgba(255, 255, 255, 0.1);
  flex: 0 0 auto;
}

.selection-header-actions {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-left: auto;
}

/* Navigation container to center buttons */
.selection-nav-container {
  display: flex;
  gap: 8px;
  align-items: center;
}

/* Navigation buttons - 20% bigger */
.selection-nav-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: rgba(239, 239, 241, 0.92);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.selection-nav-btn svg {
  width: 18px;
  height: 18px;
  stroke-width: 2;
}

.selection-nav-btn:hover {
  background: linear-gradient(135deg, rgba(145, 70, 255, 0.25), rgba(145, 70, 255, 0.15));
  border-color: rgba(145, 70, 255, 0.4);
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(145, 70, 255, 0.3);
}

.selection-icon-btn {
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: rgba(239, 239, 241, 0.86);
  font-size: 14px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.selection-icon-btn:hover {
  background: linear-gradient(135deg, rgba(145, 70, 255, 0.3), rgba(145, 70, 255, 0.2));
  border-color: rgba(145, 70, 255, 0.5);
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 4px 12px rgba(145, 70, 255, 0.4);
}

.selection-close-btn {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.18);
  border-radius: 6px;
  color: rgba(239, 239, 241, 0.92);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.selection-close-btn:hover {
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.3), rgba(244, 67, 54, 0.2));
  border-color: rgba(244, 67, 54, 0.5);
  transform: translateY(-1px) scale(1.05);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.4);
}

.selection-message-wrapper {
  display: flex;
  gap: 12px;
  align-items: stretch;
  padding: 0;
}

.selection-message-content {
  flex: 1;
  min-width: 0;
}

/* Popup body with scrolling */
.selection-popup-body {
  overflow-y: auto;
  overflow-x: hidden;
  max-height: calc(100vh - 120px);
}

.selection-popup-body::-webkit-scrollbar {
  width: 8px;
}

.selection-popup-body::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.selection-popup-body::-webkit-scrollbar-thumb {
  background: rgba(145, 70, 255, 0.4);
  border-radius: 0;
}

.selection-popup-body::-webkit-scrollbar-thumb:hover {
  background: rgba(145, 70, 255, 0.6);
}

/* Mini-profile style message display */
.mp-top {
  display: flex;
  gap: 12px;
  padding: 12px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: linear-gradient(180deg, rgba(145, 70, 255, 0.10), rgba(255, 255, 255, 0));
}

.mp-ava {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  object-fit: cover;
  flex: 0 0 auto;
}

.mp-meta {
  min-width: 0;
  flex: 1 1 auto;
}

.mp-name {
  font-weight: 900;
  font-size: 13px;
  color: rgba(239, 239, 241, 0.96);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  line-height: 1.15;
}

.mp-sub {
  margin-top: 6px;
  font-size: 11px;
  color: rgba(239, 239, 241, 0.70);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
}

.mp-chip {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.10);
  background: rgba(255, 255, 255, 0.05);
}

.mp-karma {
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid rgba(145, 70, 255, 0.3);
  background: rgba(145, 70, 255, 0.15);
  font-weight: 900;
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.mp-karma svg {
  width: 12px;
  height: 12px;
}

.mp-body {
  padding: 16px 18px;
}

.mp-msg-wrapper {
  position: relative;
  display: flex;
  flex-direction: column;
}

.mp-msg-line {
  display: block;
  margin-bottom: 8px;
}

.mp-msg-text {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(239, 239, 241, 0.92);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.mp-msg-time {
  font-size: 11px;
  color: rgba(239, 239, 241, 0.50);
  white-space: nowrap;
}

/* Media embeds container */
.mp-media-container {
  margin-top: 16px;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 12px;
}

/* Individual media items */
.mp-media {
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid rgba(145, 70, 255, 0.15);
  background: rgba(0, 0, 0, 0.4);
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.3);
  transition: all 0.2s ease;
}

.mp-media:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 24px rgba(145, 70, 255, 0.2);
  border-color: rgba(145, 70, 255, 0.3);
}

.mp-media img,
.mp-media video {
  width: 100%;
  max-height: 300px;
  object-fit: contain;
  background: rgba(0, 0, 0, 0.5);
  display: block;
}

.mp-media iframe {
  width: 100%;
  max-width: 100%;
  height: 250px;
  max-height: 250px;
  border: none;
  display: block;
}

/* Single media item - full width */
.mp-media-container:has(.mp-media:only-child) {
  grid-template-columns: 1fr;
}

.mp-media-container:has(.mp-media:only-child) .mp-media iframe {
  height: 280px;
}

/* Meta line for timestamp + reactions together */
.mp-meta-line {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 8px;
}

/* Message reactions (thumbs up/down) - same line as timestamp */
.mp-reactions {
  display: flex;
  align-items: center;
  justify-content: flex-start;
  gap: 4px;
}

.reaction-btn {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 0 6px;
  height: 18px;
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: rgba(239, 239, 241, 0.92);
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.reaction-btn svg {
  width: 36px;
  height: 36px;
  stroke-width: 2;
}

.reaction-btn:hover {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.08));
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.reaction-btn.reaction-up:hover {
  background: linear-gradient(135deg, rgba(76, 175, 80, 0.25), rgba(76, 175, 80, 0.15));
  border-color: rgba(76, 175, 80, 0.4);
  box-shadow: 0 4px 12px rgba(76, 175, 80, 0.3);
}

.reaction-btn.reaction-down:hover {
  background: linear-gradient(135deg, rgba(244, 67, 54, 0.25), rgba(244, 67, 54, 0.15));
  border-color: rgba(244, 67, 54, 0.4);
  box-shadow: 0 4px 12px rgba(244, 67, 54, 0.3);
}

.reaction-count {
  font-size: 9px;
  font-weight: 700;
  min-width: 12px;
  text-align: center;
}

.reaction-score {
  padding: 2px 6px;
  background: rgba(145, 70, 255, 0.15);
  border: 1px solid rgba(145, 70, 255, 0.25);
  border-radius: 0;
  font-size: 9px;
  font-weight: 900;
  color: rgba(239, 239, 241, 0.90);
}

/* Reply preview section */
.mp-replies {
  margin-top: 8px;
}

.mp-reply-preview {
  padding: 10px;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-left: 3px solid rgba(145, 70, 255, 0.5);
  border-radius: 8px;
}

.mp-reply-header {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  font-size: 11px;
  color: rgba(239, 239, 241, 0.70);
}

.mp-reply-icon {
  font-size: 12px;
}

.mp-reply-user {
  font-weight: 700;
  color: rgba(145, 70, 255, 0.90);
}

.mp-reply-count {
  margin-left: auto;
  padding: 2px 6px;
  background: rgba(145, 70, 255, 0.2);
  border-radius: 999px;
  font-size: 10px;
  font-weight: 700;
}

.mp-reply-text {
  font-size: 12px;
  line-height: 1.4;
  color: rgba(239, 239, 241, 0.75);
  font-style: italic;
  flex: 1;
  min-width: 0;
}

/* Scrollable Replies List */
.selection-replies-list {
  margin: 12px;
  margin-bottom: 0;
  background: rgba(0, 0, 0, 0.25);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 0;
}

.selection-replies-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  background: linear-gradient(180deg, rgba(145, 70, 255, 0.08), transparent);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.selection-replies-title {
  font-size: 12px;
  font-weight: 900;
  color: rgba(239, 239, 241, 0.85);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.selection-replies-count {
  font-size: 11px;
  font-weight: 900;
  color: rgba(239, 239, 241, 0.70);
  padding: 3px 8px;
  background: rgba(145, 70, 255, 0.2);
  border: 1px solid rgba(145, 70, 255, 0.3);
  border-radius: 0;
}

.selection-replies-container {
  max-height: 300px;
  overflow-y: auto;
  padding: 8px;
}

.selection-replies-container::-webkit-scrollbar {
  width: 8px;
}

.selection-replies-container::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
}

.selection-replies-container::-webkit-scrollbar-thumb {
  background: rgba(145, 70, 255, 0.4);
  border-radius: 0;
}

.selection-replies-container::-webkit-scrollbar-thumb:hover {
  background: rgba(145, 70, 255, 0.6);
}

.selection-reply-item {
  display: flex;
  gap: 10px;
  padding: 10px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-radius: 0;
  margin-bottom: 8px;
  transition: all 0.2s ease;
}

.selection-reply-item:last-child {
  margin-bottom: 0;
}

.selection-reply-item:hover {
  background: rgba(255, 255, 255, 0.05);
  border-color: rgba(145, 70, 255, 0.3);
}

.selection-reply-item .reply-avatar {
  width: 32px;
  height: 32px;
  border-radius: 0;
  border: 1px solid rgba(255, 255, 255, 0.12);
  background: rgba(255, 255, 255, 0.06);
  object-fit: cover;
  flex-shrink: 0;
}

.selection-reply-item .reply-content {
  flex: 1;
  min-width: 0;
}

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

.selection-reply-item .reply-username {
  font-size: 12px;
  font-weight: 900;
  line-height: 1.2;
}

.selection-reply-item .reply-time {
  font-size: 10px;
  color: rgba(239, 239, 241, 0.50);
  margin-left: auto;
}

.selection-reply-item .reply-body {
  font-size: 13px;
  line-height: 1.4;
  color: rgba(239, 239, 241, 0.85);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.selection-message-username {
  font-size: 14px;
  font-weight: 900;
  line-height: 1.2;
}

.selection-message-time {
  font-size: 11px;
  color: rgba(239, 239, 241, 0.55);
  margin-top: 2px;
}

.selection-message-body {
  font-size: 14px;
  line-height: 1.5;
  color: rgba(239, 239, 241, 0.92);
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Reply section */
.selection-reply-section {
  background: linear-gradient(135deg, rgba(0, 0, 0, 0.30), rgba(0, 0, 0, 0.20));
  border: 1px solid rgba(145, 70, 255, 0.15);
  border-radius: 8px;
  padding: 6px;
  display: flex;
  gap: 6px;
  align-items: center;
  box-shadow: inset 0 2px 8px rgba(0, 0, 0, 0.3);
}

.selection-reply-label {
  font-size: 11px;
  font-weight: 700;
  color: rgba(239, 239, 241, 0.70);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.selection-reply-input {
  flex: 1;
  min-height: 16px;
  max-height: 50px;
  padding: 5px 8px;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.16);
  border-radius: 6px;
  color: rgba(239, 239, 241, 0.95);
  font-size: 12px;
  line-height: 1.3;
  outline: none;
  resize: none;
  font-family: inherit;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.selection-reply-input:focus {
  border-color: rgba(145, 70, 255, 0.5);
  background: rgba(255, 255, 255, 0.1);
  box-shadow: 0 0 0 3px rgba(145, 70, 255, 0.1);
}

.selection-reply-input::placeholder {
  color: rgba(239, 239, 241, 0.4);
}

.selection-reply-actions {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}

/* Use website theme buttons - send button as icon */
.selection-reply-section .btn {
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.18);
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.08), rgba(255, 255, 255, 0.04));
  color: rgba(239, 239, 241, 0.92);
  font-weight: 900;
  font-size: 12px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  white-space: nowrap;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.selection-reply-section .btn:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(255, 255, 255, 0.12), rgba(255, 255, 255, 0.08));
  transform: translateY(-1px);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.3);
}

.selection-reply-section .btn-primary {
  background: linear-gradient(135deg, rgba(145, 70, 255, 0.35), rgba(145, 70, 255, 0.25));
  border-color: rgba(145, 70, 255, 0.4);
  color: #ffffff;
}

.selection-reply-section .btn-primary:hover:not(:disabled) {
  background: linear-gradient(135deg, rgba(145, 70, 255, 0.45), rgba(145, 70, 255, 0.35));
  box-shadow: 0 4px 12px rgba(145, 70, 255, 0.4);
}

.selection-reply-section .btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Remove old duplicate button styles */
/* Mobile adjustments */
@media (max-width: 600px) {
  .selection-mode-popup {
    width: calc(100vw - 16px);
    left: 8px !important;
    right: 8px !important;
  }
  
  .selection-popup-header {
    padding: 10px 12px;
    gap: 8px;
  }
  
  .selection-nav-btn {
    width: 28px;
    height: 28px;
    font-size: 18px;
  }
  
  .mp-ava {
    width: 36px;
    height: 36px;
  }
  
  .selection-reply-input {
    min-height: 60px;
  }
  
  .selection-replies-container {
    max-height: 200px;
  }
}
