/* Whiteboard Styles */
.whiteboard-view {
  display: flex;
  flex-direction: column;
  min-height: calc(100vh - 80px);
  background: #f8fafc;
}

.whiteboard-header {
  background: white;
  padding: 15px 20px;
  border-bottom: 2px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
}

.whiteboard-toolbar {
  background: #f8fafc;
  padding: 8px 20px;
  border-bottom: 1px solid #e5e7eb;
  display: flex;
  align-items: center;
  gap: 8px;
  flex-shrink: 0;
}

.whiteboard-header h2 {
  margin: 0;
  font-size: 20px;
  color: #1e293b;
}

.whiteboard-selector {
  font-size: 14px;
}

.whiteboard-controls {
  display: flex;
  gap: 8px;
  flex-wrap: nowrap;
}

.whiteboard-tool-btn {
  padding: 8px;
  width: 36px;
  height: 36px;
  border: 1px solid #d1d5db;
  border-radius: 6px;
  cursor: pointer;
  font-size: 18px;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.whiteboard-tool-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.whiteboard-tool-btn.active {
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.whiteboard-canvas {
  flex: 1;
  position: relative;
  overflow: hidden;
  background: white;
  cursor: default;
}

.whiteboard-canvas:active {
  cursor: grabbing;
}

.postit-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 5000px;
  height: 5000px;
  /* Avoid CSS transition for transform during interactive pan/zoom; use RAF-driven updates for smoothness */
  transition: none;
  will-change: transform;
  z-index: 100;
}

.postit-container.drop-target-active {
  outline: 3px dashed rgba(59, 130, 246, 0.6);
  box-shadow: 0 12px 30px rgba(99, 102, 241, 0.12);
}

.whiteboard-canvas.drop-target-active {
  outline: 3px dashed rgba(59, 130, 246, 0.6);
}

#whiteboardDropOverlay {
  transition: opacity 150ms ease-in-out;
  opacity: 1;
}

#drawingCanvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 5000px;
  height: 5000px;
  z-index: 1;
}

/* Eraser mode cursor for DOM elements */
#postItContainer.eraser-mode .postit,
#postItContainer.eraser-mode .whiteboard-image,
#postItContainer.eraser-mode .whiteboard-document,
#postItContainer.eraser-mode .project-pin {
  cursor: crosshair !important;
}

#postItContainer.eraser-mode .postit:hover,
#postItContainer.eraser-mode .whiteboard-image:hover,
#postItContainer.eraser-mode .whiteboard-document:hover,
#postItContainer.eraser-mode .project-pin:hover {
  opacity: 0.6;
  outline: 2px solid #ef4444;
}

.postit {
  position: absolute;
  width: 200px;
  min-height: 150px;
  background: #fef08a;
  border: 1px solid #fde047;
  border-radius: 4px;
  padding: 12px;
  cursor: move;
  box-shadow: 2px 2px 8px rgba(0, 0, 0, 0.1);
  transition: box-shadow 0.2s;
  z-index: 100; /* Higher than canvas */
}

/* Blink animation for newly created post-its */
@keyframes postit-blink {
  0% { opacity: 1; }
  50% { opacity: 0.15; }
  100% { opacity: 1; }
}
.postit-blink {
  animation: postit-blink 0.3s linear 3;
}

.postit:hover {
  box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.2);
}

.postit.dragging {
  opacity: 0.8;
  cursor: grabbing;
  z-index: 1000;
}

.postit-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  padding-bottom: 6px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
}

.postit-color-picker {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  border: 2px solid white;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
}

.postit-delete {
  background: none;
  border: none;
  font-size: 18px;
  cursor: pointer;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background 0.2s;
}

.postit-delete:hover {
  background: rgba(0, 0, 0, 0.1);
}

.postit-content {
  width: 100%;
  min-height: 80px;
  border: none;
  background: transparent;
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  font-size: 14px;
  resize: none;
  outline: none;
}

.postit-resize-handle {
  position: absolute;
  bottom: 2px;
  right: 2px;
  width: 16px;
  height: 16px;
  cursor: nwse-resize;
  font-size: 14px;
  color: rgba(0, 0, 0, 0.3);
  user-select: none;
  display: flex;
  align-items: center;
  justify-content: center;
}

.postit-resize-handle:hover {
  color: rgba(0, 0, 0, 0.6);
}

.postit.yellow {
  background: #fef08a;
  border-color: #fde047;
}

.postit.pink {
  background: #fbcfe8;
  border-color: #f9a8d4;
}

.postit.blue {
  background: #bfdbfe;
  border-color: #93c5fd;
}

.postit.green {
  background: #bbf7d0;
  border-color: #86efac;
}

.postit.orange {
  background: #fed7aa;
  border-color: #fdba74;
}

.task-link-postit {
  background: #dbeafe;
  border: 2px solid #3b82f6;
  cursor: pointer;
}

.task-link-postit:hover {
  background: #bfdbfe;
  transform: scale(1.02);
}

.task-link-header {
  background: #3b82f6;
  color: white;
  padding: 8px;
  margin: -12px -12px 8px -12px;
  border-radius: 4px 4px 0 0;
  font-weight: 600;
  font-size: 12px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.task-link-content {
  padding: 8px 0;
}

.task-link-title {
  font-weight: 600;
  margin-bottom: 8px;
  color: #1e293b;
}

.task-link-meta {
  font-size: 12px;
  color: #64748b;
  display: flex;
  flex-direction: column;
  gap: 4px;
}

/* Drawing Canvas */
#drawingCanvas {
  cursor: crosshair;
}

#drawingCanvas.eraser-mode {
  cursor: not-allowed;
}

/* Document thumbnails on whiteboard */
.whiteboard-document {
  position: absolute;
  background: white;
  border: 2px solid transparent; /* Gör hitboxen för drag & drop stabil men ingen synlig ram */
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  padding: 10px;
  cursor: move;
  transition: box-shadow 0.2s, transform 0.2s;
  user-select: none;
  z-index: 100;
}

.whiteboard-document:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
  transform: translateY(-2px);
}

.whiteboard-document.dragging {
  opacity: 0.8;
  cursor: grabbing;
  z-index: 1000;
}

.whiteboard-image {
  position: absolute;
  cursor: move;
  z-index: 100;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  border-radius: 4px;
}

.whiteboard-image:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.25);
}

.whiteboard-image.dragging {
  opacity: 0.8;
  cursor: grabbing;
  z-index: 1000;
}

/* Responsive */
@media (max-width: 768px) {
  .whiteboard-header {
    padding: 10px !important;
    min-height: auto !important;
    gap: 8px !important;
  }
  
  .whiteboard-header h2 {
    font-size: 18px;
  }
  
  /* Toolbar wrapping for mobile */
  .whiteboard-header > div[style*="flex-wrap: nowrap"] {
    flex-wrap: wrap !important;
    gap: 6px !important;
  }
  
  /* Selector responsive width */
  .whiteboard-selector {
    width: 100% !important;
    max-width: 100% !important;
    min-width: 120px !important;
  }
  
  /* Tool buttons smaller on mobile */
  .whiteboard-tool-btn {
    width: 32px !important;
    height: 32px !important;
    min-width: 32px !important;
    font-size: 16px !important;
    padding: 4px !important;
  }
  
  /* Drawing settings compact */
  #drawingSettings {
    width: 100%;
    flex-wrap: wrap !important;
    height: auto !important;
    padding: 8px !important;
  }
  
  #drawingSettings label {
    font-size: 11px !important;
  }
  
  #drawingSettings select,
  #drawingSettings input[type="color"] {
    font-size: 12px !important;
  }
  
  /* Zoom controls - move to new row */
  .whiteboard-header div[style*="margin-left: auto"] {
    margin-left: 0 !important;
    width: 100% !important;
    padding-left: 0 !important;
    border-left: none !important;
    border-top: 1px solid #ddd !important;
    padding-top: 8px !important;
    justify-content: center !important;
  }
  
  #whiteboardZoomLevel {
    font-size: 12px !important;
    min-width: 40px !important;
  }
  
  /* Post-its smaller on mobile */
  .postit {
    width: 140px;
    min-height: 110px;
    font-size: 13px;
  }
  
  .postit-header {
    padding: 4px;
  }
  
  .postit-content {
    font-size: 13px;
    padding: 6px;
  }
  
  /* Documents smaller */
  .whiteboard-document {
    max-width: 100px;
    font-size: 11px;
  }
  
  /* Images smaller */
  .whiteboard-image img {
    max-width: 150px !important;
  }
  
  /* Canvas touch-friendly */
  .whiteboard-canvas {
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
  }
}

