/*
 * ZBOS shell components — wireframe primitives.
 * Shared across all scaffold HTML files. No JS, no framework.
 */

/* ─── Top Nav ─────────────────────────────────────────────────── */

.zb-topnav {
  display: flex;
  align-items: center;
  gap: var(--space-6);
  height: var(--layout-topnav-height);
  padding: 0 var(--space-6);
  background: var(--surface-card);
  border-bottom: 1px solid var(--border-subtle);
  position: sticky;
  top: 0;
  z-index: var(--z-sticky);
}

.zb-topnav__logo {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  font-weight: var(--weight-semibold);
  font-size: var(--text-lg);
  color: var(--text-primary);
}

.zb-topnav__logo-mark {
  width: 28px;
  height: 28px;
  background: var(--blue-600);
  border-radius: var(--radius-md);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: var(--weight-bold);
  font-size: var(--text-base);
}

.zb-topnav__items {
  display: flex;
  gap: var(--space-1);
  flex: 1;
}

.zb-topnav__item {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border: 1px solid transparent;
  background: transparent;
  cursor: pointer;
  transition: background var(--motion-fast) var(--easing-standard);
}
.zb-topnav__item:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}
.zb-topnav__item.is-active {
  background: var(--surface-card);
  border-color: var(--border-subtle);
  color: var(--text-primary);
  box-shadow: var(--shadow-xs);
}

.zb-topnav__right {
  display: inline-flex;
  align-items: center;
  gap: var(--space-3);
}

.zb-iconbtn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  position: relative;
}
.zb-iconbtn:hover {
  background: var(--gray-100);
  color: var(--text-primary);
}
.zb-iconbtn__dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 8px;
  height: 8px;
  border-radius: var(--radius-pill);
  background: var(--red-500);
  border: 2px solid var(--surface-card);
}

.zb-user {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-1) var(--space-2);
  border-radius: var(--radius-md);
}
.zb-user__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.zb-user__role {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.zb-user__name-block {
  display: flex;
  flex-direction: column;
  line-height: 1.15;
}

.zb-avatar {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-pill);
  background: var(--blue-600);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
}

/* ─── Side Nav (admin / collapsed alt) ────────────────────────── */

.zb-sidenav {
  width: var(--layout-sidenav-width);
  min-height: calc(100vh - var(--layout-topnav-height));
  background: var(--surface-card);
  border-right: 1px solid var(--border-subtle);
  padding: var(--space-4) var(--space-2);
}

.zb-sidenav__group {
  display: block;
  font-size: var(--text-xs);
  font-weight: var(--weight-semibold);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--text-tertiary);
  padding: var(--space-3) var(--space-3) var(--space-1);
}

.zb-sidenav__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  text-decoration: none;
}
.zb-sidenav__item:hover {
  background: var(--gray-100);
  color: var(--text-primary);
  text-decoration: none;
}
.zb-sidenav__item.is-active {
  background: var(--blue-50);
  color: var(--blue-700);
  font-weight: var(--weight-medium);
}
.zb-sidenav__icon {
  width: 20px;
  height: 20px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: currentColor;
}

/* ─── Tenant Switcher ─────────────────────────────────────────── */

.zb-tenant {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  background: var(--surface-card);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  color: var(--text-primary);
  cursor: pointer;
}
.zb-tenant:hover {
  border-color: var(--border-default);
}
.zb-tenant__mark {
  width: 20px;
  height: 20px;
  border-radius: var(--radius-sm);
  background: var(--gray-900);
  color: var(--white);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: var(--weight-bold);
}
.zb-tenant__caret {
  color: var(--text-tertiary);
  font-size: var(--text-xs);
}

.zb-tenant-menu {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  min-width: 280px;
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: var(--space-2);
  z-index: var(--z-dropdown);
}
.zb-tenant-menu__item {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-2) var(--space-3);
  border-radius: var(--radius-md);
}
.zb-tenant-menu__item:hover {
  background: var(--gray-100);
}
.zb-tenant-menu__item.is-current {
  background: var(--blue-50);
}
.zb-tenant-menu__name {
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
}
.zb-tenant-menu__loc {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.zb-tenant-menu__divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-2) 0;
}
.zb-tenant-menu__cta {
  padding: var(--space-2) var(--space-3);
  font-size: var(--text-sm);
  color: var(--blue-600);
  font-weight: var(--weight-medium);
}

/* ─── Page surface ────────────────────────────────────────────── */

.zb-app {
  display: flex;
  min-height: 100vh;
  flex-direction: column;
}
.zb-page {
  max-width: var(--layout-content-max);
  margin: 0 auto;
  width: 100%;
  padding: var(--space-8) var(--space-8);
}
.zb-page__header {
  margin-bottom: var(--space-6);
}
.zb-page__title {
  font-size: var(--text-3xl);
  font-weight: var(--weight-semibold);
  margin: 0 0 var(--space-1);
}
.zb-page__subtitle {
  color: var(--text-secondary);
  font-size: var(--text-sm);
  margin: 0;
}

/* ─── Card ─────────────────────────────────────────────────────── */

.zb-card {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-xs);
}
.zb-card__head {
  padding: var(--space-4) var(--space-5);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.zb-card__title {
  font-size: var(--text-base);
  font-weight: var(--weight-semibold);
  margin: 0;
}
.zb-card__sub {
  font-size: var(--text-xs);
  color: var(--text-tertiary);
}
.zb-card__body {
  padding: var(--space-5);
}

/* ─── Buttons ──────────────────────────────────────────────────── */

.zb-btn {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
  padding: var(--space-2) var(--space-4);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  background: var(--surface-card);
  color: var(--text-primary);
  cursor: pointer;
  transition: background var(--motion-fast);
}
.zb-btn:hover {
  background: var(--gray-50);
}
.zb-btn--primary {
  background: var(--blue-600);
  color: var(--white);
  border-color: var(--blue-600);
}
.zb-btn--primary:hover {
  background: var(--blue-700);
  border-color: var(--blue-700);
}
.zb-btn--ghost {
  background: transparent;
  border-color: var(--border-default);
}
.zb-btn--danger {
  background: var(--red-600);
  color: var(--white);
  border-color: var(--red-600);
}
.zb-btn--lg {
  padding: var(--space-3) var(--space-5);
  font-size: var(--text-base);
}
.zb-btn--block {
  display: flex;
  width: 100%;
  justify-content: center;
}

/* ─── Pills · status ──────────────────────────────────────────── */

.zb-pill {
  display: inline-flex;
  align-items: center;
  gap: var(--space-1);
  padding: 2px var(--space-2);
  border-radius: var(--radius-pill);
  font-size: var(--text-xs);
  font-weight: var(--weight-medium);
}
/* Each variant carries a leading glyph so colour is not the sole signal (WCAG 1.4.1). */
.zb-pill--neutral {
  background: var(--gray-100);
  color: var(--gray-700);
}
.zb-pill--brand {
  background: var(--blue-50);
  color: var(--blue-700);
}
.zb-pill--ok {
  background: var(--green-100);
  color: var(--green-700);
}
.zb-pill--warn {
  background: var(--orange-100);
  color: var(--orange-700);
}
.zb-pill--bad {
  background: var(--red-100);
  color: var(--red-700);
}
.zb-pill--ok::before {
  content: "● ";
  font-size: 0.7em;
}
.zb-pill--warn::before {
  content: "▲ ";
  font-size: 0.7em;
}

/* Inline SVG inside icon buttons / chevrons / logo — currentColor + fixed size,
   so they render even if the system has no emoji fallback font. */
.zb-iconbtn svg,
.zb-topnav__item svg,
.zb-tenant__caret svg {
  width: 18px;
  height: 18px;
  display: block;
}
.zb-topnav__logo-mark svg {
  width: 28px;
  height: 28px;
  display: block;
}
.zb-pill--bad::before {
  content: "● ";
  font-size: 0.7em;
}

/* ─── KPI tiles ────────────────────────────────────────────────── */

.zb-kpi-row {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: var(--space-4);
}
.zb-kpi {
  background: var(--surface-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-xl);
  padding: var(--space-5);
}
.zb-kpi__label {
  font-size: var(--text-xs);
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.04em;
}
.zb-kpi__value {
  font-size: var(--text-2xl);
  font-weight: var(--weight-semibold);
  margin-top: var(--space-2);
}
.zb-kpi__delta {
  font-size: var(--text-xs);
  margin-top: var(--space-1);
}
/* Status is paired with a glyph + sign — never colour as sole signal (WCAG 1.4.1). */
.zb-kpi__delta.is-pos {
  color: var(--text-positive);
}
.zb-kpi__delta.is-neg {
  color: var(--text-negative);
}
.zb-kpi__delta.is-pos::before {
  content: "▲ ";
  font-size: 0.85em;
}
.zb-kpi__delta.is-neg::before {
  content: "▼ ";
  font-size: 0.85em;
}

/* ─── Form elements ────────────────────────────────────────────── */

.zb-input,
.zb-search {
  width: 100%;
  padding: var(--space-2) var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  background: var(--surface-card);
  color: var(--text-primary);
}
.zb-input:focus,
.zb-search:focus {
  border-color: var(--border-focus);
  outline: none;
  box-shadow: var(--shadow-focus);
}

.zb-search-row {
  display: flex;
  align-items: center;
  background: var(--surface-card);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  padding: var(--space-1) var(--space-3);
  gap: var(--space-2);
}
.zb-search-row input {
  border: none;
  background: transparent;
  flex: 1;
  outline: none;
  font-size: var(--text-sm);
}

.zb-chips {
  display: inline-flex;
  gap: var(--space-2);
  flex-wrap: wrap;
}
/* Min-height 30px to clear WCAG 2.5.8 (24x24 minimum target size, new in 2.2). */
.zb-chip {
  padding: var(--space-2) var(--space-3);
  min-height: 30px;
  border-radius: var(--radius-pill);
  border: 1px solid var(--border-subtle);
  background: var(--surface-card);
  color: var(--text-secondary);
  font-size: var(--text-sm);
  cursor: pointer;
}
.zb-chip.is-active {
  background: var(--blue-600);
  color: var(--white);
  border-color: var(--blue-600);
}

/* ─── Skip link · WCAG 2.4.1 ──────────────────────────────────── */

.zb-skip {
  position: absolute;
  top: var(--space-2);
  left: var(--space-2);
  background: var(--blue-700);
  color: var(--white);
  padding: var(--space-2) var(--space-4);
  border-radius: var(--radius-md);
  font-size: var(--text-sm);
  font-weight: var(--weight-medium);
  text-decoration: none;
  /* Off-screen until focused — visible-on-focus pattern. */
  transform: translateY(-200%);
  transition: transform var(--motion-fast) var(--easing-standard);
  z-index: var(--z-toast);
}
.zb-skip:focus,
.zb-skip:focus-visible {
  transform: translateY(0);
  outline: var(--focus-ring-width) solid var(--white);
  outline-offset: 2px;
}

/* ─── Screen-reader-only utility ─────────────────────────────── */

.zb-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ─── Misc ─────────────────────────────────────────────────────── */

.zb-stack {
  display: flex;
  flex-direction: column;
  gap: var(--space-4);
}
.zb-row {
  display: flex;
  align-items: center;
  gap: var(--space-3);
}
.zb-grow {
  flex: 1;
}
.zb-divider {
  height: 1px;
  background: var(--border-subtle);
  margin: var(--space-3) 0;
}

.zb-muted {
  color: var(--text-secondary);
}
.zb-tiny {
  font-size: var(--text-xs);
}

/* Dotted citation underline for AI Copilot grounded numbers. */
.zb-cite {
  border-bottom: 1px dotted var(--blue-600);
  cursor: help;
}
