/* Shared sidebar layout — matches the original clients.html / dashboard.html look-and-feel.
   Used by all admin pages. The .sidebar is rendered by sidebar.js into the
   placeholder `<aside id="sidebar-slot"></aside>`.
   Each page also wraps its main content in `<main class="main">…</main>`. */

:root {
  --sidebar-bg: #1d1836;
  --sidebar-w: 240px;
}

.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  /* Higher than the topmenu (40) and any page content so the
     nav-items always receive clicks. In particular: on narrow
     screens the sidebar slides in OVER the main content, so it
     must be on top. */
  z-index: 100;
  overflow-y: auto;
}
.sb-header {
  padding: 20px 16px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.07);
}
.sb-logo { display: flex; align-items: center; gap: 10px; }
.logo-mark {
  width: 32px; height: 32px; background: var(--accent); border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  font-weight: 900; font-size: 12px; color: white; flex-shrink: 0;
}
.sb-brand { font-size: 14px; font-weight: 800; color: white; }
.sb-tagline { font-size: 10px; color: rgba(255,255,255,0.35); margin-top: 1px; }
.sb-nav { padding: 12px 8px; flex: 1; }
.sb-section-label {
  font-size: 9px; font-weight: 700; letter-spacing: 0.1em;
  text-transform: uppercase; color: rgba(255,255,255,0.28);
  padding: 0 10px; margin-bottom: 4px;
}
.sb-section-label + .sb-section-label { margin-top: 12px; }

.nav-item {
  display: flex; align-items: center; gap: 10px;
  padding: 9px 10px; border-radius: 9px;
  font-size: 13px; font-weight: 500;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  transition: all var(--motion-fast) var(--ease);
  margin-bottom: 1px;
  text-decoration: none;
}
.nav-item:hover { color: rgba(255,255,255,0.8); background: rgba(255,255,255,0.05); }
.nav-item.active { color: #ff8c3a; background: rgba(255,107,0,0.16); font-weight: 600; }
.nav-item svg { width: 15px; height: 15px; flex-shrink: 0; }
.nav-badge {
  margin-left: auto;
  background: var(--danger); color: white;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 9999px;
}
/* Phase 4.60: Email Queue tab gets two pills (queued +
   blocked). The pills are stacked horizontally to the right
   of the label. */
.nav-pills {
  margin-left: auto;
  display: inline-flex;
  gap: 4px;
  align-items: center;
}
.nav-pill {
  display: inline-block;
  font-size: 10px; font-weight: 700;
  padding: 1px 6px; border-radius: 9999px;
  color: white;
  min-width: 18px;
  text-align: center;
}
.nav-pill.pill-queued   { background: var(--accent, #2d6cdf); }
.nav-pill.pill-blocked  { background: #b94a4a; }
/* Phase 4.60.1: hover tooltips for the two pills so admins
   know what each number means without clicking through. */
.nav-pill[data-pill="queued"]::after {
  content: 'Queued — emails waiting to be sent';
}
.nav-pill[data-pill="blocked"]::after {
  content: 'Blocked — emails held by admin';
}
.nav-pill {
  position: relative;
}
.nav-pill:hover::before {
  content: attr(data-tip);
  position: absolute;
  bottom: calc(100% + 6px);
  right: 0;
  background: #1d1836;
  color: white;
  font-size: 11px;
  font-weight: 500;
  padding: 5px 8px;
  border-radius: 6px;
  white-space: nowrap;
  z-index: 10;
  pointer-events: none;
  box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}
.nav-pill:hover::after {
  content: '';
  position: absolute;
  bottom: calc(100% + 1px);
  right: 8px;
  border: 5px solid transparent;
  border-top-color: #1d1836;
  z-index: 10;
  pointer-events: none;
}
/* Hide the ::after tooltip arrow from the original rules */
.nav-pill[data-pill="queued"]::after,
.nav-pill[data-pill="blocked"]::after {
  content: '';
  display: none;
}
 .sb-footer { padding: 16px; border-top: 1px solid rgba(255,255,255,0.07); }
/* Phase 4.34: bottom-of-sidebar shows the system version
   instead of the user block. The user / role / logout block
   used to live here but was removed (that info is already in
   the top-right topmenu). The version label uses the same
   size + colour as the old `.user-role` so the visual weight
   at the bottom of the sidebar stays roughly the same. */
.sb-version {
  font-size: 10px;
  color: rgba(255,255,255,0.4);
  margin-top: 1px;
  font-variant-numeric: tabular-nums;
  user-select: text;
  text-align: left;
}

/* Main content area: sits to the right of the sidebar */
.main { margin-left: var(--sidebar-w); min-height: 100vh; }
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 200ms ease;
    box-shadow: 0 0 0 rgba(0,0,0,0);
  }
  .sidebar.is-open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0,0,0,0.18);
  }
  .main { margin-left: 0; }
  /* A dim overlay behind the open sidebar makes it feel like a
     modal menu. We use pointer-events: none so it doesn't
     intercept clicks on the sidebar itself; the document-level
     click handler (in sidebar.js) handles the close-on-outside
     logic instead. The visual is purely cosmetic. */
  body.sidebar-open::before {
    content: '';
    position: fixed;
    top: 0;
    left: var(--sidebar-w);
    right: 0;
    bottom: 0;
    background: rgba(29, 24, 54, 0.32);
    z-index: 49;
    pointer-events: none;
  }
}

/* ── Shared color swatch (used by settings + cohort + template) ─
   Chrome on macOS renders <input type="color"> as a tiny narrow
   line that's almost invisible. We force a 48x48 swatch with a
   subtle border + the hex value next to it, so the user can see
   what they've selected without having to click through the
   picker. */
input[type="color"] {
  width: 48px;
  height: 36px;
  padding: 2px;
  border: 1.5px solid var(--border, #eadfba);
  border-radius: 8px;
  background: var(--surface, #fff);
  cursor: pointer;
  /* In Webkit/Blink, the native picker chrome is what looks
     cramped; padding + a fixed height makes the swatch the
     dominant visual. */
  -webkit-appearance: none;
  appearance: none;
}
input[type="color"]::-webkit-color-swatch-wrapper { padding: 0; }
input[type="color"]::-webkit-color-swatch         { border: none; border-radius: 6px; }
input[type="color"]::-moz-color-swatch            { border: none; border-radius: 6px; }

/* ── Shared icon button (used by every admin page) ────────────── */
.icon-btn {
  width: 28px; height: 28px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 7px; border: 1.5px solid var(--border);
  background: none; color: var(--muted);
  cursor: pointer; transition: all 150ms;
  padding: 0;
}
.icon-btn:hover { color: var(--fg); border-color: var(--fg-2); background: var(--bg); }
.icon-btn:active { transform: scale(0.95); }
.icon-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.icon-btn.danger:hover { color: var(--danger); border-color: var(--danger); }
.icon-btn svg { width: 13px; height: 13px; }

/* ── Trainer / training checkbox list (used by trainings + trainers drawers) */
.trainer-check-list { display: flex; flex-direction: column; gap: 4px; }
.trainer-check-item {
  display: flex; align-items: center; gap: 10px;
  padding: 6px 8px; border-radius: 8px;
  cursor: pointer; transition: background 150ms;
}
.trainer-check-item:hover { background: var(--bg); }
.trainer-check-item input[type=checkbox] { accent-color: var(--accent); }
.trainer-check-avatar {
  width: 28px; height: 28px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 11px; color: white;
  flex: 0 0 28px;
}
.trainer-check-name { font-size: 13px; font-weight: 600; color: var(--fg); }
.trainer-check-spec { font-size: 11px; color: var(--muted); }

/* Phase 4.9: row-updated highlight. Used by afterEdit().highlight()
   to briefly show the user which row their edit touched. */
@keyframes aea-row-flash {
  0%   { background-color: #fff3c4; }
  100% { background-color: transparent; }
}
tr.row-updated,
[data-row-id].row-updated {
  animation: aea-row-flash 1.5s ease-out;
}

/* Phase 4.10: email timeline inside the session fold-out */
.email-timeline-block { margin-top: 18px; padding-top: 18px; border-top: 1px solid var(--border); }
.email-timeline { list-style: none; padding: 0; margin: 0; }
.email-timeline-item {
  display: flex; align-items: flex-start; gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
}
.email-timeline-item:last-child { border-bottom: none; }
.email-timeline-item .esc-badge { flex: 0 0 auto; min-width: 72px; text-align: center; }
.email-phase {
  flex: 0 0 auto; min-width: 56px; font-size: 11px; font-weight: 700;
  text-align: center; padding: 2px 6px; border-radius: 6px;
  background: var(--bg); color: var(--fg-2);
  text-transform: uppercase; letter-spacing: 0.04em;
}
.email-phase.active  { background: #e6f6ec; color: #0e6e3a; }
.email-phase.info    { background: #e8edf6; color: #2541b2; }
.email-phase.warn    { background: #fff3e0; color: #b25e09; }
.email-phase.muted   { background: var(--bg); color: var(--muted); }
.email-timeline-body { flex: 1; min-width: 0; }
.email-subject { font-size: 13px; font-weight: 600; color: var(--fg); }
.email-recipient { font-size: 12px; color: var(--muted); }
.email-time { font-size: 11px; color: var(--muted); margin-top: 2px; }

/* Phase 4.12: owner tag in the all-scope triage row */
.triage-owner { font-size: 11px; color: var(--accent); font-weight: 600; padding: 0 6px; }
