/* Verellen ERP — navigation rail.
   Shared by the ERP shell (base.html) and the Django admin shell
   (templates/admin/base.html) so the two cannot drift. Tokens (--color-nav-*,
   --radius-*) come from base.css's :root, which both shells load first. */

/* App shell */
.app-shell { display: flex; min-height: 100vh; }

.sidebar {
  width: var(--rail-w, var(--sidebar-w));
  flex-shrink: 0;
  background: var(--color-nav-bg);
  color: var(--color-nav-text);
  display: flex;
  flex-direction: column;
  padding: 1.25rem var(--rail-pad, 0.9rem);
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.rail-toggle {
  display: flex;
  align-items: center;
  justify-content: center;
  align-self: var(--rail-justify, flex-start);
  width: 32px;
  height: 32px;
  flex-shrink: 0;
  padding: 0;
  margin-bottom: 0.5rem;
  /* Overrides the global solid-accent `button` rule. */
  background: none;
  border: 1px solid var(--color-nav-rule);
  border-radius: var(--radius-sm);
  color: var(--color-nav-dim);
  cursor: pointer;
}
.rail-toggle:hover { background: var(--color-nav-hover-strong); color: var(--color-nav-text-strong); border-color: var(--color-nav-rule-strong); }
.rail-toggle svg { width: 16px; height: 16px; }

.brand {
  font-family: var(--font-serif);
  font-size: 1.35rem;
  color: var(--color-nav-text-strong);
  letter-spacing: 0.01em;
  padding: 0.4rem 0.6rem 1.5rem;
  /* Hidden on the collapsed rail — the wordmark has nowhere to go at 56px.
     If this ever needs its own `display`, add it to the collapsed blocks
     below too or the rail will stop hiding it. */
  display: var(--rail-chrome, block);
}
.brand small { display: block; font-family: var(--font-ui); font-size: 0.68rem; color: var(--color-nav-faint); font-weight: 500; letter-spacing: 0.08em; text-transform: uppercase; margin-top: 0.15rem; }
.sidebar .brand img {
  display: block;
  max-width: 150px;
  width: 100%;
  height: auto;
  /* Source mark is black-on-transparent (built for light surfaces);
     invert it to read as off-white against the dark sidebar. A light-sidebar
     theme (base-themes.css) re-points this to `none`. */
  filter: var(--color-nav-logo-filter);
}
.sidebar .brand small { margin-top: 0.6rem; }

.nav-group { margin-bottom: 1rem; }
.nav-label { display: var(--rail-chrome, block); font-size: 0.68rem; text-transform: uppercase; letter-spacing: 0.08em; color: var(--color-nav-faint); padding: 0 0.6rem; margin-bottom: 0.4rem; }

.nav-link {
  display: flex;
  align-items: center;
  justify-content: var(--rail-justify, flex-start);
  gap: var(--rail-gap, 0.6rem);
  padding: 0.5rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--color-nav-dim);
  /* A multiplier, not a size, so the label keeps its own 0.9rem when
     expanded. Zeroed rather than display:none because the label is a bare
     text node with no element to target — and leaving it in the tree keeps
     it as the link's accessible name, so no per-item aria-label is needed. */
  font-size: calc(0.9rem * var(--rail-label, 1));
  font-weight: 500;
}
/* Explicit size, so the icon survives the zeroed font size. */
.nav-link svg { width: var(--rail-icon, 16px); height: var(--rail-icon, 16px); flex-shrink: 0; opacity: 0.85; }
.nav-link:hover { background: var(--color-nav-hover); color: var(--color-nav-text-strong); text-decoration: none; }
.nav-link.active { background: var(--color-accent); color: var(--color-nav-text-strong); }
.nav-ext { margin-left: auto; opacity: 0.6; }

.nav-link.disabled { color: var(--color-nav-disabled); cursor: default; }
.nav-link.disabled:hover { background: none; color: var(--color-nav-disabled); }

.sidebar-footer { margin-top: auto; padding-top: 1rem; border-top: 1px solid var(--color-nav-rule); }

/* ---------- Collapsed rail ----------
   Below 1100px every iPad portrait width (820/834/1024) collapses and every
   landscape width (1180/1194/1366) stays expanded, because landscape has the
   room.

   Three states from two selectors. The expanded values are the var()
   fallbacks above, so they are stated once, at the point of use, and
   `.rail-expanded` needs no declarations at all — it simply stops the media
   query from matching. Both selectors are specificity 0,1,1, so a forced
   state wins at any width: someone on an 820px screen can bring the labels
   back and keep them, which matters because a `title` tooltip never fires
   on touch.

   The class sits on <html> rather than <body> so the inline boot script in
   each shell's <head> can set it before first paint — <body> does not exist
   yet at that point. That is the only reason; <body> would work for the
   CRM's width-keyed gradient, which is what bi.css used to do.

   Deliberately not transitioned: the CRM shell paints its rail column with a
   hard-stop gradient keyed to the same width, and a tweened width would drag
   a visible seam across it. */
html.rail-collapsed {
  --rail-w: 56px;
  --rail-pad: 0.4rem;
  --rail-chrome: none;
  --rail-label: 0;
  --rail-justify: center;
  --rail-gap: 0;
  --rail-icon: 18px;
  --rail-btn-pad: 0;
}
@media (max-width: 1100px) {
  html:not(.rail-expanded) {
    --rail-w: 56px;
    --rail-pad: 0.4rem;
    --rail-chrome: none;
    --rail-label: 0;
    --rail-justify: center;
    --rail-gap: 0;
    --rail-icon: 18px;
    --rail-btn-pad: 0;
  }
}

.logout-form { margin: 0.15rem 0; }
.sidebar .btn-logout {
  width: 100%;
  justify-content: center;
  gap: var(--rail-gap, 0.6rem);
  font-size: calc(0.8rem * var(--rail-label, 1));
  /* Zero side padding when collapsed: 0.7rem each side plus the rail's own
     padding leaves under 21px of a 56px rail for the icon. */
  padding: 0.4rem var(--rail-btn-pad, 0.7rem);
  background: transparent;
  color: var(--color-nav-text);
  border-color: var(--color-nav-rule-strong);
}
.sidebar .btn-logout:hover { color: var(--color-nav-text-strong); border-color: var(--color-nav-rule-strong); }
.sidebar .btn-logout svg { width: var(--rail-icon, 16px); height: var(--rail-icon, 16px); flex-shrink: 0; }

.readonly-bar {
  display: flex; align-items: baseline; gap: 0.6rem; flex-wrap: wrap;
  padding: 0.6rem 2rem;
  background: var(--color-warning-bg);
  border-bottom: 1px solid var(--color-border-strong);
  color: var(--color-warning);
  font-size: 0.82rem;
}
.readonly-bar strong { text-transform: uppercase; letter-spacing: 0.06em; font-size: 0.72rem; font-weight: 600; }
.readonly-bar span { color: var(--color-text-muted); }
