/* ─────────────────────────────────────────────────────────────────
   ADMIN — SITEMAP

   The sitemap lives in its OWN top-level shell (#sitemap-shell in
   legacy.html, activated by the inSitemap branch in router.js). When
   active it fills the entire viewport — no admin sidebar, no admin
   topbar, no marketing chrome. Close button in the toolbar (red X)
   returns to #admin/courses.

   Layout inside the shell: header (full width) + 3-column body
   (legend / canvas / side panel). Narrow viewports collapse the side
   panel below the canvas and hide the legend.
   ───────────────────────────────────────────────────────────── */

/* ── Standalone shell — fullscreen, hidden by default ─────────── */
.sitemap-shell {
  position: fixed;
  inset: 0;
  z-index: 999;
  display: none;
  background: #0f1218;
  color: #e6e9ef;
}
.sitemap-shell.is-active { display: block; }
.sitemap-main {
  position: absolute;
  inset: 0;
  overflow: hidden;
}

.sm-page {
  display: flex;
  flex-direction: column;
  height: 100vh;
  background: #0f1218;
  color: #e6e9ef;
}

/* Loading state shown while auth resolves on direct paste / reload
   of /#sitemap. Sits inside #sitemap-main before renderAdminSitemap
   takes over. */
.sm-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100vh;
  color: #97a0b3;
  font-size: 13.5px;
}

/* ── Header ─────────────────────────────────────────────────── */
.sm-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  padding: 24px 28px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #121620;
}
.sm-head-text { max-width: 760px; }
.sm-title {
  margin: 0 0 6px 0;
  font-family: 'Fraunces', serif;
  font-size: 26px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #f1f4fa;
}
.sm-sub {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #97a0b3;
}

/* ── Tabs (Architecture / Triggers) ──────────────────────────── */
.sm-tabs {
  display: flex;
  gap: 2px;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 3px;
  margin: 4px 12px 0 12px;
  flex-shrink: 0;
}
.sm-tab {
  padding: 6px 14px;
  border-radius: 8px;
  border: none;
  background: transparent;
  color: #97a0b3;
  font-family: inherit;
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms, color 140ms;
}
.sm-tab:hover { color: #d8dde9; }
.sm-tab.is-active {
  background: rgba(255, 255, 255, 0.1);
  color: #f1f4fa;
}

.sm-toolbar {
  display: flex;
  gap: 6px;
  flex-shrink: 0;
  margin-top: 4px;
}
.sm-tb-btn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #c1c8d8;
  font-size: 16px;
  cursor: pointer;
  transition: background 120ms, border-color 120ms, color 120ms;
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: inherit;
}
.sm-tb-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  border-color: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.sm-tb-close {
  margin-left: 8px;
  background: rgba(201, 91, 91, 0.12);
  border-color: rgba(201, 91, 91, 0.4);
  color: #e8b3b3;
}
.sm-tb-close:hover {
  background: rgba(201, 91, 91, 0.22);
  border-color: rgba(201, 91, 91, 0.7);
  color: #fff;
}

/* ── Body grid ───────────────────────────────────────────────── */
.sm-body {
  display: grid;
  grid-template-columns: 200px 1fr 380px;
  gap: 0;
  flex: 1;
  min-height: 0;
}

/* ── Legend (left) ───────────────────────────────────────────── */
.sm-legend {
  padding: 20px 18px;
  border-right: 1px solid rgba(255, 255, 255, 0.05);
  background: #11151e;
  overflow-y: auto;
}
.sm-legend-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6f7689;
  margin-bottom: 12px;
}
.sm-legend-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 28px; }
.sm-legend-row {
  display: flex;
  align-items: center;
  gap: 9px;
  font-size: 12.5px;
  color: #c1c8d8;
}
.sm-legend-dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sm-legend-status {
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  padding-top: 18px;
}
.sm-legend-status-title {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6f7689;
  margin-bottom: 12px;
}
.sm-status-dot {
  width: 11px;
  height: 11px;
  border-radius: 50%;
  flex-shrink: 0;
  border: 1.5px solid;
}
.sm-status-dot.is-live   { background: #6fc285; border-color: #6fc285; }
.sm-status-dot.is-queued { background: transparent; border-color: #c9a14e; border-style: dashed; }
.sm-status-dot.is-future { background: transparent; border-color: #6f7689; border-style: dotted; }

/* ── Canvas (middle) ─────────────────────────────────────────── */
.sm-canvas-wrap {
  position: relative;
  background:
    radial-gradient(circle at 50% 38%, #1a2030 0%, #0f1218 78%);
}
/* Subtle dotted-grid backdrop — gives the canvas a faint
   "blueprint" feel without competing with the nodes. */
.sm-canvas-wrap::before {
  content: '';
  position: absolute;
  inset: 0;
  background-image: radial-gradient(circle, rgba(255, 255, 255, 0.04) 1px, transparent 1px);
  background-size: 28px 28px;
  background-position: 0 0;
  pointer-events: none;
}
.sm-canvas {
  position: absolute;
  inset: 0;
}
.sm-empty-hint {
  position: absolute;
  bottom: 16px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  color: #97a0b3;
  font-size: 12px;
  pointer-events: none;
  user-select: none;
}
.sm-empty-hint-icon { font-size: 14px; }

.sm-empty {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  color: #97a0b3;
  text-align: center;
  padding: 24px;
}
.sm-empty h3 {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  color: #c1c8d8;
  margin: 0 0 8px 0;
}

/* ── Side panel (right) ───────────────────────────────────────── */
.sm-panel {
  border-left: 1px solid rgba(255, 255, 255, 0.05);
  background: #11151e;
  overflow-y: auto;
  padding: 22px 22px 32px;
}
/* Subtle slide-fade on panel content change — fires when innerHTML
   is replaced (the * + * sibling trick re-triggers the animation). */
.sm-panel > * { animation: smPanelIn 280ms ease-out both; }
@keyframes smPanelIn {
  from { opacity: 0; transform: translateX(8px); }
  to   { opacity: 1; transform: translateX(0); }
}

.sm-panel-empty {
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 12px 0;
}
.sm-panel-empty-eyebrow {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6f7689;
}
.sm-panel-empty-msg {
  font-size: 13.5px;
  line-height: 1.55;
  color: #97a0b3;
}

.sm-panel-card {
  display: flex;
  flex-direction: column;
}
.sm-panel-card-head {
  padding: 4px 0 18px 16px;
  border-left: 3px solid;
  margin-bottom: 22px;
}
.sm-panel-cat {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6f7689;
  margin-bottom: 6px;
}
.sm-panel-title {
  font-family: 'Fraunces', serif;
  font-size: 24px;
  font-weight: 600;
  margin: 0 0 12px 0;
  color: #f1f4fa;
  letter-spacing: -0.015em;
  line-height: 1.15;
}
.sm-panel-meta {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
}
.sm-status-badge {
  display: inline-block;
  padding: 3px 9px;
  border-radius: 999px;
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
}
.sm-status-badge.is-live   { background: rgba(111, 194, 133, 0.16); color: #8fd5a3; }
.sm-status-badge.is-queued { background: rgba(201, 161, 78, 0.16);  color: #e6c478; border: 1px dashed rgba(201, 161, 78, 0.5); }
.sm-status-badge.is-future { background: rgba(111, 118, 137, 0.16); color: #a5acbd; border: 1px dotted rgba(111, 118, 137, 0.5); }
.sm-panel-counts {
  font-size: 11.5px;
  color: #a5acbd;
  background: rgba(255, 255, 255, 0.05);
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.sm-panel-section { margin-bottom: 20px; }
.sm-panel-section-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6f7689;
  margin-bottom: 8px;
}
.sm-panel-desc {
  margin: 0;
  font-size: 14px;
  line-height: 1.62;
  color: #c8cfe0;
}
.sm-panel-source {
  display: inline-block;
  font-family: 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: #97a0b3;
  background: rgba(255, 255, 255, 0.04);
  padding: 5px 9px;
  border-radius: 6px;
  border: 1px solid rgba(255, 255, 255, 0.06);
  word-break: break-all;
}

.sm-panel-empty-list {
  font-size: 12.5px;
  color: #6f7689;
  font-style: italic;
}
.sm-panel-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.sm-panel-list-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 7px 10px;
  border-radius: 7px;
  cursor: pointer;
  transition: background 120ms;
}
.sm-panel-list-item:hover { background: rgba(255, 255, 255, 0.05); }
.sm-panel-list-dot {
  width: 9px;
  height: 9px;
  border-radius: 50%;
  flex-shrink: 0;
}
.sm-panel-list-label {
  font-size: 13px;
  color: #d8dde9;
}

/* ── Triggers view (Tab 2) ──────────────────────────────────── */
.sm-body-triggers {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background: #0f1218;
}
.sm-body-triggers[hidden] { display: none; }
.sm-body[id][hidden]     { display: none; }

/* Filters bar */
.sm-trig-filters {
  padding: 20px 28px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: #11151e;
  display: flex;
  flex-direction: column;
  gap: 12px;
  flex-shrink: 0;
}
.sm-filter-row {
  display: flex;
  align-items: center;
  gap: 14px;
}
.sm-filter-label {
  font-size: 10.5px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: #6f7689;
  min-width: 70px;
}
.sm-filter-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}
.sm-pill {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 11px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #c1c8d8;
  font-family: inherit;
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 140ms, border-color 140ms, color 140ms;
}
.sm-pill em {
  font-style: normal;
  font-size: 10.5px;
  color: #6f7689;
  font-weight: 600;
}
.sm-pill:hover {
  background: rgba(255, 255, 255, 0.08);
  border-color: rgba(255, 255, 255, 0.2);
  color: #f1f4fa;
}
.sm-pill.is-active {
  background: rgba(255, 255, 255, 0.12);
  border-color: rgba(255, 255, 255, 0.3);
  color: #ffffff;
}
.sm-pill.is-active em { color: #d8dde9; }

/* Tier-coloured filter pills when active (subtle hint of the tier colour) */
.sm-pill-tier-golden.is-active   { background: rgba(143, 213, 163, 0.18); border-color: rgba(143, 213, 163, 0.5); color: #afe7c1; }
.sm-pill-tier-strong.is-active   { background: rgba(125, 211, 252, 0.18); border-color: rgba(125, 211, 252, 0.5); color: #b5e3fb; }
.sm-pill-tier-workable.is-active { background: rgba(201, 161, 78, 0.18);  border-color: rgba(201, 161, 78, 0.5);  color: #e6c478; }
.sm-pill-tier-low-confidence.is-active { background: rgba(165, 172, 189, 0.18); border-color: rgba(165, 172, 189, 0.5); color: #d1d6e0; }

.sm-filter-result {
  font-size: 12px;
  color: #97a0b3;
}
.sm-filter-result strong { color: #f1f4fa; font-weight: 600; }

/* Search input */
.sm-filter-search-row { align-items: stretch; }
.sm-search-wrap {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
}
.sm-search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: #6f7689;
  pointer-events: none;
}
.sm-search-input {
  width: 100%;
  padding: 8px 38px 8px 36px;
  border-radius: 8px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  background: rgba(255, 255, 255, 0.04);
  color: #f1f4fa;
  font-family: inherit;
  font-size: 13px;
  transition: border-color 140ms, background 140ms;
  -webkit-appearance: none;
  appearance: none;
}
.sm-search-input::placeholder { color: #6f7689; }
.sm-search-input::-webkit-search-cancel-button,
.sm-search-input::-webkit-search-decoration { -webkit-appearance: none; }
.sm-search-input:focus {
  outline: none;
  border-color: rgba(255, 255, 255, 0.28);
  background: rgba(255, 255, 255, 0.07);
}
.sm-search-clear {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 22px;
  height: 22px;
  border: none;
  background: rgba(255, 255, 255, 0.08);
  border-radius: 50%;
  color: #c1c8d8;
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 120ms, color 120ms;
  padding: 0;
  font-family: inherit;
}
.sm-search-clear:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

/* Cards grid */
.sm-trig-grid {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 40px;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(360px, 1fr));
  gap: 14px;
  align-content: start;
}
.sm-trig-empty {
  grid-column: 1 / -1;
  padding: 60px 20px;
  text-align: center;
  color: #97a0b3;
}
.sm-trig-empty h3 {
  font-family: 'Fraunces', serif;
  font-size: 18px;
  color: #c1c8d8;
  margin: 0 0 8px 0;
}
.sm-trig-empty p { margin: 0; font-size: 13.5px; }

/* Card */
.sm-trig-card {
  background: #151a25;
  border: 1px solid rgba(255, 255, 255, 0.06);
  border-left: 3px solid rgba(255, 255, 255, 0.08);
  border-radius: 10px;
  padding: 14px 16px 14px 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  transition: border-color 140ms, transform 140ms;
}
.sm-trig-card:hover {
  border-color: rgba(255, 255, 255, 0.12);
  transform: translateY(-1px);
}
.sm-trig-card.is-subj-writing   { border-left-color: #C95B5B; }
.sm-trig-card.is-subj-reading   { border-left-color: #7BAA7B; }
.sm-trig-card.is-subj-listening { border-left-color: #9C7AB0; }
.sm-trig-card.is-subj-speaking  { border-left-color: #D9A268; }
.sm-trig-card.is-subj-drill     { border-left-color: #5FA8B0; }

.sm-trig-head {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
}
.sm-trig-sig {
  font-family: 'SF Mono', 'Fira Code', Menlo, Consolas, monospace;
  font-size: 11.5px;
  color: #d8dde9;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px 7px;
  border-radius: 5px;
  word-break: break-all;
  line-height: 1.45;
}
.sm-trig-badges {
  display: flex;
  gap: 5px;
  flex-shrink: 0;
}
.sm-trig-badge {
  display: inline-block;
  padding: 2px 7px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.05);
  color: #c1c8d8;
  white-space: nowrap;
}
/* Subject badges */
.sm-trig-badge.is-subj-writing   { background: rgba(201, 91, 91, 0.18);  color: #e89b9b; }
.sm-trig-badge.is-subj-reading   { background: rgba(123, 170, 123, 0.18); color: #a8d2a8; }
.sm-trig-badge.is-subj-listening { background: rgba(156, 122, 176, 0.18); color: #c7a8d6; }
.sm-trig-badge.is-subj-speaking  { background: rgba(217, 162, 104, 0.18); color: #e8c08a; }
.sm-trig-badge.is-subj-drill     { background: rgba(95, 168, 176, 0.18);  color: #94cfd5; }
/* Tier badges */
.sm-trig-badge.is-tier-golden    { background: rgba(143, 213, 163, 0.18); color: #afe7c1; }
.sm-trig-badge.is-tier-strong    { background: rgba(125, 211, 252, 0.18); color: #b5e3fb; }
.sm-trig-badge.is-tier-workable  { background: rgba(201, 161, 78, 0.18);  color: #e6c478; }
.sm-trig-badge.is-tier-low-confidence { background: rgba(165, 172, 189, 0.18); color: #d1d6e0; }
/* Band-target badges */
.sm-trig-badge.is-band-5to6      { background: rgba(252, 211, 77, 0.14); color: #fce394; }
.sm-trig-badge.is-band-6to7      { background: rgba(125, 211, 252, 0.14); color: #a3dffc; }
.sm-trig-badge.is-band-7to8      { background: rgba(167, 139, 250, 0.14); color: #c3b1fc; }
.sm-trig-badge.is-band-universal { background: rgba(255, 255, 255, 0.06); color: #b0b8c8; }

.sm-trig-desc {
  margin: 0;
  font-size: 13px;
  line-height: 1.55;
  color: #c8cfe0;
}
.sm-trig-lessons {
  margin-top: 4px;
  padding-top: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
  display: flex;
  align-items: baseline;
  gap: 8px;
  flex-wrap: wrap;
}
.sm-trig-lessons-label {
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #6f7689;
  flex-shrink: 0;
}
.sm-trig-lessons-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}
.sm-trig-lesson {
  display: inline-block;
  font-size: 11.5px;
  color: #c1c8d8;
  background: rgba(255, 255, 255, 0.05);
  padding: 2px 8px;
  border-radius: 5px;
  border: 1px solid rgba(255, 255, 255, 0.06);
}

/* ── Responsive ──────────────────────────────────────────────── */
@media (max-width: 1100px) {
  .sm-body { grid-template-columns: 1fr 340px; }
  .sm-legend { display: none; }
}
@media (max-width: 800px) {
  .sm-body { grid-template-columns: 1fr; grid-template-rows: 1fr auto; }
  .sm-panel { max-height: 50vh; border-left: none; border-top: 1px solid rgba(255, 255, 255, 0.05); }
}
