/* EventManager supplement to shared.css — only the few helpers shared.css
   doesn't already provide. Uses the same design tokens. */

/* ── Uniform control sizing ─────────────────────────────────────────────
   Every input, select and button is an EXACT 30px tall (fixed height, not
   padding-derived) with the same --radius-sm rounding, so they line up
   pixel-for-pixel. Multi-line textareas are the only exception. */
:root { --control-h: 36px; }   /* comfortable for native selects (Safari clips them below ~32px) */

/* Every single-line input (any type except checkbox/radio/file/range),
   every select, and every button — identical 30px height + --radius-sm.
   The broad input selector matches inputs with NO type attribute too, e.g.
   the bare `<input class="search-box">` search boxes. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
select, .field select, .toolbar select,
.btn, .btn--sm {
  box-sizing: border-box;
  height: var(--control-h);
  min-height: var(--control-h);
  border-radius: var(--radius-sm);
  font-size: 14px;
  /* centre the single line within the control (height minus 1px borders) so
     select/input text isn't clipped at this compact height */
  line-height: calc(var(--control-h) - 2px);
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
select { padding: 0 10px; }
select, .field select, .toolbar select { padding-right: 30px; }
/* Selects render their text differently from inputs — a fixed line-height clips
   it at this compact height, so let the browser centre it natively. */
select, .field select, .toolbar select { line-height: normal; }

.btn, .btn--sm { padding: 0 14px; }
/* .icon-btn keeps shared.css's 32×32 GAL sizing/colours — not the 36px control
   height — so the kebab matches GAL exactly. */

/* Checkboxes/radios must stay native-small — shared.css's `.field input`
   otherwise stretches them to full-width boxes. */
input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: auto; appearance: auto;
  width: 16px; height: 16px; min-height: 0; margin: 0 8px 0 0;
  padding: 0; border-radius: 0; box-shadow: none; vertical-align: -2px; flex: none;
}
.cb-opt { display: flex; align-items: center; font-weight: 400; margin: 6px 0; color: var(--text); }
.ctl { display: block; }   /* field control wrapper (public form + template placeholders) */
/* A touch more space between grouped buttons. */
.btn-group { gap: 10px; }

/* Clickable placeholder pills (insert token at cursor) */
.ph-pill { display: inline-block; padding: 3px 9px; margin: 0 6px 6px 0; border-radius: 999px;
  background: var(--brand-soft); color: var(--brand); font-size: 12px; font-family: ui-monospace, Menlo, monospace;
  cursor: pointer; border: 1px solid transparent; user-select: none; }
.ph-pill:hover { border-color: var(--brand-ring); }

/* Rich-text editor */
input[type="color"] { -webkit-appearance: auto; appearance: auto; width: 40px; height: var(--control-h); min-height: 0; padding: 2px; border: 1px solid var(--border-soft); border-radius: var(--radius-sm); cursor: pointer; }
.rte-toolbar { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; margin-bottom: 8px; }
.rte-tb-btn { height: var(--control-h); min-height: 0; padding: 0 11px; border: 1px solid var(--border-soft); background: var(--surface);
  border-radius: var(--radius-sm); cursor: pointer; font-size: 14px; color: var(--text-mid); }
.rte-tb-btn:hover { background: var(--surface-hover); color: var(--text); }
.rte { min-height: 220px; border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 10px 12px;
  background: var(--surface); color: var(--text); overflow: auto; font-size: 14px; line-height: 1.5; }
.rte:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-ring); }
.rte p { margin: 0 0 10px; }
.rte:empty::before { content: attr(data-placeholder); color: var(--text-light); }

/* Email-style preview box */
.email-box { border: 1px solid var(--border-soft); border-radius: var(--radius); overflow: hidden; box-shadow: var(--shadow-sm); background: #fff; }
.email-head { background: var(--header-bg); padding: 12px 16px; border-bottom: 1px solid var(--border-soft); font-size: 13px; color: var(--text-mid); }
.email-head > div { padding: 2px 0; }
.email-head .email-label { display: inline-block; width: 62px; color: var(--text-light); }
/* Height is set per-instance by JS (onload, from the iframe's own content
   height) so the PAGE scrolls, not a fixed-size box inside it. min-height is
   just a sane placeholder before that first measurement lands. */
.email-body { width: 100%; min-height: 120px; border: 0; background: #fff; display: block; }
/* Single-choice / Yes-No: radio circles laid out next to each other. */
.opts-inline { display: flex; flex-wrap: wrap; gap: 6px 18px; align-items: center; }
.opts-inline .cb-opt { margin: 0; }
/* Form question labels in grey, not black. */
.field > label, .prev-field .pf-label { color: var(--text-mid); }

/* Consistent border/background/focus for ALL text inputs, selects and textareas
   (including bare `.search-box` inputs) — kills the native inset "shadow" border
   so every field matches the .field input look. Buttons are excluded. */
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]),
select, textarea, .field textarea {
  -webkit-appearance: none; appearance: none;
  border: 1px solid var(--border);
  background: var(--surface);
  color: var(--text);
  outline: none;
  box-shadow: none;
}
input:not([type="checkbox"]):not([type="radio"]):not([type="file"]):not([type="range"]):focus,
select:focus, textarea:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-ring);
}

/* Textareas keep a larger box but the same rounding. */
.field textarea, textarea { box-sizing: border-box; height: auto; border-radius: var(--radius-sm); font-size: 14px; min-height: 76px; padding: 8px 10px; }
.modal-close { height: auto; min-height: 0; }

.toast {
  position: fixed; left: 50%; bottom: 24px; transform: translateX(-50%) translateY(20px);
  background: var(--text); color: #fff; padding: 10px 18px; border-radius: var(--radius-sm);
  box-shadow: var(--shadow-lg); font-size: 14px; opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 9999; max-width: 90vw;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }
.toast-error { background: var(--red); }
.toast-ok { background: var(--green); }

.stat-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 16px; margin-bottom: 24px; }
.stat { background: var(--surface); border: 1px solid var(--border-soft); border-radius: var(--radius); padding: 18px 20px; box-shadow: var(--shadow-sm); }
.stat-num { font-size: 28px; font-weight: 700; color: var(--text); line-height: 1.1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }

.login-wrap { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 24px; }
.login-card { width: 100%; max-width: 380px; }
.login-logo { display: flex; align-items: center; gap: 10px; justify-content: center; margin-bottom: 18px; }
.login-logo img { height: 40px; }
.login-logo span { font-size: 20px; font-weight: 700; color: var(--text); }

.pill { display: inline-block; padding: 2px 9px; border-radius: 999px; font-size: 12px; font-weight: 600; }
.pill-green { background: var(--brand-soft); color: var(--green); }
.pill-amber { background: #fff7ed; color: var(--amber); }
.pill-red { background: #fef2f2; color: var(--red); }
.pill-gray { background: var(--surface-subtle); color: var(--text-muted); }
.pill-blue { background: var(--brand-soft); color: var(--brand); }
.pill-purple { background: #f3e8ff; color: #7c3aed; }

/* Activity log */
.audit-tbl td { vertical-align: middle; }
.audit-when { white-space: nowrap; font-size: 13px; }
.audit-who { display: inline-flex; align-items: center; gap: 8px; }
.audit-av { width: 26px; height: 26px; font-size: 11px; flex: none; }
.meta-chip { display: inline-flex; align-items: center; gap: 5px; padding: 2px 8px; margin: 2px 4px 2px 0;
  border-radius: var(--radius-sm); background: var(--surface-subtle); font-size: 12px; color: var(--text-mid); }
.meta-chip .meta-k { color: var(--text-light); font-weight: 600; }

.public-wrap { max-width: 640px; margin: 0 auto; padding: 40px 20px; }
.rich p { margin: 0 0 10px; }

/* Two-pane contacts layout: groups portal (left) + table (right) */
.split { display: flex; gap: 20px; align-items: flex-start; }
.split-side { width: 250px; flex: none; }
.split-main { flex: 1; min-width: 0; }
@media (max-width: 760px) { .split { flex-direction: column; } .split-side { width: 100%; } }

.group-list { display: flex; flex-direction: column; gap: 2px; }
.group-item {
  display: flex; align-items: center; gap: 8px; width: 100%; text-align: left;
  padding: 8px 10px; border: 0; background: none; border-radius: var(--radius-sm);
  color: var(--text); font-size: 14px; cursor: pointer;
}
.group-item:hover { background: var(--surface-hover); }
.group-item.active { background: var(--brand-soft); color: var(--brand); font-weight: 600; }
.group-item .group-count { margin-left: auto; font-size: 12px; color: var(--text-muted); }
.group-item.active .group-count { color: var(--brand); }
.group-item .group-del { margin-left: 6px; opacity: 0; }
.group-item:hover .group-del { opacity: .7; }
.group-item.drop-hover { background: var(--brand-soft); outline: 2px dashed var(--brand); outline-offset: -2px; }
tr[draggable="true"] { cursor: grab; }
tr[draggable="true"]:active { cursor: grabbing; }

/* Form builder */
.fb-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--brand); color: #fff; font-size: 12px; font-weight: 700; flex: none; }
.fb-handle { cursor: grab; color: var(--text-light); font-size: 18px; line-height: 1; user-select: none; padding: 0 2px; }
.fb-handle:active { cursor: grabbing; }
.fb-field { transition: box-shadow .12s, opacity .12s; }
.fb-field.drag-over { outline: 2px dashed var(--brand); outline-offset: 2px; }
.fb-field.dragging { opacity: .4; }
/* Rendered form preview (used in the builder's preview modal) — mirrors the
   real .field spacing: label above input, consistent gap between fields. */
.prev-field { margin-bottom: 16px; }
.prev-field:last-of-type { margin-bottom: 0; }
.prev-field .pf-label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--text-mid); }
.prev-field label:not(.pf-label) { display: block; font-weight: 400; margin: 3px 0; }  /* checkbox / consent options */
.req-star { color: var(--red); }
#preview input, #preview select, #preview textarea { width: 100%; }
.fb-badge { display:inline-flex; align-items:center; gap:6px; padding:2px 10px; border-radius:999px;
  background: var(--brand-soft); color: var(--brand); font-size: 12px; font-weight: 600; }

/* Wizard / step navigation */
.wizard { display: flex; gap: 8px; flex-wrap: wrap; margin: 4px 0 22px; }
.wizard-step { display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px; border: 1px solid var(--border-soft);
  border-radius: 999px; background: var(--surface); cursor: pointer; font-size: 14px; color: var(--text-mid); }
.wizard-step:hover { border-color: var(--border); }
.wizard-step .wz-num { display: inline-flex; align-items: center; justify-content: center; width: 22px; height: 22px;
  border-radius: 50%; background: var(--surface-subtle); color: var(--text-muted); font-size: 12px; font-weight: 700; }
.wizard-step.active { border-color: var(--brand); color: var(--brand); background: var(--brand-soft); font-weight: 600; }
.wizard-step.active .wz-num { background: var(--brand); color: #fff; }
.wizard-step .wz-count { font-size: 12px; color: var(--text-muted); }
.gear-btn { border: 1px solid var(--border-soft); background: var(--surface); border-radius: var(--radius-sm);
  width: var(--control-h); height: var(--control-h); cursor: pointer; font-size: 16px; color: var(--text-mid); }
.gear-btn:hover { background: var(--surface-hover); }

/* Viewers (read-only role) never see editor controls. Pages that support this
   add class "role-viewer" to <body> and mark editor buttons/links with data-edit. */
body.role-viewer [data-edit] { display: none !important; }

/* Test-mode affordances. Public pages show .test-banner; admin tables tag rows
   with .pill-purple. */
.test-banner { background: #f5edff; border: 1px solid #7c3aed; color: #5b21b6;
  padding: 10px 14px; border-radius: var(--radius-sm); font-weight: 600; margin-bottom: 16px; }
.pill-purple { background: #ede9fe; color: #5b21b6; }
/* Dark-mode overrides for the light-pastel pills / banner. Applied for both the
   OS preference AND an explicit [data-theme="dark"] (the manual toggle). */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) .test-banner { background: #2b1a4a; border-color: #7c3aed; color: #d6bcfa; }
  :root:not([data-theme="light"]) .pill-purple { background: #3b2a5e; color: #d6bcfa; }
  :root:not([data-theme="light"]) .pill-amber  { background: rgba(245,158,11,.16); color: #fbbf24; }
  :root:not([data-theme="light"]) .pill-red    { background: rgba(239,68,68,.16);  color: #fca5a5; }
  :root:not([data-theme="light"]) .row-menu button.danger:hover { background: rgba(239,68,68,.16); }
}
[data-theme="dark"] .test-banner { background: #2b1a4a; border-color: #7c3aed; color: #d6bcfa; }
[data-theme="dark"] .pill-purple { background: #3b2a5e; color: #d6bcfa; }
[data-theme="dark"] .pill-amber  { background: rgba(245,158,11,.16); color: #fbbf24; }
[data-theme="dark"] .pill-red    { background: rgba(239,68,68,.16);  color: #fca5a5; }
[data-theme="dark"] .row-menu button.danger:hover { background: rgba(239,68,68,.16); }

/* Shared row-actions ⋮ menu (EM.menu) — matched to GAL's kebab dropdown. */
.row-menu { position: absolute; z-index: 1000; min-width: 200px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 10px; box-shadow: 0 8px 24px rgba(0,0,0,.18); padding: 4px; }
.row-menu button { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left;
  background: transparent; border: none; padding: 9px 12px; border-radius: 7px; cursor: pointer; font-size: 14px; color: var(--text); }
.row-menu button:hover { background: var(--hover); }
.row-menu button.danger { color: #b91c1c; }
.row-menu button.danger:hover { background: #fee2e2; }
.row-menu svg { flex-shrink: 0; opacity: .85; }
.row-menu .menu-sep { height: 1px; background: var(--line); margin: 4px 6px; }
.row-menu .menu-header { padding: 8px 12px 6px; }
.row-menu .menu-header .mh-title { font-weight: 600; color: var(--text); font-size: 14px; line-height: 1.3; }

/* Clickable/sortable table headers. .sort-arrow is filled in with ▲/▼ by JS
   once a column becomes the active sort key. */
.tbl th.sortable { cursor: pointer; user-select: none; white-space: nowrap; }
.tbl th.sortable:hover { color: var(--text); }
.tbl th.sortable .sort-arrow { display: inline-block; width: 12px; margin-left: 2px; font-size: 10px; color: var(--brand); }
.row-menu .menu-header .mh-sub { font-size: 12px; color: var(--text-muted); margin-top: 1px; }
