/* Sticky note styles */
.sticky-note {
  position: absolute;
  background: #ffeb3b;
  border: 1px solid rgba(0,0,0,0.1);
  border-radius: 8px;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  min-width: var(--note-min-w);
  min-height: var(--note-min-h);
  cursor: default;
  transition: box-shadow 0.2s ease, transform 0.1s ease;
  overflow: hidden;
  resize: both;
  font-family: 'Courier New', monospace;
  z-index: 1;
  display: flex;
  flex-direction: column;
}

.sticky-note:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 2;
}

.sticky-note.selected {
  border: 2px solid #333;
  box-shadow: 0 4px 16px rgba(0,0,0,0.3);
  z-index: 3;
}

.sticky-note.dragging {
  opacity: 0.7;
  z-index: 10;
  cursor: grabbing;
}

/* Note header */
.note-header {
  position: relative;
  background: rgba(0,0,0,0.05);
  border-bottom: 1px solid rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  cursor: move;
  flex: 0 0 auto;
  min-height: 36px;
  flex-wrap: nowrap;
  overflow: visible;
}

.note-controls {
  display: flex;
  gap: 4px;
  opacity: 0;
  transition: opacity 0.2s ease;
}

.sticky-note:hover .note-controls {
  opacity: 1;
}

.note-btn {
  width: 16px;
  height: 16px;
  border: none;
  background: rgba(0,0,0,0.6);
  color: white;
  border-radius: 2px;
  cursor: pointer;
  font-size: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.note-btn:hover {
  background: rgba(0,0,0,0.8);
}

.note-btn.color-btn {
  background: linear-gradient(45deg, #ff0000, #00ff00, #0000ff);
}

.note-btn.delete-btn {
  background: #f44336;
}

.note-btn.delete-btn:hover {
  background: #d32f2f;
}

/* Note content area */
.note-content {
  flex: 1 1 auto;
  display: flex;
  flex-direction: column;
  position: relative;
  min-height: 0;
}

/* Text editor toolbar */
.editor-toolbar {
  display: inline-flex;
  gap: 6px;
  flex-wrap: nowrap;
  align-items: center;
  opacity: 0;
  transition: opacity 0.2s ease;
  pointer-events: auto;
}

.sticky-note:hover .editor-toolbar,
.sticky-note.editing .editor-toolbar {
  opacity: 1;
}

.toolbar-btn {
  width: 20px;
  height: 20px;
  border: none;
  background: transparent;
  color: var(--secondary-color);
  border-radius: 2px;
  cursor: pointer;
  font-size: 10px;
  font-weight: bold;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.toolbar-btn:hover {
  background: rgba(0,0,0,0.1);
  color: var(--primary-color);
}

.toolbar-btn.active {
  background: var(--primary-color);
  color: white;
}

.size-select {
  font-size: 12px;
  padding: 2px 6px;
  height: 22px;
  line-height: 18px;
  border: 1px solid rgba(0,0,0,0.2);
  border-radius: 2px;
  background: white;
  font-family: inherit;
}

/* Text content area */
.note-text {
  flex: 1;
  padding: 12px;
  border: none;
  outline: none;
  background: transparent;
  font-family: 'Courier New', monospace;
  font-size: 12px;
  line-height: 1.4;
  overflow-y: auto;
  color: rgba(0,0,0,0.8);
  word-wrap: break-word;
  white-space: pre-wrap;
  user-select: text;
  cursor: text;
}

.note-text:focus {
  color: rgba(0,0,0,0.9);
}

/* Contenteditable placeholder support */
.note-text:empty:before {
  content: attr(data-placeholder);
  color: rgba(0,0,0,0.4);
  font-style: italic;
  pointer-events: none;
}

/* Ensure formatting elements are properly styled */
.note-text b, .note-text strong {
  font-weight: bold;
}

.note-text i, .note-text em {
  font-style: italic;
}

.note-text u {
  text-decoration: underline;
}

/* Image container */
.note-image {
  margin: 8px 12px;
  max-width: calc(100% - 24px);
  max-height: 120px;
  object-fit: contain;
  border-radius: 4px;
  cursor: pointer;
  position: relative;
}

.image-container {
  position: relative;
  display: inline-block;
  margin: 8px 12px;
}

.image-remove {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 16px;
  height: 16px;
  background: #f44336;
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  font-size: 10px;
  display: none;
  align-items: center;
  justify-content: center;
}

.image-container:hover .image-remove {
  display: flex;
}

/* Drop zone styling */
.note-content.drag-over {
  background: rgba(33, 150, 243, 0.1);
  border: 2px dashed #2196f3;
}

/* Resize handle */
.sticky-note::after {
  content: '';
  position: absolute;
  bottom: 0;
  right: 0;
  width: 12px;
  height: 12px;
  background: linear-gradient(-45deg, transparent 0%, transparent 40%, rgba(0,0,0,0.3) 50%, transparent 60%, transparent 100%);
  cursor: se-resize;
  pointer-events: none;
}

/* Color variants */
.sticky-note.color-yellow { background: #ffeb3b; }
.sticky-note.color-orange { background: #ff9800; }
.sticky-note.color-red { background: #f44336; color: white; }
.sticky-note.color-pink { background: #e91e63; color: white; }
.sticky-note.color-purple { background: #9c27b0; color: white; }
.sticky-note.color-indigo { background: #673ab7; color: white; }
.sticky-note.color-blue { background: #3f51b5; color: white; }
.sticky-note.color-lightblue { background: #2196f3; color: white; }
.sticky-note.color-cyan { background: #03a9f4; color: white; }
.sticky-note.color-teal { background: #00bcd4; color: white; }
.sticky-note.color-green { background: #009688; color: white; }
.sticky-note.color-lightgreen { background: #4caf50; color: white; }
.sticky-note.color-lime { background: #8bc34a; }
.sticky-note.color-amber { background: #cddc39; }
.sticky-note.color-bluegray { background: #607d8b; color: white; }
.sticky-note.color-gray { background: #9e9e9e; color: white; }

/* Custom color support */
.sticky-note.color-custom { 
  background: var(--custom-bg-color, #ffeb3b); 
  color: var(--custom-text-color, rgba(0,0,0,0.8));
}

.sticky-note.color-custom .note-text {
  color: var(--custom-text-color, rgba(0,0,0,0.8));
}

.sticky-note.color-custom .note-text:focus {
  color: var(--custom-text-color, rgba(0,0,0,0.9));
}

.sticky-note.color-custom .note-text::placeholder {
  color: var(--custom-text-color, rgba(0,0,0,0.4));
  opacity: 0.6;
}

/* Dark text for light colors */
.sticky-note.color-yellow .note-text,
.sticky-note.color-orange .note-text,
.sticky-note.color-lime .note-text,
.sticky-note.color-amber .note-text {
  color: rgba(0,0,0,0.8);
}

.sticky-note.color-yellow .note-text:focus,
.sticky-note.color-orange .note-text:focus,
.sticky-note.color-lime .note-text:focus,
.sticky-note.color-amber .note-text:focus {
  color: rgba(0,0,0,0.9);
}

.sticky-note.color-yellow .note-text::placeholder,
.sticky-note.color-orange .note-text::placeholder,
.sticky-note.color-lime .note-text::placeholder,
.sticky-note.color-amber .note-text::placeholder {
  color: rgba(0,0,0,0.4);
}

/* Light text for dark colors */
.sticky-note.color-red .note-text,
.sticky-note.color-pink .note-text,
.sticky-note.color-purple .note-text,
.sticky-note.color-indigo .note-text,
.sticky-note.color-blue .note-text,
.sticky-note.color-lightblue .note-text,
.sticky-note.color-cyan .note-text,
.sticky-note.color-teal .note-text,
.sticky-note.color-green .note-text,
.sticky-note.color-lightgreen .note-text,
.sticky-note.color-bluegray .note-text,
.sticky-note.color-gray .note-text {
  color: rgba(255,255,255,0.9);
}

.sticky-note.color-red .note-text:focus,
.sticky-note.color-pink .note-text:focus,
.sticky-note.color-purple .note-text:focus,
.sticky-note.color-indigo .note-text:focus,
.sticky-note.color-blue .note-text:focus,
.sticky-note.color-lightblue .note-text:focus,
.sticky-note.color-cyan .note-text:focus,
.sticky-note.color-teal .note-text:focus,
.sticky-note.color-green .note-text:focus,
.sticky-note.color-lightgreen .note-text:focus,
.sticky-note.color-bluegray .note-text:focus,
.sticky-note.color-gray .note-text:focus {
  color: rgba(255,255,255,1);
}

.sticky-note.color-red .note-text::placeholder,
.sticky-note.color-pink .note-text::placeholder,
.sticky-note.color-purple .note-text::placeholder,
.sticky-note.color-indigo .note-text::placeholder,
.sticky-note.color-blue .note-text::placeholder,
.sticky-note.color-lightblue .note-text::placeholder,
.sticky-note.color-cyan .note-text::placeholder,
.sticky-note.color-teal .note-text::placeholder,
.sticky-note.color-green .note-text::placeholder,
.sticky-note.color-lightgreen .note-text::placeholder,
.sticky-note.color-bluegray .note-text::placeholder,
.sticky-note.color-gray .note-text::placeholder {
  color: rgba(255,255,255,0.5);
}

/* Text formatting */
.note-text b, .note-text strong {
  font-weight: bold;
}

.note-text i, .note-text em {
  font-style: italic;
}

.note-text u {
  text-decoration: underline;
}

/* Font sizes */
.note-text.size-small { font-size: 10px; }
.note-text.size-medium { font-size: 12px; }
.note-text.size-large { font-size: 14px; }
.note-text.size-xlarge { font-size: 16px; }

/* Selection rectangle for multi-select */
.selection-rectangle {
  position: absolute;
  border: 2px dashed #333;
  background: rgba(51, 51, 51, 0.1);
  pointer-events: none;
  z-index: 100;
}

/* Animation for new notes */
@keyframes noteAppear {
  from {
    opacity: 0;
    transform: scale(0.8) rotate(-5deg);
  }
  to {
    opacity: 1;
    transform: scale(1) rotate(0deg);
  }
}

.sticky-note.new-note {
  animation: noteAppear 0.3s ease-out;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .sticky-note {
    min-width: 140px;
    min-height: 100px;
    max-width: 300px;
    max-height: 250px;
  }
  
  .note-text {
    font-size: 11px;
    padding: 8px;
  }
  
  .editor-toolbar {
    padding: 2px 6px;
  }
  
  .toolbar-btn {
    width: 18px;
    height: 18px;
    font-size: 9px;
  }
  
  .note-btn {
    width: 14px;
    height: 14px;
    font-size: 9px;
  }
}
