/* ============================================================
   GZT COMPONENT LAYER (layer 4 - see tokens.css header)

   Named classes for patterns Bootstrap has no component for, or
   where it hardcodes a value with no variable to remap. Every class
   here has a spec entry in docs/DesignSystem.md -> Component specs.

   Rules:
     - Values come from tokens (--gz-*), never raw hex/px.
     - Each block carries a one-line "why not a Bootstrap utility".
   Load AFTER tokens.css.
   ============================================================ */

/* ------------------------------------------------------------
   APP SHELL - navbar + sidebar rail
   ------------------------------------------------------------ */

/* The top navbar background/border aren't a single Bootstrap var. */
.gz-navbar {
  background: var(--gz-surface);
  border-bottom: 1px solid var(--gz-border);
}

.gz-navbar .navbar-brand {
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--gz-text-primary);
}

/* Icon rail. No Bootstrap component covers a fixed vertical icon
   nav; these links use asp-page (tag-helper rewrites the element at
   compile time) so Razor CSS isolation can't reliably target them. */
.sidebar-rail {
  padding: var(--gz-space-2);
  display: flex;
  align-items: center;
  background: var(--gz-surface);
  border-right: 1px solid var(--gz-border);
}

.sidebar-rail .nav {
  align-items: center;
}

.sidebar-rail .nav-link {
  width: 2.75rem;
  height: 2.75rem;
  padding: 0;
  margin: 0.15rem;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: var(--gz-icon-lg);
  border-radius: var(--gz-radius);
  color: var(--gz-text-secondary);
  position: relative;
}

.sidebar-rail .nav-link:hover {
  color: var(--gz-text-primary);
  background-color: var(--gz-surface-muted);
}

/* Plain .nav-link.active has no built-in look in Bootstrap. A subtle
   tinted fill plus a short accent marker on the active edge - reads
   as "you are here" without a solid block. */
.sidebar-rail .nav-link.active {
  color: var(--gz-accent);
  background-color: var(--gz-accent-soft);
}

.sidebar-rail .nav-link.active::before {
  content: "";
  position: absolute;
  border-radius: var(--gz-radius-pill);
  background: var(--gz-accent);
}

/* horizontal rail (mobile): marker sits on the bottom edge */
.sidebar-rail .nav-link.active::before {
  left: 25%;
  right: 25%;
  bottom: -0.15rem;
  height: 2px;
}

@media (min-width: 768px) {
  .sidebar-rail {
    flex: 0 0 4rem;
    max-width: 4rem;
    flex-direction: column;
  }

  /* vertical rail (desktop): marker sits on the left edge */
  .sidebar-rail .nav-link.active::before {
    left: -0.15rem;
    top: 25%;
    bottom: 25%;
    right: auto;
    width: 2px;
    height: auto;
  }
}

/* ------------------------------------------------------------
   SUBSECTION TABS (issue #215) - one horizontal in-area nav
   strip for the settings-ish areas (Account settings, Team,
   Platform administration). Bootstrap .nav base; no Bootstrap
   component gives the accent-underline active treatment or the
   scroll-don't-wrap mobile behaviour. Rendered by
   Pages/Shared/_SubsectionTabs.cshtml; spec in
   docs/DesignSystem.md -> Component specs -> Subsection tabs.
   ------------------------------------------------------------ */
/* One row: the eyebrow that names the area, then the tab strip - the
   same shape for every "settings-ish" area (issue #230). */
.gz-subsection-nav {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: var(--gz-space-1) var(--gz-space-5);
  margin-bottom: var(--gz-space-6);
  border-bottom: 1px solid var(--gz-border);
}

/* Platform admin only: the SuperAdministrator tier signal (issue #181,
   DesignSystem.md UX priority 7) - the same row, lifted onto a tinted
   panel instead of a plain bottom rule. Not tied to the eyebrow (issue
   #230): every area carries one, only the platform area is tinted. */
.gz-subsection-nav--tiered {
  padding: var(--gz-space-1) var(--gz-space-4) 0;
  border: 1px solid var(--gz-border);
  border-radius: var(--gz-radius);
  background: var(--gz-accent-soft);
}

.gz-subsection-nav__eyebrow {
  font-size: var(--gz-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--gz-accent);
  white-space: nowrap;
  /* seat the label on the tab row's optical baseline */
  padding-bottom: var(--gz-space-1);
}

/* flex-nowrap + overflow-x so a narrow viewport scrolls the strip
   sideways rather than wrapping it or collapsing to a <select>
   (DesignSystem.md -> Breakpoints). */
.gz-subsection-nav__tabs {
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
  -webkit-overflow-scrolling: touch;
}

.gz-subsection-nav__tabs::-webkit-scrollbar {
  display: none;
}

.gz-subsection-nav__tabs .nav-link {
  padding: var(--gz-space-2) var(--gz-space-3);
  /* -1px so the 2px active underline straddles the container's 1px rule
     rather than floating just above it. */
  margin-bottom: -1px;
  border-bottom: 2px solid transparent;
  color: var(--gz-text-secondary);
  font-weight: 500;
  white-space: nowrap;
  transition: color var(--gz-dur) var(--gz-ease),
              border-color var(--gz-dur) var(--gz-ease);
}

.gz-subsection-nav__tabs .nav-link:hover {
  color: var(--gz-text-primary);
}

/* Active tab: accent text plus a 2px accent underline - the same
   "you are here" language as the sidebar-rail active marker. */
.gz-subsection-nav__tabs .nav-link.active {
  color: var(--gz-accent);
  font-weight: 600;
  border-bottom-color: var(--gz-accent);
}

/* Account settings body (issue #230). The Microsoft.AspNetCore.Identity.UI
   package pages (Email, Password, Two-factor, Personal data) each render
   their own leading heading for the same title _Layout already shows as
   the section <h1>. Suppress that first heading so the hierarchy has one
   <h1> and no visible duplicate - our own pages simply omit it. */
.gz-account-manage > :is(h1, h2, h3, h4):first-child {
  display: none;
}

/* ------------------------------------------------------------
   THEME TOGGLE - single button flipping light <-> dark. No Bootstrap
   component; icon swaps via data-bs-theme on <html>.
   ------------------------------------------------------------ */
.gz-theme-toggle {
  width: 2.25rem;
  height: 2.25rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--gz-border);
  border-radius: var(--gz-radius);
  background: var(--gz-surface);
  color: var(--gz-text-secondary);
  font-size: var(--gz-icon-md);
}

.gz-theme-toggle:hover {
  color: var(--gz-text-primary);
  border-color: var(--gz-border-strong);
  background: var(--gz-surface-muted);
}

.gz-theme-toggle .gz-theme-toggle__icon { display: none; }
:root[data-bs-theme="light"] .gz-theme-toggle__icon--light { display: inline-block; }
:root[data-bs-theme="dark"]  .gz-theme-toggle__icon--dark  { display: inline-block; }

/* ------------------------------------------------------------
   GHOST BUTTON - transparent until hover. No Bootstrap variant is
   transparent-by-default. Toolbar-adjacent use and the row-actions
   kebab trigger (issue #216); the per-row View / Edit / Delete
   buttons this once carried are one kebab now.
   ------------------------------------------------------------ */
.btn-ghost {
  --bs-btn-color: var(--gz-text-secondary);
  --bs-btn-border-color: transparent;
  --bs-btn-bg: transparent;
  --bs-btn-hover-color: var(--gz-text-primary);
  --bs-btn-hover-bg: var(--gz-surface-muted);
  --bs-btn-hover-border-color: transparent;
  --bs-btn-active-color: var(--gz-text-primary);
  --bs-btn-active-bg: var(--gz-surface-muted);
  --bs-btn-active-border-color: transparent;
  --bs-btn-focus-shadow-rgb: var(--gz-accent-rgb);
}

/* ------------------------------------------------------------
   STATUS PILL - enrichment / triage state. Bootstrap badges are
   fine for solid variants; this is the soft-tinted "state" look
   (coloured text on a wash of the same hue) used across the app.
   Variant set by an added modifier class.
   ------------------------------------------------------------ */
.gz-status-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--gz-space-1);
  padding: 0.15rem var(--gz-space-2);
  font-size: var(--gz-text-xs);
  font-weight: 600;
  line-height: 1.4;
  border-radius: var(--gz-radius-pill);
  white-space: nowrap;
}

.gz-status-pill--neutral { color: var(--gz-text-secondary); background: var(--gz-surface-muted); }
.gz-status-pill--accent  { color: var(--gz-accent);  background: var(--gz-accent-soft); }
.gz-status-pill--success { color: var(--gz-success); background: var(--gz-success-soft); }
.gz-status-pill--warning { color: var(--gz-warning); background: var(--gz-warning-soft); }
.gz-status-pill--priority { color: var(--gz-priority); background: var(--gz-priority-soft); }

/* In-progress enrichment row (Documents/Index, issue #104) - Bootstrap's
   .table-info cyan clashes with the accent. Reuse the soft accent wash. */
.gz-row-in-progress td {
  background-color: var(--gz-accent-soft);
}

/* ------------------------------------------------------------
   CLICKABLE ROW - whole-row navigation (Email/Index). site.js
   handles the click; this is just the affordance. cursor: pointer
   only where a row-click target exists (issue #216) - People (opens
   Edit), Documents and Email opt in; grids with no detail page
   (Admin/Users / Team) don't.
   ------------------------------------------------------------ */
.gz-row-clickable {
  cursor: pointer;
}

/* ------------------------------------------------------------
   ROW ACTIONS - the shared kebab cell (issue #216,
   _RowActionMenu.cshtml). One control on every grid: a
   btn-sm btn-ghost fa-ellipsis-vertical trigger + a
   dropdown-menu-end menu. The trigger sits at reduced opacity
   until the row is hovered or focused - but only on real pointer
   devices; on touch there is no hover, so it stays full opacity
   (never hover-only). site.js gives the trigger a fixed-strategy
   Popper so the menu escapes .table-responsive's overflow-x clip.
   ------------------------------------------------------------ */
.gz-row-actions [data-bs-toggle="dropdown"] {
  transition: opacity var(--gz-dur) var(--gz-ease);
}

@media (hover: hover) and (pointer: fine) {
  .gz-row-actions [data-bs-toggle="dropdown"] {
    opacity: 0;
  }

  /* revealed on row hover/focus, and kept up while the menu is open
     (Bootstrap marks the trigger .show) or the trigger itself is
     keyboard-focused. */
  tr:hover .gz-row-actions [data-bs-toggle="dropdown"],
  tr:focus-within .gz-row-actions [data-bs-toggle="dropdown"],
  .gz-row-actions [data-bs-toggle="dropdown"].show,
  .gz-row-actions [data-bs-toggle="dropdown"]:focus-visible {
    opacity: 1;
  }
}

/* ------------------------------------------------------------
   BULK BAR - replaces the list toolbar while >= 1 row is
   selected (issue #216). site.js toggles it against
   [data-bulk-toolbar] and keeps [data-bulk-count] live. Only the
   grids with bulk operations (Documents, Email) render one.
   ------------------------------------------------------------ */
.gz-bulk-bar {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--gz-space-2) var(--gz-space-3);
  padding: var(--gz-space-2) var(--gz-space-3);
  background: var(--gz-accent-soft);
  border: 1px solid var(--gz-border);
  border-radius: var(--gz-radius);
}

.gz-bulk-bar__count {
  font-weight: 600;
  color: var(--gz-text-primary);
}

/* actions + Clear pushed to the trailing edge, "(N)" counts inline */
.gz-bulk-bar__actions {
  margin-left: auto;
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: var(--gz-space-2);
}

/* The list toolbar wears the bulk bar's frame (same padding, same border
   box) so the swap to the real bulk bar on selection is the same height and
   the grid never jumps (issue #216, Email grid). Neutral fill and border
   until a row is actually selected - the accent-soft bar reads as "you're in
   selection mode now". */
.gz-bulk-bar--toolbar {
  background: transparent;
  border-color: transparent;
}

/* ------------------------------------------------------------
   EMPTY STATE - _EmptyState.cshtml. One shape for every "nothing
   here yet" surface, replacing hand-rolled centred card bodies.
   ------------------------------------------------------------ */
.gz-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--gz-space-2);
  padding: var(--gz-space-9) var(--gz-space-5);
}

/* Rounded icon tile - the empty-state icon and the home page's section
   cards both use it. */
.gz-icon-tile,
.gz-empty__icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 3rem;
  height: 3rem;
  border-radius: var(--gz-radius-lg);
  background: var(--gz-surface-muted);
  color: var(--gz-text-secondary);
  font-size: var(--gz-icon-lg);
}

.gz-empty__icon {
  margin-bottom: var(--gz-space-1);
}

/* Card that is itself a link (home page section cards) - lift on hover. */
a.card {
  color: inherit;
}
a.card:hover {
  border-color: var(--gz-border-strong);
  box-shadow: var(--gz-shadow-2);
}
a.card:hover .gz-icon-tile {
  background: var(--gz-accent-soft);
  color: var(--gz-accent);
}

.gz-empty__title {
  font-weight: 600;
  color: var(--gz-text-primary);
}

.gz-empty__body {
  color: var(--gz-text-secondary);
  font-size: var(--gz-text-md);
  max-width: 42ch;
}

/* ------------------------------------------------------------
   SKELETON - loading placeholder for async content (ingestion is
   asynchronous by design). Shimmer respects reduced-motion.
   ------------------------------------------------------------ */
.gz-skeleton {
  display: block;
  border-radius: var(--gz-radius-sm);
  background: linear-gradient(
    90deg,
    var(--gz-surface-muted) 25%,
    var(--gz-border) 37%,
    var(--gz-surface-muted) 63%
  );
  background-size: 400% 100%;
  animation: gz-skeleton-shimmer 1.4s ease infinite;
}

.gz-skeleton--text { height: 0.75rem; margin: 0.35rem 0; }
.gz-skeleton--title { height: 1.1rem; width: 40%; }
.gz-skeleton--line-short { width: 60%; }

@keyframes gz-skeleton-shimmer {
  0% { background-position: 100% 50%; }
  100% { background-position: 0 50%; }
}

@media (prefers-reduced-motion: reduce) {
  .gz-skeleton { animation: none; background: var(--gz-surface-muted); }
}

/* ------------------------------------------------------------
   LIST-LOAD STAGGER - opt-in entrance for list/grid items via
   class="gz-stagger" on the container. Pure CSS; site.js does
   nothing. Overshoot easing is deliberately NOT used on data
   (reads as sloppy on informational UI - DesignSystem.md -> Motion).
   ------------------------------------------------------------ */
@media (prefers-reduced-motion: no-preference) {
  .gz-stagger > * {
    animation: gz-fade-rise var(--gz-dur-slow) var(--gz-ease-out) both;
  }
  .gz-stagger > *:nth-child(1) { animation-delay: 0ms; }
  .gz-stagger > *:nth-child(2) { animation-delay: 30ms; }
  .gz-stagger > *:nth-child(3) { animation-delay: 60ms; }
  .gz-stagger > *:nth-child(4) { animation-delay: 90ms; }
  .gz-stagger > *:nth-child(5) { animation-delay: 120ms; }
  .gz-stagger > *:nth-child(6) { animation-delay: 150ms; }
  .gz-stagger > *:nth-child(7) { animation-delay: 180ms; }
  .gz-stagger > *:nth-child(8) { animation-delay: 210ms; }
}

@keyframes gz-fade-rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ------------------------------------------------------------
   SMALL LAYOUT UTILITIES - fixed sizes / wrap behaviour Bootstrap
   has no utility for. Kept token-based and named so views never
   need an inline style="".
   ------------------------------------------------------------ */

/* Checkbox / select column in a list table. */
.gz-col-select { width: 2.75rem; }

/* Truncating cell - pair with .text-truncate. Bootstrap has no
   max-width utility. */
.gz-cell-truncate { max-width: 20rem; }

/* Preserve source formatting in a rendered text block (chunk
   previews, plain-text email bodies). */
.gz-pre-wrap {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

/* Embedded document preview (iframe / img) - one framed box, height
   set by a modifier per content type. */
.gz-embed {
  width: 100%;
  border: 1px solid var(--gz-border);
  border-radius: var(--gz-radius);
  background: var(--gz-surface-raised);
}
.gz-embed--email { height: 400px; }
.gz-embed--html { height: 600px; }
.gz-embed--pdf { height: 800px; }
.gz-embed--image { height: auto; max-width: 100%; }

/* <details> summaries are click targets. */
summary { cursor: pointer; }

/* ------------------------------------------------------------
   MISC - small fixed-size exceptions no utility covers.
   ------------------------------------------------------------ */

/* Initials avatar in the account dropdown. */
.avatar-initials {
  width: 2rem;
  height: 2rem;
  font-size: var(--gz-text-sm);
  font-weight: 600;
  background: var(--gz-accent-soft) !important;
  color: var(--gz-accent) !important;
}

/* form-select's intrinsic auto width doesn't reserve room for its
   own chevron, so w-auto makes the arrow overlap the value. */
.page-size-select {
  width: 5rem;
}

/* Scrollable checkbox list (People Create/Edit engagement picker) -
   no Bootstrap utility caps height with overflow. */
.checklist-scroll {
  max-height: 12rem;
  overflow-y: auto;
  border: 1px solid var(--gz-border);
  border-radius: var(--gz-radius);
  padding: var(--gz-space-3);
}

/* ------------------------------------------------------------
   DROP ZONE - Upload page (issue #166). A labelled dashed target
   that also opens the file picker on click; accent-tinted while a
   file is dragged over it. Bootstrap has no equivalent.
   ------------------------------------------------------------ */
.gz-dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: var(--gz-space-2);
  padding: var(--gz-space-8) var(--gz-space-5);
  border: 2px dashed var(--gz-border-strong);
  border-radius: var(--gz-radius-lg);
  background: var(--gz-surface-muted);
  color: var(--gz-text-secondary);
  cursor: pointer;
  transition: border-color var(--gz-dur) var(--gz-ease),
              background-color var(--gz-dur) var(--gz-ease),
              color var(--gz-dur) var(--gz-ease);
}

.gz-dropzone:hover,
.gz-dropzone:focus-visible {
  border-color: var(--gz-accent);
  color: var(--gz-text-primary);
}

.gz-dropzone.is-dragover {
  border-color: var(--gz-accent);
  background: var(--gz-accent-soft);
  color: var(--gz-accent);
}

.gz-dropzone__icon {
  font-size: var(--gz-text-2xl);
}

.gz-dropzone__hint {
  font-size: var(--gz-text-sm);
  color: var(--gz-text-secondary);
}

/* ------------------------------------------------------------
   THREAD SYNTHESIS (Email/Thread, issue #135) - Markdig output
   carries no Bootstrap classes, so table styling is scoped here
   rather than styling bare <table> globally. Rule lines use the
   border token so they stay visible on any panel background.
   ------------------------------------------------------------ */
.thread-synthesis table {
  width: 100%;
  border-collapse: collapse;
  margin: var(--gz-space-3) 0;
  font-size: var(--gz-text-md);
}

.thread-synthesis th,
.thread-synthesis td {
  padding: var(--gz-space-2) var(--gz-space-3);
  text-align: left;
  border-bottom: 1px solid var(--gz-border-strong);
}

.thread-synthesis th {
  font-size: var(--gz-text-xs);
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--gz-text-secondary);
}

/* Disclosure chevron - native <details> marker isn't stylable
   cross-browser, so it's hidden and replaced with a FA chevron
   that rotates on [open], matching Bootstrap's accordion convention. */
.thread-synthesis-summary {
  list-style: none;
  cursor: pointer;
}

.thread-synthesis-summary::-webkit-details-marker {
  display: none;
}

.thread-synthesis-chevron {
  font-size: var(--gz-icon-sm);
  transition: transform var(--gz-dur) var(--gz-ease);
}

details[open] > .thread-synthesis-summary .thread-synthesis-chevron {
  transform: rotate(90deg);
}

/* ------------------------------------------------------------
   RELEASE NOTES (issue #163)

   .gz-whatsnew — the one-line "what's new" bar at the top of <main>:
   the app updated, plus a link to the full notes on /ReleaseNotes.
   Not the notes inline — a long note would swamp the page (VS Code's
   pattern: a small signal, notes on their own page). Tinted on
   --gz-accent-soft, the token the design system already uses for the
   active-nav / in-progress fill. .gz-release-list is the /ReleaseNotes
   history page.
   ------------------------------------------------------------ */
.gz-whatsnew {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: var(--gz-space-2) var(--gz-space-3);
  background: var(--gz-accent-soft);
  border: 1px solid var(--gz-border);
  border-radius: var(--gz-radius);
  padding: var(--gz-space-2) var(--gz-space-4);
  margin-bottom: var(--gz-space-4);
}

.gz-whatsnew__text {
  color: var(--gz-text-primary);
  font-size: var(--gz-text-md);
}

/* Keep "See what's new" on one line so a narrow viewport wraps the whole
   phrase, not the middle of it. */
.gz-whatsnew__text a {
  white-space: nowrap;
}

.gz-whatsnew__dismiss {
  flex-shrink: 0;
}

/* History list — plain stack of cards, one per release. */
.gz-release-list > .card + .card {
  margin-top: var(--gz-space-4);
}

/* "Seen before this point" — the divider on /ReleaseNotes above which
   the cards are ones this reader hadn't seen before this visit. */
.gz-release-list__seen-from {
  display: flex;
  align-items: center;
  gap: var(--gz-space-3);
  margin: var(--gz-space-5) 0 var(--gz-space-4);
  color: var(--gz-text-secondary);
  font-size: var(--gz-text-xs);
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.gz-release-list__seen-from::before,
.gz-release-list__seen-from::after {
  content: "";
  flex: 1;
  border-top: 1px solid var(--gz-border);
}

.gz-release-list__version {
  font-size: var(--gz-text-lg);
  font-weight: 700;
  margin: 0 0 var(--gz-space-2);
}

.gz-release-list__summary {
  font-size: var(--gz-text-md);
  color: var(--gz-text-primary);
  margin: 0 0 var(--gz-space-2);
}

.gz-release-list__bullets {
  padding-left: var(--gz-space-5);
  color: var(--gz-text-secondary);
}

.gz-release-list__bullets li + li {
  margin-top: var(--gz-space-1);
}
