/* nav.css — shared left sidebar for the SFSC app.
   Self-contained (defines its own colors) so it works on any page. */

:root {
  --nv-w: 236px;
  --nv-bg: #3d5c35;      /* sage-deep */
  --nv-bg-hover: #46683c;
  --nv-bg-active: #33502c;
  --nv-accent: #8fa882;  /* sage */
  --nv-text: rgba(255, 255, 255, 0.9);
  --nv-muted: rgba(255, 255, 255, 0.5);
  --nv-line: rgba(255, 255, 255, 0.1);
}

/* Page offset so content clears the fixed sidebar */
body.has-sidebar { padding-left: var(--nv-w); }

/* ---- Sidebar ---- */
.nv-side {
  position: fixed;
  top: 0; left: 0;
  width: var(--nv-w);
  height: 100vh;   /* fallback for older browsers */
  height: 100dvh;  /* excludes Safari's dynamic bottom bar so the footer stays visible */
  background: var(--nv-bg);
  display: flex;
  flex-direction: column;
  overflow-y: auto;
  z-index: 330; /* above the mobile backdrop (310) so links are tappable */
  font-family: -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

.nv-brand {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 18px;
  border-bottom: 1px solid var(--nv-line);
  flex-shrink: 0;
}
.nv-brand img { width: 34px; height: 34px; object-fit: contain; }
.nv-brand .nm { color: #fff; font-size: 14px; font-weight: 600; line-height: 1.15; }
.nv-brand .sub { color: var(--nv-muted); font-size: 9px; letter-spacing: 1.4px; text-transform: uppercase; margin-top: 1px; }

/* Scrollable middle so a long menu never hides the footer (Sign out) */
.nv-groups { flex: 1 1 auto; min-height: 0; overflow-y: auto; padding: 8px 0; }
.nv-group { padding: 6px 0; }
.nv-group h4 {
  margin: 8px 0 4px;
  padding: 0 18px;
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--nv-muted);
  font-weight: 700;
}
.nv-link {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 18px;
  color: var(--nv-text);
  text-decoration: none;
  font-size: 13.5px;
  border-left: 3px solid transparent;
  cursor: pointer;
}
.nv-link:hover { background: var(--nv-bg-hover); }
.nv-link.active {
  background: var(--nv-bg-active);
  border-left-color: var(--nv-accent);
  font-weight: 600;
}
.nv-badge {
  background: #c0392b; color: #fff;
  font-size: 10px; font-weight: 700;
  min-width: 17px; height: 17px; padding: 0 5px;
  border-radius: 9px; display: inline-flex; align-items: center; justify-content: center;
}
.nv-foot { border-top: 1px solid var(--nv-line); padding: 8px 0 calc(8px + env(safe-area-inset-bottom)); flex-shrink: 0; }
.nv-foot .nv-link { color: var(--nv-muted); font-size: 13px; }

/* ---- Mobile topbar + drawer ---- */
.nv-topbar { display: none; }
.nv-backdrop { display: none; }
.nv-burger { display: flex; flex-direction: column; gap: 4px; background: none; border: 0; cursor: pointer; padding: 6px; }
.nv-burger span { width: 22px; height: 2px; background: #fff; border-radius: 2px; }

/* "View as" impersonation banner */
.nv-imp-banner {
  position: fixed; top: 0; left: 0; right: 0; height: 34px;
  background: #8a5a00; color: #fff;
  display: flex; align-items: center; justify-content: center; gap: 14px;
  font-size: 13px; z-index: 9999;
}
.nv-imp-banner button {
  background: rgba(255,255,255,0.2); color: #fff;
  border: 1px solid rgba(255,255,255,0.55); border-radius: 6px;
  padding: 3px 12px; font-size: 12px; cursor: pointer;
}
body.impersonating.has-sidebar { padding-top: 34px; }
body.impersonating .nv-side { top: 34px; height: calc(100vh - 34px); height: calc(100dvh - 34px); }
body.impersonating .nv-topbar { top: 34px; }

@media (max-width: 900px) {
  body.has-sidebar { padding-left: 0; padding-top: 52px; }
  body.impersonating.has-sidebar { padding-top: 86px; }

  .nv-topbar {
    display: flex; align-items: center; gap: 12px;
    position: fixed; top: 0; left: 0; right: 0; height: 52px;
    background: var(--nv-bg); padding: 0 12px; z-index: 320;
  }
  .nv-topbar .tb-name { color: #fff; font-size: 15px; font-weight: 600; }

  .nv-side {
    transform: translateX(-100%);
    transition: transform 0.22s ease;
    box-shadow: 2px 0 16px rgba(0, 0, 0, 0.35);
  }
  .nv-side.open { transform: translateX(0); }

  .nv-backdrop.show { display: block; position: fixed; inset: 0; background: rgba(0, 0, 0, 0.45); z-index: 310; }
}
