/* ==========================================================================
   @Mention Autocomplete Dropdown
   ========================================================================== */

#mention-menu {
  display: none;
  position: absolute;
  bottom: 100%;
  left: 0;
  right: 0;
  max-height: 280px;
  overflow-y: auto;
  background: var(--sidebar-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 8px;
  box-shadow: 0 4px 12px rgba(var(--shadow-rgb), 0.15);
  z-index: 10;
}

#mention-menu.visible { display: block; }

.mention-hint {
  position: sticky;
  top: 0;
  padding: 8px 16px;
  font-size: 12px;
  color: var(--text-muted);
  background: var(--sidebar-bg);
  border-bottom: 1px solid var(--border-subtle);
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.mention-close-btn {
  border: none;
  background: none;
  color: var(--text-dimmer);
  font-size: 16px;
  cursor: pointer;
  padding: 0 2px;
  line-height: 1;
}
.mention-close-btn:hover {
  color: var(--text-secondary);
}

.mention-item {
  display: flex;
  align-items: center;
  padding: 10px 16px;
  cursor: pointer;
  gap: 10px;
  border-bottom: 1px solid var(--border-subtle);
}

.mention-item:last-child { border-bottom: none; }

.mention-item:hover,
.mention-item.active {
  background: rgba(var(--overlay-rgb), 0.05);
}

.mention-item-avatar-wrap {
  position: relative;
  width: 24px;
  height: 24px;
  flex-shrink: 0;
}
.mention-item-avatar {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  flex-shrink: 0;
}
.mention-item-vendor-badge {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  border: 1.5px solid var(--sidebar-bg);
  background: #fff;
  object-fit: cover;
  object-position: center;
}

.mention-item-info {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 1px;
}
.mention-item-name {
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
}
.mention-item-bio {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.mention-item-badge {
  display: inline-block;
  font-size: 9px;
  font-weight: 800;
  letter-spacing: 0.5px;
  padding: 1px 5px;
  border-radius: 3px;
  background: var(--accent-12, rgba(255,184,108,0.12));
  color: var(--accent, #ffb86c);
  vertical-align: middle;
  margin-left: 5px;
}

.mention-item-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* ==========================================================================
   @Mention Chip (in user bubble)
   ========================================================================== */

.mention-chip {
  display: inline;
  color: var(--accent);
  font-weight: 600;
  background: rgba(var(--accent-rgb, 124, 58, 237), 0.12);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: inherit;
}

/* ==========================================================================
   @Mention Chip (in input area)
   ========================================================================== */

#input-mention-chip {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 6px 3px 4px;
  margin: 0 0 4px 0;
  border-radius: 6px;
  background: color-mix(in srgb, var(--chip-color, #6c5ce7) 15%, var(--bg-alt));
  border: 1px solid color-mix(in srgb, var(--chip-color, #6c5ce7) 30%, var(--border));
  cursor: default;
  flex-shrink: 0;
  width: fit-content;
  animation: chip-in 0.15s ease-out;
}

@keyframes chip-in {
  from { opacity: 0; transform: scale(0.9); }
  to   { opacity: 1; transform: scale(1); }
}

.input-mention-chip-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  flex-shrink: 0;
}

.input-mention-chip-name {
  font-size: 13px;
  font-weight: 600;
  white-space: nowrap;
  line-height: 18px;
}

.input-mention-chip-remove {
  background: none;
  border: none;
  padding: 0;
  margin: 0;
  cursor: pointer;
  font-size: 15px;
  line-height: 18px;
  color: var(--text-dimmer);
  opacity: 0.6;
  transition: opacity 0.1s;
  display: flex;
  align-items: center;
}

.input-mention-chip-remove:hover {
  opacity: 1;
}

/* ==========================================================================
   @Mention Response Block
   ========================================================================== */

.msg-mention {
  position: relative;
  max-width: var(--content-width);
  margin: 0 auto 24px;
  padding: 4px 20px;
  border-radius: 12px;
  background: color-mix(in srgb, var(--mention-color, #6c5ce7) 6%, transparent);
  transition: background 0.15s;
}

.msg-mention:hover {
  background: color-mix(in srgb, var(--mention-color, #6c5ce7) 10%, transparent);
}

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

.mention-avatar {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  flex-shrink: 0;
}

.mention-name {
  font-size: 13px;
  font-weight: 700;
  color: var(--mention-color, #6c5ce7);
}

.mention-stop-btn {
  margin-left: auto;
  background: none;
  border: 1px solid var(--border, #333);
  border-radius: 4px;
  color: var(--text-secondary, #aaa);
  cursor: pointer;
  padding: 2px 6px;
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  transition: color 0.15s, border-color 0.15s;
}
.mention-stop-btn:hover {
  color: var(--danger, #e74c3c);
  border-color: var(--danger, #e74c3c);
}

.mention-content {
  font-size: 15px;
  line-height: 1.7;
  word-break: break-word;
  color: var(--text);
}

/* Activity bar inside mention block */
.msg-mention .mention-activity-bar {
  margin: 4px 0;
  padding: 0;
}

/* Copy hint ("Click to grab this") for mention blocks in project chat */
.msg-mention:hover .msg-copy-hint { opacity: 1; }
.msg-mention.copy-primed .msg-copy-hint { opacity: 1; color: var(--accent); }
.msg-mention.copy-done .msg-copy-hint { opacity: 1; color: var(--success); }

/* ==========================================================================
   @Mention in Mate DM (DM-style layout)
   ========================================================================== */

/* Badge next to mate name */
.mention-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  color: var(--text-dimmer);
  background: rgba(var(--overlay-rgb), 0.08);
  padding: 1px 5px;
  border-radius: 4px;
}

/* DM-style mention: override the DM mate avatar so it uses the mentioned mate's avatar */
.msg-mention-dm .dm-bubble-avatar-mate {
  /* Inherits dm-bubble-avatar styling from mates.css */
}

/* Activity bar inside DM-style mention */
.msg-mention-dm .mention-activity-bar {
  margin: 4px 0;
  padding: 0;
}

/* Error state */
.mention-error {
  color: var(--danger, #e74c3c);
  font-size: 13px;
  font-style: italic;
}

/* ==========================================================================
   Mobile adjustments
   ========================================================================== */

@media (max-width: 768px) {
  .msg-mention {
    max-width: 100%;
    padding: 4px 12px;
  }
}
