/* Navigation: sidebar, rail + flyout, top bar, palette (WORK-1053).
 *
 * `--sidebar-width` is redefined per layout rather than replaced by a new
 * variable, so every existing rule that positions content against the
 * navigation follows automatically -- `#content { margin-left }` in main.css
 * and `#sidebar { width }` in sidebar.css both keep working untouched.
 */

:root {
  --nav-flyout-width: 236px;
  --rail-labeled-width: 212px;
  --nav-effective-rail-width: var(--rail-width);
  --nav-row-min: 44px; /* minimum touch target (§2.1 item 7) */
}

:root[data-nav-labels='true'] {
  --nav-effective-rail-width: var(--rail-labeled-width);
}

:root[data-nav-layout='rail_flyout'],
:root[data-nav-layout='rail_hubs'] {
  --sidebar-width: var(--nav-effective-rail-width);
}

/* A pinned flyout takes space rather than overlaying: it is meant to behave
 * like the sidebar layout for one module at a time. A preview or a plain open
 * flyout overlays, so peeking never reflows the page under the pointer. */
:root[data-nav-layout='rail_flyout'][data-nav-pinned='true'] {
  --sidebar-width: calc(var(--nav-effective-rail-width) + var(--nav-flyout-width));
}

:root:is([data-nav-layout='rail_flyout'], [data-nav-layout='rail_hubs']) #sidebar {
  overflow: visible;
}

/* In the collapsed rail the lockup is the mark alone: at 64px the wordmark
 * has nowhere to go and spills over the top bar beside it. The labels mode
 * has room, so it brings the text back. */
:root:is([data-nav-layout='rail_flyout'], [data-nav-layout='rail_hubs']) .sidebar-logo {
  justify-content: center;
  padding: 14px 8px 12px;
  gap: 0;
}

:root:is([data-nav-layout='rail_flyout'], [data-nav-layout='rail_hubs']) .sidebar-logo-text {
  display: none;
}

:root:is([data-nav-layout='rail_flyout'], [data-nav-layout='rail_hubs']) #sidebar:has(.nav-rail.has-labels) .sidebar-logo {
  justify-content: flex-start;
  padding: 18px 16px 14px;
  gap: 10px;
}

:root:is([data-nav-layout='rail_flyout'], [data-nav-layout='rail_hubs']) #sidebar:has(.nav-rail.has-labels) .sidebar-logo-text {
  display: block;
}

#topbar-host {
  position: fixed;
  top: 0;
  left: var(--sidebar-width);
  right: 0;
  height: var(--header-height);
  z-index: 60;
}

/* ------------------------------------------------------------- shared -- */

.nav-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  min-height: var(--nav-row-min);
  width: 100%;
  padding: 7px 16px 7px 40px;
  color: var(--gray-400);
  text-decoration: none;
  font-size: 13px;
  text-align: left;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  cursor: pointer;
}

.nav-item:hover {
  background: rgba(255, 255, 255, 0.05);
  color: var(--gray-200);
}

.nav-item.is-active {
  background: color-mix(in srgb, var(--sazi-brand-60) 22%, transparent);
  color: #fff;
  border-left-color: var(--sazi-citrus);
}

.nav-group-label {
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
  padding: 14px 16px 4px;
  font-size: 10px;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--gray-500);
}

/* ---------------------------------------------------- layout A: sidebar -- */

.nav-sidebar {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0 12px;
}

.nav-quick .nav-item,
.nav-item.is-top {
  padding-left: 16px;
}

.nav-item.is-top {
  font-weight: 600;
  color: var(--gray-300);
}

.nav-item.is-top wa-icon {
  color: var(--sazi-brand-40);
  width: 28px;
  flex: none;
  font-size: 22px;
}

.nav-quick .nav-item wa-icon {
  color: var(--sazi-citrus);
  font-size: 12px;
}

.nav-section-header {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--nav-row-min);
  padding: 8px 16px;
  background: none;
  border: 0;
  border-left: 3px solid transparent;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray-300);
  text-align: left;
  cursor: pointer;
}

.nav-section-header:hover {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
}

.nav-section-header wa-icon:first-child {
  color: var(--sazi-brand-40);
  width: 28px;
  flex: none;
  font-size: 22px;
}

.nav-chevron {
  margin-left: auto;
  font-size: 10px;
  color: var(--gray-500);
  transition: transform 0.15s;
}

.nav-section.is-open .nav-chevron {
  transform: rotate(90deg);
}

/* -------------------------------------------------- layout C: rail + flyout -- */

.nav-rail-wrap {
  display: flex;
  flex: 1;
  min-height: 0;
}

.nav-rail {
  width: var(--nav-effective-rail-width);
  flex: none;
  display: flex;
  flex-direction: column;
  align-items: stretch;
  padding: 8px 0 12px;
  min-height: 0;
  overflow: hidden;
}

.nav-rail-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
}

.sidebar-logo,
.nav-rail-tail {
  flex-shrink: 0;
}

.nav-rail-button > wa-icon {
  width: 28px;
  flex: none;
  font-size: 24px;
}

.nav-rail.has-labels .nav-rail-button > wa-icon {
  font-size: 22px;
}

.nav-rail-button.is-small > wa-icon {
  font-size: 18px;
}

.nav-rail-button[hidden] {
  display: none;
}

.nav-rail-modules,
.nav-rail-quick {
  list-style: none;
  margin: 0;
  padding: 0 8px;
}

.nav-rail-quick {
  padding-bottom: 8px;
  margin-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-rail-button {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  width: 100%;
  min-height: var(--nav-row-min);
  margin: 2px 0;
  padding: 0;
  border: 0;
  border-radius: 10px;
  background: none;
  color: #aeb7c6;
  font: inherit;
  font-size: 16px;
  text-decoration: none;
  cursor: pointer;
}

.nav-rail.has-labels .nav-rail-button {
  justify-content: flex-start;
  padding: 0 12px;
  font-size: 13px;
  font-weight: 600;
}

.nav-rail-button:hover {
  background: rgba(255, 255, 255, 0.08);
  color: #fff;
}

.nav-rail-button.is-active,
.nav-rail-button.is-open {
  background: var(--sazi-brand-60);
  color: #fff;
}

.nav-rail-button.is-quick wa-icon {
  color: var(--sazi-citrus);
}

.nav-rail-button.is-small {
  font-size: 13px;
  color: var(--gray-500);
}

.nav-rail-label {
  display: none;
  font-size: 13px;
}

.nav-rail.has-labels .nav-rail-label {
  display: inline;
}

.nav-rail-tail {
  margin-top: auto;
  padding: 8px;
}

.nav-flyout {
  width: var(--nav-flyout-width);
  flex: none;
  display: flex;
  flex-direction: column;
  background: #1b2333;
  color: #d5dbe6;
  border-right: 1px solid rgba(255, 255, 255, 0.08);
  overflow-y: auto;
}

/* Preview and plain open overlay the page; only a pinned flyout takes space. */
.nav-flyout[data-state='preview'],
.nav-flyout[data-state='open'] {
  position: absolute;
  left: var(--nav-effective-rail-width);
  top: 0;
  bottom: 0;
  z-index: 80;
  box-shadow: 0 20px 60px rgba(17, 24, 39, 0.5);
}

/* Inside the narrow-viewport drawer the module's items sit beside the rail
 * as an ordinary column: the drawer itself is the overlay. */
.nav-flyout[data-state='drawer'] {
  position: static;
  width: var(--nav-flyout-width);
  min-height: 100%;
  box-shadow: none;
}

.nav-flyout-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 16px 10px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.nav-flyout-head h2 {
  margin: 0;
  font-size: 15px;
  color: #fff;
}

.nav-flyout-head > wa-icon {
  color: var(--sazi-brand-40);
}

.nav-flyout-pin {
  margin-left: auto;
  min-width: var(--nav-row-min);
  min-height: var(--nav-row-min);
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  /* On the flyout's dark ground the neutral grey reads as absent rather than
     as an unpressed control. */
  color: #8e99ad;
  cursor: pointer;
}

.nav-flyout-pin:hover {
  color: #fff;
}

.nav-flyout-pin[aria-pressed='true'] {
  color: var(--sazi-citrus);
}

.nav-flyout-pin.is-disabled {
  opacity: 0.45;
  cursor: default;
}

.nav-flyout .nav-item {
  padding-left: 16px;
}

.nav-item-row {
  display: flex;
  align-items: center;
}

.nav-star {
  min-width: 32px;
  min-height: var(--nav-row-min);
  display: grid;
  place-items: center;
  background: none;
  border: 0;
  color: #6b788f;
  font-size: 11px;
  cursor: pointer;
}

.nav-star:hover {
  color: #fff;
}

.nav-star.is-on {
  color: var(--sazi-citrus);
}

/* ------------------------------------------- narrow viewports: the drawer -- */
/* Below the breakpoint (§2.1 item 5, audit F2) the navigation host takes no
 * width, the page starts at the left edge, and the whole navigation -- every
 * layout, lockup included -- renders inside a `wa-drawer` opened from the
 * top bar's menu button. Light dismissal, focus containment and focus return
 * are the component's. `data-nav-narrow` is set by the navigation shell from
 * the same media query that drives its state machine, so CSS and behaviour
 * cannot disagree about where the breakpoint is. */

:root[data-nav-narrow='true'] {
  --sidebar-width: 0px;
}

:root[data-nav-narrow='true'] #sidebar {
  width: 0;
  min-width: 0;
  overflow: visible;
  border: 0;
}

/* Sized here rather than in a `style` attribute: the CSP forbids inline style
 * attributes (`style-src-attr 'none'`), and a custom property set in a
 * stylesheet reaches the component's shadow part the same way. */
wa-drawer#nav-drawer {
  --size: min(300px, 88vw);
}

wa-drawer#nav-drawer::part(dialog) {
  background: var(--gray-900);
  color: var(--gray-300);
}

wa-drawer#nav-drawer::part(body) {
  padding: 0;
  display: flex;
  flex-direction: column;
}

/* The lockup inside the drawer has room for its wordmark in every layout. */
:root[data-nav-narrow='true'] #nav-drawer .sidebar-logo {
  justify-content: flex-start;
  padding: 18px 16px 14px;
  gap: 10px;
}

:root[data-nav-narrow='true'] #nav-drawer .sidebar-logo-text {
  display: block;
}

.nav-rail-wrap.is-narrow {
  --nav-effective-rail-width: var(--rail-width);
  height: auto;
  flex: 1;
  min-height: 0;
}

.nav-rail-wrap.is-narrow .nav-rail {
  overflow-x: hidden;
}

.nav-rail-wrap.is-narrow:has(.nav-rail.has-labels) {
  --nav-effective-rail-width: var(--rail-labeled-width);
}

.topbar-menu {
  display: none;
  align-items: center;
  justify-content: center;
  width: 40px;
  min-height: var(--nav-row-min);
  border: 0;
  border-radius: 8px;
  background: none;
  color: var(--sazi-ink);
  font-size: 18px;
  cursor: pointer;
}

.topbar-menu:hover {
  background: var(--gray-100);
}

:root[data-nav-narrow='true'] .topbar-menu {
  display: flex;
}

/* A 390px top bar has no room for a breadcrumb, a 280px search pill and a
 * tenant name side by side; the search pill becomes its icon and the crumb
 * yields to the page's own heading. */
:root[data-nav-narrow='true'] .topbar {
  gap: 6px;
  padding: 0 10px;
}

:root[data-nav-narrow='true'] .topbar-crumb {
  display: none;
}

:root[data-nav-narrow='true'] .topbar-goto {
  width: auto;
  min-width: var(--nav-row-min);
  justify-content: center;
  padding: 7px 10px;
}

:root[data-nav-narrow='true'] .topbar-goto span,
:root[data-nav-narrow='true'] .topbar-goto kbd {
  display: none;
}

:root[data-nav-narrow='true'] .tenant-label {
  max-width: 96px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* ------------------------------------------------------------- top bar -- */

.topbar {
  height: 100%;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 0 20px;
  background: #fff;
  border-bottom: 1px solid var(--gray-200);
}

.topbar-crumb {
  font-size: 13px;
  color: var(--gray-500);
}

.topbar-goto {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 10px;
  width: 280px;
  min-height: 36px;
  padding: 7px 12px;
  border: 1px solid var(--gray-200);
  border-radius: 999px;
  background: var(--gray-50);
  color: var(--gray-500);
  font: inherit;
  font-size: 13px;
  cursor: pointer;
}

.topbar-goto kbd {
  margin-left: auto;
  padding: 1px 6px;
  border: 1px solid var(--gray-200);
  border-radius: 5px;
  background: #fff;
  font: 500 11px var(--sazi-font-mono);
  color: var(--gray-700);
}

.topbar-tenant {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
}

.topbar-avatar {
  width: 32px;
  height: 32px;
  border: 0;
  border-radius: 50%;
  background: var(--sazi-ink);
  color: #fff;
  font: 700 12px var(--sazi-font-display);
  cursor: pointer;
}

.topbar-user {
  position: relative;
}

.avatar-menu {
  position: absolute;
  right: 0;
  top: 40px;
  width: 260px;
  background: #fff;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  z-index: 90;
}

.avatar-menu[hidden] {
  display: none;
}

/* The notifications panel was styled for the retired sidebar-footer bell
 * (sidebar.css: `bottom: 28px`), so from the top bar it opened above the
 * viewport. Anchor it below the bell the way the avatar menu is (WORK-1084). */
.topbar .notif-panel {
  top: 40px;
  bottom: auto;
  left: auto;
  right: 0;
  width: 300px;
  max-width: calc(100vw - 32px);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
  z-index: 90;
}

@media (max-width: 899px) {
  .topbar .notif-panel {
    position: fixed;
    top: calc(var(--header-height) + 4px);
    left: 16px;
    right: 16px;
    width: auto;
    max-width: none;
  }
}

.avatar-menu-head {
  padding: 12px 14px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 12px;
  color: var(--gray-500);
}

.avatar-menu-item {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  min-height: var(--nav-row-min);
  padding: 9px 14px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13px;
  text-align: left;
  cursor: pointer;
}

.avatar-menu-item:hover {
  background: var(--gray-50);
}

.avatar-menu-separator {
  height: 1px;
  background: var(--gray-200);
}

/* --------------------------------------------------------- Go to… ------- */

.go-to-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 90px;
  background: rgba(17, 24, 39, 0.42);
  z-index: 200;
}

.go-to-panel {
  width: min(620px, calc(100vw - 32px));
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 40px 100px rgba(17, 24, 39, 0.4);
  overflow: hidden;
}

.go-to-input-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--gray-200);
}

.go-to-input {
  flex: 1;
  border: 0;
  outline: 0;
  font: 500 16px var(--sazi-font-body);
  color: var(--sazi-ink);
}

.go-to-results {
  max-height: 340px;
  overflow-y: auto;
}

.go-to-group {
  margin: 0;
  padding: 10px 18px 4px;
  font-size: 10.5px;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gray-500);
}

.go-to-row {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  min-height: var(--nav-row-min);
  padding: 9px 18px;
  border: 0;
  background: none;
  font: inherit;
  font-size: 13.5px;
  text-align: left;
  cursor: pointer;
}

.go-to-row.is-selected,
.go-to-row:hover {
  background: var(--sazi-brand-05);
}

.go-to-row-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 12px;
}

.go-to-row-context {
  margin-left: auto;
  font-size: 12px;
  color: var(--gray-500);
}

.go-to-empty {
  padding: 18px;
  margin: 0;
  color: var(--gray-500);
  font-size: 13px;
}

.go-to-foot {
  display: flex;
  gap: 16px;
  padding: 10px 18px;
  border-top: 1px solid var(--gray-200);
  font-size: 11.5px;
  color: var(--gray-500);
}

.go-to-foot kbd {
  margin-right: 4px;
  padding: 0 5px;
  border: 1px solid var(--gray-200);
  border-radius: 4px;
  font: 500 10.5px var(--sazi-font-mono);
}

.go-to-scope {
  margin-left: auto;
}

/* ------------------------------------------------------------ dialogs --- */

.nav-dialog-lead {
  margin: 0 0 12px;
  color: var(--gray-500);
  font-size: 12.5px;
}

.nav-customize-row {
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: var(--nav-row-min);
  padding: 8px 6px;
  border-bottom: 1px solid var(--gray-200);
  font-size: 13.5px;
}

.nav-customize-row.is-dragging {
  background: var(--sazi-brand-05);
  border: 1px dashed var(--sazi-brand-60);
  border-radius: 8px;
}

/* Not `is-hidden`: that class is the reserved display:none utility, and a
 * hidden module's row stays visible, only dimmed and struck through. */
.nav-customize-row.is-module-hidden {
  opacity: 0.5;
}

.nav-customize-row.is-module-hidden .nav-customize-name {
  text-decoration: line-through;
}

.nav-customize-grip {
  color: var(--gray-400);
  cursor: grab;
}

.nav-customize-icon {
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border-radius: 7px;
  background: var(--sazi-brand-05);
  color: var(--sazi-brand-60);
  font-size: 12px;
}

.nav-customize-name {
  font-weight: 600;
}

.nav-customize-count {
  color: var(--gray-500);
  font-size: 12px;
}

.nav-customize-actions {
  margin-left: auto;
  display: flex;
  gap: 4px;
}

.nav-pref {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 12px 6px;
  border-bottom: 1px solid var(--gray-200);
}

.nav-pref:last-of-type {
  border-bottom: 0;
}

.nav-pref > div:first-child {
  flex: 1;
}

.nav-pref b {
  display: block;
  font-size: 13.5px;
}

.nav-pref span {
  display: block;
  color: var(--gray-500);
  font-size: 12.5px;
  line-height: 1.4;
}

.nav-dialog-foot {
  display: flex;
  align-items: center;
  gap: 12px;
  padding-top: 12px;
  color: var(--gray-500);
  font-size: 12.5px;
}

.nav-dialog-foot > span:first-child {
  margin-right: auto;
}

/* ------------------------------------------------------------- density -- */

:root[data-density='compact'] {
  --nav-row-min: 36px;
}

@media (prefers-reduced-motion: reduce) {
  .nav-chevron {
    transition: none;
  }
}

/* ------------------------------------------------------- module hubs ---- */

.module-hub {
  max-width: var(--app-content-max);
  padding: 26px 32px 32px;
}

.module-hub-head {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 20px;
}

.module-hub-icon {
  display: grid;
  place-items: center;
  width: 46px;
  height: 46px;
  border-radius: 12px;
  background: var(--sazi-ink);
  color: var(--sazi-citrus);
  font-size: 20px;
}

.module-hub-head h1 {
  margin: 0;
  font-size: 28px;
}

.module-hub-lead {
  margin: 2px 0 0;
  color: var(--gray-500);
}

.module-hub-group {
  margin-bottom: 20px;
}

.module-hub-group-name {
  margin: 0 0 8px;
  font-family: var(--sazi-font-body);
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.2em;
  text-transform: uppercase;
  color: var(--gray-500);
}

.module-hub-tiles {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px;
}

.module-hub-tile {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 12px;
  min-height: var(--nav-row-min);
  padding: 12px 14px;
  border: 1px solid var(--gray-200);
  border-radius: 10px;
  background: #fff;
  color: inherit;
  text-decoration: none;
  cursor: pointer;
}

.module-hub-tile:hover {
  border-color: var(--sazi-brand-60);
  box-shadow: 0 6px 18px rgba(49, 93, 228, 0.12);
}

.module-hub-tile-body {
  flex: 1;
  min-width: 0;
}

.module-hub-tile b {
  display: block;
  font-size: 13.5px;
}

.module-hub-tile span {
  display: block;
  color: var(--gray-500);
  font-size: 12px;
  line-height: 1.35;
}

.module-hub-star {
  flex: none;
  display: grid;
  place-items: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 7px;
  background: none;
  color: var(--gray-300);
  font-size: 11px;
  cursor: pointer;
}

.module-hub-star:hover {
  color: var(--gray-500);
}

.module-hub-star.is-on {
  color: #c7b71a;
}

/* WORK-359 — Oppi onboarding support banner, under the top bar. */
.support-access-banner {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px 12px;
  padding: 8px 24px;
  background: var(--wa-color-warning-95, #fff5e3);
  color: var(--wa-color-warning-30, #6b4100);
  border-bottom: 1px solid var(--wa-color-warning-80, #f2d39b);
  font-size: 13px;
}
.support-access-banner a {
  color: inherit;
  font-weight: 600;
}
