/* AnnotationPanel.css — Shared component for annotations + cross-references */

.ann-panel {
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: var(--radius-md, 8px);
  background: var(--gray-50, #f9fafb);
  font-size: 0.85rem;
}

.ann-tabs {
  display: flex;
  border-bottom: 1px solid var(--gray-200, #e5e7eb);
}

.ann-tab {
  flex: 1;
  padding: 0.5rem 0.75rem;
  background: none;
  border: none;
  font-size: 0.8rem;
  font-weight: 500;
  color: var(--gray-500, #6b7280);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: all 0.15s;
}

.ann-tab:hover {
  color: var(--gray-700, #374151);
  background: var(--gray-100, #f3f4f6);
}

.ann-tab.active {
  color: var(--primary, #3b82f6);
  border-bottom-color: var(--primary, #3b82f6);
  font-weight: 600;
}

.ann-tab .ann-tab-count {
  display: inline-block;
  min-width: 1.2em;
  padding: 0 0.3em;
  font-size: 0.7rem;
  font-weight: 600;
  border-radius: 999px;
  text-align: center;
  background: var(--gray-200, #e5e7eb);
  color: var(--gray-600, #4b5563);
  margin-left: 0.3rem;
}

.ann-tab.active .ann-tab-count {
  background: var(--primary, #3b82f6);
  color: white;
}

.ann-body {
  padding: 0.75rem;
  max-height: 300px;
  overflow-y: auto;
}

/* Annotation items */
.ann-item {
  background: white;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: var(--radius-sm, 6px);
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.5rem;
}

.ann-item:last-child { margin-bottom: 0; }

.ann-item-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.25rem;
}

.ann-item-meta {
  font-size: 0.7rem;
  color: var(--gray-400, #9ca3af);
}

.ann-item-delete {
  background: none;
  border: none;
  color: var(--gray-400, #9ca3af);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  line-height: 1;
}

.ann-item-delete:hover {
  color: var(--danger, #ef4444);
}

.ann-item-content {
  color: var(--gray-700, #374151);
  line-height: 1.4;
  white-space: pre-wrap;
  word-break: break-word;
}

/* Cross-reference items */
.ann-xref {
  background: white;
  border: 1px solid var(--gray-200, #e5e7eb);
  border-radius: var(--radius-sm, 6px);
  padding: 0.5rem 0.65rem;
  margin-bottom: 0.5rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.ann-xref:last-child { margin-bottom: 0; }

.ann-xref-icon {
  font-size: 1rem;
  flex-shrink: 0;
}

.ann-xref-info {
  flex: 1;
  min-width: 0;
}

.ann-xref-target {
  font-weight: 600;
  color: var(--primary, #3b82f6);
  cursor: pointer;
  overflow-wrap: anywhere;       /* UUID-er skal aldri flyte ut av panelet */
}

.ann-xref-target:hover { text-decoration: underline; }

.ann-xref-title {
  font-weight: 400;
  color: var(--text, #1f2937);
  overflow-wrap: anywhere;
}

.ann-xref-desc {
  font-size: 0.75rem;
  color: var(--gray-500, #6b7280);
  margin-top: 0.1rem;
}

.ann-xref-meta {
  font-size: 0.65rem;
  color: var(--gray-400, #9ca3af);
}

.ann-xref-delete {
  background: none;
  border: none;
  color: var(--gray-400, #9ca3af);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
  line-height: 1;
  flex-shrink: 0;
}

.ann-xref-delete:hover { color: var(--danger, #ef4444); }

/* Input area */
.ann-input-area {
  border-top: 1px solid var(--gray-200, #e5e7eb);
  padding: 0.65rem 0.75rem;
}

.ann-input-row {
  display: flex;
  gap: 0.4rem;
  align-items: flex-end;
}

.ann-textarea {
  flex: 1;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: var(--radius-sm, 6px);
  font-size: 0.8rem;
  font-family: inherit;
  resize: vertical;
  min-height: 2rem;
  max-height: 6rem;
  line-height: 1.4;
}

.ann-textarea:focus {
  outline: none;
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.ann-btn {
  padding: 0.4rem 0.75rem;
  border: none;
  border-radius: var(--radius-sm, 6px);
  font-size: 0.75rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.ann-btn-add {
  background: var(--primary, #3b82f6);
  color: white;
}

.ann-btn-add:hover { opacity: 0.9; }
.ann-btn-add:disabled { opacity: 0.5; cursor: not-allowed; }

/* Cross-ref input */
.ann-xref-input {
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}

.ann-xref-type-row {
  display: flex;
  gap: 0.4rem;
}

.ann-xref-type-btn {
  padding: 0.25rem 0.5rem;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: var(--radius-sm, 6px);
  background: white;
  font-size: 0.75rem;
  cursor: pointer;
  transition: all 0.15s;
}

.ann-xref-type-btn.active {
  background: var(--primary, #3b82f6);
  color: white;
  border-color: var(--primary, #3b82f6);
}

.ann-xref-ta-wrap {
  position: relative;
}

.ann-xref-ta-input {
  width: 100%;
  padding: 0.4rem 0.5rem;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: var(--radius-sm, 6px);
  font-size: 0.8rem;
  font-family: inherit;
}

.ann-xref-ta-input:focus {
  outline: none;
  border-color: var(--primary, #3b82f6);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.15);
}

.ann-xref-ta-list {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 150px;
  overflow-y: auto;
  background: white;
  border: 1px solid var(--gray-300, #d1d5db);
  border-radius: var(--radius-sm, 6px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.1);
  z-index: 100;
}

.ann-xref-ta-list.show { display: block; }

.ann-xref-ta-item {
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.8rem;
  border-bottom: 1px solid var(--gray-100, #f3f4f6);
}

.ann-xref-ta-item:hover { background: var(--gray-50, #f9fafb); }
.ann-xref-ta-item:last-child { border-bottom: none; }

.ann-xref-ta-item strong {
  font-family: monospace;
  color: var(--primary, #3b82f6);
}

.ann-xref-ta-item .ann-xref-ta-sub {
  font-size: 0.7rem;
  color: var(--gray-400, #9ca3af);
}

.ann-xref-selected {
  display: flex;
  align-items: center;
  flex-wrap: wrap;               /* lange titler/id-er bryter i stedet for aa flyte ut */
  gap: 0.3rem;
  padding: 0.25rem 0.5rem;
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm, 6px);
  font-size: 0.8rem;
  min-width: 0;
  overflow-wrap: anywhere;
}
.ann-xref-selected-title {
  flex: 1 1 auto;
  min-width: 0;
  overflow-wrap: anywhere;
}

.ann-xref-selected-clear {
  background: none;
  border: none;
  color: var(--gray-400, #9ca3af);
  cursor: pointer;
  font-size: 0.9rem;
  padding: 0;
}

.ann-empty {
  text-align: center;
  color: var(--gray-400, #9ca3af);
  padding: 1rem;
  font-size: 0.8rem;
}

.ann-loading {
  text-align: center;
  color: var(--gray-400, #9ca3af);
  padding: 1rem;
  font-size: 0.8rem;
}

/* Dark theme overrides (for Dolphin) */
.ann-panel.ann-dark {
  background: rgba(26, 26, 46, 0.6);
  border-color: rgba(139, 92, 246, 0.2);
}

.ann-dark .ann-tabs { border-bottom-color: rgba(139, 92, 246, 0.2); }
.ann-dark .ann-tab { color: #9ca3af; }
.ann-dark .ann-tab:hover { color: #e5e7eb; background: rgba(255,255,255,0.05); }
.ann-dark .ann-tab.active { color: #c4b5fd; border-bottom-color: #8b5cf6; }
.ann-dark .ann-tab .ann-tab-count { background: rgba(139,92,246,0.3); color: #e5e7eb; }
.ann-dark .ann-tab.active .ann-tab-count { background: #8b5cf6; color: white; }

.ann-dark .ann-item { background: rgba(26,26,46,0.8); border-color: rgba(139,92,246,0.15); }
.ann-dark .ann-item-content { color: #e5e7eb; }
.ann-dark .ann-item-meta { color: #6b7280; }

.ann-dark .ann-xref { background: rgba(26,26,46,0.8); border-color: rgba(139,92,246,0.15); }
.ann-dark .ann-xref-target { color: #c4b5fd; }
.ann-dark .ann-xref-desc { color: #9ca3af; }

.ann-dark .ann-input-area { border-top-color: rgba(139,92,246,0.2); }
.ann-dark .ann-textarea { background: rgba(0,0,0,0.3); border-color: rgba(139,92,246,0.3); color: #e5e7eb; }
.ann-dark .ann-textarea:focus { border-color: #8b5cf6; box-shadow: 0 0 0 2px rgba(139,92,246,0.2); }
.ann-dark .ann-xref-ta-input { background: rgba(0,0,0,0.3); border-color: rgba(139,92,246,0.3); color: #e5e7eb; }
.ann-dark .ann-xref-ta-list { background: #1a1a2e; border-color: rgba(139,92,246,0.3); }
.ann-dark .ann-xref-ta-item:hover { background: rgba(139,92,246,0.1); }
.ann-dark .ann-xref-selected { background: rgba(139,92,246,0.15); border-color: rgba(139,92,246,0.3); color: #e5e7eb; }
.ann-dark .ann-xref-type-btn { background: rgba(0,0,0,0.3); border-color: rgba(139,92,246,0.3); color: #e5e7eb; }
.ann-dark .ann-xref-type-btn.active { background: #8b5cf6; border-color: #8b5cf6; }
.ann-dark .ann-btn-add { background: #8b5cf6; }
.ann-dark .ann-empty { color: #6b7280; }
