/* WPSNA app frame, built on FluentLayout (header, side menu, content, footer).
   Do not hard-code colors here; reference design tokens from wpsi-fluent-theme.css.

   The frame always renders (anonymous marketing visitors included): the side menu holds page
   navigation and the header's end slot holds the account / sign-in controls.

   Fluent's layout styles load after this file, so rules that replace them name the layout class too. */

.fluent-layout.wps-shell {
  height: 100dvh;
}

/* —— Header —— */
.fluent-layout .fluent-layout-item.wps-shell-topbar {
  display: block;
  padding: 0;
  background: var(--neutral-layer-3);
  color: var(--neutral-foreground-rest);
  border-bottom: 1px solid var(--neutral-stroke-rest);
  box-shadow: 0 1px 0 rgb(0 0 0 / 18%);
}

.fluent-layout .wps-shell-topbar .wps-shell-hamburger {
  fill: currentColor;
}

.fluent-layout .wps-shell-topbar .wps-shell-hamburger:hover {
  background-color: var(--neutral-fill-stealth-hover);
}

.fluent-layout[mobile] .wps-shell-collapse {
  display: none;
}
.wps-shell-header {
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  column-gap: 1rem;
  row-gap: 0.5rem;
  padding: 0.55rem 1rem;
  width: 100%;
  box-sizing: border-box;
}

.wps-shell-header-start {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  min-width: 0;
  gap: 0.75rem;
  overflow: hidden;
}

.wps-shell-header-end {
  display: flex;
  flex-direction: row;
  flex-wrap: nowrap;
  align-items: center;
  justify-content: flex-end;
  gap: 0.75rem;
  min-width: 0;
}

/* —— Brand (logo + name + subtitle), links to home —— */
.wps-shell-brand-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  min-width: 0;
  text-decoration: none;
  color: inherit;
}

.wps-shell-logo {
  display: block;
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  object-fit: contain;
  background: transparent;
  filter: drop-shadow(0 2px 8px color-mix(in srgb, var(--wpsi-accent) 40%, transparent));
}

.wps-shell-brand-text {
  display: flex;
  flex-direction: column;
  justify-content: center;
  min-width: 0;
  overflow: hidden;
}

.wps-shell-brand {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.wps-shell-subtitle {
  display: block;
  font-size: 0.75rem;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  color: var(--neutral-foreground-hint);
}

/* —— Account profile menu in the header end slot —— */
.wps-profile-content {
  display: flex;
  flex-direction: column;
  gap: 0.6rem;
  min-width: 15rem;
  padding: 0.25rem;
}

.wps-profile-identity {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  max-width: 20rem;
}

.wps-profile-name {
  font-weight: 600;
  overflow-wrap: anywhere;
}

.wps-profile-detail {
  font-size: 0.8rem;
  color: var(--neutral-foreground-hint);
}

.wps-profile-form {
  margin: 0;
}

/* Signed-in profile button. Fluent's component stylesheet also styles it, but that file is loaded under an
   unversioned address, and a browser holding an older copy shows a square default button. */
.wps-shell-header-end .fluent-profile-menu > button {
  appearance: none;
  display: inline-flex;
  align-items: center;
  padding: 0;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: inherit;
  cursor: pointer;
}

/* Plain links and buttons, so they look and work the same without any component script */
.wps-profile-action {
  display: flex;
  align-items: center;
  justify-content: center;
  box-sizing: border-box;
  width: 100%;
  min-height: 2rem;
  padding: 0.35rem 0.75rem;
  border-radius: 6px;
  border: 1px solid var(--neutral-stroke-rest, #555);
  background: transparent;
  color: var(--neutral-foreground-rest, #f0f0f5);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
}

.wps-profile-action:hover,
.wps-profile-action:focus-visible {
  color: var(--neutral-foreground-rest, #f0f0f5);
  background: var(--neutral-fill-stealth-hover, #333);
  text-decoration: none;
}

.wps-profile-action--primary,
.wps-profile-action--primary:hover,
.wps-profile-action--primary:focus-visible {
  border-color: transparent;
  background: #5c56ca;
  color: #fff;
}

.wps-profile-action--primary:hover,
.wps-profile-action--primary:focus-visible {
  filter: brightness(1.12);
}

/* Round button and popover used when signed out and on statically rendered pages */
.wps-profile-toggle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--neutral-stroke-rest, #555);
  background: transparent;
  color: inherit;
  cursor: pointer;
  font-size: 0.8rem;
  font-weight: 600;
}

/* A popover opens in the top layer; pin it under the header's right end. */
.wps-profile-panel {
  position: fixed;
  inset: 3.5rem 1rem auto auto;
  margin: 0;
  padding: 0.75rem;
  border-radius: 8px;
  border: 1px solid var(--neutral-stroke-rest, #555);
  background: var(--neutral-layer-2, #1f1f23);
  color: var(--neutral-foreground-rest, #f0f0f5);
  box-shadow: 0 8px 24px rgb(0 0 0 / 40%);
}

/* —— Side menu —— */
.fluent-layout .fluent-layout-item.wps-shell-nav-area {
  min-width: 0;
  min-height: 0;
  overflow-x: hidden;
  background: var(--wpsi-surface-elevated);
  border-right: 1px solid var(--neutral-stroke-rest);
}

.wps-shell-sidebar {
  min-width: 0;
  overflow-x: hidden;
}
/* —— Sidebar nav (NavLink rows; replaces FluentNav/FluentNavItem) —— */
.wps-shell-nav-list {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  padding: 0.35rem 0;
}

.wps-shell-nav-link {
  display: flex;
  flex-direction: row;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 0.85rem;
  margin: 0 0.35rem;
  border-radius: 6px;
  text-decoration: none;
  color: var(--neutral-foreground-rest);
  line-height: 1.25;
  min-width: 0;
}

.wps-shell-nav-link:hover,
.wps-shell-nav-link:focus-visible {
  color: var(--neutral-foreground-hover);
  background-color: var(--neutral-fill-stealth-hover);
}

.wps-shell-nav-link.active {
  color: var(--wpsi-accent-light);
  background-color: var(--neutral-fill-stealth-hover);
  font-weight: 600;
}

.wps-shell-nav-label {
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.wps-shell-nav-link--back {
  margin-bottom: 0.35rem;
  font-weight: 600;
}

.wps-shell-nav-group-title {
  margin: 0.85rem 0.35rem 0.25rem;
  padding: 0 0.5rem;
  font-size: 0.68rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: var(--neutral-foreground-hint);
}

.wps-shell-nav-group-toggle {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  width: calc(100% - 0.7rem);
  margin: 0.85rem 0.35rem 0.25rem;
  padding: 0.15rem 0.5rem;
  border: 0;
  background: transparent;
  text-align: left;
  cursor: pointer;
  color: var(--neutral-foreground-hint);
}

.wps-shell-nav-group-toggle:hover,
.wps-shell-nav-group-toggle:focus-visible {
  color: var(--neutral-foreground-hover);
}

.wps-shell-nav-link--branch {
  width: calc(100% - 0.7rem);
  border: 0;
  background: transparent;
  cursor: pointer;
  text-align: left;
  font: inherit;
}

.wps-shell-nav-link--nested {
  padding-left: 2.15rem;
}

.wps-shell-nav-branch-chevron {
  margin-left: auto;
  flex-shrink: 0;
}

.wps-shell-sidebar--collapsed .wps-shell-nav-group-title,
.wps-shell-sidebar--collapsed .wps-shell-nav-group-toggle {
  display: none;
}

/* Legacy FluentNav token aliases (sidebar surface) */
.wps-shell-sidebar .fluent-nav,
.wps-shell-sidebar .fluent-navitem,
.wps-shell-sidebar .fluent-navcategoryitem,
.wps-shell-sidebar .wps-shell-nav-link {
  --nav-bg-color: transparent;
  --nav-bg-color-hover: var(--neutral-fill-stealth-hover);
}

/* —— FluentNav sidebar: purple category accent + visible icons —— */
.wps-shell-sidebar {
  --wps-nav-category-accent: #7c3aed;
  --wps-nav-category-accent-soft: rgba(124, 58, 237, 0.12);
}

/* Category header rows (top-level groups and nested branches) get the purple accent.
   The FluentNav bundle sets the title color to a neutral token at the same specificity,
   so we qualify with .fluent-nav (extra class) to make the TEXT win too — matching the
   chevron/icon color. */
.wps-shell-sidebar .fluent-nav .fluent-navcategoryitem,
.wps-shell-sidebar .fluent-nav .fluent-navcategoryitem > * {
  color: var(--wps-nav-category-accent);
  font-weight: 600;
}

.wps-shell-sidebar .fluent-nav .fluent-navcategoryitem:hover {
  background: var(--wps-nav-category-accent-soft);
}

/* Tint the icon + chevron on category headers to match the accent. */
.wps-shell-sidebar .fluent-nav .fluent-navcategoryitem svg,
.wps-shell-sidebar .fluent-nav .fluent-navcategoryitem > .expand-icon {
  color: var(--wps-nav-category-accent);
  fill: currentColor;
}

/* Leaf items are FluentNav sub-items (text-only by default), so we render the icon inside
   the item content via .wps-nav-leaf. Lay it out as an icon + label row. */
.wps-shell-sidebar .wps-nav-leaf {
  display: inline-flex;
  align-items: center;
  gap: 0.6rem;
  min-width: 0;
}

.wps-shell-sidebar .wps-nav-leaf svg {
  width: 20px;
  height: 20px;
  flex: 0 0 auto;
}

.wps-shell-sidebar .wps-nav-leaf-text {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* Sub-items default to a deep 46px text indent (to clear the parent icon). Now that leaf
   items carry their own icon, pull that back so icons align under the category. */
.wps-shell-sidebar .fluent-nav .fluent-navsubitemgroup:has(.fluent-navsubitem) .fluent-navsubitem {
  padding-inline-start: 16px;
}

/* Selected item: FluentNav only adds an "active" class (semibold + a thin bar that the sidebar
   padding hides), which is easy to miss. Give the current page a filled row, an accent bar on
   the leading edge and accent-colored text/icon, matching the collapsed-rail .active style. */
.wps-shell-sidebar .fluent-nav .fluent-navitem.active,
.wps-shell-sidebar .fluent-nav .fluent-navsubitem.active {
  background-color: var(--wps-nav-category-accent-soft);
  box-shadow: inset 3px 0 0 var(--wps-nav-category-accent);
  color: var(--wpsi-accent-light);
  font-weight: 600;
}

.wps-shell-sidebar .fluent-nav .fluent-navitem.active:after,
.wps-shell-sidebar .fluent-nav .fluent-navsubitem.active:after {
  display: none;
}

.wps-shell-sidebar .fluent-nav .fluent-navitem.active > *,
.wps-shell-sidebar .fluent-nav .fluent-navsubitem.active > *,
.wps-shell-sidebar .fluent-nav .fluent-navitem.active .wps-nav-leaf,
.wps-shell-sidebar .fluent-nav .fluent-navsubitem.active .wps-nav-leaf {
  color: inherit;
}

.wps-shell-sidebar .fluent-nav .fluent-navitem.active:hover,
.wps-shell-sidebar .fluent-nav .fluent-navsubitem.active:hover {
  background-color: var(--wps-nav-category-accent-soft);
}

/* —— Collapsed sidebar: icon-only, pinned to the left —— */
.wps-shell-sidebar--collapsed .wps-shell-nav-list {
  overflow: hidden;
}

.wps-shell-sidebar--collapsed .wps-shell-nav-link {
  justify-content: flex-start;
  gap: 0;
  padding-left: 0.85rem;
  padding-right: 0;
  white-space: nowrap;
  font-size: 0;
}

.wps-shell-sidebar--collapsed .wps-shell-nav-link svg {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  font-size: 20px;
}

.wps-shell-sidebar--collapsed .wps-shell-nav-label {
  display: none;
}

/* —— Content: breadcrumb bar + scrolling page content —— */
.fluent-layout .fluent-layout-item.wps-shell-body {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
}
.wps-shell-content {
  flex: 1 1 auto;
  min-height: 0;
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
  overflow-x: hidden;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  /* Full-width pages pull back over this padding, so keep these as the one place it is set. */
  --wps-content-pad-x: 0.85rem;
  --wps-content-pad-y: 0.75rem;
  padding: var(--wps-content-pad-y) var(--wps-content-pad-x);
}

/* —— Footer —— */
.fluent-layout .fluent-layout-item.wps-shell-footer-bar {
  display: block;
  padding: 2px 8px;
  text-align: center;
  color: var(--neutral-foreground-rest);
  border-top: 1px solid var(--neutral-stroke-divider);
  background: var(--neutral-layer-2);
}
/* The footer wraps on small screens, so it takes the height it needs. */
.fluent-layout[mobile] .fluent-layout-item.wps-shell-footer-bar {
  height: auto !important;
}

/* —— Narrow screens: brand text drops to just the name; subtitle hides —— */
@media (max-width: 640px) {
  .wps-shell-subtitle {
    display: none;
  }

  .wps-shell-user-name {
    display: none;
  }
}

/* Every "edit" icon button in the app is yellow (billing grids use .billing-icon-edit for the same look). */
fluent-button.wps-icon-edit,
fluent-button.wps-icon-edit svg,
.wps-icon-edit,
.wps-icon-edit svg {
  color: #f5c518;
  fill: currentColor;
}

.wps-icon-edit:hover:not([disabled]) {
  background: rgba(245, 197, 24, 0.16);
}
