/* ─────────────────────────────────────────────────────────────────
   Admin Bar — barra persistente "impersonation" per utenti admin.
   Include assets/admin_bar.js che la inietta se role === 'admin'.
   ───────────────────────────────────────────────────────────────── */

:root {
  --admin-bar-h: 38px;
  --admin-bar-bg: #2b1f63;
  --admin-bar-bg-hi: #3a2b82;
  --admin-bar-fg: #ffffff;
  --admin-bar-muted: rgba(255,255,255,0.55);
  --admin-bar-accent: #F0B429;
}

body.has-admin-bar { padding-top: var(--admin-bar-h); }

/* Shift known fixed / sticky headers down below the bar */
body.has-admin-bar .nav     { top: var(--admin-bar-h) !important; }
body.has-admin-bar .st-hero { top: var(--admin-bar-h) !important; }
body.has-admin-bar .sidebar { top: var(--admin-bar-h) !important; height: calc(100vh - var(--admin-bar-h)) !important; }
/* insights.html main column: 100vh would overflow under the bar */
body.has-admin-bar .main { height: calc(100vh - var(--admin-bar-h)) !important; }

/* ═══ BAR ═════════════════════════════════════════════════════════ */
.admin-bar {
  position: fixed; top: 0; left: 0; right: 0;
  height: var(--admin-bar-h); z-index: 100000;
  background: var(--admin-bar-bg);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex; align-items: stretch;
  font-family: 'DM Sans', 'Inter', system-ui, sans-serif;
  color: var(--admin-bar-fg);
  user-select: none;
}

.admin-bar__inner {
  flex: 1; display: flex; align-items: center; justify-content: space-between;
  padding: 0 16px; gap: 16px; max-width: 1600px; margin: 0 auto;
}

/* ─── Left: context label ─────────────────────────────────────── */
.admin-bar__left {
  display: flex; align-items: center; gap: 10px;
  min-width: 0; flex-shrink: 1;
}
.admin-bar__dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--admin-bar-accent); flex-shrink: 0;
  box-shadow: 0 0 8px rgba(240,180,41,0.6);
}
.admin-bar__label {
  font-size: 11px; font-weight: 600; letter-spacing: .01em;
  color: var(--admin-bar-fg);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.admin-bar__label em {
  color: var(--admin-bar-muted); font-style: normal; font-weight: 500;
}

/* ─── Center: segmented control ──────────────────────────────── */
.admin-bar__seg {
  display: flex; align-items: center; gap: 2px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.1);
  padding: 3px; border-radius: 8px;
  flex-shrink: 0;
}
.admin-bar__seg a {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 4px 12px; border-radius: 6px;
  font-size: 11px; font-weight: 600; color: rgba(255,255,255,0.7);
  text-decoration: none; transition: background .12s, color .12s;
  white-space: nowrap;
}
.admin-bar__seg a:hover { background: rgba(255,255,255,0.08); color: #fff; }
.admin-bar__seg a.is-active {
  background: var(--admin-bar-bg-hi); color: #fff;
  box-shadow: 0 0 0 1px rgba(255,255,255,0.14);
}
.admin-bar__seg a svg {
  width: 11px; height: 11px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ─── Right: CTA back-to-student ─────────────────────────────── */
.admin-bar__right { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.admin-bar__cta {
  display: inline-flex; align-items: center; gap: 6px;
  padding: 5px 12px; border-radius: 6px;
  font-size: 11px; font-weight: 600; color: var(--admin-bar-fg);
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.12);
  text-decoration: none; cursor: pointer;
  transition: background .12s, border-color .12s;
  font-family: inherit;
}
.admin-bar__cta:hover { background: rgba(255,255,255,0.14); border-color: rgba(255,255,255,0.2); }
.admin-bar__cta svg {
  width: 11px; height: 11px; stroke: currentColor; fill: none;
  stroke-width: 2; stroke-linecap: round; stroke-linejoin: round;
}

/* ─── Mobile ──────────────────────────────────────────────────── */
@media (max-width: 720px) {
  :root { --admin-bar-h: 44px; }
  .admin-bar__inner { padding: 0 10px; gap: 8px; }
  .admin-bar__label { font-size: 10px; }
  .admin-bar__label .admin-bar__label-ctx { display: none; } /* nasconde il sub */
  .admin-bar__seg a { padding: 4px 8px; }
  .admin-bar__seg a span.admin-bar__seg-label { display: none; } /* icon-only */
  .admin-bar__cta { padding: 4px 8px; }
  .admin-bar__cta span { display: none; }
}
