/* WPSNA app shell — top header bar, left collapsible FluentNav sidebar, footer bar.
   Source of truth: Wpsna-Web-Site/wwwroot (this file + wpsi-fluent-theme.css tokens).
   Do not hard-code colors here; reference design tokens from wpsi-fluent-theme.css.

   The shell always renders (anonymous marketing visitors included): the sidebar holds page
   navigation and the header's end slot holds the account / sign-in controls. */

/* —— Outer shell: fixed full-height column (header · workspace · footer) —— */
.wps-shell {
  display: flex;
  flex-direction: column;
  height: 100vh;
  min-height: 100vh;
  overflow: hidden;
}

/* —— Top header bar —— */
.wps-shell-topbar {
  position: relative;
  z-index: 200;
  flex: 0 0 auto;
  width: 100%;
  box-sizing: border-box;
  background: var(--neutral-layer-3);
  border-bottom: 1px solid var(--neutral-stroke-rest);
  box-shadow: 0 1px 0 rgb(0 0 0 / 18%);
}

.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 / user chip in the header end slot —— */
.wps-shell-user {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  max-width: 16rem;
  padding: 0.3rem 0.5rem;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  white-space: nowrap;
  overflow: hidden;
}

.wps-shell-user:hover,
.wps-shell-user:focus-visible {
  color: var(--neutral-foreground-hover);
  background-color: var(--neutral-fill-stealth-hover);
}

.wps-shell-user-name {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  font-size: 0.875rem;
  font-weight: 600;
}

.wps-shell-logout-form {
  margin: 0;
  display: inline-flex;
}

/* —— Workspace: sidebar + scrolling body —— */
.wps-shell-workspace {
  display: grid;
  grid-template-columns: var(--wpsi-sidebar-width) minmax(0, 1fr);
  grid-template-rows: minmax(0, 1fr);
  flex: 1 1 auto;
  min-height: 0;
  overflow: hidden;
  align-items: stretch;
}

.wps-shell-workspace--collapsed {
  grid-template-columns: var(--wpsi-sidebar-collapsed-width) minmax(0, 1fr);
}

.wps-shell-sidebar {
  grid-column: 1;
  grid-row: 1;
  min-height: 0;
  min-width: 0;
  overflow-x: hidden;
  overflow-y: auto;
  background: var(--wpsi-surface-elevated);
  border-right: 1px solid var(--neutral-stroke-rest);
}

.wps-shell-sidebar--collapsed {
  width: var(--wpsi-sidebar-collapsed-width);
  min-width: var(--wpsi-sidebar-collapsed-width);
  max-width: var(--wpsi-sidebar-collapsed-width);
}

/* —— 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 .fluent-icon,
.wps-shell-sidebar .fluent-nav .fluent-navcategoryitem fluent-icon,
.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 .fluent-icon,
.wps-shell-sidebar .wps-nav-leaf fluent-icon,
.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;
}

/* —— 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,
.wps-shell-sidebar--collapsed .wps-shell-nav-link fluent-icon,
.wps-shell-sidebar--collapsed .wps-shell-nav-link .fluent-icon {
  flex: 0 0 auto;
  width: 20px;
  height: 20px;
  font-size: 20px;
}

.wps-shell-sidebar--collapsed .wps-shell-nav-label {
  display: none;
}

/* —— Body: breadcrumb bar + scrolling page content —— */
.wps-shell-body {
  grid-column: 2;
  grid-row: 1;
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  overflow: hidden;
  padding: 0;
}

.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;
  padding: 0.75rem 0.85rem;
}

/* —— Footer bar —— */
.wps-shell-footer-bar {
  flex: 0 0 auto;
  width: 100%;
  padding: 2px 8px;
  text-align: center;
  border-top: 1px solid var(--neutral-stroke-divider);
  background: var(--neutral-layer-2);
}

/* —— 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;
  }
}
