/* ============================================================
   Members Shell — branded left sidebar + 2-col layout
   Used when templates/layout.php is invoked with $membersShell = true.
   Mobile-first: 320px baseline. Touch targets >= 44x44.
   ============================================================ */

.members-shell {
  display: block;
}

.members-shell__body {
  display: flex;
  align-items: flex-start;
  gap: 1.5rem;
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 1rem;
  box-sizing: border-box;
}

.members-shell__main {
  flex: 1;
  min-width: 0;
  width: 100%;
}

/* ---------- Sidebar ---------- */
.hbcl-side {
  flex-shrink: 0;
  width: 100%;
  background: var(--hbcl-card, #fff);
  border: 1px solid var(--hbcl-border, rgba(84, 61, 147, 0.15));
  border-radius: 14px;
  box-shadow: 0 2px 12px rgba(84, 61, 147, 0.06);
  margin-bottom: 1rem;
  overflow: hidden;
}

.hbcl-side__toggle {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  width: 100%;
  min-height: 44px;
  padding: 0.75rem 1rem;
  background: var(--hbcl-grad-primary, linear-gradient(232deg, #543D93 0%, #ED70A3 100%));
  color: #fff;
  border: none;
  font: inherit;
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  text-align: left;
}

.hbcl-side__toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: -3px;
}

.hbcl-side__toggle-icon {
  display: inline-flex;
  align-items: center;
}

.hbcl-side__nav {
  display: none;
  padding: 0.5rem 0 0.75rem;
}

.hbcl-side.hbcl-side--open .hbcl-side__nav {
  display: block;
}

.hbcl-side__group {
  margin-bottom: 0.25rem;
}

.hbcl-side__group + .hbcl-side__group {
  border-top: 1px solid var(--hbcl-border, rgba(84, 61, 147, 0.1));
  margin-top: 0.5rem;
  padding-top: 0.5rem;
}

.hbcl-side__group-label {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.1em;
  color: var(--hbcl-text-muted, #6952BA);
  padding: 0.5rem 1rem 0.25rem;
  font-weight: 700;
}

.hbcl-side-link {
  display: block;
  width: 100%;
  min-height: 44px;
  text-decoration: none;
  font: inherit;
  font-size: 0.95rem;
  color: var(--hbcl-text, #1a0f2e);
  padding: 0.625rem 1rem;
  line-height: 1.4;
  border-left: 3px solid transparent;
  transition: background 150ms ease, color 150ms ease, border-left-color 150ms ease;
}

.hbcl-side-link:hover,
.hbcl-side-link:focus-visible {
  background: var(--hbcl-surface-alt, #f3f0fb);
  color: var(--hbcl-purple-dark, #3d2b73);
  outline: none;
}

.hbcl-side-link--active {
  background: var(--hbcl-surface-alt, #f3f0fb);
  color: var(--hbcl-primary, #543D93);
  border-left-color: var(--hbcl-primary, #543D93);
  font-weight: 600;
}

/* ---------- Desktop layout (>=900px) ---------- */
@media (min-width: 900px) {
  .members-shell__body {
    padding: 1.5rem;
    gap: 2rem;
  }
  .hbcl-side {
    width: 240px;
    margin-bottom: 0;
    position: sticky;
    top: 1rem;
  }
  .hbcl-side__toggle {
    /* Toggle button hidden on desktop — nav is always visible */
    display: none;
  }
  .hbcl-side__nav {
    display: block;
    padding-top: 0.75rem;
  }
}

/* Print: hide sidebar */
@media print {
  .hbcl-side { display: none !important; }
  .members-shell__body { display: block; padding: 0; }
  .hbcl-impersonation-banner { display: none !important; }
}

/* ============================================================
   View As switcher (admin sidebar top) + Impersonation banner
   Additive — only renders when admin + impersonating.
   ============================================================ */

/* ---------- Sidebar "View Mode" control ----------
   Deliberately distinct from nav: dashed border, eye icon, segmented pill
   control, warning tint while impersonating. Communicates "this changes
   your viewing perspective" — not "this is a page link." */
.hbcl-side-viewas {
  background: linear-gradient(180deg, rgba(237, 112, 163, 0.06) 0%, rgba(84, 61, 147, 0.04) 100%);
  border: 2px dashed rgba(84, 61, 147, 0.35);
  border-radius: 12px;
  padding: 0.875rem;
  display: flex;
  flex-direction: column;
  gap: 0.625rem;
  margin: 0 0 1rem;
  transition: background 200ms ease, border-color 200ms ease;
}

/* Warning tint when admin is impersonating — the "you are not seeing the
   site as yourself" state should be glanceable from across the room. */
.hbcl-side-viewas[data-viewas-active="provider"],
.hbcl-side-viewas[data-viewas-active="user"] {
  background: linear-gradient(180deg, rgba(255, 183, 77, 0.18) 0%, rgba(237, 112, 163, 0.10) 100%);
  border-color: rgba(217, 119, 6, 0.55);
}

.hbcl-side-viewas__head {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.hbcl-side-viewas__icon {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  color: var(--hbcl-purple, #543D93);
}

.hbcl-side-viewas[data-viewas-active="provider"] .hbcl-side-viewas__icon,
.hbcl-side-viewas[data-viewas-active="user"] .hbcl-side-viewas__icon {
  color: #b45309;
}

.hbcl-side-viewas__label {
  text-transform: uppercase;
  font-size: 0.7rem;
  letter-spacing: 0.12em;
  color: var(--hbcl-text-muted, #6952BA);
  font-weight: 700;
}

.hbcl-side-viewas__hint {
  margin: 0;
  font-size: 0.72rem;
  line-height: 1.4;
  color: var(--hbcl-text-muted, #6952BA);
  font-style: italic;
}

/* Segmented pill control — buttons share borders, no gaps. Active state is
   a fully-filled pill that visually "slides" between options. */
.hbcl-side-viewas__segctl {
  display: flex;
  flex-direction: row;
  background: var(--hbcl-card, #fff);
  border: 1px solid var(--hbcl-border, rgba(84, 61, 147, 0.18));
  border-radius: 999px;
  padding: 3px;
  gap: 0;
  box-shadow: inset 0 1px 2px rgba(84, 61, 147, 0.08);
}

.hbcl-viewas-btn {
  flex: 1 1 0;
  min-width: 0;
  min-height: 44px;
  padding: 0.5rem 0.5rem;
  background: transparent;
  color: var(--hbcl-text-muted, #6952BA);
  border: 0;
  border-radius: 999px;
  font: inherit;
  font-family: 'Marcellus', Georgia, serif;
  font-size: 0.875rem;
  font-weight: 500;
  cursor: pointer;
  text-align: center;
  transition: background 180ms ease, color 180ms ease, box-shadow 180ms ease;
  box-sizing: border-box;
}

.hbcl-viewas-btn:hover {
  color: var(--hbcl-purple, #543D93);
  background: rgba(84, 61, 147, 0.06);
}

.hbcl-viewas-btn:focus-visible {
  outline: 2px solid var(--hbcl-purple, #543D93);
  outline-offset: 2px;
}

.hbcl-viewas-btn[aria-pressed="true"] {
  background: var(--hbcl-purple, #543D93);
  color: #fff;
  font-weight: 700;
  box-shadow: 0 2px 6px rgba(84, 61, 147, 0.28);
}

/* When the panel is in a non-admin mode, the active pill flips to warning
   color too — keeping the visual signal cohesive. */
.hbcl-side-viewas[data-viewas-active="provider"] .hbcl-viewas-btn[aria-pressed="true"],
.hbcl-side-viewas[data-viewas-active="user"] .hbcl-viewas-btn[aria-pressed="true"] {
  background: #d97706;
  box-shadow: 0 2px 6px rgba(217, 119, 6, 0.30);
}

/* On very narrow screens (≤480px) the segmented control stacks vertically.
   Active pill keeps its fill — visual contract preserved. */
@media (max-width: 480px) {
  /* Gap separates stacked 44px tap targets so adjacent pills don't merge. */
  .hbcl-side-viewas__segctl {
    flex-direction: column;
    border-radius: 14px;
    gap: 4px;
  }
  .hbcl-viewas-btn {
    width: 100%;
    border-radius: 12px;
  }
}

/* ---------- Impersonation banner ---------- */
/* z-index ≥ 100 so the sticky banner sits above tab-pane shadows / inline
   widgets that introduce their own stacking contexts. */
.hbcl-impersonation-banner {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  flex-wrap: wrap;
  background: var(--hbcl-warning, #fff7e6);
  color: var(--hbcl-primary, #543D93);
  padding: 0.75rem 1rem;
  border: 1px solid rgba(84, 61, 147, 0.2);
  border-radius: 10px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  box-shadow: 0 2px 8px rgba(84, 61, 147, 0.08);
  box-sizing: border-box;
  width: 100%;
}

.hbcl-impersonation-banner__msg {
  flex: 1 1 auto;
  min-width: 0;
  line-height: 1.4;
}

.hbcl-impersonation-banner__stop {
  flex-shrink: 0;
  min-height: 44px;
  padding: 0.5rem 1rem;
  background: var(--hbcl-purple, #543D93);
  color: #fff;
  border: 1px solid var(--hbcl-purple, #543D93);
  border-radius: 999px;
  font: inherit;
  font-family: 'Marcellus', Georgia, serif;
  font-size: 0.875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease, color 150ms ease;
}

.hbcl-impersonation-banner__stop:hover,
.hbcl-impersonation-banner__stop:focus-visible {
  background: var(--hbcl-purple-dark, #3d2b73);
  outline: none;
}

.hbcl-impersonation-banner__stop:focus-visible {
  outline: 2px solid var(--hbcl-purple-dark, #3d2b73);
  outline-offset: 2px;
}

/* Stack banner contents vertically on small screens */
@media (max-width: 480px) {
  .hbcl-impersonation-banner {
    flex-direction: column;
    align-items: stretch;
    text-align: center;
  }
  .hbcl-impersonation-banner__stop {
    width: 100%;
  }
}

/* ============================================================
   View As modal (built by members-shell.js)
   ============================================================ */
.hbcl-viewas-modal {
  position: fixed;
  inset: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  box-sizing: border-box;
}

.hbcl-viewas-modal__backdrop {
  position: absolute;
  inset: 0;
  background: rgba(26, 15, 46, 0.55);
}

.hbcl-viewas-modal__dialog {
  position: relative;
  z-index: 1;
  background: var(--hbcl-card, #fff);
  border-radius: 14px;
  box-shadow: 0 12px 40px rgba(26, 15, 46, 0.3);
  width: 100%;
  max-width: 480px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.hbcl-viewas-modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--hbcl-border, rgba(84, 61, 147, 0.1));
}

.hbcl-viewas-modal__title {
  margin: 0;
  font-family: 'Marcellus', Georgia, serif;
  font-size: 1.125rem;
  color: var(--hbcl-primary, #543D93);
}

.hbcl-viewas-modal__close {
  min-width: 44px;
  min-height: 44px;
  background: transparent;
  color: var(--hbcl-text, #1a0f2e);
  border: none;
  font-size: 1.5rem;
  line-height: 1;
  cursor: pointer;
}

.hbcl-viewas-modal__body {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 0.5rem;
}

.hbcl-viewas-modal__item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
  width: 100%;
  min-height: 44px;
  padding: 0.625rem 0.875rem;
  background: transparent;
  color: var(--hbcl-text, #1a0f2e);
  border: 1px solid transparent;
  border-radius: 8px;
  font: inherit;
  font-size: 0.9rem;
  text-align: left;
  cursor: pointer;
  box-sizing: border-box;
}

.hbcl-viewas-modal__item:hover,
.hbcl-viewas-modal__item:focus-visible {
  background: var(--hbcl-surface-alt, #f3f0fb);
  border-color: var(--hbcl-border, rgba(84, 61, 147, 0.2));
  outline: none;
}

.hbcl-viewas-modal__name {
  font-weight: 600;
  color: var(--hbcl-primary, #543D93);
}

.hbcl-viewas-modal__meta {
  font-size: 0.8rem;
  color: var(--hbcl-text-muted, #6952BA);
}

.hbcl-viewas-modal__empty {
  padding: 1rem 1.25rem;
  color: var(--hbcl-text-muted, #6952BA);
  text-align: center;
}
