/* Professional Modern jstree CSS */
:root {
  /* Professional color palette - subdued */
  --jstree-primary: #475569;
  --jstree-primary-light: #64748b;
  --jstree-primary-dark: #334155;
  --jstree-success: #059669;
  --jstree-warning: #d97706;
  --jstree-danger: #dc2626;
  --jstree-surface: #ffffff;
  --jstree-surface-hover: #f8fafc;
  --jstree-surface-selected: #f1f5f9;
  --jstree-surface-drag: #f1f5f9;
  --jstree-border: #e2e8f0;
  --jstree-text: #1e293b;
  --jstree-text-muted: #64748b;
  --jstree-shadow: rgba(0, 0, 0, 0.1);
  --jstree-shadow-lg: rgba(0, 0, 0, 0.15);
  
  /* Spacing */
  --jstree-icon-size: 18px;
  --jstree-spacing: 6px;
  --jstree-radius: 6px;
  
  /* Professional SVG icons */
  --jstree-arrow-right: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Cg fill='none' stroke='%23475569' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m9 18 6-6-6-6'/%3E%3C/g%3E%3C/svg%3E");
  --jstree-arrow-down: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Cg fill='none' stroke='%23475569' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/g%3E%3C/svg%3E");
  --jstree-folder: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Cpath d='M10 4H4c-1.1 0-2 .9-2 2v12c0 1.1.9 2 2 2h16c1.1 0 2-.9 2-2V8c0-1.1-.9-2-2-2h-8l-2-2z' fill='%23d97706'/%3E%3C/svg%3E");
  --jstree-folder-open: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Cpath d='M19 20H4c-1.1 0-2-.9-2-2V6c0-1.1.9-2 2-2h6l2 2h7c1.1 0 2 .9 2 2v10c0 1.1-.9 2-2 2' fill='%23f59e0b'/%3E%3C/svg%3E");
  --jstree-file: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Cpath d='M14 2H6c-1.1 0-2 .9-2 2v16c0 1.1.9 2 2 2h12c1.1 0 2-.9 2-2V8l-6-6z' fill='%23475569'/%3E%3C/svg%3E");
  --jstree-checkbox: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Crect x='3' y='3' width='18' height='18' rx='3' fill='none' stroke='%23475569' stroke-width='1.5'/%3E%3C/svg%3E");
  --jstree-checkbox-checked: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Crect x='3' y='3' width='18' height='18' rx='3' fill='%23059669'/%3E%3Cpath d='m9 12 2 2 4-4' fill='none' stroke='white' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  --jstree-checkbox-indeterminate: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Crect x='3' y='3' width='18' height='18' rx='3' fill='%23d97706'/%3E%3Crect x='8' y='11' width='8' height='2' rx='1' fill='white'/%3E%3C/svg%3E");
  --jstree-drag-ok: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23059669'/%3E%3Cpath d='m9 12 2 2 4-4' fill='none' stroke='white' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  --jstree-drag-error: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' width='20' height='20'%3E%3Ccircle cx='12' cy='12' r='10' fill='%23dc2626'/%3E%3Cpath d='m9 9 6 6' fill='none' stroke='white' stroke-width='1.5' stroke-linecap='round'/%3E%3Cpath d='m15 9-6 6' fill='none' stroke='white' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
}

/* Demo container */
.demo {
  background: var(--jstree-surface);
  border: 1px solid var(--jstree-border);
  border-radius: var(--jstree-radius);
  padding: var(--jstree-spacing);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  box-shadow: 0 1px 3px var(--jstree-shadow);
  margin-bottom: 20px;
  position: relative;
}

/* Tree container */
.jstree-container-ul {
  padding: 0 !important;
  margin: 0 !important;
}

/* Node layout */
.jstree-node {
  display: block !important;
  margin-left: 0 !important;
  padding: 2px 0 !important;
  margin-top: 1px !important;
  margin-bottom: 1px !important;
  border-radius: var(--jstree-radius) !important;
  transition: all 0.15s ease !important;
  position: relative !important;
}

.jstree-container-ul > .jstree-node,
.jstree-node > .jstree-children > .jstree-node {
  margin-left: 0 !important;
}

.jstree-node:hover {
  background: transparent !important;
}

.jstree-anchor.jstree-clicked,
.jstree-anchor.jstree-selected {
  background: var(--jstree-surface-selected) !important;
  box-shadow: 0 0 0 1px var(--jstree-primary-light) !important;
}

/* Drag states */
.jstree-node.jstree-draggable {
  cursor: move !important;
}

.jstree-node.jstree-draggable:hover {
  background: var(--jstree-surface-drag) !important;
  transform: scale(1.01) !important;
  box-shadow: 0 2px 8px var(--jstree-shadow) !important;
}

.jstree-dragging {
  opacity: 0.7 !important;
  transform: rotate(1deg) !important;
  box-shadow: 0 4px 16px var(--jstree-shadow-lg) !important;
  z-index: 1000 !important;
}

.jstree-drop-target {
  background: var(--jstree-surface-drag) !important;
  border: 1px dashed var(--jstree-primary) !important;
}

/* Anchor text */
.jstree-anchor {
  display: inline-flex !important;
  align-items: center !important;
  gap: var(--jstree-spacing) !important;
  color: var(--jstree-text) !important;
  text-decoration: none !important;
  font-weight: 400 !important;
  font-size: 13px !important;
  padding: 3px 4px !important;
  border-radius: calc(var(--jstree-radius) - 1px) !important;
  transition: all 0.15s ease !important;
  background: transparent !important;
  max-width: calc(100% - 4px) !important;
  user-select: none !important;
}

.jstree-anchor:focus {
  outline: none !important;
  box-shadow: 0 0 0 1px var(--jstree-primary) !important;
}

/* Icons */
.jstree-icon {
  width: var(--jstree-icon-size) !important;
  height: var(--jstree-icon-size) !important;
  background-size: contain !important;
  background-repeat: no-repeat !important;
  background-position: center !important;
  display: inline-block !important;
  transition: transform 0.15s ease !important;
  flex-shrink: 0 !important;
}

/* Arrow icons */
.jstree-ocl {
  background-image: var(--jstree-arrow-right) !important;
  cursor: pointer !important;
  border-radius: 3px !important;
  padding: 1px !important;
}

.jstree-ocl:hover {
  transform: scale(1.05) !important;
  background-color: rgba(71, 85, 105, 0.1) !important;
}

.jstree-open > .jstree-ocl {
  transform: rotate(90deg) !important;
  background-image: var(--jstree-arrow-down) !important;
}

.jstree-leaf > .jstree-ocl {
  opacity: 0 !important;
  cursor: default !important;
  pointer-events: none !important;
}

/* Theme icons */
.jstree-themeicon {
  background-image: var(--jstree-folder) !important;
  border-radius: 2px !important;
}

.jstree-themeicon-hidden {
  display: none !important;
}

.jstree-open > .jstree-themeicon {
  background-image: var(--jstree-folder-open) !important;
}

.jstree-leaf > .jstree-themeicon,
.jstree-themeicon.jstree-file {
  background-image: var(--jstree-file) !important;
}

/* Children container */
.jstree-node > .jstree-children {
  margin-left: calc(var(--jstree-icon-size) + 8px) !important;
  margin-top: 2px !important;
  padding-left: 10px !important;
  border-left: 1px solid var(--jstree-border) !important;
  display: none !important;
  position: relative !important;
}

.jstree-node.jstree-open > .jstree-children {
  display: block !important;
}

/* Checkbox plugin styles */
.jstree-checkbox {
  background-image: var(--jstree-checkbox) !important;
  border-radius: 3px !important;
}

.jstree-checkbox:hover {
  transform: scale(1.02) !important;
}

.jstree-checkbox-selection .jstree-anchor.jstree-clicked > .jstree-checkbox,
.jstree-checked > .jstree-checkbox {
  background-image: var(--jstree-checkbox-checked) !important;
  box-shadow: 0 0 0 2px rgba(5, 150, 105, 0.2) !important;
}

.jstree-anchor > .jstree-checkbox.jstree-undetermined,
.jstree-checkbox.jstree-undetermined {
  background-image: var(--jstree-checkbox-indeterminate) !important;
  box-shadow: 0 0 0 2px rgba(217, 119, 6, 0.2) !important;
}

/* Search highlight */
.jstree-search {
  background: rgba(71, 85, 105, 0.1) !important;
  border-radius: 3px !important;
  border: 1px solid rgba(71, 85, 105, 0.2) !important;
}

/* Drag and Drop Markers */
#jstree-marker {
  border-left: 2px solid var(--jstree-primary) !important;
  width: 0 !important;
  height: 20px !important;
  position: absolute !important;
  background: transparent !important;
  border-radius: 1px !important;
  z-index: 1001 !important;
}

#jstree-dnd {
  background: var(--jstree-surface) !important;
  border: 1px solid var(--jstree-primary) !important;
  border-radius: var(--jstree-radius) !important;
  padding: 6px 10px !important;
  box-shadow: 0 2px 12px rgba(71, 85, 105, 0.2) !important;
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  font-size: 13px !important;
  font-weight: 400 !important;
  color: var(--jstree-text) !important;
  z-index: 1002 !important;
}

#jstree-dnd .jstree-ok,
#jstree-dnd .jstree-er {
  width: 16px !important;
  height: 16px !important;
  border-radius: 50% !important;
  background-size: contain !important;
}

#jstree-dnd .jstree-ok {
  background-image: var(--jstree-drag-ok) !important;
}

#jstree-dnd .jstree-er {
  background-image: var(--jstree-drag-error) !important;
}

/* Context menu */
.vakata-context {
  position: absolute !important;
  background: var(--jstree-surface) !important;
  border: 1px solid var(--jstree-border) !important;
  border-radius: var(--jstree-radius) !important;
  box-shadow: 0 2px 12px var(--jstree-shadow) !important;
  margin: 0 !important;
  padding: 4px 0 !important;
  min-width: 160px !important;
  z-index: 1000 !important;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif !important;
}

.vakata-context ul {
  margin: 0 !important;
  padding: 0 !important;
}

.vakata-context li {
  list-style: none !important;
}

.vakata-context li a {
  display: flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 8px 12px !important;
  color: var(--jstree-text) !important;
  text-decoration: none !important;
  transition: all 0.15s ease !important;
  font-size: 13px !important;
}

.vakata-context li a:hover {
  background-color: var(--jstree-surface-hover) !important;
}

/* Size variants */
.jstree-small .jstree-icon {
  --jstree-icon-size: 16px !important;
}

.jstree-small .jstree-anchor {
  font-size: 12px !important;
}

.jstree-large .jstree-icon {
  --jstree-icon-size: 24px !important;
}

.jstree-large .jstree-anchor {
  font-size: 16px !important;
}

/* Dark mode */
@media (prefers-color-scheme: dark) {
  :root {
    --jstree-surface: #f8fafc;
    --jstree-surface-hover: #f1f5f9;
    --jstree-surface-selected: #e2e8f0;
    --jstree-surface-drag: #e2e8f0;
    --jstree-border: #cbd5e1;
    --jstree-text: #1e293b;
    --jstree-text-muted: #475569;
    --jstree-shadow: rgba(0, 0, 0, 0.1);
    --jstree-shadow-lg: rgba(0, 0, 0, 0.2);
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Loading state */
.jstree-loading .jstree-themeicon {
  background-image: var(--jstree-arrow-right) !important;
  animation: spin 1s linear infinite !important;
}

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

/* Hide default theme backgrounds */
.jstree-default .jstree-icon {
  background-color: transparent !important;
  background-image: none !important;
}

.jstree-default .jstree-ocl {
  background-image: var(--jstree-arrow-right) !important;
}

.jstree-default .jstree-themeicon {
  background-image: var(--jstree-folder) !important;
}

.jstree-default.jstree-open > .jstree-themeicon {
  background-image: var(--jstree-folder-open) !important;
}

.jstree-default.jstree-leaf > .jstree-themeicon,
.jstree-default .jstree-themeicon.jstree-file {
  background-image: var(--jstree-file) !important;
}

.jstree-default .jstree-checkbox {
  background-image: var(--jstree-checkbox) !important;
}

.jstree-default.jstree-checked .jstree-checkbox {
  background-image: var(--jstree-checkbox-checked) !important;
}

.jstree-default.jstree-undetermined .jstree-checkbox {
  background-image: var(--jstree-checkbox-indeterminate) !important;
}
