/**
 * Plan Builder Modal (Increment 3 — Step 4 level picker)
 *
 * Self-contained, pbm-* namespaced so it can mount over any page (launched from
 * the teacher-dashboard plan-management flyout) without clashing with page CSS.
 * Visual language ported faithfully from frontend/plan-builder-scratch.html Step 4 —
 * exact palette, Montserrat type, and the count badge match the mock.
 */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700;800&display=swap');

.pbm-overlay {
  /* Exact mock palette (plan-builder-scratch.html :root). */
  --pbm-green: #44A148;
  --pbm-green-d: #2D6A2F;
  --pbm-green-soft: rgba(68,161,72,.10);
  --pbm-green-50: #EAF5EA;
  --pbm-amber: #b45309;
  --pbm-ink: #1A2718;
  --pbm-muted: #5b6b5c;
  --pbm-faint: #929d92;
  --pbm-line: #E6EAE6;
  --pbm-line2: #EFF2EF;
  --pbm-font: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  position: fixed;
  inset: 0;
  z-index: 10000;
  display: none;
  align-items: center;
  justify-content: center;
  background: rgba(20, 32, 18, 0.45);
  padding: 24px;
}
.pbm-overlay.pbm-open { display: flex; }

.pbm-panel {
  background: #f7faf6;
  border-radius: 16px;
  width: min(680px, 100%);
  max-height: min(86vh, 760px);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(20, 40, 16, 0.28);
  font-family: var(--pbm-font);
  color: var(--pbm-ink);
  line-height: 1.45;
}

.pbm-head {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  background: #fff;
  border-bottom: 1px solid var(--pbm-line);
}
.pbm-head-title { font-size: 16px; font-weight: 800; }
.pbm-head-sub { font-size: 12.5px; color: var(--pbm-muted); }
.pbm-close {
  margin-left: 4px;
  border: none;
  background: transparent;
  font-size: 22px;
  line-height: 1;
  color: var(--pbm-muted);
  cursor: pointer;
  padding: 4px 8px;
  border-radius: 8px;
}
.pbm-close:hover { background: var(--pbm-line2); color: var(--pbm-ink); }
/* Quick-add fast lane — always reachable from the header. */
.pbm-find {
  margin-left: auto;
  border: 1.5px solid var(--pbm-green);
  background: var(--pbm-green-50);
  color: var(--pbm-green-d);
  font-family: inherit;
  font-weight: 700;
  font-size: 13px;
  padding: 8px 14px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}
.pbm-find:hover { background: var(--pbm-green); color: #fff; }

.pbm-intro { padding: 14px 20px 4px; font-size: 12.5px; color: var(--pbm-muted); }

.pbm-body { padding: 10px 20px 16px; overflow-y: auto; }

.pbm-empty, .pbm-loading, .pbm-error {
  padding: 36px 20px;
  text-align: center;
  font-size: 13.5px;
  color: var(--pbm-muted);
}
.pbm-error { color: #c0392b; }

/* ── Suite row ───────────────────────────────────────────────── */
.pbm-srow {
  border: 1px solid var(--pbm-line);
  border-radius: 12px;
  margin-bottom: 9px;
  background: #fff;
  overflow: hidden;
}
.pbm-srow-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 11px 13px;
  border-bottom: 1px solid var(--pbm-line2);
}
.pbm-sw { flex-shrink: 0; width: 11px; height: 11px; border-radius: 3px; background: var(--pbm-green); }
.pbm-nm { font-weight: 700; font-size: 14px; }
.pbm-ctrl { margin-left: auto; display: flex; align-items: center; gap: 11px; }
.pbm-seg-label { font-size: 11px; font-weight: 700; color: var(--pbm-muted); }

.pbm-seg { display: inline-flex; border: 1.5px solid #bcd3bc; border-radius: 9px; overflow: hidden; }
.pbm-seg-btn {
  font: inherit;
  font-size: 11.5px;
  font-weight: 700;
  border: none;
  background: #fff;
  color: var(--pbm-ink);
  padding: 6px 11px;
  cursor: pointer;
  border-left: 1px solid #bcd3bc;
}
.pbm-seg-btn:first-child { border-left: none; }
.pbm-seg-btn:hover { background: var(--pbm-green-soft); }
.pbm-seg-btn.pbm-on { background: var(--pbm-green); color: #fff; }
.pbm-seg-btn:disabled { opacity: 0.55; cursor: progress; }

.pbm-srow-body { padding: 11px 13px 13px 35px; }
.pbm-rubric {
  font-size: 12.5px;
  color: var(--pbm-muted);
  line-height: 1.5;
  padding: 0 0 10px;
  border-bottom: 1px solid var(--pbm-line2);
  margin-bottom: 10px;
}
.pbm-rubric .pbm-rtag { font-weight: 800; color: var(--pbm-green-d); }
.pbm-rubric.pbm-zero, .pbm-cntpill.pbm-zero { color: var(--pbm-amber); }

.pbm-lgrp-row {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: 10px;
  font-size: 10px;
  font-weight: 800;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--pbm-faint);
  margin: 4px 0 2px;
}
.pbm-cntpill {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12px;
  font-weight: 700;
  color: var(--pbm-green-d);
  text-transform: none;
  letter-spacing: normal;
}
.pbm-cnum {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 22px;
  height: 22px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--pbm-green-50);
  color: var(--pbm-green-d);
  font-size: 12px;
  font-weight: 800;
}

.pbm-llist { margin-top: 9px; display: flex; flex-direction: column; gap: 3px; }
.pbm-lrow {
  font-size: 13px; padding: 4px 6px 4px 14px; border-left: 2px solid var(--pbm-line);
  color: #3f4a3e; display: flex; align-items: center; gap: 8px;
}
.pbm-lrow > span:first-child { flex: 1; min-width: 0; }
.pbm-lrow.pbm-below { color: var(--pbm-faint); text-decoration: line-through; text-decoration-color: #d6dad6; }
/* per-lesson controls */
.pbm-lbtn {
  flex-shrink: 0; border: 1px solid var(--pbm-line); background: #fff; cursor: pointer;
  width: 22px; height: 22px; border-radius: 6px; font-size: 14px; line-height: 1;
  color: var(--pbm-muted); display: inline-flex; align-items: center; justify-content: center;
}
.pbm-remove:hover { border-color: #f3c4c0; background: #fef2f2; color: #b42318; }
.pbm-restore:hover { border-color: #bcd3bc; background: var(--pbm-green-50); color: var(--pbm-green-d); }
.pbm-lrow.pbm-removed { color: var(--pbm-faint); }
.pbm-lrow.pbm-removed > span:first-child { text-decoration: line-through; text-decoration-color: #d6dad6; }
/* completed lesson — grayed title + a plain green "✓ (Completed)" tag (not removable) */
.pbm-lrow.pbm-completed > span:first-child { color: var(--pbm-faint); }
.pbm-check {
  flex-shrink: 0; font-size: 12px; font-weight: 400;
  color: var(--pbm-green); opacity: .8; white-space: nowrap;
}
.pbm-disclo {
  font-size: 12px;
  font-weight: 700;
  color: var(--pbm-green-d);
  cursor: pointer;
  user-select: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin: 9px 16px 0 0;
}
.pbm-disclo:hover { color: var(--pbm-ink); }

/* ── Footer ──────────────────────────────────────────────────── */
.pbm-foot {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 13px 20px;
  background: #fff;
  border-top: 1px solid var(--pbm-line);
}
.pbm-total { font-size: 13px; font-weight: 700; color: var(--pbm-green-d); }
.pbm-saved { font-size: 12px; color: var(--pbm-muted); margin-left: auto; }

/* Launch trigger (lives in the dashboard plan-management flyout). */
.pbm-launch-btn {
  margin-left: auto;
  border: 1.5px solid #44A148;
  background: #EAF5EA;
  color: #2D6A2F;
  font-family: 'Montserrat', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  font-weight: 700;
  font-size: 12.5px;
  padding: 7px 14px;
  border-radius: 9px;
  cursor: pointer;
  white-space: nowrap;
}
.pbm-launch-btn:hover { background: #44A148; color: #fff; }
