/* =========================================
   ANNOTATIONS - Аннотации на документах
   ========================================= */

/* Кликабельные аннотации - отключаем DnD, пропускаем события */
.annotation-link {
  text-decoration: none;
  color: inherit;
  display: inline-block;
  -webkit-user-drag: none;
  user-select: none;
  pointer-events: none;
}

.annotation-link.annotation-pin {
  display: block;
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
  z-index: 10;
}

.annotation-link.annotation-text {
  pointer-events: auto;
  cursor: pointer;
  display: block;
}

.annotation-text .text-wrapper {
  display: inline-block;
  min-width: 20px;
  min-height: 20px;
}

.annotation-text .text-content {
  display: inline-block;
  min-width: 10px;
  padding: 4px 8px;
}

.annotation-link.annotation-pin svg {
  display: block;
}

.annotation-svg {
  display: block;
}

.annotation-link svg {
  -webkit-user-drag: none;
}

.annotation-link rect.clickable-area,
.annotation-link ellipse.clickable-area,
.annotation-link line.clickable-area,
.annotation-link path.clickable-area {
  fill: none;
  pointer-events: stroke;
  cursor: pointer;
}

/* Hover эффекты отключены для избежания перемигивания SVG */
/* При необходимости можно добавить лёгкие эффекты без filter */

/* Слой аннотаций - pointer-events auto для корректного hover */
.annotations-layer {
  position: absolute;
  top: 0;
  left: 0;
  z-index: 15;
  transform-origin: 0 0;
  overflow: visible;
}

/* Pin wrapper */
.pin-wrapper {
  position: absolute;
  pointer-events: auto;
  z-index: 10;
  display: block;
  width: 20px;
  height: 32px;
}

.pin-wrapper .annotation-link {
  display: block;
  width: 20px;
  height: 32px;
}

.pin-wrapper svg {
  display: block;
  width: 20px;
  height: 32px;
}

/* Убран transition - вызывает перемигивание */

.annotations-layer .annotation {
  pointer-events: auto;
}

.annotations-layer svg {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
}

.annotations-layer .pin-marker,
.annotations-layer .text-annotation {
  pointer-events: auto;
  cursor: pointer;
}

.annotations-layer .text-annotation {
  background: rgba(255,255,255,0.9);
  padding: 4px 8px;
  border-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.15);
}

.pin-marker {
  font-size: 24px;
}

.text-content {
  background: white;
  padding: 4px 8px;
  border: 1px solid var(--cdr-border);
  border-radius: var(--cdr-border-radius);
  white-space: nowrap;
}

.arrow-marker {
  font-size: 20px;
}

/* Панель аннотаций - Telegram style */
.annotation-panel {
  position: fixed;
  right: 20px;
  top: 60px;
  width: 320px;
  max-height: calc(100vh - 80px);
  background: white;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 101;
  overflow: hidden;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }
  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.annotation-panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  background: linear-gradient(to bottom, #f0f0f0, #e8e8e8);
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.annotation-info {
  display: flex;
  align-items: center;
  gap: 8px;
}

.annotation-type {
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  color: #6c757d;
}

.annotation-id {
  font-size: 11px;
  font-family: monospace;
  color: #adb5bd;
  background: #f8f9fa;
  padding: 2px 6px;
  border-radius: 4px;
}

.close-panel {
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.05);
  color: #6c757d;
  font-size: 20px;
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
  border: none;
}

.close-panel:hover {
  background: rgba(0, 0, 0, 0.1);
  color: #dc3545;
}

/* Комментарии */
.comments-list {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.comment {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 12px;
  border-radius: 12px;
  background: white;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  max-width: 85%;
}

.comment[data-show-user="true"] {
  margin-top: 12px;
}

.comment[data-show-user="false"] {
  margin-top: 2px;
  padding-top: 4px;
  padding-bottom: 4px;
  border-radius: 8px;
}

.comment-user-name {
  font-size: 13px;
  font-weight: 600;
  color: #007bff;
  margin-bottom: 4px;
}

.comment-content {
  font-size: 14px;
  color: #212529;
  line-height: 1.4;
  white-space: pre-wrap;
}

.comment-time {
  font-size: 11px;
  color: #adb5bd;
  align-self: flex-end;
  margin-top: 2px;
}

.comment-form {
  padding: 12px 16px;
  background: #f8f9fa;
  border-top: 1px solid rgba(0, 0, 0, 0.1);
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.comment-form textarea {
  flex: 1;
  min-height: 60px;
  max-height: 120px;
  padding: 8px 12px;
  border: 1px solid rgba(0, 0, 0, 0.2);
  border-radius: 12px;
  font-size: 14px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  resize: vertical;
  background: white;
  color: #212529;
  outline: none;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.comment-form textarea:focus {
  border-color: #007bff;
  box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1);
}

.comment-form textarea::placeholder {
  color: #adb5bd;
}

.send-button {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: #007bff;
  color: white;
  font-size: 18px;
  cursor: pointer;
  transition: all 0.2s;
  box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
  flex-shrink: 0;
}

.send-button:hover {
  background: #0056b3;
  transform: scale(1.05);
  box-shadow: 0 4px 12px rgba(0, 123, 255, 0.4);
}

.send-button:active {
  transform: scale(0.95);
}

/* Canvas для рисования аннотаций */
.draw-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 20;
  cursor: crosshair;
  touch-action: none;
  pointer-events: none;
}

.draw-canvas.drawing {
  pointer-events: auto;
}

.annotation {
  position: absolute;
  pointer-events: auto;
  cursor: pointer;
}