/* ==========================================================================
   Portanus shell — PR2 of the console redesign (app-shell layer).

   Builds on the PR1 token layer (portanus-theme.css). Restyles the Falcon
   vertical sidebar into grouped, collapsible <details> sections, adds the
   ⌘K command-palette trigger, a sidebar footer, and the command-palette
   overlay. Structure/markup changes live in base/navbar_*.html +
   base/command_palette.html; this file is the styling.

   Loaded AFTER portanus-theme.css so it can lean on the --pt-* tokens.
   ========================================================================== */

/* ---- Sidebar shell -------------------------------------------------------- */

.navbar-vertical .navbar-vertical-content { padding: 0 .6rem .5rem; }

/* Brand row a touch tighter, brand wordmark uses the brand ink. */
.navbar-vertical .navbar-brand .font-sans-serif { letter-spacing: .02em; }

/* ⌘K trigger bar (sidebar) — opens the command palette. */
.pt-kbar {
  display: flex;
  align-items: center;
  gap: .5rem;
  width: 100%;
  margin: .1rem 0 .75rem;
  padding: .5rem .65rem;
  font-size: .82rem;
  color: var(--pt-ink-3);
  background: var(--pt-surface-2);
  border: 1px solid var(--pt-line);
  border-radius: 10px;
  cursor: text;
  transition: border-color .12s ease, background .12s ease;
}
.pt-kbar:hover { border-color: var(--pt-brand-border); }
.pt-kbar .pt-kbar-icon { display: inline-flex; flex: 0 0 auto; opacity: .8; }
.pt-kbar .pt-kbar-label { flex: 1 1 auto; text-align: left; }
.pt-kbar kbd {
  flex: 0 0 auto;
  font: 600 10px/1 ui-monospace, "SFMono-Regular", Menlo, monospace;
  color: var(--pt-ink-2);
  background: var(--pt-surface);
  border: 1px solid var(--pt-line);
  border-radius: 5px;
  padding: 3px 5px;
}

/* ---- Grouped nav (<details class="nav-group">) ---------------------------- */

#navbarVerticalNav { display: block; }

.nav-group { margin: 0 0 .15rem; border: 0; }

.nav-group > summary {
  display: flex;
  align-items: center;
  gap: .4rem;
  list-style: none;
  cursor: pointer;
  padding: .5rem .55rem .3rem;
  margin-top: .35rem;
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: .07em;
  text-transform: uppercase;
  color: var(--pt-ink-3);
  user-select: none;
  border-radius: 8px;
}
.nav-group > summary::-webkit-details-marker { display: none; }
.nav-group > summary:hover { color: var(--pt-ink-2); }

/* Chevron drawn from borders — rotates when the group is open. */
.nav-group > summary::after {
  content: "";
  width: .42rem;
  height: .42rem;
  margin-left: auto;
  border-right: 2px solid currentColor;
  border-bottom: 2px solid currentColor;
  transform: rotate(45deg);
  transform-origin: 55% 55%;
  opacity: .65;
  transition: transform .15s ease;
}
.nav-group[open] > summary::after { transform: rotate(-135deg); }

/* Hide a group whose links are all permission/license-gated out. Pure CSS
   via :has() — an empty <details> (only its <summary>) collapses away so a
   restricted user never sees a bare header. */
.nav-group:not(:has(a.nav-link)) { display: none; }

/* ---- Nav links (inside groups + favorites) -------------------------------- */

.navbar-vertical .navbar-nav .nav-link {
  display: flex;
  align-items: center;
  border-radius: 9px;
  padding: .48rem .55rem;
  margin: 1px 0;
  color: var(--pt-ink-2);
  font-weight: 500;
  transition: background .12s ease, color .12s ease;
}
.navbar-vertical .navbar-nav .nav-link .nav-link-icon {
  width: 1.35rem;
  text-align: center;
  color: var(--pt-ink-3);
  transition: color .12s ease;
}
.navbar-vertical .navbar-nav .nav-link:hover {
  background: var(--pt-surface-2);
  color: var(--pt-ink);
}
.navbar-vertical .navbar-nav .nav-link:hover .nav-link-icon { color: var(--pt-ink-2); }

/* Active item — brand tint fill, brand ink text + icon, left accent bar. */
.navbar-vertical .navbar-nav .nav-link.active {
  position: relative;
  background: var(--pt-brand-tint);
  color: var(--pt-brand-ink);
  font-weight: 600;
}
.navbar-vertical .navbar-nav .nav-link.active .nav-link-icon { color: var(--pt-brand-ink); }
.navbar-vertical .navbar-nav .nav-link.active::before {
  content: "";
  position: absolute;
  left: -.6rem;
  top: 50%;
  transform: translateY(-50%);
  width: 3px;
  height: 1.15rem;
  border-radius: 0 3px 3px 0;
  background: var(--pt-brand);
}
.navbar-vertical .navbar-nav .nav-link.disabled { color: var(--pt-ink-3); opacity: .6; }

/* Section labels for the classic Falcon label rows (Favorites/App/Admin that
   aren't <details> summaries) keep the same muted treatment. */
.navbar-vertical .navbar-vertical-label { color: var(--pt-ink-3); font-weight: 700; letter-spacing: .07em; }
.navbar-vertical .navbar-vertical-divider .navbar-vertical-hr,
.navbar-vertical hr.navbar-vertical-divider { border-color: var(--pt-line); }

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

.pt-sidefoot {
  display: flex;
  align-items: center;
  gap: .55rem;
  margin: .5rem .1rem .2rem;
  padding: .55rem .5rem;
  border-top: 1px solid var(--pt-line);
}
.pt-sidefoot .pt-sf-avatar {
  flex: 0 0 auto;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .72rem;
  font-weight: 700;
  color: #fff;
  background: linear-gradient(135deg, #4f63c5 0%, #5a3683 100%);
}
.pt-sidefoot .pt-sf-meta { min-width: 0; line-height: 1.2; }
.pt-sidefoot .pt-sf-name {
  font-size: .82rem; font-weight: 600; color: var(--pt-ink);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.pt-sidefoot .pt-sf-role {
  font-size: .72rem; color: var(--pt-ink-3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

/* ---- Command palette overlay --------------------------------------------- */

.pt-pal { position: fixed; inset: 0; z-index: 2000; display: none; }
.pt-pal.is-open { display: block; }
.pt-pal-scrim {
  position: absolute; inset: 0;
  background: rgba(6, 10, 22, .55);
  backdrop-filter: blur(3px);
}
.pt-pal-box {
  position: relative;
  max-width: 560px;
  margin: 11vh auto 0;
  background: var(--pt-surface);
  border: 1px solid var(--pt-line);
  border-radius: 14px;
  box-shadow: 0 30px 80px -20px rgba(0, 0, 0, .55);
  overflow: hidden;
}
.pt-pal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid var(--pt-line-2);
}
.pt-pal-head svg { flex: 0 0 auto; }
.pt-pal-input {
  border: 0; outline: 0; background: transparent;
  color: var(--pt-ink); font-size: 15px; width: 100%;
}
.pt-pal-input::placeholder { color: var(--pt-ink-3); }
.pt-pal-head kbd {
  font: 600 10px/1 ui-monospace, monospace;
  color: var(--pt-ink-3); border: 1px solid var(--pt-line);
  border-radius: 5px; padding: 4px 6px;
}
.pt-pal-list { padding: 8px; max-height: 52vh; overflow-y: auto; }
.pt-pal-cat {
  font-size: 11px; font-weight: 650; letter-spacing: .06em;
  text-transform: uppercase; color: var(--pt-ink-3);
  padding: 8px 10px 4px;
}
.pt-pal-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  color: var(--pt-ink-2); font-size: .9rem;
  cursor: pointer; text-decoration: none;
}
.pt-pal-item .pt-pal-ico { width: 1.2rem; text-align: center; color: var(--pt-ink-3); flex: 0 0 auto; }
.pt-pal-item .pt-pal-sub { color: var(--pt-ink-3); font-size: .78rem; margin-left: auto; }
.pt-pal-item:hover,
.pt-pal-item.is-active { background: var(--pt-brand-tint); color: var(--pt-brand-ink); }
.pt-pal-item:hover .pt-pal-ico,
.pt-pal-item.is-active .pt-pal-ico { color: var(--pt-brand-ink); }
.pt-pal-empty { padding: 22px 12px; text-align: center; color: var(--pt-ink-3); font-size: .88rem; }

@media (prefers-reduced-motion: reduce) {
  .nav-group > summary::after,
  .navbar-vertical .navbar-nav .nav-link { transition: none; }
}

/* ==========================================================================
   PR7 — shell fidelity to the approved console mockup.
   ========================================================================== */

/* ---- Slim topbar ----------------------------------------------------------- */

.pt-topbar {
  min-height: var(--pt-top-nav-height);
  padding: 0 1.25rem;
  /* Falcon bleeds the top bar sideways with `margin: 0 -1rem` so it can span a
     container's gutters. Our container has none, so both edges escaped: the
     left 16px hid behind the sidebar, and the right 16px hung off the viewport
     — which is what put a horizontal scrollbar on every authenticated page.
     Zeroing both lands the bar exactly on the content column, flush with the
     sidebar's edge and with .pt-page below it. */
  margin-left: 0;
  margin-right: 0;
  background: color-mix(in srgb, var(--pt-canvas) 82%, transparent);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--pt-line-2);
  box-shadow: none;
}
.pt-topbar-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border-radius: 9px;
  color: var(--pt-ink-2);
  font-size: .95rem;
}
.pt-topbar-icon:hover { background: var(--pt-surface-2); color: var(--pt-ink); }
.pt-topbar .dropdown-toggle::after { display: none; }

/* Breadcrumb folded into the bar: plain inline trail (mockup:
   "Overview / Dashboard"), no card chrome. Must outrank the component
   layer's nav[aria-label="breadcrumb"] card look — hence the prefix. */
.pt-topbar nav[aria-label="breadcrumb"],
.pt-topbar .modern-breadcrumb {
  background: transparent;
  border: 0;
  box-shadow: none;
  padding: 0;
  margin: 0;
  border-radius: 0;
}
.pt-topbar .modern-breadcrumb ol { flex-wrap: nowrap; overflow: hidden; }
.pt-topbar .modern-breadcrumb li {
  color: var(--pt-ink-3);
  font-size: .84rem;
  white-space: nowrap;
}
.pt-topbar .modern-breadcrumb a { color: var(--pt-ink-3); padding: .1rem .25rem; }
.pt-topbar .modern-breadcrumb a:hover { color: var(--pt-brand-ink); background: transparent; }
.pt-topbar nav[aria-label="breadcrumb"] .active,
.pt-topbar .modern-breadcrumb .active {
  color: var(--pt-ink);
  background: transparent;
  padding: .1rem 0 .1rem .25rem;
  font-weight: 600;
}
.pt-topbar .modern-breadcrumb li:not(:last-child)::after {
  width: 5px; height: 5px; margin: 0 .5rem;
}

/* ---- Sidebar brand block --------------------------------------------------- */

/* Own flex here (no Bootstrap `d-flex` utility on the markup — its
   !important would beat the mobile display:none below). */
.pt-brandrow { display: flex; align-items: center; padding: .9rem .35rem .55rem; }
/* Beat compat's `.navbar-vertical.navbar-expand-xl .navbar-brand
   { display:block; text-align:center }` (0,3,1). */
.navbar-vertical.navbar-expand-xl .navbar-brand.pt-brandblock {
  display: flex;
  align-items: center;
  text-align: left;
  gap: .6rem;
  min-width: 0;
  padding: 0;
  margin: 0;
}
.pt-brand-mark {
  height: 2rem;
  width: 2rem;
  object-fit: contain;
  flex: 0 0 auto;
}
.pt-brand-meta { display: flex; flex-direction: column; min-width: 0; line-height: 1.15; }
.pt-brand-name {
  font-family: var(--pt-font-sans-serif);
  font-weight: 700;
  font-size: 1rem;
  color: var(--pt-ink);
  letter-spacing: .01em;
}
.pt-brand-ws {
  font-size: .72rem;
  color: var(--pt-ink-3);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Collapsed rail: mark only. */
.navbar-vertical-collapsed:not(.navbar-vertical-collapsed-hover) .pt-brand-meta { display: none; }

/* ---- Favorite chips -------------------------------------------------------- */

.pt-favs {
  display: flex;
  flex-wrap: wrap;
  gap: .4rem;
  padding: .1rem .15rem .65rem;
}
.pt-fav-chip {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .28rem .65rem;
  border: 1px solid var(--pt-line);
  border-radius: 999px;
  background: var(--pt-surface-2);
  color: var(--pt-ink-2);
  font-size: .78rem;
  font-weight: 600;
  text-decoration: none;
  max-width: 100%;
  transition: border-color .12s ease, color .12s ease;
}
.pt-fav-chip .pt-fav-star { font-size: .62rem; color: var(--pt-warn); }
.pt-fav-chip:hover { border-color: var(--pt-brand-border); color: var(--pt-ink); }
.pt-fav-chip.active {
  border-color: var(--pt-brand-border);
  background: var(--pt-brand-tint);
  color: var(--pt-brand-ink);
}
.pt-fav-chip.pt-fav-manage { padding-inline: .5rem; }
.pt-fav-chip.pt-fav-manage .fas { font-size: .62rem; color: var(--pt-ink-3); }
/* Hidden in the collapsed rail. */
.navbar-vertical-collapsed:not(.navbar-vertical-collapsed-hover) .pt-favs { display: none; }

/* ---- Comfortable page column ---------------------------------------------- */

.pt-page {
  max-width: 1320px;
  margin-inline: auto;
  width: 100%;
  padding: 1.4rem 1.25rem 0;
}
@media (min-width: 1200px) {
  .pt-page { padding-inline: 2rem; }
}

/* ==========================================================================
   PR9 — pinned sidebar, sidebar-footer identity, full-bleed layout.
   ========================================================================== */

/* The layout container no longer centers: the sidebar pins to the viewport's
   left edge (mockup) and the content column fills the rest. Page gutters come
   from .pt-page, so dropping this container's padding is safe. */
.container[data-layout] {
  max-width: none;
  width: 100%;
  padding: 0;
  margin: 0;
}

@media (min-width: 1200px) {
  /* Pinned, full-height sidebar as a flex column:
     brand (fixed) → nav (scrolls) → footer (pinned). The nav region's own
     overflow is what makes long group lists scrollable independently of the
     page — the old fixed height-calc silently broke this. */
  .navbar-vertical.navbar-expand-xl {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 17rem;
    max-width: 17rem;
    height: 100dvh;
    margin: 0;
    padding: 0 .9rem;
    background: var(--pt-surface);
    border-right: 1px solid var(--pt-line-2);
    display: flex;
    flex-direction: column;
    align-items: stretch;
    z-index: 1035;
  }
  .navbar-vertical.navbar-expand-xl .pt-brandrow { flex: 0 0 auto; }
  .navbar-vertical.navbar-expand-xl .navbar-collapse {
    flex: 1 1 auto;
    min-height: 0;
    display: flex !important;
    flex-direction: column;
    align-items: stretch;
    width: auto;
    margin-top: 0;
  }
  .navbar-vertical.navbar-expand-xl .navbar-vertical-content {
    flex: 1 1 auto;
    min-height: 0;
    height: auto;   /* override the compat layer's viewport calc */
    width: auto;
    overflow-y: auto;
    padding: 0 .1rem .75rem 0;
  }
  .navbar-vertical.navbar-expand-xl + .content { margin-left: 17rem; }
}

/* Footer as controls: the identity block opens the account menu (dropup);
   the icon button opens the theme menu. */
.pt-sidefoot { flex: 0 0 auto; }
.pt-sf-trigger {
  display: flex;
  align-items: center;
  gap: .55rem;
  width: 100%;
  min-width: 0;
  background: transparent;
  border: 0;
  padding: .4rem .45rem;
  border-radius: 10px;
  text-align: left;
}
/* The name/role are <span>s inside the trigger button — force block so the
   ellipsis truncation actually applies (inline elements can't truncate,
   which let long tenant names run under the theme button). */
.pt-sf-trigger .pt-sf-meta { display: block; flex: 1 1 auto; min-width: 0; }
.pt-sf-trigger .pt-sf-name,
.pt-sf-trigger .pt-sf-role { display: block; }
.pt-sidefoot .theme-control-dropdown { flex: 0 0 auto; }

/* Below the desktop breakpoint the sidebar is a drawer (its contents live in
   .navbar-collapse) — the brand row sits OUTSIDE the collapse and would
   otherwise bleed over the page content. */
@media (max-width: 1199.98px) {
  .navbar-vertical .pt-brandrow { display: none; }
  /* Drawer scroll: compat caps .navbar-vertical-content at
     calc(100vh - topnav) and hides overflow on the collapse, which CLIPS
     the lower groups + the account/theme footer. Make the open drawer one
     scrollable column instead. */
  .navbar-vertical .navbar-collapse.show { overflow-y: auto; max-height: 100dvh; }
  .navbar-vertical .navbar-collapse .navbar-vertical-content { max-height: none; }
}
.pt-sf-trigger:hover { background: var(--pt-surface-2); }
.pt-sf-iconbtn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 2.1rem;
  height: 2.1rem;
  border: 0;
  background: transparent;
  border-radius: 9px;
  color: var(--pt-ink-2);
}
.pt-sf-iconbtn:hover { background: var(--pt-surface-2); color: var(--pt-ink); }
.pt-sidefoot .dropdown-menu { min-width: 15rem; }

/* Shared avatar + dropdown polish (moved here from the topbar template when
   the account menu relocated to the sidebar footer). */
.avatar-name {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  /* Darker gradient stops so white text clears WCAG AA contrast (~4.5:1). */
  background: linear-gradient(135deg, #4f63c5 0%, #5a3683 100%);
  color: #fff;
  font-weight: bold;
  font-size: 1.2em;
}
.dropdown-item { transition: background-color .2s ease; }
.dropdown-item i { width: 20px; text-align: center; }
