/* ===== assets/utms.css =====
   Módulo Gerador de UTMs, portado do arquivo standalone (utms.html) sem
   mudança de UI/UX. Changes vs. the legacy <style> block, all mechanical:

   1) `:root{...}` (palette) and the legacy `body{...}` reset are scoped to
      `.utm-app` instead of the document root/body element — marketing.css
      and shell.css already define their own `:root`/`body` rules with
      different variable names, so keeping these unscoped would silently
      repaint the whole shell the moment this stylesheet loaded, and would
      also make this module's theme toggle (`data-theme` attribute) affect
      the rest of the shell. Same reasoning `:root[data-theme="dark"]` /
      `:root[data-theme="light"]` become `.utm-app[data-theme="dark"]` /
      `.utm-app[data-theme="light"]` — no existing use of `data-theme` on
      `<html>`/`<body>` was found anywhere in auth.js/shell.js/shell.css, but
      scoping to the module wrapper is the safer choice regardless.
   2) `*{box-sizing:border-box}` and `html,body{margin:0;padding:0}` were
      dropped entirely: marketing.css already applies
      `* { box-sizing: border-box; }` globally and shell.css already zeroes
      out `body{margin:0}`.
   3) the bare `main` selector is scoped as `.utm-main` (class added to the
      <main> element in the rendered markup) instead of a global element
      selector, and `header.page-head` / `footer.site-foot` keep their
      element qualifiers but with the class renamed (`.utm-page-head` /
      `.utm-site-foot`) — same reasoning as (1), a bare `main`/`footer`
      selector would leak outside this module.
   4) the `@media (prefers-reduced-motion: reduce) { * {...} } ` rule is
      scoped to `.utm-app *` instead of every element on the page.
   5) EVERY class selector from the legacy file is prefixed with `utm-`
      (`.field` → `.utm-field`, `.card` → `.utm-card`, `.btn` → `.utm-btn`,
      `.chip` → `.utm-chip`, `.toast` → `.utm-toast`, etc., no exceptions) —
      confirmed via grep against marketing.css/shell.css/midia-paga.css that
      several of these generic names (`.field`, `.card`, `.btn`, `.chip`,
      `.toast`, `.actions`, `.hint`, `.lede`, `.display`, `.mono`, `.active`,
      `.empty`) do collide with rules already defined there.
   6) `.sync-pill*` (and its `.shared`/`.local`/`.warn` variants) is removed
      entirely — the shared-vs-local history distinction no longer exists
      now that history lives in Supabase for everyone (see utms.js). The
      `.link-clear.warn` rule is kept (still used by "limpar tudo").
   IDs are not prefixed (already unique per-document by construction) except
   `#toast` → `#utmToast`: `id="toast"` already exists in midia-paga.js's
   rendered markup, and since shell views stay in the DOM (just
   display:none) once mounted, both would collide.
*/

.utm-app {
  color-scheme: light;
  --masthead-bg: #003315;
  --masthead-fg: #f5eddd;
  --masthead-line: #8A81FE;

  --accent: #8A81FE;
  --accent-ink: #1c1740;
  --danger: #a8462d;
  --success: #2f6b45;

  /* fundo principal na mesma cor areia do cabeçalho (--topbar-bg, igual
     Planejamento/Orçamento); --surface continua branco pros cards, pra manter
     contraste — --surface-2 fica independente pra não mexer em campo/
     histórico/etc. */
  --bg: #f2ecdd;
  --surface: #ffffff;
  --surface-2: #f0e6d2;
  --text: #000000;
  --text-muted: #5b6b5f;
  --border: rgba(0, 51, 21, 0.14);
  --border-strong: rgba(0, 51, 21, 0.28);
  --shadow: 0 1px 2px rgba(0, 51, 21, 0.06), 0 8px 24px rgba(0, 51, 21, 0.07);
  --code-bg: #ffffff;

  --topbar-bg: #f2ecdd;
  --topbar-border: #E8E0D6;
  --header-muted: #6B6259;
  --header-title: #1c361d;
}
@media (prefers-color-scheme: dark) {
  .utm-app {
    color-scheme: dark;
    --bg: #05170c;
    --surface: #0a2415;
    --surface-2: #0e2f1b;
    --text: #f5eddd;
    --text-muted: #a9c2af;
    --border: rgba(245, 237, 221, 0.14);
    --border-strong: rgba(245, 237, 221, 0.26);
    --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
    --code-bg: #08200f;
    --success: #7fcf9c;
    --danger: #e08063;
    --topbar-bg: #0e2f1b;
    --topbar-border: rgba(245, 237, 221, 0.14);
    --header-muted: #a9c2af;
    --header-title: #f5eddd;
  }
}
.utm-app[data-theme="dark"] {
  color-scheme: dark;
  --bg: #05170c;
  --surface: #0a2415;
  --surface-2: #0e2f1b;
  --text: #f5eddd;
  --text-muted: #a9c2af;
  --border: rgba(245, 237, 221, 0.14);
  --border-strong: rgba(245, 237, 221, 0.26);
  --shadow: 0 1px 2px rgba(0, 0, 0, 0.3), 0 8px 28px rgba(0, 0, 0, 0.35);
  --code-bg: #08200f;
  --success: #7fcf9c;
  --danger: #e08063;
  --topbar-bg: #0e2f1b;
  --topbar-border: rgba(245, 237, 221, 0.14);
  --header-muted: #a9c2af;
  --header-title: #f5eddd;
}
.utm-app[data-theme="light"] {
  color-scheme: light;
  --bg: #f2ecdd;
  --surface: #ffffff;
  --surface-2: #f0e6d2;
  --text: #000000;
  --text-muted: #5b6b5f;
  --border: rgba(0, 51, 21, 0.14);
  --border-strong: rgba(0, 51, 21, 0.28);
  --shadow: 0 1px 2px rgba(0, 51, 21, 0.06), 0 8px 24px rgba(0, 51, 21, 0.07);
  --code-bg: #ffffff;
  --success: #2f6b45;
  --danger: #a8462d;
  --topbar-bg: #f2ecdd;
  --topbar-border: #E8E0D6;
  --header-muted: #6B6259;
  --header-title: #1c361d;
}

.utm-app {
  background: var(--bg);
  color: var(--text);
  font-family: ui-sans-serif, "Inter", "Helvetica Neue", Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  min-height: 100%;
  overflow-x: hidden;
}
.utm-display {
  font-family: 'Fraunces', serif;
  font-weight: 600;
  text-wrap: balance;
}
.utm-mono {
  font-family: ui-monospace, "SF Mono", "Cascadia Code", Menlo, Consolas, monospace;
  font-variant-numeric: tabular-nums;
}

/* ---------- topbar: brand block (título) + theme toggle ----------
   Cor/tipografia/dimensões seguem exatamente o cabeçalho de Planejamento e
   Orçamento (.header/.header-title-group/.eyebrow/h1 em
   marketing.css) — --topbar-bg/--topbar-border/--header-muted/--header-title
   são variáveis dedicadas (não reaproveitam --surface-2/--text-muted/--text)
   assim campo/histórico/etc. do restante da ferramenta não mudam. */
.utm-topbar {
  background: var(--topbar-bg);
  border-bottom: 2px solid var(--topbar-border);
  padding: 28px 24px 24px;
}
.utm-topbar-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
}
.utm-brand-block {
  display: flex;
  align-items: center;
  gap: 14px;
}
.utm-eyebrow {
  font-size: 12px;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--header-muted);
  margin: 0 0 6px;
  font-weight: 600;
}
.utm-theme-toggle {
  appearance: none;
  background: var(--surface);
  border: 1px solid var(--border-strong);
  color: var(--text);
  width: 36px;
  height: 36px;
  border-radius: 999px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}
.utm-theme-toggle:hover { background: var(--surface-2); }
.utm-theme-toggle svg { width: 16px; height: 16px; }

.utm-main {
  max-width: 1040px;
  margin: 0;
  padding: 36px 24px 80px;
}

h1.utm-display {
  font-size: var(--fs-page-title);
  margin: 0;
  text-transform: lowercase;
  color: var(--header-title);
}
.utm-lede {
  margin: 6px 0 0;
  color: var(--text-muted);
  font-size: 13.5px;
  max-width: 60ch;
  line-height: 1.5;
}

.utm-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  gap: 14px;
}
@media (min-width: 880px) {
  .utm-layout { grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); align-items: start; }
  .utm-preview-col { position: sticky; top: 24px; }
}
.utm-history-card { grid-column: 1 / -1; }

.utm-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 16px;
}
.utm-card + .utm-card { margin-top: 12px; }

.utm-card h2 {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  margin: 0 0 12px;
  font-weight: 600;
}

.utm-field { margin-bottom: 8px; }
.utm-field:last-child { margin-bottom: 0; }
.utm-field label {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  font-size: 0.82rem;
  font-weight: 600;
  margin-bottom: 4px;
}
.utm-field label .utm-opt {
  font-weight: 400;
  font-size: 0.76rem;
  color: var(--text-muted);
  text-transform: none;
  letter-spacing: 0;
}
.utm-field input[type="text"], .utm-field input[type="url"] {
  width: 100%;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 6px 9px;
  font-size: 0.82rem;
  color: var(--text);
  font-family: inherit;
}
.utm-field input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 30%, transparent);
}
.utm-field .utm-hint {
  margin-top: 3px;
  font-size: 0.76rem;
  color: var(--text-muted);
}
.utm-field .utm-hint.utm-err { color: var(--danger); }

.utm-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 8px;
}
.utm-chip {
  appearance: none;
  cursor: pointer;
  background: var(--surface);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 0.72rem;
  font-family: inherit;
  line-height: 1.3;
}
.utm-chip:hover { border-color: var(--border-strong); }
.utm-chip.utm-active {
  background: color-mix(in srgb, var(--accent) 22%, var(--surface));
  border-color: var(--accent);
  font-weight: 600;
}
.utm-campaign-note {
  margin-top: 8px;
  font-size: 0.78rem;
  color: var(--text-muted);
  min-height: 1.1em;
}

.utm-opts-toggle {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  margin-top: 8px;
  font-size: 0.76rem;
  text-decoration: underline;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
  display: block;
}
.utm-opts-toggle:hover { color: var(--text); }

.utm-options-editor {
  margin-top: 10px;
  padding: 10px;
  border: 1px dashed var(--border-strong);
  border-radius: 10px;
  background: var(--surface);
}
.utm-opts-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.utm-opt-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 999px;
  padding: 4px 4px 4px 12px;
  font-size: 0.78rem;
}
.utm-opt-chip button {
  appearance: none;
  border: none;
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  padding: 2px 6px;
  font-family: inherit;
}
.utm-opt-chip button:hover { color: var(--danger); }
.utm-opts-empty {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-style: italic;
  margin: 0 0 12px;
}
.utm-opts-add { display: flex; gap: 8px; margin-bottom: 10px; }
.utm-opts-add input {
  flex: 1;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 9px;
  padding: 8px 11px;
  font-size: 0.85rem;
  color: var(--text);
  font-family: inherit;
}
.utm-btn-sm { padding: 8px 13px; font-size: var(--fs-btn-sm); flex: 0 0 auto; }
.utm-opts-reset {
  appearance: none;
  background: none;
  border: none;
  padding: 0;
  font-size: 0.76rem;
  text-decoration: underline;
  color: var(--text-muted);
  cursor: pointer;
  font-family: inherit;
}
.utm-opts-reset:hover { color: var(--danger); }

.utm-opts-rows {
  display: grid;
  gap: 8px;
  margin-bottom: 10px;
}
.utm-opts-row {
  position: relative;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 10px 34px 10px 10px;
  border: 1px solid var(--border);
  border-radius: 9px;
  background: var(--surface);
}
.utm-opts-row input {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 6px 8px;
  font-size: 0.78rem;
  color: var(--text);
  font-family: inherit;
  width: 100%;
}
.utm-opts-row input.utm-opts-row-label { font-weight: 600; }
.utm-opts-row-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 24px;
  height: 24px;
  border-radius: 7px;
  border: 1px solid var(--border);
  background: var(--surface-2);
  color: var(--text-muted);
  cursor: pointer;
  font-size: 0.95rem;
  line-height: 1;
  font-family: inherit;
}
.utm-opts-row-remove:hover { color: var(--danger); border-color: var(--danger); }

/* ---------- preview ---------- */
.utm-url-box {
  background: var(--code-bg);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 14px 16px;
  overflow-x: auto;
  font-size: 0.86rem;
  line-height: 1.6;
  word-break: break-all;
  white-space: pre-wrap;
}
.utm-url-box .utm-base { color: var(--text); }
.utm-url-box .utm-key { color: var(--text-muted); }
.utm-url-box .utm-val { color: color-mix(in srgb, var(--accent) 78%, var(--text)); font-weight: 600; }
.utm-url-box .utm-amp { color: var(--text-muted); }
.utm-url-box.utm-empty { color: var(--text-muted); font-style: normal; }

.utm-param-list {
  list-style: none;
  margin: 14px 0 0;
  padding: 0;
  display: grid;
  gap: 6px;
}
.utm-param-list li {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
}
.utm-param-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--border-strong);
  flex: 0 0 auto;
}
.utm-param-list li.utm-filled .utm-param-dot { background: var(--accent); }
.utm-param-list li .utm-pkey { color: var(--text-muted); min-width: 96px; }
.utm-param-list li.utm-filled .utm-pval { font-weight: 600; }
.utm-param-list li:not(.utm-filled) .utm-pval { color: var(--text-muted); font-style: italic; }

.utm-actions {
  display: flex;
  gap: 10px;
  margin-top: 18px;
  flex-wrap: wrap;
}
button.utm-btn {
  appearance: none;
  border: none;
  border-radius: 9px;
  padding: 10px 16px;
  font-size: var(--fs-btn);
  font-weight: var(--fw-semibold);
  font-family: inherit;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 8px;
}
button.utm-btn-primary {
  background: #e4aad7;
  color: var(--accent-ink);
}
button.utm-btn-primary:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}
button.utm-btn-secondary {
  background: transparent;
  border: 1px solid var(--border-strong);
  color: var(--text);
}
button.utm-btn-secondary:hover { background: var(--surface-2); }
button.utm-btn:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.utm-toast {
  position: fixed;
  bottom: 22px;
  left: 50%;
  transform: translateX(-50%) translateY(10px);
  background: var(--text);
  color: var(--bg);
  padding: 10px 18px;
  border-radius: 999px;
  font-size: 0.85rem;
  font-weight: 600;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.18s ease, transform 0.18s ease;
  box-shadow: var(--shadow);
  z-index: 20;
}
.utm-toast.utm-show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- history ---------- */
.utm-history-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-bottom: 14px;
}
.utm-history-head h2 { margin: 0; }
.utm-history-head-title { display: flex; align-items: center; gap: 10px; }
.utm-history-head-actions { display: flex; gap: 14px; flex-wrap: wrap; }
.utm-link-clear {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 0.76rem;
  text-decoration: underline;
  cursor: pointer;
  font-family: inherit;
  padding: 0;
}
.utm-link-clear:hover { color: var(--danger); }
.utm-link-clear.utm-warn:hover { color: var(--danger); }
.utm-backup-note {
  margin: -6px 0 14px;
  font-size: 0.76rem;
  color: var(--text-muted);
}

.utm-history-empty {
  color: var(--text-muted);
  font-size: 0.86rem;
  padding: 10px 0 2px;
}
.utm-history-list { display: grid; gap: 4px; }
.utm-history-item {
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 5px 8px;
  background: var(--surface);
  display: flex;
  align-items: center;
  gap: 6px;
}
.utm-history-item .utm-icon-btn { margin-top: 0; }
.utm-history-item .utm-hi-main { min-width: 0; flex: 1; }
.utm-history-item .utm-hi-head {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin: 0;
}
.utm-history-item .utm-hi-campaign {
  font-weight: 700;
  font-size: 0.74rem;
  flex: 0 0 auto;
}
.utm-history-item .utm-hi-meta {
  font-size: 0.64rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.utm-history-item .utm-hi-url {
  font-size: 0.68rem;
  color: var(--text-muted);
  white-space: normal;
  word-break: break-all;
  overflow-wrap: anywhere;
  line-height: 1.3;
  margin: 1px 0 0;
}
.utm-icon-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  width: 24px; height: 24px;
  border-radius: 6px;
  display: grid;
  place-items: center;
  cursor: pointer;
  flex: 0 0 auto;
}
.utm-icon-btn:hover { color: var(--text); border-color: var(--border-strong); }
.utm-icon-btn svg { width: 12px; height: 12px; }

.utm-site-foot {
  max-width: 1040px;
  margin: 40px 0 0;
  padding: 0 24px;
  color: var(--text-muted);
  font-size: 0.78rem;
  display: flex;
  justify-content: space-between;
  gap: 12px;
}

@media (prefers-reduced-motion: reduce) {
  .utm-app * { transition: none !important; }
}
