/* ─────────────────────────────────────────────────────────
   Labbie — Manage Mode
   Loaded by workspace.html. Scope-prefixed with .ws- / .mg- / #manageCanvas
   so it cannot leak into the editor or the generated preview.
───────────────────────────────────────────────────────── */

/* ── Preview/Manage switch — lives in .browser-bar on desktop,
      moved to .tb-actions on mobile by syncBtnsLocation JS        ── */
.ws-mode-switch {
  display: inline-flex;
  align-items: center;
  gap: 2px;
  padding: 3px;
  border-radius: 999px;
  background: #f3f4f6;
  border: 1px solid #e5e7eb;
  flex-shrink: 0;
}
.wsm-btn {
  appearance: none;
  border: 0;
  background: transparent;
  padding: 5px 14px;
  border-radius: 999px;
  font: inherit;
  font-size: 0.8rem;
  font-weight: 500;
  color: #6b7280;
  cursor: pointer;
  transition: background 140ms, color 140ms, box-shadow 140ms;
  letter-spacing: -0.005em;
}
.wsm-btn:hover { color: #111827; }
.wsm-btn.active {
  background: #ffffff;
  color: #111827;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08), 0 0 0 1px rgba(0,0,0,0.04);
}

/* Mobile: in tb-actions, hide switch when in Chat mode */
@media (max-width: 900px) {
  body:not(.mobile-preview):not(.manage-mode) .tb-actions #wsModeSwitch { display: none !important; }
  .tb-actions #wsModeSwitch { flex-shrink: 0; }
  .wsm-btn { padding: 4px 11px; font-size: 0.76rem; }
}
@media (max-width: 480px) {
  .ws-mode-switch { padding: 2px; }
  .wsm-btn { padding: 3px 9px; font-size: 0.72rem; }
}

/* ── Hide editor chrome while in Manage mode ── */
/* Keep .browser-bar visible — it holds the Preview/Manage switch on desktop */
body.manage-mode .wse-toolbar-slot { display: none !important; }
body.manage-mode #wseToolbarMobileRow { display: none !important; }
body.manage-mode #wseToolbar { display: none !important; }
body.manage-mode .preview-area { display: none !important; }
body.manage-mode .preview-btns { display: none !important; }
body.manage-mode .manage-canvas { display: flex !important; }

/* ── Manage canvas shell ── */
.manage-canvas {
  flex: 1;
  min-height: 0;
  display: none;
  flex-direction: column;
  background: #fafafa;
  overflow: hidden;
}

.mg-tabs {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 24px 0;
  border-bottom: 1px solid #e5e7eb;
  background: #ffffff;
}
.mg-tab {
  appearance: none;
  border: 0;
  background: transparent;
  font: inherit;
  font-size: 0.875rem;
  font-weight: 500;
  color: #6b7280;
  padding: 10px 14px;
  border-radius: 8px 8px 0 0;
  cursor: pointer;
  position: relative;
  transition: color 130ms, background 130ms;
  display: inline-flex; align-items: center; gap: 7px;
}
.mg-tab:hover { color: #111827; background: #f9fafb; }
.mg-tab.active { color: #111827; }
.mg-tab.active::after {
  content: '';
  position: absolute;
  left: 14px; right: 14px; bottom: -1px;
  height: 2px;
  background: #111827;
  border-radius: 2px;
}
.mg-count {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 18px; height: 18px; padding: 0 5px;
  border-radius: 999px;
  font-size: 0.68rem; font-weight: 500;
  background: #111827; color: #fff;
}
.mg-count:empty { display: none; }

.mg-body {
  flex: 1;
  min-height: 0;
  overflow: auto;
}
/* Enforce Labbie's heading/body weight everywhere in Manage — never bold.
   Browser default <strong>/<b> is 700; pin to 500 so emphasis matches the
   app shell (headings 500, body 400). */
.mg-body strong, .mg-body b { font-weight: 500; }

/* ── Overview ── */
.mg-overview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
  padding: 24px;
  max-width: 1100px;
  margin: 0 auto;
}
.mg-card {
  background: #ffffff;
  border: 1px solid #e5e7eb;
  border-radius: 14px;
  padding: 18px 20px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 132px;
}
.mg-card-latest { grid-column: span 2; }
@media (max-width: 720px) { .mg-card-latest { grid-column: auto; } }

.mg-card-label {
  font-size: 0.72rem;
  font-weight: 500;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #9ca3af;
}
.mg-card-big {
  font-size: 2.2rem;
  font-weight: 500;
  letter-spacing: -0.02em;
  color: #111827;
  line-height: 1.1;
}
.mg-card-meta { font-size: 0.82rem; color: #6b7280; }

.mg-status {
  display: inline-flex; align-items: center; gap: 8px;
  font-size: 1rem; font-weight: 500;
  color: #111827;
}
.mg-status-loading { color: #6b7280; }
.mg-status-live { color: #047857; }
.mg-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 0 3px rgba(16,185,129,0.18);
}
.mg-dot-grey {
  background: #9ca3af;
  box-shadow: 0 0 0 3px rgba(156,163,175,0.18);
}
.mg-status-sub { font-size: 0.82rem; color: #6b7280; }
.mg-link {
  font-size: 0.84rem;
  color: #111827;
  text-decoration: none;
  word-break: break-all;
  border-bottom: 1px solid #d1d5db;
  padding-bottom: 1px;
  align-self: flex-start;
}
.mg-link:hover { color: #000; border-color: #111827; }

.mg-latest-name { font-size: 1rem; font-weight: 500; color: #111827; }
.mg-latest-meta { font-size: 0.78rem; color: #6b7280; margin-top: 2px; }
.mg-latest-msg { font-size: 0.875rem; color: #374151; line-height: 1.5; margin-top: 4px; }

/* ── Buttons ── */
.mg-btn-primary,
.mg-btn-secondary,
.mg-btn-ghost {
  appearance: none;
  border: 1px solid transparent;
  border-radius: 8px;
  padding: 7px 14px;
  font: inherit;
  font-size: 0.82rem;
  font-weight: 500;
  cursor: pointer;
  text-decoration: none;
  display: inline-flex; align-items: center; gap: 6px;
  transition: background 130ms, color 130ms, border-color 130ms, box-shadow 130ms;
  line-height: 1.2;
}
.mg-btn-primary { background: #111827; color: #fff; align-self: flex-start; }
.mg-btn-primary:hover { background: #000; }
.mg-btn-secondary { background: #f3f4f6; color: #111827; border-color: #e5e7eb; }
.mg-btn-secondary:hover { background: #e5e7eb; }
.mg-btn-ghost { background: transparent; color: #374151; border-color: #e5e7eb; align-self: flex-start; }
.mg-btn-ghost:hover { background: #f3f4f6; color: #111827; }

/* Email compose chooser (Gmail / Outlook / Default mail app) — Issue 4 */
.mg-email-menu {
  position: fixed;
  z-index: 10000;
  min-width: 172px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(17, 24, 39, 0.18);
  padding: 5px;
  display: flex;
  flex-direction: column;
  gap: 2px;
}
.mg-email-menu-item {
  appearance: none;
  border: none;
  background: transparent;
  text-align: left;
  padding: 8px 12px;
  border-radius: 7px;
  font: inherit;
  font-size: 0.85rem;
  font-weight: 500;
  color: #111827;
  cursor: pointer;
}
.mg-email-menu-item:hover { background: #f3f4f6; }

.mg-empty { font-size: 0.875rem; color: #6b7280; line-height: 1.55; }

/* ── Leads ── */
.mg-leads {
  display: grid;
  grid-template-columns: minmax(280px, 360px) 1fr;
  gap: 0;
  height: 100%;
  background: #ffffff;
}
@media (max-width: 760px) {
  .mg-leads { grid-template-columns: 1fr; }
  .mg-leads-detail { display: none; }
  .mg-leads.detail-open .mg-leads-list { display: none; }
  .mg-leads.detail-open .mg-leads-detail { display: block; }
}

.mg-leads-list {
  border-right: 1px solid #e5e7eb;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.mg-leads-toolbar {
  flex-shrink: 0;
  padding: 14px 16px 10px;
  border-bottom: 1px solid #f3f4f6;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #fafafa;
}
.mg-search {
  appearance: none;
  border: 1px solid #e5e7eb;
  background: #ffffff;
  border-radius: 8px;
  padding: 7px 12px;
  font: inherit;
  font-size: 0.84rem;
  color: #111827;
  outline: none;
  transition: border-color 130ms, box-shadow 130ms;
}
.mg-search:focus {
  border-color: #111827;
  box-shadow: 0 0 0 3px rgba(17,24,39,0.08);
}
.mg-filter {
  display: inline-flex; gap: 2px;
  padding: 2px;
  border-radius: 999px;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  align-self: flex-start;
}
.mg-fbtn {
  appearance: none; border: 0; background: transparent;
  font: inherit;
  font-size: 0.76rem; font-weight: 500;
  padding: 4px 11px;
  border-radius: 999px;
  color: #6b7280;
  cursor: pointer;
  transition: background 130ms, color 130ms;
}
.mg-fbtn:hover { color: #111827; }
.mg-fbtn.active { background: #111827; color: #fff; }

.mg-leads-items { flex: 1; overflow-y: auto; padding: 6px 0; }
.mg-lead-item {
  padding: 12px 16px;
  border-bottom: 1px solid #f3f4f6;
  cursor: pointer;
  transition: background 120ms;
}
.mg-lead-item:hover { background: #fafafa; }
.mg-lead-item.selected { background: #f3f4f6; }
.mg-lead-item.handled { opacity: 0.7; }
.mg-lead-head {
  display: flex; justify-content: space-between; align-items: baseline;
  gap: 8px;
}
.mg-lead-name {
  font-size: 0.875rem; font-weight: 500; color: #111827;
  display: inline-flex; align-items: center; gap: 6px;
}
.mg-lead-time { font-size: 0.72rem; color: #9ca3af; flex-shrink: 0; }
.mg-new-pill {
  font-size: 0.62rem; font-weight: 500;
  background: #111827; color: #fff;
  padding: 1px 6px; border-radius: 999px;
  letter-spacing: 0.04em; text-transform: uppercase;
}
.mg-lead-email { font-size: 0.78rem; color: #6b7280; margin-top: 2px; }
.mg-lead-snip {
  font-size: 0.8rem; color: #374151;
  margin-top: 4px;
  overflow: hidden;
  text-overflow: ellipsis;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  line-height: 1.4;
}
.mg-empty-leads { padding: 24px 16px; text-align: center; }
.mg-empty-cta { display: flex; flex-direction: column; align-items: center; gap: 6px; padding: 36px 20px; }
.mg-empty-cta-title { font-size: 0.95rem; font-weight: 500; color: #111827; }
.mg-empty-cta-sub { font-size: 0.84rem; color: #6b7280; line-height: 1.5; max-width: 280px; }
.mg-empty-cta .mg-btn-primary { align-self: center; margin-top: 10px; }

.mg-leads-detail { overflow-y: auto; padding: 28px 32px; min-height: 0; }
.mg-empty-detail {
  display: flex; align-items: center; justify-content: center;
  height: 100%;
  text-align: center;
  padding: 32px;
}
.mg-detail-head {
  display: flex; justify-content: space-between; align-items: baseline;
  margin-bottom: 22px;
  gap: 16px;
}
.mg-detail-name { font-size: 1.35rem; font-weight: 500; color: #111827; letter-spacing: -0.015em; }
.mg-detail-time { font-size: 0.78rem; color: #9ca3af; }

.mg-detail-fields {
  display: flex; flex-direction: column; gap: 0;
  margin: 0 0 22px;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  overflow: hidden;
}
.mg-field {
  display: grid;
  grid-template-columns: 90px 1fr;
  align-items: center;
  padding: 11px 14px;
  border-bottom: 1px solid #f3f4f6;
}
.mg-field:last-child { border-bottom: 0; }
.mg-field dt {
  font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: #9ca3af;
}
.mg-field dd { font-size: 0.875rem; color: #111827; margin: 0; }
.mg-field dd a { color: #111827; text-decoration: underline; text-decoration-color: #d1d5db; }
.mg-field dd a:hover { text-decoration-color: #111827; }

.mg-detail-msg-label {
  font-size: 0.72rem; font-weight: 500;
  letter-spacing: 0.04em; text-transform: uppercase;
  color: #9ca3af;
  margin-bottom: 8px;
}
.mg-detail-msg {
  font-size: 0.95rem; color: #1f2937;
  line-height: 1.6;
  background: #f9fafb;
  border: 1px solid #f3f4f6;
  border-radius: 10px;
  padding: 14px 16px;
  white-space: pre-wrap;
  margin-bottom: 22px;
}
.mg-detail-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* ── V2 (real data): status pills / buttons, notes, export ── */
.mg-status-pill {
  display: inline-block; font-size: 10px; font-weight: 500; letter-spacing: 0.04em;
  text-transform: uppercase; padding: 2px 7px; border-radius: 999px; margin-left: 6px;
  background: #f3f4f6; color: #4b5563;
}
.mg-status-pill.mg-st-completed { background: #dcfce7; color: #166534; }
.mg-status-pill.mg-st-closed    { background: #e5e7eb; color: #4b5563; }

.mg-status-row { display: flex; gap: 6px; flex-wrap: wrap; margin: 6px 0 14px; }
.mg-sbtn {
  font-size: 12px; font-weight: 500; padding: 6px 12px; border-radius: 999px;
  border: 1px solid #e5e7eb; background: #fff; color: #4b5563; cursor: pointer;
  transition: background .12s ease, color .12s ease, border-color .12s ease;
}
.mg-sbtn:hover { background: #f3f4f6; color: #111827; }
.mg-sbtn.active { background: #111827; color: #fff; border-color: #111827; }
.mg-sbtn.mg-st-completed.active { background: #166534; border-color: #166534; }
.mg-sbtn.mg-st-closed.active    { background: #6b7280; border-color: #6b7280; }

.mg-notes {
  width: 100%; box-sizing: border-box; font: inherit; font-size: 13px;
  padding: 10px 12px; border-radius: 10px; border: 1px solid #e5e7eb;
  background: #fff; color: #111827; resize: vertical; margin: 6px 0 2px;
}
.mg-notes:focus { outline: none; border-color: #111827; box-shadow: 0 0 0 3px rgba(17,24,39,0.06); }
.mg-notes-saved { font-size: 11px; color: #16a34a; font-weight: 500; }

.mg-export {
  font-size: 12px; font-weight: 500; color: #4b5563; text-decoration: none;
  padding: 6px 10px; border-radius: 8px; border: 1px solid #e5e7eb; background: #fff;
  white-space: nowrap;
}
.mg-export:hover { background: #f3f4f6; color: #111827; }

/* ── Launch checklist (pre-publish empty state) ── */
.mg-loading-block {
  padding: 44px 24px; text-align: center; color: #9ca3af; font-size: 0.875rem;
}

.mg-checklist-wrap { max-width: 600px; margin: 0 auto; padding: 30px 24px 44px; }

.mg-chk-head { margin-bottom: 20px; }
.mg-chk-h {
  font-size: 1.4rem; font-weight: 500; letter-spacing: -0.02em;
  color: #111827; margin: 0;
}
.mg-chk-p { font-size: 0.9rem; color: #6b7280; line-height: 1.55; margin: 6px 0 0; }
.mg-chk-progress {
  height: 6px; width: 100%; max-width: 260px;
  background: #eef0f2; border-radius: 999px; overflow: hidden; margin-top: 16px;
}
.mg-chk-progress-fill {
  display: block; height: 100%; background: #10b981; border-radius: 999px;
  transition: width 0.45s cubic-bezier(0.4, 0, 0.2, 1);
}
.mg-chk-progress-label { font-size: 0.74rem; color: #9ca3af; margin-top: 7px; font-weight: 500; }

.mg-chk-list {
  list-style: none; margin: 0; padding: 24px 22px;
  background: #ffffff; border: 1px solid #e5e7eb; border-radius: 16px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.mg-chk-step { position: relative; display: flex; gap: 14px; padding-bottom: 22px; }
.mg-chk-step:last-child { padding-bottom: 0; }
/* connector line between marks */
.mg-chk-step:not(:last-child)::after {
  content: ''; position: absolute; left: 13px; top: 30px; bottom: 2px;
  width: 2px; background: #e8eaed; transform: translateX(-50%);
}

.mg-chk-mark {
  flex-shrink: 0; position: relative; z-index: 1;
  width: 26px; height: 26px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: #ffffff; border: 2px solid #e5e7eb; color: #9ca3af;
}
.mg-chk-done .mg-chk-mark { background: #10b981; border-color: #10b981; color: #fff; }
.mg-chk-active .mg-chk-mark { border-color: #cbd0d6; }
.mg-chk-next .mg-chk-mark { border-color: #111827; }
.mg-chk-next .mg-chk-mark::after {
  content: ''; width: 8px; height: 8px; border-radius: 50%; background: #111827;
}
.mg-chk-locked .mg-chk-mark { border-color: #eceef0; color: #c2c7cd; }

.mg-chk-body { flex: 1; min-width: 0; padding-top: 1px; }
.mg-chk-title {
  font-size: 0.95rem; font-weight: 500; color: #111827;
  display: flex; align-items: center; gap: 8px;
}
.mg-chk-locked .mg-chk-title { color: #9ca3af; }
.mg-chk-sub { font-size: 0.83rem; color: #6b7280; line-height: 1.5; margin-top: 3px; }
.mg-chk-btn { margin-top: 12px; }

.mg-chk-badge {
  font-size: 0.6rem; font-weight: 500; letter-spacing: 0.05em; text-transform: uppercase;
  padding: 2px 7px; border-radius: 999px;
  background: #fdf6e3; color: #a16207; border: 1px solid #fadf9b;
}

/* ── Operating dashboard (published) ── */
.mg-dash { max-width: 1100px; margin: 0 auto; padding: 24px; display: flex; flex-direction: column; gap: 16px; }

/* Anchor (hero) */
.mg-anchor {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  background: #ffffff; border: 1px solid #e5e7eb; border-radius: 16px; padding: 18px 22px;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}
.mg-anchor-main { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.mg-anchor .mg-status { font-size: 0.82rem; }
.mg-anchor-url {
  font-size: 1.05rem; font-weight: 500; color: #111827; text-decoration: none; word-break: break-all;
}
.mg-anchor-url:hover { color: #000; text-decoration: underline; text-decoration-color: #d1d5db; }
.mg-anchor-actions { display: flex; gap: 8px; flex-wrap: wrap; }

/* Coach (next-best-action) */
.mg-coach {
  display: flex; justify-content: space-between; align-items: center; gap: 16px; flex-wrap: wrap;
  border: 1px solid; border-radius: 14px; padding: 14px 18px;
}
.mg-coach-txt { font-size: 0.9rem; line-height: 1.5; color: #374151; flex: 1; min-width: 220px; }
.mg-coach-txt strong { color: #111827; font-weight: 500; }
.mg-coach-btn { flex-shrink: 0; }
.mg-coach-info { background: #f0f6ff; border-color: #dbe7fb; }
.mg-coach-warn { background: #fff7ed; border-color: #fed7aa; }
.mg-coach-good { background: #f0fdf4; border-color: #bbf7d0; }

/* Metric cards (derived from records — no traffic analytics) */
.mg-metric-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 16px; }
.mg-metric { gap: 6px; }

/* Recent activity */
.mg-act { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; }
.mg-act-item {
  display: flex; align-items: center; gap: 10px; padding: 10px 0;
  border-bottom: 1px solid #f3f4f6; cursor: pointer;
}
.mg-act-item:last-child { border-bottom: 0; }
.mg-act-dot { width: 7px; height: 7px; border-radius: 50%; background: #10b981; flex-shrink: 0; }
.mg-act-txt { font-size: 0.86rem; color: #374151; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.mg-act-txt strong { color: #111827; font-weight: 500; }
.mg-act-item:hover .mg-act-txt { color: #111827; }
.mg-act-time { font-size: 0.74rem; color: #9ca3af; flex-shrink: 0; }
