/* The clerk menu (D-143): the desk's side menu, shared by desk, admin, catalog, scan and the
   production board. The desk has the menu in its markup; app/js/app-nav.js builds the same one
   on the other pages (.app-nav). <html data-nav="top"> lays it out as one row (per user). */

.desk-nav {
  width: 256px;
  flex-shrink: 0;
  background: var(--nav);
  color: var(--on-nav);
  border-inline-end: 0;
  padding: 20px 12px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
  scrollbar-width: thin;
}
.desk-nav-brand {
  padding: 4px 8px 12px;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}
.desk-nav-logo { width: 30px; height: 30px; color: var(--on-nav); flex: none; }
.desk-nav-mark {
  margin: 0;
  flex: 1 1 0;
  min-width: 0;
  align-self: center;
  font-size: var(--fs-lg);
  font-weight: 800;
  line-height: 1.15;
  color: var(--on-nav);
}
.desk-nav-brand .sub {
  margin: 4px 0 0;
  color: var(--on-nav-muted);
  font-size: .82rem;
  font-weight: 400;
  line-height: 1.35;
  width: 100%;
}
.desk-nav-more {
  display: none;
  border: 1.5px solid color-mix(in srgb, var(--on-nav) 35%, transparent);
  background: transparent;
  color: var(--on-nav);
  font: inherit;
  font-weight: 700;
  font-size: .92rem;
  min-height: var(--tap);
  padding: 8px 14px;
  border-radius: var(--r-sm);
  cursor: pointer;
}
.desk-nav-more:hover { border-color: var(--on-nav); color: var(--on-nav); }
.desk-nav-more[aria-expanded="true"] {
  background: color-mix(in srgb, var(--on-nav) 16%, transparent);
  border-color: var(--on-nav);
  color: var(--on-nav);
}
/* Group titles read as labels, not items (D-126 sidebar pass). */
.desk-nav-label {
  margin: var(--sp-5) var(--space-3) var(--sp-1);
  font-size: var(--fs-14);
  font-weight: 700;
  letter-spacing: 0;
  color: var(--on-nav-muted);
}
.desk-nav-main .desk-nav-label:first-child { margin-top: var(--sp-2); }
.desk-nav-label-sys {
  padding-top: var(--sp-4);
  border-top: 1px solid color-mix(in srgb, var(--on-nav) 14%, transparent);
}
.desk-nav-main,
.desk-nav-foot {
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.desk-nav-main { flex: 1; }
.desk-nav-foot {
  padding-top: 12px;
  margin-top: 8px;
  border-top: 1px solid color-mix(in srgb, var(--on-nav) 18%, transparent);
}
.tab-btn {
  width: 100%;
  border: 0;
  background: transparent;
  padding: 10px 12px;
  min-height: var(--tap);
  border-radius: var(--r-sm);
  font: inherit;
  font-size: var(--fs-md);
  font-weight: 700;
  color: var(--on-nav);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: start;
  gap: 8px;
  position: relative;
  box-shadow: none;
}
.tab-btn:hover { background: color-mix(in srgb, var(--on-nav) 12%, transparent); }
.tab-btn.active {
  color: var(--on-nav);
  font-weight: 800;
  background: color-mix(in srgb, var(--on-nav) 18%, transparent);
}
/* "You are here": the mark orange edge (D-126). */
.tab-btn.active::before {
  content: "";
  position: absolute;
  inset-block: 8px;
  inset-inline-start: 0;
  width: 4px;
  border-radius: 999px;
  background: var(--accent-mark);
}
/* הזמנה חדשה is the desk's main action: a deep-orange button, shown first in its group. */
#tabLinks {
  margin: var(--sp-1) 0 var(--sp-2);
  background: var(--accent);
  color: var(--on-accent);
  justify-content: center;
}
#tabLinks::after { content: none; }
#tabLinks > span::before { content: "+ "; }
#tabLinks:hover { background: var(--accent-hover); }
#tabLinks.active { background: var(--accent-hover); }
.tab-btn:focus-visible,
.nav-link:focus-visible,
.desk-nav-more:focus-visible {
  outline: 2px solid var(--on-nav);
  outline-offset: 2px;
}
/* New orders: charcoal on the mark orange (6.1:1). */
.tab-badge {
  background: var(--accent-mark);
  color: #1C1916; /* the bright mark is the same in every theme, so its text is too (D-153) */
  border: 0;
  font-size: var(--fs-12);
  font-weight: 800;
  min-width: 22px;
  text-align: center;
  padding: 2px 7px;
  border-radius: 999px;
  margin-inline-start: auto;
}
.tab-badge[hidden] { display: none !important; }
.tab-btn.active .tab-badge {
  background: var(--accent-mark);
  color: #1C1916; /* the bright mark is the same in every theme, so its text is too (D-153) */
  border-color: transparent;
}
.nav-link {
  display: flex;
  align-items: center;
  width: 100%;
  min-height: var(--tap);
  padding: 8px 12px;
  border: 0;
  background: transparent;
  color: var(--on-nav);
  font: inherit;
  font-weight: 600;
  font-size: 1rem;
  text-decoration: none;
  cursor: pointer;
  border-radius: var(--r-sm);
  text-align: start;
}
.nav-link[hidden],
.tab-btn[hidden] { display: none !important; }
.nav-link:hover { background: color-mix(in srgb, var(--on-nav) 12%, transparent); color: var(--on-nav); }
.desk-mill-scope {
  width: 100%;
  padding: 0 12px 10px;
}
.desk-mill-scope[hidden] { display: none !important; }
.desk-mill-scope select {
  width: 100%;
  min-height: var(--tap);
  border-radius: var(--r-sm);
  border: 1.5px solid color-mix(in srgb, var(--on-nav) 35%, transparent);
  background: color-mix(in srgb, var(--on-nav) 10%, transparent);
  color: var(--on-nav);
  font: inherit;
  font-weight: 700;
  padding: 8px 10px;
}
.desk-mill-scope select:focus-visible {
  outline: 2px solid var(--on-nav);
  outline-offset: 2px;
}
/* Open list: ink on surface (light/dark/contrast). Closed face stays --on-nav on the dark nav. */
.desk-mill-scope select option {
  background-color: var(--surface);
  color: var(--ink);
}

/* ── back + layout switch (D-143) ── */
.nav-back {
  display: inline-flex; align-items: center; gap: 6px;
  min-height: 40px; padding: 6px 14px; margin: 0 4px 8px;
  border: 1.5px solid color-mix(in srgb, var(--on-nav) 35%, transparent); border-radius: var(--r-sm);
  background: transparent; color: var(--on-nav); font: inherit; font-weight: 800; font-size: 1rem; cursor: pointer;
}
.nav-back:hover:not(:disabled) { background: color-mix(in srgb, var(--on-nav) 12%, transparent); border-color: var(--on-nav); }
.nav-back:disabled { opacity: .45; cursor: default; }
.nav-back:focus-visible, .nav-more-btn:focus-visible { outline: 2px solid var(--on-nav); outline-offset: 2px; }
/* The arrow points back: right in Hebrew/Arabic, left in English/Russian. */
.nav-back svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2.4; stroke-linecap: round; stroke-linejoin: round; }
html[dir="ltr"] .nav-back svg { transform: scaleX(-1); }
/* The side/top switch (D-164): one icon pill in the settings at the menu foot (app-nav.js
   toggleHtml); the top row is forced below 1200 px (D-152), so there it is not offered. */
.desk-nav .uc-navsw { flex: 0 0 auto; justify-content: center; padding: 0 9px; }
@media (max-width: 1199px) { .desk-nav .uc-navsw { display: none; } }
/* The version line (app-version.js) under "יציאה", small and quiet. */
.nav-version { margin: 2px 0 0; padding: 0 12px; font-size: var(--fs-12); line-height: 1.4; color: var(--on-nav-muted); text-align: start; }
a.tab-btn { text-decoration: none; }
.nav-more-btn { display: none; }
.nav-more-pop {
  position: absolute; z-index: 70; min-width: 200px; padding: 4px;
  background: var(--nav); color: var(--on-nav); border-radius: var(--r-md); box-shadow: var(--sh-3);
  display: flex; flex-direction: column; gap: 2px;
}
.nav-more-pop[hidden] { display: none; }
.nav-more-pop .tab-btn, .nav-more-pop .nav-link { justify-content: start; width: 100%; }

/* ── "חזרה" on the desk (≥720 px, D-164): a small icon beside the brand, only when there is
   somewhere to go back (paintBack disables it on the first screen); the word is its tooltip and
   label. A phone keeps the full "חזרה" row. ── */
@media screen and (min-width: 720px) {
  .nav-back { width: 34px; min-height: 34px; height: 34px; padding: 0; justify-content: center; flex: none; }
  .nav-back span { display: none; }
  .nav-back:disabled { display: none; }
}

/* ── the side menu at desk density (≥720 px, D-157 / D-164): the brand stays on top, the foot
   (settings, יציאה, version) at the bottom, and only the item list scrolls between them. ── */
@media screen and (min-width: 720px) {
  html:not([data-nav="top"]) .desk-nav { padding: 14px 10px 8px; gap: 2px; overflow: hidden; }
  html:not([data-nav="top"]) .desk-nav-brand {
    flex: none; display: grid; grid-template-columns: auto minmax(0, 1fr); align-items: center;
    column-gap: 10px; row-gap: 0; padding-block: 2px 10px; padding-inline: 4px 44px;
  }
  html:not([data-nav="top"]) .desk-nav-brand > :first-child { grid-row: 1 / span 2; display: flex; }
  html:not([data-nav="top"]) .desk-nav-mark {
    font-size: 1.08rem; line-height: 1.3; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  }
  html:not([data-nav="top"]) .desk-nav-brand .sub { margin: 0; grid-column: 2; font-size: var(--fs-12); line-height: 1.4; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html:not([data-nav="top"]) .desk-nav-brand .sub:empty { display: none; }
  html:not([data-nav="top"]) .nav-back { position: absolute; top: 16px; inset-inline-end: 10px; margin: 0; }
  html:not([data-nav="top"]) .desk-mill-scope { flex: none; padding: 0 2px 8px; }
  /* the brand above already names the mill; the picker keeps its own aria-label */
  html:not([data-nav="top"]) .desk-mill-scope .desk-nav-label { display: none; }
  html:not([data-nav="top"]) .desk-mill-scope select { min-height: var(--ctl-desk); padding: 4px 10px; }
  html:not([data-nav="top"]) .desk-nav-main {
    flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; scrollbar-width: thin;
    padding: 2px; margin: 0 -2px;
  }
  html:not([data-nav="top"]) .desk-nav-label { margin: var(--sp-3) var(--space-3) var(--sp-1); font-size: var(--fs-12); }
  html:not([data-nav="top"]) .desk-nav-main .desk-nav-label:first-child { margin-top: var(--sp-1); }
  html:not([data-nav="top"]) .desk-nav-label-sys { padding-top: var(--sp-3); }
  html:not([data-nav="top"]) .tab-btn { min-height: var(--ctl-desk); padding: 6px 12px; font-size: 1rem; }
  html:not([data-nav="top"]) .tab-btn.active::before { inset-block: 7px; }
  html:not([data-nav="top"]) #tabLinks { margin: var(--sp-1) 0; }
  html:not([data-nav="top"]) .desk-nav-foot { flex: none; padding-top: 8px; margin-top: 4px; }
  html:not([data-nav="top"]) .nav-link { min-height: 36px; padding: 6px 12px; }
  html:not([data-nav="top"]) .desk-nav .nav-prefs.uc { padding-bottom: 6px; }
  html:not([data-nav="top"]) .desk-nav .uc-pill { min-height: 34px; }
}

/* The menu measures the same on every page, whatever the page's own box sizing. */
.desk-nav, .desk-nav *, .nav-more-pop, .nav-more-pop * { box-sizing: border-box; }

/* ── the menu on admin, catalog, scan and production (built by app-nav.js) ── */
/* The production board's own יציאה: the menu has it. */
html.has-app-nav #wbLogout { display: none; }
.app-nav { position: fixed; inset-block: 0; inset-inline-start: 0; z-index: 40; }
@media screen and (min-width: 720px) {
  html.has-app-nav:not([data-nav="top"]) body { padding-inline-start: 256px; }
}

/* ── top layout (≥720 px): one row across the page ── */
@media screen and (min-width: 720px) {
  html[data-nav="top"] .desk-nav {
    width: 100%; height: auto; flex-direction: row; align-items: center; flex-wrap: nowrap; gap: 4px;
    padding: 6px 12px; overflow: visible; border-bottom: 1px solid color-mix(in srgb, var(--on-nav) 18%, transparent);
  }
  html[data-nav="top"] .desk-nav-brand { flex: 0 1 auto; flex-wrap: nowrap; align-items: center; padding: 0 4px; max-width: 220px; }
  html[data-nav="top"] .desk-nav-brand .sub,
  html[data-nav="top"] .desk-nav-label,
  html[data-nav="top"] .desk-nav-more { display: none; }
  html[data-nav="top"] .desk-nav-mark { font-size: 1rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
  html[data-nav="top"] .desk-nav-logo { width: 24px; height: 24px; }
  html[data-nav="top"] .desk-mill-scope { width: auto; padding: 0 4px; }
  html[data-nav="top"] .desk-mill-scope { flex: 0 1 auto; min-width: 0; }
  /* narrow: the mill's name only, cut with an ellipsis; the full name is the tooltip (D-164) */
  html[data-nav="top"] .desk-mill-scope select { min-height: 36px; padding: 4px 8px; width: 150px; max-width: 150px; text-overflow: ellipsis; }
  html[data-nav="top"] .nav-back { margin: 0 4px; }
  html[data-nav="top"] .desk-nav-main,
  html[data-nav="top"] .desk-nav-foot {
    flex-direction: row; align-items: center; flex-wrap: nowrap; gap: 2px; overflow: hidden;
    padding: 0; margin: 0; border: 0;
  }
  html[data-nav="top"] .desk-nav-main { flex: 1 1 auto; min-width: 0; }
  html[data-nav="top"] .desk-nav-foot { flex: 0 0 auto; display: flex; }
  html[data-nav="top"] .tab-btn,
  html[data-nav="top"] .nav-link { width: auto; flex: 0 0 auto; white-space: nowrap; min-height: 40px; padding: 6px 12px; font-size: .95rem; }
  html[data-nav="top"] #tabLinks { margin: 0 4px 0 0; }
  html[data-nav="top"] .tab-btn.active::before { inset-block: auto; inset-block-end: 0; inset-inline: 10px; width: auto; height: 3px; }
  html[data-nav="top"] .nav-overflow { display: none !important; }
  html[data-nav="top"] .nav-more-btn.on { display: inline-flex; }
  /* desk: the row sits above the screen */
  html[data-nav="top"] body:has(> .desk-nav) { flex-direction: column; }
  html[data-nav="top"] body:has(> .desk-nav) > .desk-main { height: auto; flex: 1 1 auto; min-height: 0; }
  html[data-nav="top"] .desk-nav { position: sticky; top: 0; z-index: 40; }
  html[data-nav="top"] .app-nav { position: fixed; inset-inline: 0; inset-block: 0 auto; }
  html.has-app-nav[data-nav="top"] body { padding-top: var(--app-nav-h, 56px); }
  html.has-app-nav[data-nav="top"] .scan-top { top: var(--app-nav-h, 56px); }
}

/* A narrower top row (720–1199 px, D-152): the switch shows its icons and the logo stands without
   the mill name, so the screens keep the room and nothing is pushed off the window. */
@media screen and (min-width: 720px) and (max-width: 1199px) {
  html[data-nav="top"] .desk-nav-mark { display: none; }
  html[data-nav="top"] .desk-nav-brand { max-width: none; }
}

/* ── phone: the compact bar on every page, whatever the choice ── */
@media (max-width: 719px) {
  .app-nav {
    position: sticky; top: 0; width: 100%; height: auto; z-index: 40;
    padding: 8px 12px 6px; border-bottom: 1px solid color-mix(in srgb, var(--on-nav) 18%, transparent);
  }
  html.has-app-nav body { padding-inline-start: 0; padding-top: 0; }
  .app-nav .desk-nav-brand { padding: 0 4px 6px; }
  .app-nav .desk-nav-brand .sub, .app-nav .desk-nav-label { display: none; }
  .app-nav .desk-nav-more { display: inline-flex; align-items: center; }
  .app-nav .desk-nav-main { flex-direction: row; flex-wrap: nowrap; overflow-x: auto; scrollbar-width: none; }
  .app-nav .tab-btn { width: auto; flex: 0 0 auto; white-space: nowrap; padding: 8px 10px; font-size: .95rem; }
  .app-nav #tabLinks { margin: 0; }
  .app-nav .desk-nav-foot { display: none; flex-direction: column; }
  .app-nav .desk-nav-foot.open { display: flex; }
  .nav-back { margin: 0 4px 6px; min-height: var(--tap); align-self: flex-start; }
}
/* The settings in the menu (D-154): name, theme and language at the foot, above "יציאה", stacked
   in the side menu and in a row at the end of the top row. The menu is dark in every theme. */
.desk-nav .nav-prefs.uc { flex-direction: row; flex-wrap: wrap; align-items: stretch; gap: 6px; padding: 0 0 8px; }
.desk-nav .uc-name { flex: 1 1 100%; }
.desk-nav .uc-theme { flex: 1 1 auto; }
.desk-nav .uc-lang { flex: 0 0 auto; }
.desk-nav .uc-pill {
  justify-content: flex-start; min-height: 38px;
  background: color-mix(in srgb, var(--on-nav) 8%, transparent);
  border-color: color-mix(in srgb, var(--on-nav) 22%, transparent); color: var(--on-nav);
}
.desk-nav .uc-pill:hover { background: color-mix(in srgb, var(--on-nav) 16%, transparent); }
.desk-nav .uc-pill:focus-visible { box-shadow: 0 0 0 3px color-mix(in srgb, var(--on-nav) 60%, transparent); }
/* the phone bar: the settings pills meet the finger size too (UX run 2026-11-05) */
@media (max-width: 719px) { .desk-nav .uc-pill { min-height: var(--tap); } }
@media screen and (min-width: 720px) {
  html[data-nav="top"] .desk-nav .nav-prefs.uc { flex-direction: row; align-items: center; padding: 0; margin-inline-end: 4px; }
  html[data-nav="top"] .desk-nav .nav-prefs.uc { flex-wrap: nowrap; }
  html[data-nav="top"] .desk-nav .uc-pill { flex: 0 0 auto; min-height: 34px; padding: 0 10px; }
  /* the top row keeps its room for the screens: icons only, the words are in the tooltips */
  html[data-nav="top"] .desk-nav .uc-theme-t,
  html[data-nav="top"] .desk-nav .uc-name-t { display: none; }
}
@media print { .desk-nav, .nav-back, .nav-more-pop { display: none !important; } html.has-app-nav body { padding: 0 !important; } }
