/* ==========================================================================
   Admin ⇄ Customer — the portal switch (assets/js/ui/portal-switch.js)
   --------------------------------------------------------------------------
   Two equal halves in a pill, a thumb under the side you are on. Tokens
   only, so it follows the light and dark themes of whichever page holds it.
   ========================================================================== */

.portal-switch {
  position: relative;
  display: inline-grid;
  grid-template-columns: 1fr 1fr;
  padding: 3px;
  border-radius: 999px;
  background: var(--surface-sunk);
  border: 1px solid var(--line-soft);
  font-size: 0.8rem;
  font-weight: 600;
  letter-spacing: -0.005em;
  line-height: 1;
  user-select: none;
}

.portal-switch__thumb {
  position: absolute;
  top: 3px;
  bottom: 3px;
  left: 3px;
  width: calc(50% - 3px);
  border-radius: 999px;
  background: var(--accent);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.18);
  transition: transform 180ms var(--ease);
}
.portal-switch[data-on="customer"] .portal-switch__thumb { transform: translateX(100%); }

.portal-switch__opt {
  position: relative;
  z-index: 1;
  display: grid;
  place-items: center;
  min-width: 5.2rem;
  padding: 0.5rem 0.85rem;
  border-radius: 999px;
  color: var(--text-2);
  text-decoration: none;
  white-space: nowrap;
  transition: color 180ms var(--ease);
}
.portal-switch__opt:hover { color: var(--text); }
.portal-switch[data-on="admin"] .portal-switch__opt[data-side="admin"],
.portal-switch[data-on="customer"] .portal-switch__opt[data-side="customer"] { color: var(--accent-ink); }
.portal-switch__opt:focus-visible { outline: 2px solid var(--accent-ring); outline-offset: 2px; }

@media (prefers-reduced-motion: reduce) {
  .portal-switch__thumb,
  .portal-switch__opt { transition: none; }
}

/* ── where it sits ─────────────────────────────────────────────────────── */

/* Admin: its own row under the brand, full sidebar width. A narrow rail has
   no room for two words, so the switch steps aside until the rail opens. */
.adm-side__portal { padding: 0 0.9rem 0.6rem 1.15rem; flex: 0 0 auto; }
.adm-side__portal .portal-switch { display: grid; width: 100%; }
@media (min-width: 1001px) {
  body.adm.is-narrow .adm-side__portal { display: none; }
}

/* Customer: beside the brand in the top bar. */
.dash-nav__portal { flex: 0 0 auto; }
.dash-nav__portal:empty { display: none; }
@media (max-width: 520px) {
  .dash-nav:has(.portal-switch) { gap: 0.6rem; }
  .dash-nav:has(.portal-switch) .brand__name,
  .dash-nav:has(.portal-switch) .dash-nav__who .pill { display: none; }
  .portal-switch__opt { min-width: 4.4rem; padding-inline: 0.6rem; }
}
