/* =========================================================================
   VIYA sidebar
   Self-contained styling for the rebuilt main menu. Loaded after style.css.

   The outer element keeps the template's .sidebar class so page geometry
   (fixed position, the 252px / 86px widths, the mobile slide-in) still comes
   from the template. Everything inside is owned here, so template updates
   cannot fight it.
   ========================================================================= */

/* Sizes here are stated as the whole box. Without this the rail inherits
   whichever reset the page happens to load, and every row grows by its
   padding — the same menu ends up 40% taller than it was drawn. */
.viya-nav,
.viya-nav *,
.viya-nav *::before,
.viya-nav *::after {
  box-sizing: border-box;
}

.viya-nav {
  --nav-w: 252px;
  --nav-w-mini: 86px;
  /* Matches the header height so the brand's bottom border and the header's
     meet as one line across the window. */
  --nav-brand-h: 65px;

  --nav-bg: #ffffff;
  --nav-border: #e8edf3;
  --nav-text: #344054;
  --nav-muted: #98a2b3;
  --nav-icon: #667085;
  --nav-brand: #45234c;
  --nav-brand-soft: rgba(69, 35, 76, 0.07);
  --nav-hover: #f4f6f9;
  --nav-divider: #f1f4f8;
  --nav-field: #f7f9fc;
  --nav-danger: #b42318;
  --nav-danger-soft: rgba(220, 38, 38, 0.08);

  display: flex;
  flex-direction: column;
  background: var(--nav-bg);
  border-right: 1px solid var(--nav-border);
  box-shadow: 8px 0 24px rgba(15, 23, 42, 0.045);

  /* style.css styles the bare `aside` element for an unrelated panel:
     `padding: 24px`, `border-left` and `overflow-y: auto`. The rail is an
     <aside>, so it was picking all three up — a 24px dead band on every
     side (which clipped the active marker and left a gap above the brand)
     and a second scrollbar outside the one on the menu. Class beats
     element, so naming them here is enough to keep them off. */
  padding: 0;
  /* visible, not hidden: the collapse button sits half outside the rail. The
     menu does its own scrolling, so nothing here needs to be clipped. */
  overflow: visible;
  border-left: 0;
}

/* Full height: the rail runs from the top of the window to the bottom.
   The header is not above it — the template hides .header-left and starts
   .header at the rail's edge on desktop, so anything less than top:0 leaves
   a dead rectangle in the corner where the logo used to sit. */
@media (min-width: 991.98px) {
  .viya-nav.sidebar {
    top: 0;
    bottom: 0;
    height: auto;
    min-height: 0;
    max-height: none;
    margin-bottom: 0;
  }
}

/* ---------- brand ---------- */

.viya-nav__brand {
  position: relative;
  display: flex;
  align-items: center;
  flex: 0 0 var(--nav-brand-h);
  height: var(--nav-brand-h);
  padding: 0 16px;
  border-bottom: 1px solid var(--nav-border);
}

.viya-nav__logo {
  display: flex;
  align-items: center;
  min-width: 0;
}

.viya-nav__logo-full {
  max-width: 168px;
  max-height: 42px;
  width: auto;
  object-fit: contain;
}

.viya-nav__logo-mark {
  display: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  object-fit: contain;
}

.viya-nav__collapse {
  position: absolute;
  top: 50%;
  right: -15px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  padding: 0;
  border: 3px solid #ffffff;
  border-radius: 50%;
  background: var(--nav-brand);
  box-shadow: 0 8px 18px rgba(69, 35, 76, 0.22);
  color: #ffffff;
  font-size: 14px;
  line-height: 1;
  transform: translateY(-50%);
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 3;
}

.viya-nav__collapse:hover {
  background: #572d60;
}

/* ---------- filter ---------- */

.viya-nav__search {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  padding: 12px 10px 4px;
  background: var(--nav-bg);
  transition: box-shadow 0.2s ease;
}

/* Tells the eye the list continues above the fold. */
.viya-nav.is-scrolled .viya-nav__search {
  box-shadow: 0 10px 14px -10px rgba(15, 23, 42, 0.22);
}

.viya-nav__search-input {
  width: 100%;
  height: 34px;
  padding: 0 32px;
  border: 1px solid var(--nav-border);
  border-radius: 9px;
  background: var(--nav-field);
  color: var(--nav-text);
  font-family: inherit;
  font-size: 12.5px;
  line-height: 32px;
  transition:
    border-color 0.15s ease,
    background-color 0.15s ease,
    box-shadow 0.15s ease;
}

.viya-nav__search-input::placeholder {
  color: var(--nav-muted);
}

.viya-nav__search-input:focus {
  outline: none;
  border-color: var(--nav-brand);
  background: var(--nav-bg);
  box-shadow: 0 0 0 3px var(--nav-brand-soft);
}

/* Both overlays line up with the input: same offsets, same 34px box. */
.viya-nav__search-icon,
.viya-nav__search-clear {
  position: absolute;
  top: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 34px;
  color: var(--nav-muted);
  font-size: 15px;
  line-height: 1;
  pointer-events: none;
}

.viya-nav__search-icon {
  left: 10px;
}

.viya-nav__search-clear {
  right: 10px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  cursor: pointer;
  pointer-events: auto;
}

.viya-nav__search-clear:hover {
  color: var(--nav-text);
}

.viya-nav__search-clear[hidden] {
  display: none;
}

.viya-nav__empty {
  display: block;
  padding: 22px 12px;
  color: var(--nav-muted);
  font-size: 12.5px;
  line-height: 1.5;
  text-align: center;
}

.viya-nav__empty[hidden] {
  display: none;
}

/* While filtering, whole sections come and go; the rules between them would
   otherwise strand themselves above the first surviving group. */
.viya-nav [hidden] {
  display: none !important;
}

.viya-nav.is-filtering .viya-nav__group + .viya-nav__group,
.viya-nav.is-filtering .viya-nav__list + .viya-nav__group {
  margin-top: 13px;
  padding-top: 0;
  border-top: 0;
}

/* ---------- scroll area ---------- */

.viya-nav__scroll {
  flex: 1 1 auto;
  min-height: 0;
  scroll-padding-top: 10px;
  padding: 12px 10px 6px;
  overflow-x: hidden;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
  scrollbar-color: rgba(69, 35, 76, 0.24) transparent;
}

.viya-nav__scroll::-webkit-scrollbar {
  width: 6px;
}

.viya-nav__scroll::-webkit-scrollbar-track {
  background: transparent;
}

.viya-nav__scroll::-webkit-scrollbar-thumb {
  background: rgba(69, 35, 76, 0.22);
  border-radius: 999px;
}

/* ---------- groups ---------- */

.viya-nav__group + .viya-nav__group,
.viya-nav__list + .viya-nav__group {
  margin-top: 14px;
  padding-top: 14px;
  border-top: 1px solid var(--nav-divider);
}

.viya-nav__group-title {
  margin: 0 0 6px;
  padding: 0 9px;
  color: var(--nav-muted);
  font-size: 10.5px;
  font-weight: 800;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
}

.viya-nav__list,
.viya-nav__sublist {
  margin: 0;
  padding: 0;
  list-style: none;
}

/* ---------- links ---------- */

.viya-nav__link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: inherit;
  line-height: 1.3;
  width: 100%;
  min-height: 38px;
  margin-bottom: 2px;
  padding: 8px 9px;
  border: 0;
  border-radius: 9px;
  background: transparent;
  color: var(--nav-text);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: -0.005em;
  text-align: left;
  text-decoration: none;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.viya-nav__link:hover {
  background: var(--nav-hover);
  color: var(--nav-brand);
}

.viya-nav__link:focus-visible {
  outline: 2px solid var(--nav-brand);
  outline-offset: -2px;
}

.viya-nav__link.is-active {
  background: var(--nav-brand-soft);
  color: var(--nav-brand);
  font-weight: 600;
}

.viya-nav__link.is-active::before {
  content: "";
  position: absolute;
  top: 50%;
  /* Must match the horizontal padding of .viya-nav__scroll. */
  left: -10px;
  width: 3px;
  height: 20px;
  border-radius: 0 3px 3px 0;
  background: var(--nav-brand);
  transform: translateY(-50%);
}

.viya-nav__icon {
  flex: 0 0 18px;
  width: 18px;
  color: var(--nav-icon);
  font-size: 17px;
  line-height: 1;
  text-align: center;
  transition: color 0.15s ease;
}

.viya-nav__link:hover .viya-nav__icon,
.viya-nav__link.is-active .viya-nav__icon {
  color: var(--nav-brand);
}

.viya-nav__label {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* A tinted pill rather than a solid one: several rows can carry a count at
   once, and solid brand pills turn the list into a scoreboard. The count is
   only rendered when it is non-zero, so a badge here always means something. */
.viya-nav__badge {
  flex: 0 0 auto;
  min-width: 20px;
  padding: 1px 6px;
  border-radius: 999px;
  background: var(--nav-brand-soft);
  color: var(--nav-brand);
  font-size: 10.5px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  line-height: 1.6;
  text-align: center;
}

.viya-nav__link.is-active .viya-nav__badge {
  background: var(--nav-brand);
  color: #ffffff;
}

/* ---------- footer ---------- */

.viya-nav__footer {
  position: relative;
  z-index: 1;
  flex: 0 0 auto;
  box-shadow: 0 -10px 14px -10px rgba(15, 23, 42, 0.14);
  padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
  border-top: 1px solid var(--nav-border);
  background: var(--nav-bg);
}

.viya-nav__user {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 6px 8px;
  border-radius: 10px;
  background: var(--nav-hover);
}

.viya-nav__avatar {
  flex: 0 0 32px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #e6ebf2;
  object-fit: cover;
}

.viya-nav__user-meta {
  display: flex;
  flex: 1 1 auto;
  flex-direction: column;
  min-width: 0;
}

.viya-nav__user-name,
.viya-nav__user-role {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.viya-nav__user-name {
  color: var(--nav-text);
  font-size: 12.5px;
  font-weight: 600;
  line-height: 1.3;
}

.viya-nav__user-role {
  color: var(--nav-muted);
  font-size: 11px;
  line-height: 1.35;
  text-transform: capitalize;
}

.viya-nav__logout {
  display: flex;
  flex: 0 0 30px;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: 8px;
  color: var(--nav-icon);
  font-size: 16px;
  line-height: 1;
  text-decoration: none;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.viya-nav__logout:hover {
  background: var(--nav-danger-soft);
  color: var(--nav-danger);
}

.viya-nav__logout:focus-visible {
  outline: 2px solid var(--nav-brand);
  outline-offset: 2px;
}

/* ---------- collapsible section ---------- */

.viya-nav__toggle {
  cursor: pointer;
}

.viya-nav__chevron {
  flex: 0 0 14px;
  width: 14px;
  margin-left: 2px;
  color: var(--nav-muted);
  font-size: 14px;
  text-align: center;
  transition: transform 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.viya-nav__parent.is-open > .viya-nav__toggle .viya-nav__chevron {
  transform: rotate(90deg);
}

/* Height animation without measuring in JavaScript. */
.viya-nav__panel {
  display: grid;
  grid-template-rows: 0fr;
  transition: grid-template-rows 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

.viya-nav__panel > * {
  overflow: hidden;
}

.viya-nav__parent.is-open > .viya-nav__panel {
  grid-template-rows: 1fr;
}

/* Browsers without grid-row animation: fall back to a max-height slide. */
@supports not (grid-template-rows: 0fr) {
  .viya-nav__panel {
    display: block;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.22s cubic-bezier(0.4, 0, 0.2, 1);
  }

  .viya-nav__parent.is-open > .viya-nav__panel {
    max-height: 480px;
  }
}

.viya-nav__sublist {
  position: relative;
  margin: 2px 0 4px;
  padding: 0 0 0 19px;
}

/* Guide line ties the children to the section above them. */
.viya-nav__sublist::before {
  content: "";
  position: absolute;
  top: 4px;
  bottom: 4px;
  left: 9px;
  width: 1px;
  background: var(--nav-border);
}

.viya-nav__sublink {
  display: block;
  padding: 7px 9px;
  border-radius: 8px;
  overflow: hidden;
  color: var(--nav-icon);
  font-size: 13px;
  font-weight: 500;
  text-decoration: none;
  text-overflow: ellipsis;
  white-space: nowrap;
  transition:
    background-color 0.15s ease,
    color 0.15s ease;
}

.viya-nav__sublink:hover {
  background: var(--nav-hover);
  color: var(--nav-brand);
}

.viya-nav__sublink.is-active {
  background: var(--nav-brand-soft);
  color: var(--nav-brand);
  font-weight: 600;
}

/* =========================================================================
   Collapsed rail
   The template sets .sidebar width to 86px under body.mini-sidebar and
   restores 252px while .expand-menu is on (pointer over the sidebar).
   ========================================================================= */

@media (min-width: 991.98px) {
  .mini-sidebar:not(.expand-menu) .viya-nav__logo-full {
    display: none;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__logo-mark {
    display: block;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__brand {
    justify-content: center;
    padding: 0 10px;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__collapse i {
    transform: rotate(180deg);
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__label,
  .mini-sidebar:not(.expand-menu) .viya-nav__badge,
  .mini-sidebar:not(.expand-menu) .viya-nav__chevron {
    display: none;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__group-title {
    height: 1px;
    margin: 10px 8px;
    padding: 0;
    overflow: hidden;
    background: #eef2f6;
    color: transparent;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__link {
    justify-content: center;
    padding: 8px;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__link.is-active::before {
    display: none;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__panel {
    display: none;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__scroll,
  .mini-sidebar:not(.expand-menu) .viya-nav__footer {
    padding-left: 10px;
    padding-right: 10px;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__sublist::before {
    display: none;
  }

  /* The field keeps its box so the rail does not jump on hover; only the
     text and the clear button go, and the icon slides to the middle. */
  .mini-sidebar:not(.expand-menu) .viya-nav__search-input {
    padding: 0;
    font-size: 0;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__search-icon {
    left: 10px;
    right: 10px;
    width: auto;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__search-clear {
    display: none;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__user {
    flex-direction: column;
    gap: 6px;
    padding: 4px 0;
    background: transparent;
  }

  .mini-sidebar:not(.expand-menu) .viya-nav__user-meta {
    display: none;
  }
}

/* =========================================================================
   Dark theme
   ========================================================================= */

[data-theme="dark"] .viya-nav,
[data-layout-mode="dark_mode"] .viya-nav {
  --nav-bg: #0f1621;
  --nav-border: #1f2937;
  --nav-text: #d8dfee;
  --nav-muted: #64748b;
  --nav-icon: #94a3b8;
  --nav-brand: #c9a7d4;
  --nav-brand-soft: rgba(201, 167, 212, 0.12);
  --nav-hover: rgba(255, 255, 255, 0.05);
  --nav-divider: #1b2432;
  --nav-field: rgba(255, 255, 255, 0.04);
  --nav-danger: #f87171;
  --nav-danger-soft: rgba(248, 113, 113, 0.14);

  box-shadow: none;
}

[data-theme="dark"] .viya-nav__link.is-active .viya-nav__badge,
[data-layout-mode="dark_mode"] .viya-nav__link.is-active .viya-nav__badge {
  color: #1a0f1e;
}

[data-theme="dark"] .viya-nav__avatar,
[data-layout-mode="dark_mode"] .viya-nav__avatar {
  background: #1f2937;
}

[data-theme="dark"] .viya-nav.is-scrolled .viya-nav__search,
[data-layout-mode="dark_mode"] .viya-nav.is-scrolled .viya-nav__search {
  box-shadow: 0 10px 14px -10px rgba(0, 0, 0, 0.6);
}

[data-theme="dark"] .viya-nav__collapse,
[data-layout-mode="dark_mode"] .viya-nav__collapse {
  border-color: #0f1621;
  background: #45234c;
  color: #ffffff;
}

/* =========================================================================
   Reduced motion
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
  .viya-nav__link,
  .viya-nav__sublink,
  .viya-nav__chevron,
  .viya-nav__panel,
  .viya-nav__collapse,
  .viya-nav__search,
  .viya-nav__search-input,
  .viya-nav__logout {
    transition: none !important;
  }
}
