/* Clean, intuitive TOC editing styles
 * 
 * UX Design:
 * - Double-click to edit any TOC item
 * - Delete key or button to remove item
 * - + button to add sibling items, Ctrl+N to add child items
 * - Minimal, non-intrusive button UI with subtle hover effects
 * - Clean, natural interaction pattern for document outline editing
 */

/* Toolbar at the top of the TOC */
.tocToolbar {
  display: flex;
  gap: 4px;
  padding: 8px;
  border-bottom: 1px solid #e0e0e0;
  background-color: #f9f9f9;
  margin-bottom: 8px;
  flex-shrink: 0;
  position: sticky;
  top: 0;
  z-index: 100;
}

.outline-editing-mode .treeItem {
  display: flex;
  align-items: center;
  padding: 3px 0 3px 6px;
  border-left: 2px solid transparent;
  transition: all 0.15s ease;
  line-height: 1.4;
  overflow: hidden;
  pointer-events: auto;
  gap: 8px;
}

.outline-editing-mode .treeItem:hover {
  border-left-color: #2196f3;
  background-color: rgba(33, 150, 243, 0.1);
  border-radius: 2px;
}

.outline-editing-mode .treeItem.selected {
  border-left-color: #2196f3;
  background-color: rgba(33, 150, 243, 0.2);
  border-radius: 2px;
  font-weight: 500;
}

.outline-editing-mode .treeItem:focus-within {
  background-color: rgba(33, 150, 243, 0.05);
  border-left-color: #2196f3;
}

/* Inline edit input */
.treeItemEditInput {
  display: inline-block;
  min-width: 100px;
  padding: 4px 8px;
  border: 1px solid #2196f3;
  border-radius: 3px;
  font-size: 0.9em;
  font-family: inherit;
  background: transparent;
  outline: none;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
}

.treeItemEditInput:focus {
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

/* Page number display */
.treeItemPageNumber {
  display: inline-block;
  margin-left: auto;
  padding: 2px 6px;
  background-color: rgba(33, 150, 243, 0.1);
  color: #2196f3;
  border-radius: 3px;
  font-size: 0.75em;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.treeItemPageNumber:hover {
  background-color: rgba(33, 150, 243, 0.2);
  color: #1976d2;
}

/* Page number edit input */
.treeItemPageEditInput {
  display: inline-block;
  width: 60px;
  padding: 2px 4px;
  border: 1px solid #2196f3;
  border-radius: 3px;
  font-size: 0.75em;
  font-family: inherit;
  background: transparent;
  outline: none;
  box-shadow: 0 0 0 2px rgba(33, 150, 243, 0.1);
  text-align: center;
}

.treeItemPageEditInput:focus {
  box-shadow: 0 0 0 3px rgba(33, 150, 243, 0.2);
}

/* Tree item link text - with clipping */
.outline-editing-mode .treeItem a {
  display: inline-block;
  text-decoration: none;
  color: inherit;
  cursor: pointer;
  transition: all 0.15s ease;
  white-space: nowrap;
  overflow: hidden;
  flex: 1;
  min-width: 0;
}

.outline-editing-mode .treeItem a:hover {
  text-decoration: underline;
  color: #2196f3;
}

/* Control buttons toolbar - hidden since buttons are in top toolbar now */
.treeItemControls {
  display: none;
}

/* Empty state messaging */
.tocEmptyState {
  padding: 16px;
  text-align: center;
  color: #999;
  font-size: 0.9em;
  line-height: 1.4;
}

/* Add and Delete buttons */
.treeItemAddButton,
.treeItemDeleteButton {
  padding: 2px 6px;
  border: 1px solid #d0d0d0;
  background: white;
  border-radius: 3px;
  cursor: pointer;
  font-size: 1em;
  line-height: 1;
  min-width: 24px;
  height: 24px;
  transition: all 0.15s ease;
  color: #666;
  flex-shrink: 0;
}

.treeItemAddButton:hover {
  border-color: #4caf50;
  background-color: #f1f8e9;
  color: #4caf50;
}

.treeItemDeleteButton:hover {
  border-color: #f44336;
  background-color: #ffebee;
  color: #f44336;
}

.treeItemAddButton:active,
.treeItemDeleteButton:active {
  transform: scale(0.95);
}

/* Make tree items keyboard accessible */
.outline-editing-mode .treeItem {
  cursor: pointer;
  outline: none;
}

.outline-editing-mode .treeItem:focus {
  background-color: rgba(33, 150, 243, 0.08);
  border-left-color: #2196f3;
  border-radius: 2px;
}

/* Nested items styling - File system style tree structure */
.outline-editing-mode .treeItems {
  margin-left: 20px;
}

/* Index button styling */
.treeItemIndexButton {
  padding: 4px 10px;
  border: 1px solid #2196f3;
  background: white;
  border-radius: 3px;
  cursor: pointer;
  font-size: 0.75em;
  line-height: 1;
  min-width: 70px;
  height: 24px;
  transition: all 0.15s ease;
  color: #2196f3;
  flex-shrink: 0;
  font-weight: 500;
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  white-space: nowrap;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", sans-serif;
}

.treeItemIndexButton:hover:not(:disabled) {
  border-color: #1976d2;
  background-color: #e3f2fd;
  color: #1976d2;
}

.treeItemIndexButton:active:not(:disabled) {
  transform: scale(0.95);
}

.treeItemIndexButton:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  border-color: #ccc;
  color: #999;
}

/* Skeleton loading animation */
@keyframes shimmer {
  0% {
    background-position: -1000px 0;
  }
  100% {
    background-position: 1000px 0;
  }
}

.tocSkeletonLoading {
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.skeletonItem {
  display: flex;
  align-items: center;
  gap: 8px;
  animation: fadeIn 0.3s ease;
}

.skeletonLine {
  height: 16px;
  background: linear-gradient(
    90deg,
    #e0e0e0 0%,
    #f0f0f0 50%,
    #e0e0e0 100%
  );
  background-size: 1000px 100%;
  animation: shimmer 2s infinite;
  border-radius: 4px;
  flex: 1;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
