/* Overrides for real-page rendering. The artboard CSS was authored for a
   fixed-canvas designer surface (parent forces height:100%). We selectively
   relax that per layout family. */

html, body {
  margin: 0;
  background: var(--bg);
}
body {
  min-height: 100vh;
}

/* ── Landing pages ─────────────────────────────────────────────── */
.jb-artboard.land {
  height: auto !important;
  min-height: 100vh;
  overflow-y: visible !important;
  isolation: isolate;
}

/* ── Dashboard ─────────────────────────────────────────────────── */
.jb-artboard.dash {
  height: 100vh !important;
  overflow: hidden !important;
  isolation: isolate;
}

/* ── Auth shell ────────────────────────────────────────────────── */
.jb-artboard:not(.land):not(.dash) {
  isolation: isolate;
}

/* ── Dropdown items ────────────────────────────────────────────── */
.dropdown-item {
  display: flex;
  align-items: center;
  gap: 11px;
  width: 100%;
  padding: 9px 12px;
  background: transparent;
  border: none;
  cursor: pointer;
  text-align: left;
  color: var(--text);
  font-family: inherit;
  text-decoration: none;
  transition: background 140ms;
}
.dropdown-item:hover {
  background: var(--hover-bg);
}

/* Theme segmented control inside the user popover. Selected state is driven by
   the data-selected attribute that site.js sets when setTheme runs; an initial
   value is applied lazily on first popover open via JS2MailApi.refreshTheme(). */
[data-theme-option][data-selected="true"] {
  background: var(--surface-1) !important;
  color: var(--text) !important;
  box-shadow: 0 1px 2px rgba(0,0,0,0.18);
}
[data-theme-option]:hover { color: var(--text); }

/* ── Quick Send rich-text editor (Faz 7c) ──────────────────────────
   Toolbar bar + contenteditable body sharing one bordered shell so the
   whole thing reads as one input. We drive formatting with the
   deprecated-but-universal document.execCommand — works in every browser
   today, no bundler/library needed, and the output is plain HTML the
   mail providers happily relay. */
.qs-editor-wrap {
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--surface-2);
  overflow: hidden;
}
.qs-editor-toolbar {
  display: flex; align-items: center; gap: 2px;
  padding: 4px 6px;
  border-bottom: 1px solid var(--border-soft);
  background: var(--surface-2);
}
.qs-editor-toolbar button {
  appearance: none; background: transparent; border: none;
  width: 26px; height: 26px;
  display: grid; place-items: center;
  border-radius: 5px;
  color: var(--text-2);
  cursor: pointer;
  font-family: inherit; font-size: 12.5px;
  transition: background 140ms, color 140ms;
}
.qs-editor-toolbar button:hover { background: var(--hover-bg); color: var(--text); }
.qs-editor-toolbar button[data-active="true"] {
  background: var(--accent-soft);
  color: var(--accent);
}
.qs-editor-toolbar .qs-sep {
  width: 1px; height: 14px; background: var(--border);
  margin: 0 4px;
}
.qs-editor {
  min-height: 140px;
  padding: 10px 12px;
  font-family: var(--font-sans);
  font-size: 13px; line-height: 1.55;
  color: var(--text);
  outline: none;
  background: var(--surface-2);
  overflow-y: auto;
  max-height: 320px;
}
.qs-editor:focus { background: color-mix(in oklab, var(--surface-2), var(--text) 2%); }
/* Placeholder via CSS so it's purely visual — the editor stays a real
   contenteditable, no value-binding plumbing needed. */
.qs-editor:empty::before {
  content: attr(data-placeholder);
  color: var(--text-3);
  white-space: pre-wrap;
  pointer-events: none;
}
.qs-editor a { color: var(--accent); text-decoration: underline; }
.qs-editor ul, .qs-editor ol { padding-left: 24px; margin: 6px 0; }
.qs-editor p { margin: 0 0 6px; }
/* Plain/HTML mode buttons need auto width — they contain text labels, not icons. */
.qs-editor-toolbar button[data-cmd="__plain"],
.qs-editor-toolbar button[data-cmd="__html"] {
  width: auto; padding: 0 8px; margin-left: 2px; font-size: 11px;
}
.qs-editor-toolbar button[data-cmd="__plain"] { margin-left: auto; }

/* Plain-text fallback — when the user clicks "Plain" we swap to a textarea
   look. Handled by JS adding .is-plain to the wrap. */
.qs-editor-wrap.is-plain .qs-editor-toolbar > button:not([data-cmd="__plain"]):not([data-cmd="__html"]) { display: none; }
.qs-editor-wrap.is-plain .qs-editor {
  font-family: var(--font-mono);
  font-size: 12.5px;
  white-space: pre-wrap;
}
.qs-editor-wrap.is-plain .qs-editor:empty::before { font-family: var(--font-mono); }

/* HTML source mode — only Plain button stays visible in the toolbar. */
.qs-editor-wrap.is-html .qs-editor-toolbar > button:not([data-cmd="__plain"]):not([data-cmd="__html"]) { display: none; }
.qs-editor-wrap.is-html .qs-editor-toolbar .qs-sep { display: none; }

/* ── Docs page section primitives (Faz 7d) ─────────────────────── */
/* TOC: active button gets accent-soft bg, set on click by site.js. */
[data-doc-target][data-active="true"] {
  background: var(--accent-soft) !important;
  color: var(--text) !important;
}
[data-doc-target]:hover { background: var(--hover-bg); color: var(--text); }

.qd-step { display: flex; gap: 18px; margin-bottom: 22px; }
.qd-num  {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--accent-soft); color: var(--accent);
  display: grid; place-items: center;
  font-size: 12.5px; font-weight: 600; flex: none;
}
.qd-body { flex: 1; min-width: 0; }
.qd-h    { font-size: 14px; font-weight: 600; margin-bottom: 8px; }
.qd-body p { font-size: 13px; color: var(--text-2); line-height: 1.6; margin: 0 0 12px; }
.qd-h2   { font-size: 13px; font-weight: 600; margin: 18px 0 10px; color: var(--text); }
.qd-list { font-size: 13px; color: var(--text-2); line-height: 1.7; padding-left: 20px; margin: 0 0 14px; }
.qd-list li { margin-bottom: 4px; }
.qd-link { color: var(--accent); text-decoration: none; }
.qd-link:hover { text-decoration: underline; }
.qd-body code, .qd-list code {
  font-family: var(--font-mono);
  font-size: 12px;
  background: var(--surface-2);
  padding: 1px 6px;
  border-radius: 4px;
  color: var(--accent);
}

/* ─────── Overview B variant (Faz 7e) ─────── */
/* Pipeline diagram — horizontal flow of nodes connected by animated send-lines.
   Replaces the simple stat-grid with a visual representation of how a send
   actually moves through the system (API → Queue → Worker → Provider → Inbox). */
.pipeline {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 0;
  margin-bottom: 18px;
  background: linear-gradient(180deg, var(--surface-1), color-mix(in oklab, var(--surface-1), var(--accent) 3%));
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  padding: 18px 14px;
  position: relative;
  overflow: hidden;
}
.pipeline-node {
  display: flex; flex-direction: column;
  align-items: center; gap: 8px;
  position: relative;
  z-index: 2;
}
.pipeline-node .pn-icon {
  width: 40px; height: 40px;
  border-radius: 10px;
  background: var(--surface-2);
  color: var(--accent);
  display: grid; place-items: center;
  border: 1px solid var(--border);
  transition: background 200ms, border-color 200ms;
}
.pipeline-node[data-active="true"] .pn-icon {
  background: var(--accent-soft);
  border-color: rgba(110,123,255,0.35);
  box-shadow: 0 0 0 4px rgba(110,123,255,0.08);
}
.pipeline-node .pn-label {
  font-size: 11px;
  color: var(--text-3);
  letter-spacing: 0.4px;
  text-transform: uppercase;
  font-weight: 500;
}
.pipeline-node .pn-value {
  font-family: var(--font-mono);
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}
.pipeline-node .pn-sub {
  font-size: 10.5px;
  color: var(--text-3);
  font-family: var(--font-mono);
  margin-top: -2px;
}
/* Connecting arrows between nodes. Light dashed line with a single animated
   pulse traveling along it — pulse only renders when the segment is active
   (data-active drives the @keyframes via animation-play-state). */
.pipeline-arrow {
  position: absolute;
  top: 38px;
  height: 2px;
  background: linear-gradient(90deg, transparent, var(--border-strong), transparent);
}
.pipeline-arrow::before {
  content: "";
  position: absolute;
  top: -2px; left: 0;
  width: 18%; height: 6px;
  border-radius: 99px;
  background: var(--accent);
  filter: blur(2px);
  opacity: 0;
  animation: pipePulse 2.4s cubic-bezier(.5,.1,.3,1) infinite;
}
.pipeline-arrow[data-active="true"]::before { opacity: 0.9; }
@keyframes pipePulse {
  0%   { transform: translateX(0);   opacity: 0; }
  10%  { opacity: 0.9; }
  85%  { opacity: 0.9; }
  100% { transform: translateX(550%); opacity: 0; }
}
.pipeline-arrow.is-error::before { background: var(--error); }
.pipeline-arrow.is-warn::before  { background: var(--warning); }

/* Terminal logs — monospace stream of recent sends. Mimics a real shell. */
.term {
  background: #0A0F1F;
  border: 1px solid var(--border);
  border-radius: var(--r-xl);
  overflow: hidden;
  font-family: var(--font-mono);
}
[data-theme="light"] .term { background: #0F172A; }
.term-head {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}
.term-head .term-dots {
  display: flex; gap: 6px;
}
.term-head .term-dots span {
  width: 9px; height: 9px; border-radius: 50%;
  background: rgba(255,255,255,0.12);
}
.term-title {
  font-size: 11.5px;
  color: rgba(255,255,255,0.5);
  margin-left: 4px;
}
.term-body {
  padding: 12px 14px;
  font-size: 12px;
  line-height: 1.65;
  color: #C7CCDB;
  max-height: 320px;
  overflow-y: auto;
}
.term-body .term-prompt { color: #6B7280; }
.term-body .term-cmd    { color: #C7CCDB; }
.term-body .term-row    { display: grid; grid-template-columns: 70px 70px 1fr 80px; gap: 12px; align-items: baseline; white-space: nowrap; }
.term-body .term-time   { color: rgba(255,255,255,0.4); }
.term-body .term-tag    { font-weight: 600; }
.term-body .term-tag.is-sent     { color: #4ADE80; }
.term-body .term-tag.is-failed   { color: #F87171; }
.term-body .term-tag.is-deferred { color: #FBBF24; }
.term-body .term-tag.is-queued   { color: #93C5FD; }
.term-body .term-to     { color: #E2E8F0; overflow: hidden; text-overflow: ellipsis; }
.term-body .term-meta   { color: rgba(255,255,255,0.45); text-align: right; }
.term-body .term-empty  { color: rgba(255,255,255,0.5); padding: 18px 0; text-align: center; }

/* ProvidersCompact — a denser take on the Provider health card for the
   2-column layout sitting next to TerminalLogs. */
.prov-compact { padding: 6px; }
.prov-compact .pc-row {
  display: grid;
  grid-template-columns: 22px 1fr auto;
  gap: 10px;
  align-items: center;
  padding: 8px 10px;
  border-radius: 8px;
  text-decoration: none;
  color: inherit;
  transition: background 140ms;
}
.prov-compact .pc-row:hover { background: var(--hover-bg); }
.prov-compact .pc-name { font-size: 12.5px; color: var(--text); }
.prov-compact .pc-sub  { font-size: 10.5px; color: var(--text-3); font-family: var(--font-mono); margin-top: 1px; }
.prov-compact .pc-empty {
  padding: 18px 14px; text-align: center;
  color: var(--text-3); font-size: 12px;
}

/* Logo asset swap. Two <img> tags ship side-by-side; CSS hides the wrong one for
   the active theme. !important defeats the existing inline `style="display:block"`
   on the dark variant so the light-theme hide rule actually wins. Manual user
   override survives because we drive off data-theme, not prefers-color-scheme. */
.js2-logo-light { display: none !important; }
[data-theme="light"] .js2-logo-dark  { display: none !important; }
[data-theme="light"] .js2-logo-light { display: block !important; }
a.side-item { text-decoration: none; }

/* ── Modal (HTML5 <dialog>) ────────────────────────────────────── */
dialog.js2-modal {
  padding: 0;
  background: var(--surface-1);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--elev-2);
  max-height: 88vh;
  max-width: calc(100vw - 64px);
  overflow: hidden;
  font-family: var(--font-sans);
}
dialog.js2-modal::backdrop {
  background: color-mix(in oklab, var(--bg), transparent 28%);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: js2ModalFade 0.16s ease-out;
}
dialog.js2-modal[open] {
  animation: js2ModalIn 0.20s cubic-bezier(0.2, 0.9, 0.3, 1.1);
  display: flex;
  flex-direction: column;
}
@keyframes js2ModalFade {
  from { opacity: 0 } to { opacity: 1 }
}
@keyframes js2ModalIn {
  from { opacity: 0; transform: translateY(8px) scale(.985) }
  to   { opacity: 1; transform: translateY(0)   scale(1) }
}

dialog.js2-modal .m-head {
  padding: 18px 22px 14px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: flex-start;
  gap: 14px;
  flex: none;
}
dialog.js2-modal .m-head-icon {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  display: grid;
  place-items: center;
  flex: none;
  background: rgba(110,123,255,0.14);
  color: var(--accent);
  border: 1px solid rgba(110,123,255,0.26);
}
dialog.js2-modal .m-head-icon.is-warn   { background: rgba(245,158,11,0.16);  color: var(--warning); border-color: rgba(245,158,11,0.35); }
dialog.js2-modal .m-head-icon.is-danger { background: rgba(239,68,68,0.16);   color: var(--error);   border-color: rgba(239,68,68,0.35); }
dialog.js2-modal .m-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text);
  line-height: 1.2;
}
dialog.js2-modal .m-sub {
  font-size: 12.5px;
  color: var(--text-3);
  margin-top: 4px;
  line-height: 1.45;
}
dialog.js2-modal .m-body {
  padding: 18px 22px;
  overflow: auto;
  flex: 1;
  min-height: 0;
}
dialog.js2-modal .m-foot {
  padding: 14px 22px;
  border-top: 1px solid var(--border);
  background: var(--surface-2);
  display: flex;
  align-items: center;
  gap: 10px;
  justify-content: flex-end;
  flex: none;
}

dialog.js2-modal .m-field {
  margin-bottom: 14px;
}
dialog.js2-modal .m-field-label {
  font-size: 12px;
  color: var(--text-2);
  margin-bottom: 6px;
  font-weight: 500;
}
dialog.js2-modal .m-field-hint {
  font-size: 11px;
  color: var(--text-3);
  margin-top: 5px;
}
dialog.js2-modal .m-input {
  width: 100%;
  padding: 0 12px;
  height: 36px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: 13px;
  font-family: var(--font-sans);
  outline: none;
  box-sizing: border-box;
  transition: border-color 140ms;
}
dialog.js2-modal .m-input.mono { font-family: var(--font-mono); }
dialog.js2-modal textarea.m-input {
  height: auto;
  padding: 12px;
  resize: vertical;
  line-height: 1.5;
}
dialog.js2-modal .m-input:focus { border-color: var(--accent); }

/* Multi-step: step 0 has no inline style (visible by default); steps 1..N
   are marked `style="display:none"` in the markup. JS toggles via inline
   display only — no global CSS hiding rule, otherwise an empty inline string
   would collapse back to display:none and the body would never appear. */

/* Stepper dots */
.m-stepper {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}
.m-step-dot {
  width: 22px;
  height: 22px;
  border-radius: 50%;
  display: grid;
  place-items: center;
  font-size: 11px;
  font-family: var(--font-mono);
  font-weight: 600;
  background: var(--surface-2);
  color: var(--text-3);
  border: 1px solid var(--border);
}
.m-step-dot.is-current { background: rgba(110,123,255,0.16); color: var(--accent); border-color: var(--accent); }
.m-step-dot.is-done    { background: var(--accent);          color: #fff;          border-color: var(--accent); }
.m-step-line { flex: 1; height: 1px; background: var(--border); }
.m-step-line.is-done { background: var(--accent); }
.m-step-label { font-size: 12px; color: var(--text-3); }
.m-step-label.is-active { color: var(--text); font-weight: 500; }
.m-step-label.is-done   { color: var(--text); }

/* Segmented radio */
.m-seg {
  display: inline-flex;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 3px;
  gap: 2px;
}
.m-seg-btn {
  padding: 6px 12px;
  border-radius: 6px;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--text-3);
  font-family: inherit;
  font-size: 12.5px;
  transition: background 140ms, color 140ms;
}
.m-seg-btn.is-active {
  background: var(--surface-3);
  color: var(--text);
  box-shadow: inset 0 0 0 1px var(--border-strong);
}

/* Provider tile chooser */
.m-prov-tile {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 8px;
  padding: 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
  transition: all 140ms;
}
.m-prov-tile:hover  { border-color: var(--border-strong); }
.m-prov-tile.is-active { background: var(--surface-3); border-color: var(--accent); }

/* Plan card */
.m-plan {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 10px;
  padding: 16px;
  position: relative;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  text-align: left;
  font-family: inherit;
  color: var(--text);
}
.m-plan.is-active { background: var(--surface-3); border-color: var(--accent); }
