/* ============================================================
   Notes Explorer — hierarchical folder tree
   ============================================================ */

.notes-explorer {
  display: flex;
  flex-direction: column;
  height: calc(100vh - var(--navbar-height));
  height: calc(100dvh - var(--navbar-height));
  max-width: 100%;
  animation: fadeInUp var(--duration-slow) var(--ease-out) both;
}

.notes-explorer__header {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 20px 24px 12px;
  flex-wrap: wrap;
  flex-shrink: 0;
}

.notes-explorer__heading {
  flex: 1;
  min-width: 0;
}

.notes-explorer__actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.notes-explorer__toolbar {
  padding: 0 24px 12px;
  flex-shrink: 0;
}

.notes-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
  padding: 0 24px 12px;
  font-size: var(--font-size-sm);
}

.notes-bc__item {
  background: none;
  border: none;
  color: var(--color-text-secondary);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  font-size: inherit;
}

.notes-bc__item:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.notes-bc__item--current {
  color: var(--color-text-primary);
  font-weight: var(--font-weight-medium);
  cursor: default;
}

.notes-bc__sep {
  color: var(--color-text-tertiary);
  user-select: none;
}

.notes-explorer__body {
  display: flex;
  flex: 1;
  min-height: 0;
  border-top: 1px solid var(--color-border);
}

.notes-explorer__sidebar {
  width: 280px;
  flex-shrink: 0;
  overflow-y: auto;
  background: var(--color-bg-subtle);
  border-right: 1px solid var(--color-border);
  padding: 12px 8px;
}

.notes-explorer__main {
  flex: 1;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--color-bg);
}

/* Tree */
.notes-tree__section {
  margin-bottom: 16px;
}

.notes-tree__section-title {
  font-size: 10px;
  font-weight: var(--font-weight-bold);
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--color-text-tertiary);
  padding: 4px 8px 8px;
  margin: 0;
}

.notes-tree__row {
  display: flex;
  align-items: center;
  gap: 6px;
  width: 100%;
  min-height: 28px;
  padding: 4px 8px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-align: left;
  font-size: var(--font-size-sm);
  color: var(--color-text-primary);
  transition: background var(--duration-fast);
}

.notes-tree__row:hover {
  background: var(--color-bg-hover);
}

.notes-tree__row.is-selected {
  background: color-mix(in srgb, var(--color-accent) 15%, var(--color-bg-hover));
  color: var(--color-accent);
}

.notes-tree__row.is-dragging {
  opacity: 0.5;
}

.notes-tree__row.is-drop-target,
.notes-tree__root.is-drop-target {
  background: color-mix(in srgb, var(--color-accent) 12%, transparent);
  outline: 1px dashed var(--color-accent);
}

.notes-tree__chevron {
  width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: none;
  cursor: pointer;
  color: var(--color-text-tertiary);
  flex-shrink: 0;
  transition: transform var(--duration-fast);
}

.notes-tree__chevron.is-open {
  transform: rotate(90deg);
}

.notes-tree__chevron.is-hidden {
  visibility: hidden;
}

.notes-tree__icon {
  flex-shrink: 0;
  display: flex;
  color: var(--folder-color, var(--color-accent));
}

.notes-tree__icon--note {
  color: var(--color-text-secondary);
}

.notes-tree__label {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.notes-tree__children {
  overflow: hidden;
  max-height: 0;
  opacity: 0;
  transition: max-height 0.25s var(--ease-out), opacity 0.2s;
}

.notes-tree__children.is-expanded {
  max-height: 5000px;
  opacity: 1;
}

.notes-tree__quick {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 6px 10px;
  border: none;
  background: transparent;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: var(--font-size-sm);
  text-align: left;
  color: var(--color-text-secondary);
}

.notes-tree__quick:hover {
  background: var(--color-bg-hover);
}

.notes-tree__empty {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  padding: 8px;
  margin: 0;
}

.notes-tree__fav {
  color: var(--color-warning);
  font-size: 10px;
}

/* Main panel */
.notes-panel__card {
  position: relative;
  padding: 16px 20px;
  margin-bottom: 12px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  background: var(--color-bg-elevated);
  cursor: pointer;
  transition: border-color var(--duration-fast), box-shadow var(--duration-fast);
}

.notes-panel__card-delete {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  padding: 0;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  background: transparent;
  color: var(--color-text-muted);
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration-fast), color var(--duration-fast), background var(--duration-fast), border-color var(--duration-fast);
}

.notes-panel__card-actions {
  position: absolute;
  top: 12px;
  right: 12px;
  display: flex;
  gap: 6px;
  align-items: center;
}

.notes-panel__card-revise {
  padding: 5px 10px;
  font-size: 11px;
  font-weight: var(--font-weight-medium);
  border: 1px solid color-mix(in srgb, #0d9488 40%, transparent);
  border-radius: var(--radius-sm);
  background: color-mix(in srgb, #0d9488 10%, transparent);
  color: #0d9488;
  cursor: pointer;
  opacity: 0;
  transition: opacity var(--duration-fast), background var(--duration-fast), color var(--duration-fast);
}

.notes-panel__card:hover .notes-panel__card-revise,
.notes-panel__card:focus-within .notes-panel__card-revise,
.notes-panel__card:hover .notes-panel__card-delete,
.notes-panel__card:focus-within .notes-panel__card-delete {
  opacity: 1;
}

.notes-panel__card-revise:hover {
  background: #0d9488;
  color: #fff;
}

.notes-panel__card-delete:hover {
  color: #c0392b;
  background: rgba(192, 57, 43, 0.08);
  border-color: rgba(192, 57, 43, 0.25);
}

.notes-panel__card-delete:focus-visible {
  opacity: 1;
  outline: 2px solid var(--color-accent);
  outline-offset: 2px;
}

.notes-panel__card:hover {
  border-color: var(--color-accent);
  box-shadow: var(--shadow-sm);
}

.notes-panel__card-title {
  margin: 0 0 8px;
  font-size: var(--font-size-base);
}

.notes-panel__card-preview {
  margin: 0 0 12px;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
  line-height: 1.5;
}

.notes-panel__card-meta {
  display: flex;
  gap: 12px;
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

.notes-panel__empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--color-text-tertiary);
}

/* Search */
.notes-search-results h3 {
  font-size: var(--font-size-sm);
  margin: 0 0 12px;
  color: var(--color-text-secondary);
}

.notes-search__row {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  width: 100%;
  padding: 12px 16px;
  margin-bottom: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  background: var(--color-bg-elevated);
  cursor: pointer;
  text-align: left;
}

.notes-search__row:hover {
  border-color: var(--color-accent);
}

.notes-search__type {
  font-size: 10px;
  text-transform: uppercase;
  color: var(--color-accent);
}

.notes-search__path {
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

.notes-search-mark {
  background: color-mix(in srgb, var(--color-warning) 35%, transparent);
  border-radius: 2px;
  padding: 0 2px;
}

/* Context menu */
.notes-ctx {
  position: fixed;
  z-index: 500;
  min-width: 180px;
  background: var(--color-bg-elevated);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  padding: 6px 0;
  display: none;
}

.notes-ctx.is-visible {
  display: block;
}

.notes-ctx__title {
  padding: 8px 14px;
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-tertiary);
  border-bottom: 1px solid var(--color-border);
  margin-bottom: 4px;
}

.notes-ctx__item {
  display: block;
  width: 100%;
  padding: 8px 14px;
  border: none;
  background: none;
  text-align: left;
  font-size: var(--font-size-sm);
  cursor: pointer;
  color: var(--color-text-primary);
}

.notes-ctx__item:hover {
  background: var(--color-bg-hover);
}

.notes-ctx__item--danger {
  color: var(--color-danger);
}

.notes-ctx__sep {
  height: 1px;
  background: var(--color-border);
  margin: 4px 0;
}

@media (max-width: 768px) {
  .notes-explorer__sidebar {
    width: 220px;
  }

  .notes-explorer__header,
  .notes-explorer__toolbar,
  .notes-breadcrumb {
    padding-left: 16px;
    padding-right: 16px;
  }
}

@media (max-width: 600px) {
  .notes-explorer__body {
    flex-direction: column;
  }

  .notes-explorer__sidebar {
    width: 100%;
    max-height: 40vh;
    border-right: none;
    border-bottom: 1px solid var(--color-border);
  }
}
