/* v2.3.2 — Product category dropdown tree + admin hierarchy sorter */
.vlg-category-dropdown {
  width: min(360px, calc(100vw - 28px));
}
.vlg-cat-tree,
.vlg-cat-tree .vlg-cat-submenu {
  list-style: none;
  margin: 0;
  padding: 0;
}
.vlg-cat-tree .vlg-cat-item {
  position: relative;
  margin: 0;
}
.vlg-cat-tree .vlg-cat-row {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  align-items: center;
  gap: 6px;
}
.vlg-cat-tree .vlg-cat-link {
  min-width: 0;
}
.vlg-cat-tree .vlg-cat-title {
  min-width: 0;
  overflow-wrap: anywhere;
  color: inherit;
  font-size: inherit;
  font-weight: inherit;
}
.vlg-cat-tree .vlg-cat-count {
  flex: 0 0 auto;
  color: var(--vlg-muted, #64748b);
  font-size: 12px;
}
.vlg-cat-subtoggle {
  width: 34px;
  height: 34px;
  display: inline-grid;
  place-items: center;
  border: 1px solid #e4edf6;
  border-radius: 10px;
  background: #fff;
  color: var(--vlg-primary, #f28a00);
  font-size: 16px;
  font-weight: 900;
  cursor: pointer;
  transition: transform .18s ease, background .18s ease, border-color .18s ease;
}
.vlg-cat-subtoggle:hover {
  background: #fff5e8;
  border-color: rgba(242,138,0,.32);
}
.vlg-cat-item.is-sub-open > .vlg-cat-row .vlg-cat-subtoggle span,
.vlg-cat-item:hover > .vlg-cat-row .vlg-cat-subtoggle span {
  transform: rotate(180deg);
}
.vlg-cat-tree .vlg-cat-submenu {
  display: none;
}
.vlg-cat-submenu-mode-inline .vlg-cat-submenu,
.vlg-cat-item.is-sub-open > .vlg-cat-submenu {
  display: grid;
  gap: 5px;
  padding: 4px 0 6px 12px;
  margin: 2px 0 4px 8px;
  border-left: 2px solid rgba(242,138,0,.18);
}
.vlg-cat-submenu .vlg-cat-link {
  font-size: 13px;
  font-weight: 800;
  padding-top: 9px;
  padding-bottom: 9px;
}
.vlg-cat-depth-1 .vlg-cat-title::before,
.vlg-cat-depth-2 .vlg-cat-title::before,
.vlg-cat-depth-3 .vlg-cat-title::before,
.vlg-cat-depth-4 .vlg-cat-title::before {
  content: "↳ ";
  color: var(--vlg-primary, #f28a00);
}

@media (min-width: 783px) {
  .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:hover > .vlg-cat-submenu,
  .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:focus-within > .vlg-cat-submenu {
    display: grid;
    gap: 6px;
    position: absolute;
    left: calc(100% + 10px);
    top: 0;
    width: min(310px, calc(100vw - 420px));
    min-width: 250px;
    max-height: min(72vh, 520px);
    overflow: auto;
    padding: 10px;
    margin: 0;
    border: 1px solid var(--vlg-line, #e4eaf2);
    border-radius: 16px;
    background: #fff;
    box-shadow: var(--vlg-shadow, 0 18px 45px rgba(15,23,42,.14));
    z-index: 82;
  }
  .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:hover > .vlg-cat-row .vlg-cat-link,
  .vlg-cat-submenu-mode-accordion .vlg-cat-item.has-children:focus-within > .vlg-cat-row .vlg-cat-link {
    background: #fff5e8;
    color: var(--vlg-primary, #f28a00);
  }
}

@media (max-width: 782px) {
  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-row {
    grid-template-columns: minmax(0, 1fr) 42px;
    gap: 8px;
  }
  body.vlg-theme .vlg-nav.is-open .vlg-cat-subtoggle {
    width: 42px;
    height: 42px;
    border-radius: 14px;
    background: #fff7ed;
  }
  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-submenu {
    position: static;
    width: auto;
    max-height: none;
    box-shadow: none;
    border: 0;
  }
  body.vlg-theme .vlg-nav.is-open .vlg-cat-submenu-mode-inline .vlg-cat-submenu,
  body.vlg-theme .vlg-nav.is-open .vlg-cat-item.is-sub-open > .vlg-cat-submenu {
    display: grid !important;
    gap: 6px;
    margin: 7px 0 7px 14px !important;
    padding: 0 0 0 10px !important;
    border-left: 2px solid rgba(242,138,0,.24);
  }
  body.vlg-theme .vlg-nav.is-open .vlg-cat-tree .vlg-cat-submenu a {
    min-height: 44px !important;
    font-size: 13.5px !important;
    background: #fffaf3 !important;
  }
}

.vlg-admin-mini-callout {
  padding: 14px;
  border: 1px solid #dbe6f2;
  border-radius: 14px;
  background: linear-gradient(135deg, #fff 0%, #f8fafc 100%);
}
.vlg-admin-mini-callout .button {
  width: fit-content;
  margin-top: 8px;
}
.vlg-category-tree-sorter-field {
  grid-column: 1 / -1;
}
.vlg-category-tree-toolbar {
  display: grid;
  grid-template-columns: minmax(260px, 1fr) auto;
  gap: 12px;
  align-items: end;
  margin: 8px 0 12px;
}
.vlg-category-tree-toolbar label {
  display: grid;
  gap: 6px;
  margin: 0;
}
.vlg-category-tree-toolbar select {
  max-width: 440px;
}
.vlg-category-tree-actions {
  display: flex;
  gap: 8px;
  justify-content: flex-end;
  flex-wrap: wrap;
}
.vlg-category-tree-sorter {
  display: grid;
  gap: 8px;
  max-height: 560px;
  overflow: auto;
  margin: 0;
  padding: 12px;
  border: 1px solid #d8e3ef;
  border-radius: 16px;
  background: #f8fafc;
}
.vlg-category-tree-row {
  display: grid;
  grid-template-columns: 30px minmax(0, 1fr);
  align-items: center;
  gap: 9px;
  margin: 0;
  padding: 11px 12px;
  border: 1px solid #dbe6f2;
  border-radius: 14px;
  background: #fff;
  cursor: grab;
  box-shadow: 0 6px 16px rgba(15, 23, 42, .035);
}
.vlg-category-tree-row.is-hidden-by-filter {
  display: none;
}
.vlg-category-tree-row.is-dragging {
  opacity: .55;
  cursor: grabbing;
}
.vlg-category-tree-row .dashicons-move {
  color: var(--vlg-primary, #f28a00);
  cursor: grab;
}
.vlg-category-tree-row label {
  display: flex;
  align-items: center;
  min-width: 0;
  gap: 10px;
  margin: 0;
}
.vlg-cat-admin-main {
  display: grid;
  min-width: 0;
  gap: 3px;
}
.vlg-cat-admin-main strong {
  overflow-wrap: anywhere;
}
.vlg-cat-admin-main small {
  color: #64748b;
}
.vlg-category-tree-row.has-children {
  border-color: rgba(242,138,0,.28);
  background: linear-gradient(135deg, #fff 0%, #fffaf3 100%);
}
.vlg-category-tree-row[data-depth="1"] { margin-left: 22px; }
.vlg-category-tree-row[data-depth="2"] { margin-left: 44px; }
.vlg-category-tree-row[data-depth="3"] { margin-left: 66px; }
.vlg-category-tree-row[data-depth="4"] { margin-left: 88px; }
.vlg-category-tree-row[data-depth]:not([data-depth="0"]) .vlg-cat-admin-main strong::before {
  content: "↳ ";
  color: var(--vlg-primary, #f28a00);
}
@media (max-width: 900px) {
  .vlg-category-tree-toolbar {
    grid-template-columns: 1fr;
  }
  .vlg-category-tree-actions {
    justify-content: flex-start;
  }
  .vlg-category-tree-row[data-depth="1"] { margin-left: 10px; }
  .vlg-category-tree-row[data-depth="2"] { margin-left: 20px; }
  .vlg-category-tree-row[data-depth="3"] { margin-left: 30px; }
  .vlg-category-tree-row[data-depth="4"] { margin-left: 40px; }
}
@media (max-width: 560px) {
  .vlg-category-tree-row {
    grid-template-columns: 24px minmax(0, 1fr);
  }
  .vlg-category-tree-row label {
    align-items: flex-start;
  }
  .vlg-cat-admin-main small {
    font-size: 11px;
  }
}
