/* sidebar.css - Styles for tree sidebar navigation */

:root {
  --sidebar-width: 280px;
  --sidebar-bg: #f5f5f5;
  --sidebar-text: #333;
  --sidebar-border: #e0e0e0;
  --sidebar-hover: #f0f0f0;
}

/* Main layout with sidebar */
body.has-sidebar {
  display: block !important;
  margin-left: var(--sidebar-width);
  padding: 2rem 1rem !important;
}

.tree-sidebar {
  position: fixed;
  left: 0;
  top: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background-color: var(--sidebar-bg);
  border-right: 1px solid var(--sidebar-border);
  overflow-y: auto;
  overflow-x: hidden;
  z-index: 100;
  padding: 0;
  margin: 0;
}

.tree-sidebar-content {
  padding: 1.5rem 1rem;
  font-family: monospace;
}

.tree-sidebar-title {
  margin: 0 0 1.5rem 0;
  padding: 0;
  font-size: 0.875rem;
  font-weight: 600;
}

.tree-sidebar-title a {
  color: #0066cc;
  text-decoration: none;
  transition: color 0.2s ease;
}

.tree-sidebar-title a:hover {
  text-decoration: underline;
}

#tree-container {
  font-size: 0.8125rem;
}

.tree-container {
  font-family: monospace;
}

.tree-container ul {
  list-style: none;
  margin: 0.25rem 0;
}

.tree-container ul ul {
  padding-left: 18px; /* Indent nested lists */
}


.tree-container li {
  margin: 0;
  line-height: 1.6;
  padding: 0;
}

.tree-container strong.folder {
  cursor: pointer;
  user-select: none;
  position: relative;
  padding: 0.2rem 0.6rem 0.2rem 24px;
  font-weight: 600;
  font-size: inherit;
  display: block;
  border-radius: 4px;
  transition: background-color 0.15s ease, color 0.15s ease;
  color: var(--sidebar-text);
  margin: 0.1rem 0;
}

.tree-container strong.folder::before {
  content: '▶';
  position: absolute;
  left: 6px;
  transition: transform 0.15s ease;
  font-size: 0.75rem;
}

.tree-container strong.folder.expanded::before {
  transform: rotate(90deg);
}

.tree-container strong.folder:hover {
  background-color: var(--sidebar-hover);
}

.tree-container .folder-content {
  display: none;
  margin-left: 0;
  /* Remove padding-left here, as it's handled by ul ul */
}

.tree-container strong.folder.expanded + .folder-content {
  display: block;
}

.tree-container a {
  display: block;
  padding: 0.2rem 0.6rem;
  color: #0066cc;
  text-decoration: none;
  border-radius: 4px;
  transition: background-color 0.15s ease, color 0.15s ease;
  font-size: inherit;
  margin: 0.1rem 0;
}

.tree-container a:hover {
  background-color: #e8e8ff;
  text-decoration: underline;
}

.tree-container a.active {
  background-color: #0066cc;
  color: white;
  font-weight: 600;
}

.tree-container a.active:hover {
  background-color: #0052a3;
  text-decoration: none;
}

/* Add sidebar margin to main content */
/* This rule is handled by body.has-sidebar margin-left above */

/* Responsive behavior */
@media (max-width: 1024px) {
  :root {
    --sidebar-width: 240px;
  }

  .tree-sidebar {
    width: var(--sidebar-width);
    transform: translateX(0);
    transition: transform 0.3s ease;
  }

  .tree-sidebar.collapsed {
    transform: translateX(-100%);
  }
}

@media (max-width: 768px) {
  :root {
    --sidebar-width: 100%;
  }

  body.has-sidebar {
    margin-left: 0;
    margin-top: 70vh;
  }

  .tree-sidebar {
    position: fixed;
    width: 100%;
    height: auto;
    max-height: 70vh;
    border-right: none;
    border-bottom: 1px solid var(--sidebar-border);
    z-index: 1000;
  }

  .tree-sidebar-content {
    padding: 1rem;
  }

  .tree-sidebar-title {
    margin-bottom: 0.75rem;
  }

  #tree-container {
    columns: 2;
    gap: 1rem;
  }
}

@media (max-width: 480px) {
  #tree-container {
    columns: 1;
  }

  .tree-sidebar-content {
    padding: 0.75rem;
  }

  .tree-container strong.folder,
  .tree-container a {
    padding: 0.15rem 0.4rem;
    font-size: 0.75rem;
  }
}
