/* ── File Tree (Navigator) ─────────────────────────── */

.file-tree {
  font-size: var(--text-sm);
}

.tree-item {
  display: flex;
  align-items: center;
  gap: var(--space-2);
  padding: 2px var(--space-2);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  color: var(--color-text-secondary);
  min-height: 26px;
}

.tree-item:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.tree-item.active {
  background: hsla(220, 50%, 40%, 0.3);
  color: hsl(210, 80%, 85%);
}

.tree-chevron {
  width: 16px;
  height: 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--color-text-muted);
  transition: transform var(--transition-fast);
}

.tree-chevron.expanded {
  transform: rotate(90deg);
}

.tree-chevron svg {
  width: 12px;
  height: 12px;
}

.tree-icon {
  font-size: var(--text-xs);
  flex-shrink: 0;
  width: 16px;
  height: 16px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-tertiary);
}

.tree-icon svg {
  width: 14px;
  height: 14px;
  flex-shrink: 0;
}

.tree-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: var(--text-xs);
}

.tree-children {
  padding-left: var(--space-3);
}

/* ── Highlighted Explorer Items ─────────────────────── */

/* Memory — teal colored pill badge */
.tree-item--memory {
  background: var(--color-memory-subtle);
  border: 1px solid color-mix(in srgb, var(--color-memory) 20%, transparent);
  border-radius: var(--radius-md);
  margin-bottom: 1px;
}
.tree-item--memory .tree-name {
  color: var(--color-memory-text);
  font-weight: var(--font-semi);
  letter-spacing: 0.01em;
}
.tree-item--memory .tree-icon {
  filter: saturate(1.4) brightness(1.1);
}
.tree-item--memory .tree-chevron {
  color: var(--color-memory-text);
  opacity: 0.7;
}
.tree-item--memory:hover {
  background: var(--color-memory-muted);
  border-color: color-mix(in srgb, var(--color-memory) 35%, transparent);
}
.tree-item--memory.active {
  background: var(--color-memory-muted);
  border-color: color-mix(in srgb, var(--color-memory) 45%, transparent);
  color: var(--color-memory-text);
}

/* Storage — amber colored pill badge */
.tree-item--storage {
  background: var(--color-storage-subtle);
  border: 1px solid color-mix(in srgb, var(--color-storage) 20%, transparent);
  border-radius: var(--radius-md);
  margin-bottom: 1px;
}
.tree-item--storage .tree-name {
  color: var(--color-storage-text);
  font-weight: var(--font-semi);
  letter-spacing: 0.01em;
}
.tree-item--storage .tree-icon {
  filter: saturate(1.4) brightness(1.1);
}
.tree-item--storage .tree-chevron {
  color: var(--color-storage-text);
  opacity: 0.7;
}
.tree-item--storage:hover {
  background: var(--color-storage-muted);
  border-color: color-mix(in srgb, var(--color-storage) 35%, transparent);
}
.tree-item--storage.active {
  background: var(--color-storage-muted);
  border-color: color-mix(in srgb, var(--color-storage) 45%, transparent);
  color: var(--color-storage-text);
}

/* index.md — primary knowledge file, most-used */
.tree-item--index .tree-name {
  color: hsl(340, 70%, 76%);
  font-weight: var(--font-semi);
  letter-spacing: 0.01em;
}
.tree-item--index .tree-icon {
  filter: brightness(1.3);
}
.tree-item--index::after {
  content: '';
  position: absolute;
  left: 0;
  top: 2px;
  bottom: 2px;
  width: 2px;
  border-radius: 1px;
  background: hsl(340, 65%, 60%);
}
.tree-item--index {
  position: relative;
}

/* log.md — secondary reference file */
.tree-item--log .tree-name {
  color: hsl(250, 55%, 76%);
  font-weight: var(--font-medium);
}
.tree-item--log .tree-icon {
  filter: brightness(1.15);
}

/* Drag-and-drop: item being dragged */
.tree-item--dragging {
  opacity: 0.4;
}

/* Drag-and-drop: folder ready to receive an internal move */
.tree-item--drop-target {
  background: rgba(99, 102, 241, 0.15);
  outline: 2px dashed rgba(99, 102, 241, 0.5);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
}

/* Drag-and-drop: folder ready to receive external files from OS */
.tree-item--external-drop-target {
  background: rgba(52, 211, 153, 0.2) !important;
  outline: 2px solid rgba(52, 211, 153, 0.7);
  outline-offset: -2px;
  border-radius: var(--radius-sm);
  color: hsl(160, 85%, 75%) !important;
  box-shadow: 0 0 8px rgba(52, 211, 153, 0.25);
}

/* Subtle pulsing glow on the tree when external files are being dragged in */
.nav-tree--external-drag {
  outline: 2px dashed rgba(52, 211, 153, 0.3);
  outline-offset: -2px;
  border-radius: var(--radius-md);
}

/* Breadcrumb (used in editor toolbar) */
.breadcrumb-bar {
  display: flex;
  align-items: center;
  gap: var(--space-1);
  overflow-x: auto;
}

.breadcrumb-item {
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  padding: var(--space-1) var(--space-1);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all var(--transition-fast);
  white-space: nowrap;
  background: none;
  border: none;
}

.breadcrumb-item:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
}

.breadcrumb-item.active {
  color: var(--color-text-primary);
  font-weight: var(--font-medium);
}

.breadcrumb-sep {
  color: var(--color-text-muted);
  font-size: 10px;
}

/* Upload Overlay */
.upload-overlay {
  position: absolute;
  inset: 0;
  background: hsla(240, 60%, 25%, 0.3);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-overlay);
  border: 3px dashed var(--color-accent);
  border-radius: var(--radius-lg);
  margin: var(--space-4);
}

.upload-overlay-content {
  text-align: center;
  color: var(--color-accent-text);
}

.upload-overlay-content p {
  font-size: var(--text-lg);
  font-weight: var(--font-semi);
  margin-top: var(--space-3);
}

/* ── PDF Viewer ─────────────────────────────────────── */

.editor-pdf-container {
  flex: 1;
  overflow-y: auto;
  background: hsl(225, 20%, 12%);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-4);
  padding: var(--space-6) var(--space-4);
}

.editor-pdf-page {
  background: white;
  box-shadow:
    0 2px 8px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  position: relative;
  overflow: hidden;
}

.editor-pdf-page canvas {
  display: block;
}

.editor-pdf-page-placeholder {
  background: hsl(225, 15%, 18%);
  border-radius: 2px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--color-text-muted);
  font-size: var(--text-xs);
}

.editor-pdf-page-number {
  position: absolute;
  bottom: 4px;
  right: 8px;
  font-size: 10px;
  color: rgba(0, 0, 0, 0.3);
  pointer-events: none;
}

.editor-pdf-loading {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: var(--space-3);
  padding: var(--space-12);
  color: var(--color-text-tertiary);
  font-size: var(--text-sm);
}

.editor-pdf-loading-spinner {
  width: 28px;
  height: 28px;
  border: 3px solid hsl(225, 15%, 25%);
  border-top-color: var(--color-accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* PDF Toolbar controls */
.editor-pdf-zoom-controls {
  display: flex;
  align-items: center;
  gap: var(--space-1);
}

.editor-pdf-zoom-controls button {
  background: none;
  border: 1px solid hsl(225, 15%, 25%);
  color: var(--color-text-secondary);
  width: 24px;
  height: 24px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  transition: all var(--transition-fast);
}

.editor-pdf-zoom-controls button:hover {
  background: var(--color-bg-hover);
  color: var(--color-text-primary);
  border-color: hsl(225, 15%, 35%);
}

.editor-pdf-zoom-label {
  font-size: 10px;
  color: var(--color-text-muted);
  min-width: 36px;
  text-align: center;
}

.editor-pdf-page-info {
  font-size: 10px;
  color: var(--color-text-muted);
}

/* ── DOCX Viewer ────────────────────────────────────── */

.editor-docx-container {
  flex: 1;
  overflow-y: auto;
  background: hsl(225, 15%, 16%);
  padding: var(--space-6);
  display: flex;
  justify-content: center;
}

.editor-docx-wrapper {
  background: white;
  color: #222;
  max-width: 816px; /* ~8.5" at 96dpi */
  width: 100%;
  padding: 48px 64px;
  box-shadow:
    0 2px 12px rgba(0, 0, 0, 0.3),
    0 0 0 1px rgba(255, 255, 255, 0.05);
  border-radius: 2px;
  font-family: 'Calibri', 'Arial', sans-serif;
  font-size: 11pt;
  line-height: 1.5;
  min-height: 100%;
}

/* Override docx-preview's default styles for dark-mode embedding */
.editor-docx-wrapper .docx-wrapper {
  background: white !important;
  padding: 0 !important;
}

.editor-docx-wrapper table {
  border-collapse: collapse;
  width: 100%;
}

.editor-docx-wrapper table td,
.editor-docx-wrapper table th {
  border: 1px solid #ccc;
  padding: 4px 8px;
}

/* ── XLSX Viewer ────────────────────────────────────── */

.editor-xlsx-container {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.editor-xlsx-tabs {
  display: flex;
  gap: 0;
  border-bottom: 1px solid hsl(225, 15%, 18%);
  background: hsl(225, 20%, 10%);
  overflow-x: auto;
  flex-shrink: 0;
  padding: 0 var(--space-2);
}

.editor-xlsx-tab {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-xs);
  color: var(--color-text-tertiary);
  cursor: pointer;
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  transition: all var(--transition-fast);
  white-space: nowrap;
}

.editor-xlsx-tab:hover {
  color: var(--color-text-secondary);
  background: hsl(225, 15%, 14%);
}

.editor-xlsx-tab.active {
  color: var(--color-accent-text);
  border-bottom-color: var(--color-accent);
}

.editor-xlsx-table-container {
  flex: 1;
  overflow: auto;
}

/* Reuse the CSV table base styles for XLSX too */
.editor-xlsx-table-container .editor-csv-table {
  width: max-content;
  min-width: 100%;
}

