/* left-menu.php only
   Scope rule: every selector starts with .sidebar#leftMenu or .layout.
   This prevents sitemap/admin/editor styles from hiding tree buttons. */
@media (min-width:901px){
  .layout:not(.no-sidebar){
    grid-template-columns:minmax(250px, max-content) minmax(0,1fr);
  }
  .sidebar#leftMenu{
    position:sticky;
    top:var(--topbar-height,68px);
    align-self:start;
    max-height:calc(100vh - var(--topbar-height,68px));
    overflow-y:auto!important;
    overflow-x:auto!important;
    overscroll-behavior:contain;
  }
}

.sidebar#leftMenu{
  width:max-content;
  min-width:250px;
  max-width:min(560px,42vw);
  padding:18px 16px 24px;
  border-right:1px solid var(--line);
  background:linear-gradient(180deg,rgba(10,16,24,.92),rgba(8,13,20,.86));
  scrollbar-width:thin;
  scrollbar-color:rgba(100,202,255,.45) rgba(8,13,20,.75);
}

.sidebar#leftMenu::-webkit-scrollbar{width:10px;height:10px}
.sidebar#leftMenu::-webkit-scrollbar-track{background:rgba(8,13,20,.75);border-radius:999px}
.sidebar#leftMenu::-webkit-scrollbar-thumb{background:rgba(100,202,255,.35);border-radius:999px;border:2px solid rgba(8,13,20,.75)}
.sidebar#leftMenu::-webkit-scrollbar-thumb:hover{background:rgba(246,195,67,.45)}

.sidebar#leftMenu .side-title{
  display:flex;
  align-items:center;
  gap:8px;
  margin:0 0 8px;
  color:var(--yellow);
  font-size:14px;
  font-weight:950;
  letter-spacing:.04em;
  white-space:nowrap;
}
.sidebar#leftMenu .side-title::before{
  content:"";
  width:8px;
  height:8px;
  border-radius:50%;
  background:var(--blue);
  box-shadow:0 0 14px rgba(100,202,255,.55);
}
.sidebar#leftMenu .tree-help{
  max-width:400px;
  margin:0 0 14px;
  color:var(--muted);
  font-size:12px;
  line-height:1.45;
}

.sidebar#leftMenu .tree,
.sidebar#leftMenu .tree ul{
  list-style:none!important;
  margin:0!important;
  padding:0!important;
  border:0!important;
}
.sidebar#leftMenu .tree-item{
  margin:4px 0;
  padding:0;
  list-style:none!important;
}
.sidebar#leftMenu .tree-row{
  display:flex;
  align-items:center;
  gap:5px;
  min-width:0;
  white-space:nowrap;
}

/* Restore and protect left-menu expand/collapse buttons */
.sidebar#leftMenu .tree-toggle,
.sidebar#leftMenu .tree-toggle-spacer{
  all:unset;
  box-sizing:border-box;
  width:26px!important;
  height:26px!important;
  min-width:26px!important;
  flex:0 0 26px!important;
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  border:1px solid rgba(100,202,255,.18)!important;
  border-radius:9px!important;
  background:rgba(100,202,255,.08)!important;
  color:var(--yellow)!important;
  font-size:13px!important;
  line-height:1!important;
  font-weight:900!important;
  cursor:pointer!important;
  visibility:visible!important;
  opacity:1!important;
  transform:none;
}
.sidebar#leftMenu .tree-toggle:hover{
  border-color:rgba(100,202,255,.48)!important;
  background:rgba(100,202,255,.18)!important;
  color:var(--blue)!important;
}
.sidebar#leftMenu .tree-toggle.is-collapsed{
  transform:rotate(-90deg)!important;
}
.sidebar#leftMenu .tree-toggle-spacer{
  cursor:default!important;
  background:transparent!important;
  border-color:transparent!important;
}

.sidebar#leftMenu .tree-link{
  display:inline-flex!important;
  align-items:center;
  min-height:31px;
  max-width:100%;
  padding:7px 10px;
  color:#dcefff;
  text-decoration:none;
  border:1px solid transparent;
  border-radius:12px;
  background:transparent;
  box-shadow:none!important;
  transform:none!important;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
.sidebar#leftMenu .tree-link:hover{
  color:var(--blue);
  border-color:rgba(100,202,255,.18);
  background:#172638;
}
.sidebar#leftMenu .tree-link.active,
.sidebar#leftMenu .tree-link[aria-current="page"]{
  color:#fff;
  border-color:rgba(246,195,67,.35);
  background:linear-gradient(90deg,rgba(246,195,67,.14),rgba(100,202,255,.08));
}
.sidebar#leftMenu .tree-label{
  display:inline-block;
  max-width:460px;
  overflow:hidden;
  text-overflow:ellipsis;
  vertical-align:middle;
}
.sidebar#leftMenu .tree-item.depth-2{margin-left:16px}
.sidebar#leftMenu .tree-item.depth-3{margin-left:32px}
.sidebar#leftMenu .tree-children{display:block!important}
.sidebar#leftMenu .tree-children.is-hidden,
.sidebar#leftMenu .tree-children-default-hidden{display:none!important}
.sidebar#leftMenu .tree-children.is-open,
.sidebar#leftMenu .tree-children-default-hidden.is-open{display:block!important}

/* Restore admin menu button in left menu */
.sidebar#leftMenu .side-admin{
  display:inline-flex!important;
  align-items:center!important;
  justify-content:center!important;
  gap:6px;
  min-height:36px!important;
  min-width:110px!important;
  margin-top:16px;
  padding:8px 13px!important;
  color:var(--yellow)!important;
  text-decoration:none!important;
  font-weight:850!important;
  font-size:13px!important;
  line-height:1.15!important;
  white-space:nowrap!important;
  border:1px solid rgba(246,195,67,.32)!important;
  border-radius:999px!important;
  background:linear-gradient(180deg,rgba(66,48,12,.78),rgba(37,31,17,.92))!important;
  box-shadow:0 8px 18px rgba(0,0,0,.16)!important;
  visibility:visible!important;
  opacity:1!important;
}
.sidebar#leftMenu .side-admin:hover{
  color:#fff!important;
  border-color:rgba(246,195,67,.62)!important;
  background:linear-gradient(180deg,rgba(88,63,14,.88),rgba(45,37,18,.96))!important;
}

/* Hard isolation from image viewer/editor/sitemap global rules */
.sidebar#leftMenu img,
.sidebar#leftMenu figure,
.sidebar#leftMenu .image,
.sidebar#leftMenu .wiki-previewable-image{
  max-width:none!important;
  max-height:none!important;
  width:auto!important;
  height:auto!important;
  box-shadow:none!important;
  transform:none!important;
  cursor:inherit!important;
}

@media(max-width:900px){
  .sidebar#leftMenu{
    position:relative;
    width:100%!important;
    max-width:none!important;
    max-height:45vh;
    border-right:0;
    border-bottom:1px solid var(--line);
    overflow:auto!important;
  }
  .sidebar#leftMenu .tree-row{white-space:normal}
  .sidebar#leftMenu .tree-link{white-space:normal}
  .sidebar#leftMenu .tree-label{max-width:100%}
  .sidebar#leftMenu .tree-item.depth-2{margin-left:12px}
  .sidebar#leftMenu .tree-item.depth-3{margin-left:24px}
}
