/* ============================================================
   topnav.css — the top navigation bar and the full-width page
   (Andrew 2026-10-26: the left sidebar is gone).

   Markup: base.html (`header.topbar`). Behaviour: topnav.js.
   Loads after theme_br.css. Colours are tokens only, so light and
   dark both follow tokens.css.

   1. Brand (the Book Runners logo mark + name)
   2. Section menus (trigger, underline, alert dot, panel, items)
   3. Account menu extras (dark-mode switch, user, sign out)
   4. Right-hand tools (job pill, Report an issue, ISBN search) wrap
   5. Breadcrumbs row
   6. Full-width page: one-line labels, tables scroll in their box,
      tab rows never show scroll arrows
   ============================================================ */

/* ---------- 1. Brand ---------- */
.topnav-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: none;
  min-height: 60px;
  margin-right: 14px;
}
/* The logo is the real Book Runners mark (static/br_logo_mark.png, cut from
   white_logo_transparent.png). The PNG is white on transparent, so it is used as a
   mask over a theme colour: dark on the white bar, light on the dark bar, always crisp. */
.topnav-logo {
  width: 30px;
  height: 30px;
  flex: none;
  background-color: var(--text);
  -webkit-mask: url("br_logo_mark.png") center / contain no-repeat;
  mask: url("br_logo_mark.png") center / contain no-repeat;
}
.topnav-brand-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.2;
}
.topnav-brand-name {
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--text);
  white-space: nowrap;
}
.topnav-brand-env {
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-muted);
  white-space: nowrap;
}

/* ---------- 2. Section menus ---------- */
.topnav-menus {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  align-self: stretch;
  min-height: 60px;
  gap: 2px;
}
.topnav-menu {
  position: relative;
  display: flex;
  align-items: center;
}
.topnav-trigger {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 38px;
  padding: 0 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text-muted);
  font: 600 12px/1 var(--font-sans);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  white-space: nowrap;
  cursor: pointer;
}
.topnav-trigger:hover,
.topnav-menu.is-open .topnav-trigger {
  background: var(--surface-2);
  color: var(--text);
}
.topnav-trigger:focus-visible,
.topnav-item:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 1px;
}
.topnav-chev {
  width: 14px;
  height: 14px;
  flex: none;
  transition: transform 0.15s ease;
}
.topnav-menu.is-open .topnav-chev { transform: rotate(180deg); }

/* Current section: orange label and an orange underline on the bar's bottom edge. */
.topnav-menu.is-current .topnav-trigger { color: var(--brand-deep); }
.topnav-menu.is-current::after {
  content: "";
  position: absolute;
  left: 10px;
  right: 10px;
  bottom: 0;
  height: 2px;
  border-radius: 2px 2px 0 0;
  background: var(--brand);
}

/* System Status alert: a dot on the OPERATIONS label, visible with the menu closed. */
.topnav-alert-dot {
  width: 8px;
  height: 8px;
  flex: none;
  border-radius: 50%;
  background: var(--danger);
}

.topnav-panel {
  position: absolute;
  top: 100%;
  left: 0;
  z-index: 100;
  min-width: 268px;
  max-width: calc(100vw - 16px);
  padding: 6px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}
.topnav-panel[hidden] { display: none; }

.topnav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 9px 12px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--text);
  font: 500 14px/1.3 var(--font-sans);
  text-align: left;
  text-decoration: none;
  white-space: nowrap;
  cursor: pointer;
}
.topnav-item:hover { background: var(--surface-2); }
.topnav-item.is-active {
  background: var(--brand-soft);
  color: var(--brand-deep);
  font-weight: 600;
}
.topnav-ic {
  width: 18px;
  height: 18px;
  flex: none;
  color: var(--text-muted);
}
.topnav-item.is-active .topnav-ic { color: currentColor; }
.topnav-label { flex: 1; min-width: 0; }
.topnav-ext {
  width: 14px;
  height: 14px;
  flex: none;
  color: var(--text-muted);
}

/* Alert badge on the System Status entry (a count, "!" when degraded). */
.topnav-badge {
  display: inline-grid;
  place-items: center;
  min-width: 20px;
  height: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--danger);
  color: var(--brand-fg);
  font-size: 11px;
  font-weight: 700;
  line-height: 1;
}
/* Count variant (Flags): an inventory count, not an alert, so no red fill. */
.topnav-badge--count {
  background: transparent;
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-weight: 500;
}
.topnav-item.is-active .topnav-badge--count { color: inherit; }

/* ---------- 3. Account menu extras ---------- */
.topnav-sep {
  height: 1px;
  margin: 6px 4px;
  background: var(--border);
}
.topnav-theme-btn .topnav-switch {
  position: relative;
  flex: none;
  width: 28px;
  height: 16px;
  border-radius: 999px;
  border: 1px solid var(--border-strong);
  background: var(--surface-2);
}
.topnav-theme-btn .topnav-switch::after {
  content: "";
  position: absolute;
  top: 2px;
  left: 2px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-muted);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
[data-theme="dark"] .topnav-theme-btn .topnav-switch {
  border-color: color-mix(in srgb, var(--accent) 45%, transparent);
  background: var(--accent-soft);
}
[data-theme="dark"] .topnav-theme-btn .topnav-switch::after {
  background: var(--accent);
  transform: translateX(12px);
}
.topnav-user {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 8px 12px;
}
.topnav-avatar {
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  flex: none;
  border-radius: 50%;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 11.5px;
  font-weight: 700;
}
[data-theme="dark"] .topnav-avatar {
  background: var(--surface-2);
  color: var(--text);
}
.topnav-user-text {
  display: flex;
  flex-direction: column;
  min-width: 0;
  line-height: 1.25;
}
.topnav-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.topnav-user-role {
  font-size: 11px;
  color: var(--text-muted);
}
.topnav-signout:hover { color: var(--danger); }

/* ---------- 4. Right-hand tools ---------- */
/* The job pill, Report an issue and the ISBN search stay on the first line while they fit.
   When they do not, the whole group drops to a second line under the menus (the bar is
   flex-wrap), and inside the group they wrap again on a very narrow window. Nothing is cut off. */
.topnav-tools {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  min-width: 0;
  max-width: 100%;
  margin-left: auto;
  padding: 10px 0;
}

/* Below 1040px the five menus (777px wide at full padding) need the brand's room to stay on the logo's row:
   only the mark shows, without the margin its name needed, and the menu buttons pad 10px a side. */
@media (max-width: 1040px) {
  .topnav-brand-text { display: none; }
  .topnav-brand { margin-right: 0; }
  .topnav-trigger { padding: 0 10px; }
}

@media (max-width: 700px) {
  header.topbar { padding: 0 12px; gap: 0 12px; }
  .topnav-menus { flex: 1 1 100%; min-height: 48px; }
  .topnav-brand { min-height: 52px; }
  .topnav-trigger { padding: 0 9px; }
  .topnav-tools { flex: 1 1 100%; justify-content: flex-start; }
  .isbn-topbar-search { flex: 1 1 220px; width: auto; min-width: 0; }
}

/* ---------- 5. Breadcrumbs ---------- */
/* A page's own trail, shown only when it carries a link back (Amazon / Overview / Books,
   Reporting / FBA Buying Dashboard / Batch). A bare "Section / Page" pair repeats the menu and
   the page heading, so it stays out of the way. */
.crumbs { padding: 12px 24px 0; }
.crumbs:not(:has(a)) { display: none; }
@media (max-width: 700px) {
  .crumbs { padding-inline: 12px; }
}

/* ---------- 6. Full-width page ---------- */
/* Labels stay on one line: tabs and buttons. (Pills and chips sit inside table cells that wrap them on
   purpose; table headers and section names are
   measured by the visual-QA job and fixed where they actually wrap, not blanket-forced: many
   tables are fixed-layout with their own column widths.) */
:where(.page) :where(.pill-tab, .btn, button, a.button-link) { white-space: nowrap; }  /* zero specificity: a control that wraps on purpose (.rp-rules-button) keeps its own rule */

/* A wide table scrolls sideways inside its own box instead of pushing the page. */
.page :is(.card, .panel):has(> table) {
  max-width: 100%;
  overflow-x: auto;
}
