/* ============================================
   Turbo Web Styles - Universal Components
   ============================================

   Universal UI patterns reused across multiple web projects.
   Uses BEM naming convention and CSS custom properties.

   Low-volatility: changes here affect all consuming projects.
   Only add components used across at least two separate projects.
   Dashboard-specific or project-specific styles go in the
   consuming project's own dashboard.css file.
   ============================================ */

/* ============================================
   FORM SELECT (COMPACT)
   ============================================ */

.form-select-compact {
  font-size: var(--font-size-sm);
  padding: var(--spacing-xs) var(--spacing-sm);
  height: var(--input-height-sm);
  border-radius: var(--border-radius-sm);
  background-color: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  color: var(--color-text-primary);
  transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}

.form-select-compact:focus {
  border-color: var(--color-border-focus);
  box-shadow: 0 0 0 2px rgba(var(--color-primary-rgb), 0.1);
  outline: none;
}

.form-select-compact:disabled {
  background-color: var(--color-surface-disabled);
  color: var(--color-text-disabled);
  cursor: not-allowed;
}

/* ============================================
   COMBOBOX (editable input + suggestion list)
   ============================================ */

.combobox {
  position: relative;
}

/* Combobox.razor.js re-anchors this to position:fixed on open to clear clipping ancestors;
   these absolute rules are the pre-script fallback. */
.combobox__dropdown {
  position: absolute;
  top: calc(100% + var(--spacing-xs));
  left: 0;
  right: 0;
  z-index: var(--z-index-dropdown);
  margin: 0;
  padding: var(--spacing-xs) 0;
  list-style: none;
  background: var(--color-surface);
  border: var(--border-width) solid var(--color-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  max-height: 18rem;
  overflow-y: auto;
}

/* Applied while the list has no selectable rows (loading / no matches): the short strip
   would otherwise swallow clicks aimed at controls beneath it. State-scoped because
   pointer-events: none also makes a populated list's scrollbar undraggable. */
.combobox__dropdown--inert {
  pointer-events: none;
}

.combobox__empty {
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--color-text-secondary);
  font-style: italic;
}

.combobox__item {
  padding: var(--spacing-xs) var(--spacing-md);
  cursor: pointer;
}

.combobox__item--active {
  background: rgba(var(--color-primary-rgb), 0.08);
}

/* ============================================
   BUTTON DISABLED STATE
   ============================================

   Bootstrap sets `.btn:disabled { pointer-events: none }`, which
   suppresses hover events on the button itself — meaning native
   `title` tooltips never appear, and the user gets no explanation
   for why the button is unusable. Re-enabling pointer events lets
   the tooltip fire while the `disabled` attribute still blocks
   activation. Stronger opacity + `not-allowed` cursor make the
   disabled state visually unambiguous.
   ============================================ */

.btn:disabled,
.btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: auto;
}

/* ============================================
   SKELETON LOADER
   ============================================ */

.skeleton {
  background: linear-gradient(
    90deg,
    var(--color-surface-hover) 25%,
    var(--color-surface-active) 50%,
    var(--color-surface-hover) 75%
  );
  background-size: 200% 100%;
  animation: skeleton-loading 1.5s ease-in-out infinite;
  border-radius: var(--border-radius-sm);
}

@keyframes skeleton-loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.skeleton--text {
  height: 14px;
  margin-bottom: var(--spacing-sm);
}

.skeleton--title {
  height: 24px;
  width: 60%;
  margin-bottom: var(--spacing-lg);
}

.skeleton--metric {
  height: 48px;
  width: 100%;
  margin-bottom: var(--spacing-md);
}

.skeleton--table-row {
  height: 40px;
  width: 100%;
  margin-bottom: var(--spacing-xs);
}

/* ============================================
   EMPTY STATE
   ============================================ */

.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-3xl) var(--spacing-xl);
  text-align: center;
  color: var(--color-text-secondary);
}

.empty-state__icon {
  font-size: 48px;
  margin-bottom: var(--spacing-lg);
  opacity: 0.5;
}

.empty-state__message {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0 0 var(--spacing-sm);
}

.empty-state__detail {
  color: var(--color-text-secondary);
  margin: 0;
}

.empty-state__action {
  margin-top: var(--spacing-md);
}

/* ============================================
   ERROR STATE
   ============================================ */

.error-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl) var(--spacing-xl);
  text-align: center;
  color: var(--color-error);
  background-color: rgba(var(--color-error-rgb), 0.05);
  border: var(--border-width) solid var(--color-error);
  border-radius: var(--border-radius-md);
}

.error-state__icon {
  font-size: 32px;
  margin-bottom: var(--spacing-md);
}

.error-state__message {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  margin-bottom: var(--spacing-xs);
}

.error-state__detail {
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.error-state__action {
  margin-top: var(--spacing-md);
}

/* ============================================
   REFRESH PILL (STYLEGUIDE § 3.5.1 phase 2)
   ============================================ */

.refresh-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
  padding: 2px 10px;
  border-radius: var(--border-radius-pill);
  background: rgba(var(--color-warning-rgb), 0.15);
  color: var(--color-text-secondary);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-semibold);
}

.refresh-pill__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-warning);
  animation: refresh-pill-pulse 1.2s ease-in-out infinite;
}

@keyframes refresh-pill-pulse {
  50% { opacity: 0.3; }
}

/* ============================================
   CARD LOADER (STYLEGUIDE § 3.5.1)
   ============================================ */

.card-loader {
  transition: opacity var(--transition-base);
}

.card-loader--refreshing .card-loader__content {
  opacity: 0.55;
  transition: opacity var(--transition-base);
}

.card-loader__refresh {
  margin-bottom: var(--spacing-sm);
}

.card-loader__content {
  animation: card-loader-fade-in 220ms ease-out;
}

@keyframes card-loader-fade-in {
  from { opacity: 0; }
  to { opacity: 1; }
}

/* ============================================
   LOADING INDICATOR
   ============================================ */

.loading-indicator {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: var(--spacing-2xl);
  color: var(--color-text-secondary);
}

.loading-indicator__text {
  font-size: var(--font-size-sm);
}

/* ============================================
   PAGE HEADER
   ============================================ */

.page-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: var(--spacing-2xl);
  padding: 0 0 var(--spacing-lg);
  background: none;
  border-bottom: var(--border-width) solid var(--color-border);
}

.page-header__title {
  font-size: var(--font-size-2xl);
  font-weight: var(--font-weight-bold);
  color: var(--color-text-primary);
  margin: 0;
  display: inline-flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* Title → description gap. A sibling selector rather than a margin-bottom on the
   title itself: several headers carry a title alone, or follow it with a badge
   row, and neither should pick up the gap. */
.page-header__title + p {
  margin-top: var(--spacing-sm);
}

.page-header__logo {
  width: 28px;
  height: 28px;
  object-fit: contain;
  flex: 0 0 auto;
}

.page-header__actions {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
}

/* List-filter input. Two homes:
     .page-header__search   — single-grid pages (search lives in page-header actions)
     .card-header__search   — multi-card pages (search lives in card-header per table)
   Fixed width and no shrink so it never crowds out the sibling toggles/buttons;
   the sibling controls also need to keep their single-line labels regardless
   of viewport width. */
.page-header__search,
.card-header__search {
  width: 240px;
  flex: 0 0 auto;
}

.page-header__actions > .form-check-inline,
.page-header__actions > .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

/* Bootstrap's .form-check-inline ships with margin-right: 1rem; inside a flex
   container with gap that double-spaces the right side. Let flex gap own all
   spacing between siblings. */
.page-header__actions > .form-check-inline {
  margin-right: 0;
}

@media (max-width: 768px) {
  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: var(--spacing-md);
  }

  /* Let the action controls keep flowing left-to-right and wrap only when a
     row runs out of room, instead of collapsing to one control per line. The
     full-width search below takes the first row, so buttons/selects pack onto
     the next row together and wrap again only if they still don't fit. */
  .page-header__actions {
    width: 100%;
    flex-wrap: wrap;
    gap: var(--spacing-sm);
  }

  .page-header__search,
  .card-header__search {
    width: 100%;
  }

  /* Same hybrid as .list-toolbar: inside the page-header actions the search
     shares the row with the sibling controls while they fit, and only spans the
     full row once its min-width can't hold alongside them. */
  .page-header__actions .page-header__search {
    width: auto;
    flex: 1 1 260px;
    min-width: 240px;
  }
}

/* ============================================
   LIST TOOLBAR

   The row above a list/grid holding a search box and one or more action
   controls (an "Add X" button or a dropdown). Replaces the ad-hoc
   `d-flex align-items-center [justify-content-between] gap-2 mb-3` container so
   the pattern behaves the same everywhere. Action controls are pinned right and
   never wrap their label; below the breakpoint the whole row wraps so the
   full-width search takes the first line and the actions drop to the next line
   at full size instead of being squeezed to two or three lines.
   ============================================ */

.list-toolbar {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-lg);
}

/* First trailing action (a button or a dropdown wrapper) absorbs the free space
   and right-aligns the action group — replaces per-page `ms-auto`. */
.list-toolbar > .btn,
.list-toolbar > .dropdown {
  margin-left: auto;
}

.list-toolbar .btn {
  flex: 0 0 auto;
  white-space: nowrap;
}

@media (max-width: 768px) {
  .list-toolbar {
    flex-wrap: wrap;
  }

  /* Search grows to share the row with the action(s) while both fit; its
     min-width is the wrap point, so on phone widths the action drops below and
     the search spans the full row (roomy tablet: share; phone: stack). */
  .list-toolbar .page-header__search {
    width: auto;
    flex: 1 1 260px;
    min-width: 240px;
  }
}

/* ============================================
   CARD HEADER — wrap when title + actions collide

   A `.card-header.d-flex justify-content-between` holding a title/select on the
   left and controls on the right overflows the card at narrow widths. Let it
   wrap so the two groups stack instead of clipping. */
.card-header.d-flex {
  gap: var(--spacing-sm);
}

@media (max-width: 768px) {
  .card-header.d-flex {
    flex-wrap: wrap;
  }
}

/* ============================================
   SCROLLBAR
   ============================================ */

.scrollbar-thin {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) transparent;
}

.scrollbar-thin::-webkit-scrollbar {
  width: 6px;
}

.scrollbar-thin::-webkit-scrollbar-track {
  background: transparent;
}

.scrollbar-thin::-webkit-scrollbar-thumb {
  background-color: var(--color-border);
  border-radius: 3px;
}

/* ============================================
   APP SHELL (top bar + body row with optional sidebar)

   Structure (used by Portal, Settings, Admin):

     .app-shell                    column flex, viewport-height
       .app-shell__topbar          horizontal bar, sticky top
       .app-shell__body            row flex, fills remaining height
         .app-nav                  optional left rail
         .app-shell__content       column flex, scrolls inside
           .app-shell__main        scrollable content area
           .app-footer             flex footer
   ============================================ */

.app-shell {
  --app-shell-topbar-height: 56px;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

.app-shell__body {
  display: flex;
  flex: 1;
  min-height: 0;
}

.app-shell__content {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-shell__main {
  flex: 1;
  overflow-y: auto;
  /* Clips the page action bar's full-bleed ::before to the pane (EditFormActions.razor.css);
     wide page content uses its own scroll containers. */
  overflow-x: hidden;
  padding: var(--spacing-2xl);
}

/* ============================================
   APP SHELL TOPBAR
   ============================================ */

.app-shell__topbar {
  height: var(--app-shell-topbar-height);
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  padding: 0 var(--spacing-xl);
  background: var(--color-surface);
  border-bottom: 1px solid var(--color-border);
}

.app-shell__topbar-start {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  min-width: 0;
  flex: 1 1 auto;
}

.app-shell__topbar-end {
  display: flex;
  align-items: center;
  gap: var(--spacing-lg);
  flex: 0 0 auto;
}

.app-shell__brand {
  display: inline-flex;
  align-items: center;
  flex-shrink: 0;
  color: inherit;
}

.app-shell__brand:hover {
  color: inherit;
}

.app-shell__brand-logo {
  width: 40px;
  height: 40px;
}

.app-shell__section {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  white-space: nowrap;
  margin-left: var(--spacing-sm);
}

a.app-shell__section:hover {
  color: var(--color-text-primary);
}

/* Continuation crumbs that follow .app-shell__section. Same size as the section
   anchor, but normal weight + secondary color so the section reads as the
   dominant element and the trailing crumbs read as context. */
.app-shell__crumb,
.app-shell__crumb-sep {
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-normal);
  white-space: nowrap;
}

.app-shell__crumb {
  color: var(--color-text-primary);
}

/* The current page (including a lone section root) reads as the title: bold, never a link. */
.app-shell__crumb[aria-current="page"] {
  font-weight: var(--font-weight-semibold);
}

.app-shell__crumb-sep {
  color: var(--color-text-tertiary);
  margin: 0 var(--spacing-xs);
}

a.app-shell__crumb {
  color: var(--color-link);
}

a.app-shell__crumb:hover {
  text-decoration: underline;
}

/* Space the leading crumb from the brand icon. */
.app-shell__brand + .app-shell__crumb,
.app-shell__brand + .app-shell__crumbs {
  margin-left: var(--spacing-sm);
}

/* Breadcrumb component (Turbo.Web.Styles/Components/Breadcrumb.razor): a <nav> wrapping an
   ordered list. Reuses the .app-shell__crumb colour rules above (link = blue, current = white);
   these rules only reset the list and draw the decorative "/" separator between items. */
.app-shell__crumbs {
  display: inline-flex;
  align-items: center;
  min-width: 0;
  overflow: hidden;
}

.app-shell__crumbs-list {
  list-style: none;
  display: flex;
  align-items: center;
  margin: 0;
  padding: 0;
  min-width: 0;
}

.app-shell__crumb-item {
  display: inline-flex;
  align-items: center;
  white-space: nowrap;
}

.app-shell__crumb-item + .app-shell__crumb-item::before {
  content: "/";
  color: var(--color-text-tertiary);
  margin: 0 var(--spacing-xs);
}

/* Deep trail on a narrow topbar: let the current-page leaf shrink and ellipsize
   instead of painting under the account menu / theme toggle. Non-leaf crumbs
   keep their nowrap layout so the trail stays readable up to the leaf. */
.app-shell__crumb-item:last-child {
  min-width: 0;
  overflow: hidden;
}

.app-shell__crumb-item:last-child .app-shell__crumb {
  display: block;
  overflow: hidden;
  text-overflow: ellipsis;
}

.app-shell__topbar-link {
  color: var(--color-text-primary);
  font-weight: 600;
  font-size: var(--font-size-base);
}

.app-shell__topbar-link:hover {
  color: var(--color-link);
}

/* Generic topbar icon button — theme toggle, New Session, session tabs, etc. */
.app-shell__icon-button {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-secondary);
  font-size: var(--font-size-base);
  padding: var(--spacing-xs);
  border-radius: var(--border-radius-sm);
  flex-shrink: 0;
  line-height: 1;
}

.app-shell__icon-button:hover {
  color: var(--color-text-primary);
  background: var(--color-surface-hover);
}

/* Theme-icon asset swap — driven by --asset-display-*-inline tokens (see theme.css). */
.app-shell__theme-icon--light { display: var(--asset-display-light-inline); }
.app-shell__theme-icon--dark  { display: var(--asset-display-dark-inline); }

@media (max-width: 960px) {
  .app-shell__topbar {
    padding: 0 var(--spacing-md);
  }
}

/* ============================================
   ACCOUNT MENU (top-bar identity dropdown)
   ============================================ */

.account-menu {
  position: relative;
}

.account-menu__trigger {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  padding: var(--spacing-xs) 0;
  border: none;
  background: transparent;
  cursor: pointer;
  font: inherit;
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  font-weight: 600;
}

.account-menu__trigger:hover {
  color: var(--color-link);
}

.account-menu__name {
  max-width: 160px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.account-menu__panel {
  position: absolute;
  right: 0;
  top: calc(100% + 4px);
  min-width: 220px;
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  z-index: 201;
  display: none;
  padding: var(--spacing-xs) 0;
}

.account-menu--open .account-menu__panel {
  display: block;
}

/* Transparent fullscreen overlay — captures clicks anywhere off the panel and
   closes the dropdown. Sits above page content but below the panel itself.
   Same pattern as .portal-ctx-menu__backdrop. */
.account-menu__backdrop {
  position: fixed;
  inset: 0;
  z-index: 200;
  cursor: default;
}

.account-menu__item {
  display: block;
  padding: var(--spacing-sm) var(--spacing-md);
  color: var(--color-text-primary);
  font-size: var(--font-size-base);
  text-decoration: none;
  white-space: nowrap;
}

button.account-menu__item {
  width: 100%;
  border: 0;
  background: transparent;
  font: inherit;
  text-align: left;
}

.account-menu__item:hover {
  background: var(--color-surface-hover);
  color: var(--color-text-primary);
}

.account-menu__divider {
  height: 1px;
  background: var(--color-border);
  margin: var(--spacing-xs) 0;
}

/* The current surface in the cross-product switcher: still a live link to its own home (clicking
   it returns there), just muted and flagged with a check so you can see where you are. Not
   disabled - it hovers and clicks like any other item (the base :hover rule wins on hover). */
.account-menu__item--current {
  color: var(--color-text-tertiary);
}

.account-menu__check {
  margin-left: var(--spacing-sm);
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
}

/* ============================================
   APP NAV (left-edge sidebar)
   ============================================ */

.app-nav {
  display: flex;
  flex-direction: column;
  width: 240px;
  flex-shrink: 0;
  background: var(--color-surface);
  border-right: 1px solid var(--color-border);
  overflow-y: auto;
}

/* Sidebar footer — brand mark on the left, version right-aligned, single row
   pinned at the bottom of .app-nav via position:sticky so it stays visible
   even when the nav scrolls. */
.app-nav__footer {
  position: sticky;
  bottom: 0;
  margin-top: auto;
  padding: var(--spacing-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--spacing-sm);
  background: var(--color-surface);
  border-top: 1px solid var(--color-border);
}

.app-nav__footer-logo {
  display: inline-flex;
  flex: 0 1 auto;
  min-width: 0;
  opacity: 0.35;
  transition: opacity var(--transition-fast);
}

.app-nav__footer-logo:hover {
  opacity: 0.6;
}

.app-nav__footer-watermark {
  display: block;
  width: 100%;
  max-width: 120px;
  height: auto;
}

/* Watermark asset swap — driven by --asset-display-* tokens (see theme.css). */
.app-nav__footer-watermark--light { display: var(--asset-display-light); }
.app-nav__footer-watermark--dark  { display: var(--asset-display-dark); }

.app-nav__footer-version {
  flex-shrink: 0;
  font-size: var(--font-size-xs);
  color: var(--color-text-tertiary);
  white-space: nowrap;
}

/* ============================================
   APP SIDENAV (container for nav sections)
   ============================================ */

.app-sidenav {
  display: flex;
  flex-direction: column;
  padding: var(--spacing-md) 0;
  flex: 1;
}

/* ============================================
   NAV SECTION (collapsible nav group)
   ============================================ */

.nav-section__header {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  width: 100%;
  padding: var(--spacing-sm) var(--spacing-lg);
  margin-top: var(--spacing-lg);
  color: var(--color-text-secondary);
  font-size: var(--font-size-xs);
  font-weight: var(--font-weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.nav-section__header:hover {
  color: var(--color-text-primary);
}

.nav-section__title-link {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  flex: 1;
  min-width: 0;
  color: inherit;
}

.nav-section__title-link:hover,
.nav-section__title-link:focus {
  color: inherit;
}

.nav-section__title-link.active {
  color: var(--color-primary);
}

.nav-section__title-link--static {
  display: flex;
  align-items: center;
  gap: var(--spacing-xs);
  flex: 1;
  min-width: 0;
}

.nav-section__icon {
  font-size: var(--font-size-sm);
  width: 14px;
  text-align: center;
  flex-shrink: 0;
}

.nav-section__toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  /* Negative margins cancel the padding's footprint, so the larger hit area
     leaves the header height and chevron position unchanged. */
  margin-left: auto;
  margin-right: calc(-1 * var(--spacing-sm));
  margin-top: calc(-1 * var(--spacing-sm));
  margin-bottom: calc(-1 * var(--spacing-sm));
  padding: var(--spacing-sm);
  background: none;
  border: none;
  cursor: pointer;
  color: inherit;
}

.nav-section__chevron {
  font-size: 10px;
}

.nav-section__items {
  display: flex;
  flex-direction: column;
}

.nav-section__items a {
  display: block;
  padding: var(--spacing-sm) var(--spacing-lg) var(--spacing-sm) calc(var(--spacing-lg) + 14px + var(--spacing-xs));
  color: var(--color-text-primary);
  font-size: 13px;
  border-left: 2px solid transparent;
  transition: background 150ms, border-color 150ms;
}

.nav-section__items a:hover {
  background: rgba(var(--color-primary-rgb), 0.06);
  /* Sidebar items are Blazor <NavLink>s, which render a class-less <a> when
     inactive, so the global a:not([class]):hover underline (globals.css) would
     otherwise reach them. The hover affordance here is the background tint. */
  text-decoration: none;
}

.nav-section__items a.active {
  color: var(--color-primary);
  border-left-color: var(--color-primary);
  background: rgba(var(--color-primary-rgb), 0.08);
  font-weight: 600;
}

/* ============================================
   MOBILE NAV DRAWER (max-width: 768px)
   ============================================ */

.app-shell__nav-toggle {
  display: none;
}

.app-shell__nav-toggle-icon--open {
  display: none;
}

.app-shell--nav-open .app-shell__nav-toggle-icon--closed {
  display: none;
}

.app-shell--nav-open .app-shell__nav-toggle-icon--open {
  display: inline;
}

.app-nav__scrim {
  display: none;
}

@media (max-width: 768px) {
  .app-shell__nav-toggle {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    /* Fixed width stops the topbar shifting when the glyph swaps bars/xmark. */
    width: 40px;
    height: 40px;
    font-size: var(--font-size-xl);
  }

  .app-nav {
    position: fixed;
    top: var(--app-shell-topbar-height);
    left: 0;
    bottom: 0;
    width: min(280px, 86vw);
    transform: translateX(-100%);
    transition: transform var(--transition-base);
    z-index: var(--z-index-modal);
    box-shadow: var(--shadow-lg);
  }

  .app-shell--nav-open .app-nav {
    transform: translateX(0);
  }

  .app-nav__scrim {
    display: block;
    position: fixed;
    top: var(--app-shell-topbar-height);
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--color-overlay);
    z-index: var(--z-index-overlay);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-fast);
  }

  .app-shell--nav-open .app-nav__scrim {
    opacity: 1;
    pointer-events: auto;
  }
}

/* ============================================
   NAV UNDERLINE — color override

   Bootstrap's default has active = emphasis (white-ish) and inactive = link
   color (blue), which inverts how the sidebar nav signals "selected" (active
   = brand, inactive = default text). Re-map so both navs follow the same
   convention: active item gets the brand color, inactive items use the
   default text color.
   ============================================ */

.nav-underline {
  --bs-nav-link-color: var(--color-text-primary);
  --bs-nav-link-hover-color: var(--color-primary);
  --bs-nav-underline-link-active-color: var(--color-primary);

  /* Keep the tab strip a single row. Bootstrap's .nav wraps, so a strip with
     several tabs breaks onto a second line at narrow widths and the active
     underline detaches from the rest. Scroll horizontally instead; the
     partially-clipped trailing tab is the scroll affordance. No effect when the
     tabs already fit (overflow-x: auto shows nothing until they don't). */
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none; /* Firefox: hide the scrollbar, keep the scrolling */
}

.nav-underline::-webkit-scrollbar {
  display: none; /* WebKit/Blink: same */
}

.nav-underline .nav-link {
  white-space: nowrap;
}

/* ============================================
   APP FOOTER
   ============================================ */

.app-footer {
  display: flex;
  align-items: center;
  padding: var(--spacing-md) var(--spacing-lg);
  background: var(--color-surface-hover);
  border-top: 1px solid var(--color-border);
  flex-shrink: 0;
}

.app-footer__spacer {
  flex: 1;
  display: flex;
  justify-content: flex-end;
  align-items: center;
}

.app-footer__logo {
  display: inline-block;
  opacity: 0.25;
  transition: opacity var(--transition-fast);
}

.app-footer__logo:hover {
  opacity: 0.4;
}

.app-footer__watermark {
  display: block;
  width: 125px;
  height: auto;
}

/* Watermark asset swap — driven by --asset-display-* tokens (see theme.css). */
.app-footer__watermark--light { display: var(--asset-display-light); }
.app-footer__watermark--dark  { display: var(--asset-display-dark); }

.app-footer__version {
  font-size: var(--font-size-sm);
  color: var(--color-text-tertiary);
}

/* ============================================
   LOGIN PAGE + BOX
   ============================================ */

.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--color-background);
}

.login-page__center {
  width: 100%;
  max-width: 380px;
  padding: var(--spacing-lg);
}

.login-box {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  padding: var(--spacing-2xl);
  box-shadow: var(--shadow-sm);
}

.login-box__header {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-sm);
  margin-bottom: var(--spacing-2xl);
  text-align: center;
}

.login-box__logo {
  width: 40px;
  height: 40px;
}

.login-box__title {
  font-size: var(--font-size-xl);
  font-weight: var(--font-weight-semibold);
  color: var(--color-text-primary);
  margin: 0;
}

/* "or" separator between the credentials form and the SSO button. */
.login-box__sso-divider {
  display: flex;
  align-items: center;
  gap: var(--spacing-sm);
  margin: var(--spacing-md) 0;
  color: var(--color-text-muted);
  font-size: var(--font-size-sm);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.login-box__sso-divider::before,
.login-box__sso-divider::after {
  content: "";
  flex: 1;
  height: 1px;
  background: var(--color-border);
}

/* Blazor Server reconnection modal.
   Blazor's built-in reconnect UI renders a hardcoded white dialog inside a shadow
   root, so it ignores the page theme and can't be styled from here. Supplying an
   element with id "components-reconnect-modal" makes blazor.web.js drive that
   element instead — it only toggles state classes and fills the attempt/countdown
   spans — leaving the look entirely to this stylesheet. State classes are
   components-reconnect-{show,hide,retrying,failed,paused,resume-failed,rejected};
   spans are #components-reconnect-current-attempt, #components-reconnect-max-retries,
   #components-seconds-to-next-attempt. */
#components-reconnect-modal {
  display: none;
  position: fixed;
  inset: 0;
  /* Above Radzen dialogs/toasts (1040/1045) — the reconnect UI must stay reachable. */
  z-index: 10000;
  align-items: center;
  justify-content: center;
  background: var(--color-overlay);
  font-family: var(--font-family-primary);
}

#components-reconnect-modal.components-reconnect-show,
#components-reconnect-modal.components-reconnect-retrying,
#components-reconnect-modal.components-reconnect-failed,
#components-reconnect-modal.components-reconnect-rejected,
#components-reconnect-modal.components-reconnect-paused,
#components-reconnect-modal.components-reconnect-resume-failed {
  display: flex;
}

.reconnect-modal__dialog {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--spacing-lg);
  width: 20rem;
  max-width: calc(100vw - var(--spacing-3xl));
  padding: var(--spacing-2xl);
  background: var(--color-surface);
  color: var(--color-text-primary);
  border: 1px solid var(--color-border);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-lg);
  text-align: center;
}

.reconnect-modal__spinner {
  width: 40px;
  height: 40px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: reconnect-modal-spin 1s linear infinite;
}

@keyframes reconnect-modal-spin {
  to { transform: rotate(360deg); }
}

.reconnect-modal__message {
  margin: 0;
  font-size: var(--font-size-base);
  font-weight: var(--font-weight-medium);
}

.reconnect-modal__detail {
  margin: 0;
  font-size: var(--font-size-sm);
  color: var(--color-text-secondary);
}

.reconnect-modal__button {
  border: 0;
  padding: var(--spacing-sm) var(--spacing-2xl);
  border-radius: var(--border-radius-sm);
  background: var(--color-primary);
  color: var(--color-text-inverse);
  font-size: var(--font-size-base);
  cursor: pointer;
}

.reconnect-modal__button:hover {
  background: var(--color-primary-hover);
}

/* The dialog carries markup for every state; CSS reveals the block matching the
   current state class. Default (reconnecting) shows the spinner + reconnecting
   message; retrying additionally surfaces the attempt/countdown line; failed and
   rejected drop the spinner and offer a reload. */
.reconnect-modal__retrying,
.reconnect-modal__failed {
  display: none;
}

#components-reconnect-modal.components-reconnect-retrying .reconnect-modal__retrying {
  display: block;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-modal__spinner,
#components-reconnect-modal.components-reconnect-rejected .reconnect-modal__spinner,
#components-reconnect-modal.components-reconnect-failed .reconnect-modal__reconnecting,
#components-reconnect-modal.components-reconnect-rejected .reconnect-modal__reconnecting,
#components-reconnect-modal.components-reconnect-failed .reconnect-modal__retrying,
#components-reconnect-modal.components-reconnect-rejected .reconnect-modal__retrying {
  display: none;
}

#components-reconnect-modal.components-reconnect-failed .reconnect-modal__failed,
#components-reconnect-modal.components-reconnect-rejected .reconnect-modal__failed {
  display: block;
}
