/**
 * Document Mention Chip + Detail Modal
 */

.doc-mention {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 2px 6px 2px 8px;
  margin: 0 2px;
  background: #eef2ff;
  border: 1px solid #c7d2fe;
  border-radius: 999px;
  font-size: 0.95em;
  color: #3730a3;
  white-space: nowrap;
  vertical-align: baseline;
}

.doc-mention-icon {
  font-size: 1em;
  line-height: 1;
}

.doc-mention-text {
  font-weight: 500;
}

.doc-mention-btn {
  border: none;
  background: #4f46e5;
  color: #fff;
  font-size: 0.78em;
  font-weight: 600;
  padding: 2px 9px;
  border-radius: 999px;
  cursor: pointer;
  transition: background-color 0.15s, transform 0.1s;
  margin-left: 2px;
}

.doc-mention-btn:hover {
  background: #4338ca;
}

.doc-mention-btn:active {
  transform: translateY(1px);
}

/* Modal */

.doc-modal {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9999;
  background: rgba(15, 23, 42, 0.55);
  align-items: center;
  justify-content: center;
  padding: 24px;
  animation: docModalFadeIn 0.15s ease-out;
}

.doc-modal.show {
  display: flex;
}

@keyframes docModalFadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

.doc-modal-content {
  background: #fff;
  width: min(720px, 100%);
  max-height: 85vh;
  border-radius: 16px;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
  animation: docModalSlideIn 0.2s ease-out;
}

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

.doc-modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: #fff;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  font-size: 22px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s;
}

.doc-modal-close:hover {
  background: rgba(255, 255, 255, 0.4);
}

.doc-modal-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: #fff;
  padding: 22px 24px 18px;
}

.doc-modal-icon {
  font-size: 28px;
  margin-bottom: 4px;
  display: block;
}

.doc-modal-title {
  margin: 0 0 8px;
  font-size: 19px;
  font-weight: 700;
  word-break: break-word;
  padding-right: 40px;
}

.doc-modal-query {
  font-size: 12px;
  opacity: 0.85;
  font-style: italic;
}

.doc-modal-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 16px;
  padding: 12px 24px;
  background: #f8fafc;
  border-bottom: 1px solid #e5e7eb;
  font-size: 12.5px;
  color: #475569;
}

.doc-modal-meta:empty {
  display: none;
}

.doc-meta-item {
  white-space: nowrap;
}

.doc-meta-item strong {
  color: #1f2937;
  margin-right: 3px;
}

.doc-modal-body {
  padding: 18px 24px;
  overflow-y: auto;
  flex: 1;
  min-height: 80px;
  font-size: 14px;
  line-height: 1.55;
  color: #1f2937;
}

.doc-modal-loading,
.doc-modal-empty,
.doc-modal-error {
  text-align: center;
  padding: 40px 20px;
  color: #64748b;
}

.doc-modal-error {
  color: #b91c1c;
}

.doc-modal-snippets-header {
  font-size: 13px;
  font-weight: 600;
  color: #475569;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.doc-snippet {
  display: flex;
  gap: 12px;
  padding: 12px 14px;
  margin-bottom: 10px;
  background: #f8fafc;
  border-left: 3px solid #6366f1;
  border-radius: 6px;
}

.doc-snippet:last-child {
  margin-bottom: 0;
}

.doc-snippet-num {
  font-weight: 700;
  color: #6366f1;
  font-size: 13px;
  flex-shrink: 0;
  min-width: 24px;
}

.doc-snippet-text {
  flex: 1;
  word-break: break-word;
}

.doc-modal-footer {
  padding: 12px 24px 16px;
  border-top: 1px solid #e5e7eb;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: #f8fafc;
}

.doc-modal-close-btn {
  background: #6366f1;
  color: #fff;
  border: none;
  padding: 8px 18px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: background-color 0.15s;
}

.doc-modal-close-btn:hover {
  background: #4f46e5;
}

@media (max-width: 600px) {
  .doc-modal {
    padding: 12px;
  }
  .doc-modal-content {
    max-height: 90vh;
  }
  .doc-modal-header,
  .doc-modal-meta,
  .doc-modal-body,
  .doc-modal-footer {
    padding-left: 16px;
    padding-right: 16px;
  }
  .doc-mention {
    flex-wrap: wrap;
  }
}
