/* =============================================================================
   Outliner Styles - Logseq-inspired hierarchical block editor
   ============================================================================= */

/* =============================================================================
   Outliner Widget Container
   ============================================================================= */

.outliner-widget {
  display: flex;
  flex-direction: column;
  height: 100%;
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.05));
  border-radius: 8px;
  overflow: hidden;
}

.outliner-page {
  display: flex;
  height: 100vh;
  background: var(--nm-bg, #1a1a2e);
}

.outliner-sidebar {
  width: 240px;
  border-right: 1px solid var(--nm-border, rgba(255, 255, 255, 0.1));
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.03));
  overflow-y: auto;
}

.outliner-main {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
}

/* =============================================================================
   Outliner Header
   ============================================================================= */

.outliner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 16px;
  border-bottom: 1px solid var(--nm-border, rgba(255, 255, 255, 0.1));
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.03));
}

.outliner-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: var(--nm-text, #e0e0e0);
  margin: 0;
  cursor: pointer;
}

.outliner-title:hover {
  color: var(--nm-text-bright, #fff);
}

.outliner-title-input {
  font-size: 1.1rem;
  font-weight: 600;
  background: var(--nm-input-bg, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--nm-primary, #6366f1);
  border-radius: 4px;
  padding: 4px 8px;
  color: var(--nm-text, #e0e0e0);
  outline: none;
}

.outliner-actions {
  display: flex;
  gap: 8px;
}

.outliner-actions button {
  background: transparent;
  border: none;
  color: var(--nm-text-muted, #888);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.2s;
}

.outliner-actions button:hover {
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.1));
  color: var(--nm-text, #e0e0e0);
}

/* =============================================================================
   Outliner Content
   ============================================================================= */

.outliner-content {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* =============================================================================
   Block Component
   ============================================================================= */

.outline-block {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  padding: 2px 8px;
  margin: 1px 0;
  border-radius: 4px;
  transition: background 0.15s;
}

.outline-block:hover {
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.03));
}

.outline-block.selected {
  background: var(--nm-primary-alpha, rgba(99, 102, 241, 0.15));
}

.outline-block.dragging {
  opacity: 0.5;
}

.outline-block.drag-over {
  border-top: 2px solid var(--nm-primary, #6366f1);
}

/* =============================================================================
   Block Bullet
   ============================================================================= */

.block-bullet {
  display: flex;
  align-items: center;
  min-width: 28px;
  height: 24px;
  flex-shrink: 0;
}

.bullet-spacer {
  width: 16px;
}

.bullet {
  color: var(--nm-text-muted, #666);
  font-size: 10px;
  margin-left: 4px;
}

.collapse-toggle {
  background: none;
  border: none;
  color: var(--nm-text-muted, #666);
  cursor: pointer;
  padding: 2px;
  font-size: 10px;
  line-height: 1;
  border-radius: 2px;
  transition: all 0.15s;
}

.collapse-toggle:hover {
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.1));
  color: var(--nm-text, #e0e0e0);
}

/* =============================================================================
   Block Content
   ============================================================================= */

.block-content {
  flex: 1;
  min-height: 24px;
  padding: 2px 6px;
  border-radius: 4px;
  color: var(--nm-text, #e0e0e0);
  font-size: 14px;
  line-height: 1.6;
  outline: none;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.block-content:focus {
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.05));
  box-shadow: 0 0 0 1px var(--nm-primary-alpha, rgba(99, 102, 241, 0.3));
}

.block-content:empty::before {
  content: "Type something...";
  color: var(--nm-text-muted, #555);
  font-style: italic;
}

.block-children {
  width: 100%;
}

/* =============================================================================
   Block References
   ============================================================================= */

.block-reference {
  display: inline;
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.1));
  padding: 1px 4px;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
  transition: all 0.15s;
}

.block-reference:hover {
  background: var(--nm-primary-alpha, rgba(99, 102, 241, 0.2));
}

.ref-marker {
  color: var(--nm-text-muted, #666);
  font-size: 12px;
}

.ref-content {
  color: var(--nm-primary, #6366f1);
}

.ref-not-found {
  color: var(--nm-error, #ef4444);
  font-style: italic;
}

.block-reference-inline {
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.1));
  padding: 1px 4px;
  border-radius: 3px;
  color: var(--nm-primary, #6366f1);
}

.block-reference-preview {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 1000;
  background: var(--nm-card-bg, #252538);
  border: 1px solid var(--nm-border, rgba(255, 255, 255, 0.1));
  border-radius: 6px;
  padding: 8px 12px;
  min-width: 200px;
  max-width: 400px;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
  margin-top: 4px;
}

.preview-content {
  font-size: 13px;
  color: var(--nm-text, #e0e0e0);
  line-height: 1.5;
}

.preview-content .not-found {
  color: var(--nm-error, #ef4444);
  font-style: italic;
}

/* =============================================================================
   Empty State
   ============================================================================= */

.outline-empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  text-align: center;
}

.outline-empty-state p {
  color: var(--nm-text-muted, #666);
  margin-bottom: 16px;
}

.btn-add-block {
  background: var(--nm-primary, #6366f1);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-add-block:hover {
  background: var(--nm-primary-hover, #5558e3);
  transform: translateY(-1px);
}

/* =============================================================================
   Outliner Footer
   ============================================================================= */

.outliner-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
  border-top: 1px solid var(--nm-border, rgba(255, 255, 255, 0.1));
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.03));
  font-size: 12px;
  color: var(--nm-text-muted, #666);
}

.block-count {
  opacity: 0.8;
}

/* =============================================================================
   Shortcuts Help Panel
   ============================================================================= */

.shortcuts-help-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  background: var(--nm-card-bg, #252538);
  border: 1px solid var(--nm-border, rgba(255, 255, 255, 0.1));
  border-radius: 8px;
  padding: 16px;
  min-width: 280px;
  max-width: 360px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
  z-index: 1000;
}

.shortcuts-help-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--nm-border, rgba(255, 255, 255, 0.1));
}

.shortcuts-help-header h4 {
  margin: 0;
  font-size: 14px;
  color: var(--nm-text, #e0e0e0);
}

.shortcuts-help-header .close-btn {
  background: none;
  border: none;
  color: var(--nm-text-muted, #666);
  cursor: pointer;
  font-size: 18px;
  padding: 0;
  line-height: 1;
}

.shortcuts-help-header .close-btn:hover {
  color: var(--nm-text, #e0e0e0);
}

.shortcuts-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.shortcut-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.shortcut-item kbd {
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.1));
  border: 1px solid var(--nm-border, rgba(255, 255, 255, 0.15));
  border-radius: 4px;
  padding: 2px 8px;
  font-family: monospace;
  font-size: 12px;
  color: var(--nm-text, #e0e0e0);
  min-width: 80px;
  text-align: center;
}

.shortcut-item span {
  font-size: 13px;
  color: var(--nm-text-muted, #888);
}

/* =============================================================================
   Outline List (Sidebar)
   ============================================================================= */

.outline-list {
  padding: 8px;
}

.outline-list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
  margin-bottom: 8px;
}

.outline-list-header h4 {
  margin: 0;
  font-size: 14px;
  color: var(--nm-text-muted, #888);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.btn-create-outline {
  background: transparent;
  border: 1px solid var(--nm-border, rgba(255, 255, 255, 0.2));
  color: var(--nm-text-muted, #888);
  cursor: pointer;
  padding: 4px 10px;
  border-radius: 4px;
  font-size: 14px;
  transition: all 0.2s;
}

.btn-create-outline:hover {
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.1));
  color: var(--nm-text, #e0e0e0);
  border-color: var(--nm-primary, #6366f1);
}

.outline-list-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.outline-list-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
}

.outline-list-item:hover {
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.05));
}

.outline-list-item.active {
  background: var(--nm-primary-alpha, rgba(99, 102, 241, 0.15));
}

.outline-icon {
  font-size: 16px;
}

.outline-title {
  flex: 1;
  font-size: 14px;
  color: var(--nm-text, #e0e0e0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.delete-outline {
  background: none;
  border: none;
  color: var(--nm-text-muted, #666);
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 4px;
  font-size: 14px;
  opacity: 0;
  transition: all 0.15s;
}

.outline-list-item:hover .delete-outline {
  opacity: 1;
}

.delete-outline:hover {
  background: var(--nm-error-alpha, rgba(239, 68, 68, 0.2));
  color: var(--nm-error, #ef4444);
}

.outline-list-empty {
  text-align: center;
  padding: 24px 16px;
}

.outline-list-empty p {
  color: var(--nm-text-muted, #666);
  margin-bottom: 12px;
}

.btn-create-first {
  background: var(--nm-primary, #6366f1);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 13px;
}

.btn-create-first:hover {
  background: var(--nm-primary-hover, #5558e3);
}

/* =============================================================================
   Block List
   ============================================================================= */

.block-list {
  display: flex;
  flex-direction: column;
}

/* =============================================================================
   Action Buttons in Header
   ============================================================================= */

.btn-collapse-all,
.btn-expand-all,
.btn-shortcuts-help {
  font-size: 12px !important;
}

/* =============================================================================
   Responsive Styles
   ============================================================================= */

@media (max-width: 768px) {
  .outliner-page {
    flex-direction: column;
  }

  .outliner-sidebar {
    width: 100%;
    height: auto;
    max-height: 200px;
    border-right: none;
    border-bottom: 1px solid var(--nm-border, rgba(255, 255, 255, 0.1));
  }

  .shortcuts-help-panel {
    left: 20px;
    right: 20px;
    bottom: 10px;
    min-width: auto;
  }
}

/* =============================================================================
   Focus Indication for Accessibility
   ============================================================================= */

.block-content:focus-visible {
  outline: 2px solid var(--nm-primary, #6366f1);
  outline-offset: 2px;
}

.collapse-toggle:focus-visible,
.btn-add-block:focus-visible,
.btn-create-outline:focus-visible {
  outline: 2px solid var(--nm-primary, #6366f1);
  outline-offset: 2px;
}

/* =============================================================================
   Animation for Collapse/Expand
   ============================================================================= */

.block-children {
  animation: fadeIn 0.15s ease-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-4px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =============================================================================
   Backlinks Panel
   ============================================================================= */

.outliner-footer {
  display: flex;
  flex-direction: column;
  border-top: 1px solid var(--nm-border, rgba(255, 255, 255, 0.1));
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.03));
}

.footer-stats {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 16px;
}

.btn-backlinks {
  padding: 4px 8px;
  background: transparent;
  border: 1px solid var(--nm-border, rgba(255, 255, 255, 0.1));
  border-radius: 4px;
  color: var(--nm-text-secondary, #a0a0b8);
  cursor: pointer;
  font-size: 12px;
  transition: all 0.15s ease;
}

.btn-backlinks:hover,
.btn-backlinks.active {
  background: var(--nm-primary, #6366f1);
  border-color: var(--nm-primary, #6366f1);
  color: white;
}

.backlinks-panel {
  border-top: 1px solid var(--nm-border, rgba(255, 255, 255, 0.1));
  padding: 12px 16px;
  background: var(--nm-bg-dark, rgba(0, 0, 0, 0.2));
  animation: fadeIn 0.15s ease-out;
}

.backlinks-header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}

.backlinks-header h4 {
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--nm-text-muted, #606078);
}

.backlinks-count {
  font-size: 11px;
  color: var(--nm-text-muted, #606078);
}

.backlinks-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 200px;
  overflow-y: auto;
}

.backlink-item {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 8px 12px;
  background: var(--nm-glass-bg, rgba(255, 255, 255, 0.03));
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.backlink-item:hover {
  background: var(--nm-primary-alpha, rgba(99, 102, 241, 0.1));
  border-color: var(--nm-primary, #6366f1);
}

.backlink-bullet {
  color: var(--nm-primary, #6366f1);
  font-size: 14px;
  line-height: 1.5;
}

.backlink-text {
  font-size: 13px;
  color: var(--nm-text-primary, #f0f0f5);
  line-height: 1.5;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
}

.backlinks-empty {
  padding: 16px;
  text-align: center;
  color: var(--nm-text-muted, #606078);
  font-size: 13px;
  font-style: italic;
}
