/**
 * Mentions System Styles
 * Includes: MentionInput, MentionsPanel, mention tags
 */

/* ========================================
   MENTION INPUT COMPONENT
   ======================================== */

.mention-input-wrapper {
  position: relative;
  width: 100%;
}

.mention-input {
  width: 100%;
  min-height: 80px;
  resize: vertical;
}

/* Contenteditable editor styles */
.mention-editor {
  white-space: pre-wrap;
  word-break: break-word;
  overflow-y: auto;
  cursor: text;
  line-height: 1.5;
}

.mention-editor:empty:before {
  content: attr(data-placeholder);
  color: var(--text-muted);
  pointer-events: none;
}

.mention-editor:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.15);
}

/* Mention Badge (in editor) */
.mention-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: rgba(102, 126, 234, 0.15);
  color: var(--primary-color);
  padding: 2px 8px 2px 4px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 13px;
  vertical-align: middle;
  user-select: all;
  cursor: default;
  margin: 0 1px;
}

.mention-badge-avatar {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.mention-badge-name {
  white-space: nowrap;
}

.mention-badge-avatar-placeholder {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 600;
  flex-shrink: 0;
}

[data-theme="dark"] .mention-badge {
  background: rgba(102, 126, 234, 0.25);
}

/* Mention Dropdown */
.mention-dropdown {
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 200px;
  overflow-y: auto;
  background: var(--content-bg);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  z-index: 1000;
  margin-top: 4px;
}

.mention-dropdown-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.mention-dropdown-item:hover,
.mention-dropdown-item.active {
  background: var(--hover-bg);
}

.mention-dropdown-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}

.mention-dropdown-name {
  font-size: 14px;
  color: var(--content-text);
}

/* Avatar placeholder in dropdown */
.mention-dropdown-avatar-placeholder {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--primary-color);
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 600;
  flex-shrink: 0;
}

/* Mention Tag (in display) */
.mention-tag {
  display: inline;
  background: rgba(102, 126, 234, 0.15);
  color: var(--primary-color);
  padding: 2px 6px;
  border-radius: 4px;
  font-weight: 500;
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.mention-tag:hover {
  background: rgba(102, 126, 234, 0.25);
}

[data-theme="dark"] .mention-tag {
  background: rgba(102, 126, 234, 0.25);
}

[data-theme="dark"] .mention-tag:hover {
  background: rgba(102, 126, 234, 0.35);
}

/* ========================================
   MENTIONS PANEL
   ======================================== */

.mentions-panel {
  position: fixed;
  top: 0;
  right: -400px;
  width: 400px;
  height: 100vh;
  background: var(--content-bg);
  border-left: 1px solid var(--border-color);
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
  z-index: 1001;
  display: flex;
  flex-direction: column;
  transition: right 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.mentions-panel.visible {
  right: 0;
}

/* Panel Header */
.mentions-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.mentions-panel-title {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  font-size: 18px;
  font-weight: 600;
  color: var(--content-text);
}

.mentions-icon {
  font-size: 20px;
}

.mentions-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  background: var(--primary-color);
  color: white;
  font-size: 11px;
  font-weight: 600;
  border-radius: 10px;
}

.mentions-close-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mentions-close-btn:hover {
  background: var(--hover-bg);
  color: var(--content-text);
}

/* Panel Filters */
.mentions-panel-filters {
  display: flex;
  gap: 8px;
  padding: 12px 20px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.mentions-filter-btn {
  padding: 6px 14px;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 20px;
  font-size: 13px;
  color: var(--text-muted);
  cursor: pointer;
  transition: all 0.15s ease;
}

.mentions-filter-btn:hover {
  border-color: var(--primary-color);
  color: var(--primary-color);
}

.mentions-filter-btn.active {
  background: var(--primary-color);
  border-color: var(--primary-color);
  color: white;
}

/* Panel Content */
.mentions-panel-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* Loading State */
.mentions-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 14px;
}

/* Empty State */
.mentions-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 20px;
  text-align: center;
}

.mentions-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.mentions-empty-text {
  font-size: 16px;
  font-weight: 500;
  color: var(--content-text);
  margin-bottom: 8px;
}

.mentions-empty-hint {
  font-size: 13px;
  color: var(--text-muted);
  max-width: 250px;
}

/* Error State */
.mentions-error {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 40px 20px;
  color: var(--text-muted);
}

.mentions-retry-btn {
  padding: 8px 16px;
  background: var(--primary-color);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

/* Mention Item */
.mention-item {
  display: flex;
  gap: 12px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-color);
  transition: background-color 0.15s ease;
}

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

.mention-item:hover {
  background: var(--hover-bg);
}

.mention-item.unread {
  background: rgba(102, 126, 234, 0.05);
}

.mention-item.unread:hover {
  background: rgba(102, 126, 234, 0.1);
}

.mention-item.completed {
  opacity: 0.6;
}

/* Avatar */
.mention-item-avatar {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
}

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

.mention-avatar-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  background: var(--primary-color);
  color: white;
  border-radius: 50%;
  font-size: 16px;
  font-weight: 600;
}

/* Content */
.mention-item-content {
  flex: 1;
  min-width: 0;
  cursor: pointer;
}

.mention-item-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 4px;
}

.mention-item-author {
  font-size: 14px;
  font-weight: 600;
  color: var(--content-text);
}

.mention-item-time {
  font-size: 12px;
  color: var(--text-muted);
}

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

.mention-source-icon {
  font-size: 12px;
}

.mention-source-title {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-item-note {
  font-size: 14px;
  color: var(--content-text);
  line-height: 1.4;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* Actions */
.mention-item-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-shrink: 0;
}

.mention-action-btn {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.15s ease;
}

.mention-action-btn:hover {
  background: var(--hover-bg);
  border-color: var(--primary-color);
}

.mention-action-done:hover {
  background: rgba(16, 185, 129, 0.1);
  border-color: #10b981;
  color: #10b981;
}

.mention-completed-badge {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 4px 8px;
  background: rgba(16, 185, 129, 0.1);
  color: #10b981;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 500;
}

/* ========================================
   SIDEBAR TRIGGER BUTTON
   ======================================== */

.mentions-trigger {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  background: transparent;
  border: none;
  border-radius: 8px;
  cursor: pointer;
  color: var(--sidebar-text);
  font-size: 14px;
  transition: all 0.15s ease;
  width: 100%;
  text-align: left;
  position: relative;
}

.mentions-trigger:hover {
  background: var(--sidebar-hover);
}

.mentions-trigger-icon {
  font-size: 18px;
}

.mentions-trigger-badge {
  position: absolute;
  top: 4px;
  right: 8px;
  min-width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0 5px;
  background: #ef4444;
  color: white;
  font-size: 10px;
  font-weight: 600;
  border-radius: 9px;
}

/* ========================================
   MENTION NOTE CELL (in table view)
   ======================================== */

.mention-note-cell {
  max-width: 300px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.mention-note-cell .mention-tag {
  font-size: 12px;
  padding: 1px 4px;
}

/* Expanded note in modal */
.mention-note-expanded {
  white-space: pre-wrap;
  word-break: break-word;
}

/* ========================================
   FORM FIELD - MENTION TYPE
   ======================================== */

.dv-mention-field {
  width: 100%;
}

.dv-mention-field .mention-input-wrapper {
  width: 100%;
}

.dv-mention-field .mention-input {
  min-height: 100px;
}

/* ========================================
   DARK MODE ADJUSTMENTS
   ======================================== */

[data-theme="dark"] .mentions-panel {
  box-shadow: -4px 0 20px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .mention-dropdown {
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="dark"] .mention-item.unread {
  background: rgba(102, 126, 234, 0.1);
}

[data-theme="dark"] .mention-item.unread:hover {
  background: rgba(102, 126, 234, 0.15);
}

/* ========================================
   RESPONSIVE / MOBILE
   ======================================== */

@media (max-width: 768px) {
  .mentions-panel {
    width: 100%;
    right: -100%;
  }

  .mention-item {
    padding: 12px 16px;
  }

  .mention-item-avatar {
    width: 36px;
    height: 36px;
  }
}
