/* Automações: lista, builder visual (gatilhos, nós, ramos, painel lateral), webhooks e URLs de entrada. */

.automations-table .trig-list { font-size: 12.5px; line-height: 1.4; }

/* ---------------------------------------------------------------- builder: barra e abas */
.ab { display: flex; flex-direction: column; gap: 0; margin: -20px -24px -32px; min-height: calc(100vh - var(--topbar)); }
.ab-bar { position: sticky; top: var(--topbar); z-index: 5; background: var(--material-bar); backdrop-filter: var(--blur); -webkit-backdrop-filter: var(--blur); border-bottom: 1px solid var(--separator); }
.ab-bar-main { display: flex; align-items: center; gap: 10px; padding: 10px 20px 6px; flex-wrap: wrap; }
.ab-name { flex: 1; min-width: 180px; max-width: 520px; height: 36px; border: 1px solid transparent; border-radius: var(--radius-s); background: transparent; font: inherit; font-size: 17px; font-weight: 650; color: var(--text); padding: 0 8px; }
.ab-name:hover { background: var(--hover); }
.ab-name:focus { outline: none; border-color: var(--accent); background: var(--field); box-shadow: var(--ring); }
.ab-dirty { display: none; font-size: 12px; font-weight: 600; color: var(--warn-text); background: var(--warn-bg); border: 1px solid var(--warn-border); border-radius: 999px; padding: 2px 9px; }
.ab-dirty.on { display: inline-block; }
.ab-tabs { padding: 0 20px; border-bottom: 0; }
.ab-body { padding: 18px 24px 40px; flex: 1; }

/* ---------------------------------------------------------------- builder: canvas */
.ab-flow { display: flex; gap: 20px; align-items: flex-start; }
.ab-canvas { flex: 1; min-width: 0; overflow-x: auto; padding: 8px 8px 60px; display: flex; flex-direction: column; align-items: center; }
.ab-triggers { width: 420px; max-width: 100%; background: var(--surface); border: 1px dashed var(--border-strong); border-radius: var(--radius-l); padding: 12px 14px; box-shadow: var(--shadow-sm); }
.ab-triggers-head { display: flex; align-items: center; gap: 6px; margin-bottom: 8px; color: var(--accent-text); }
.ab-triggers-head b { color: var(--text); }
.ab-trigger-list { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; }
.ab-trigger { display: flex; align-items: center; justify-content: space-between; gap: 8px; width: 100%; text-align: left; border: 1px solid var(--border); background: var(--surface-2); border-radius: var(--radius); padding: 8px 10px; font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; }
.ab-trigger:hover { border-color: var(--accent); }
.ab-trigger .icon { color: var(--muted); flex: none; }
.ab-line { width: 2px; height: 22px; background: var(--border-strong); }
.ab-col { display: flex; flex-direction: column; align-items: center; min-width: 240px; }
.ab-col.main { width: 420px; max-width: 100%; }
.ab-plus { width: 26px; height: 26px; border-radius: 50%; border: 1.5px solid var(--border-strong); background: var(--surface); color: var(--muted); display: grid; place-items: center; cursor: pointer; margin: 2px 0; position: relative; }
.ab-plus::before, .ab-plus::after { content: ""; position: absolute; left: 50%; width: 2px; height: 12px; background: var(--border-strong); transform: translateX(-50%); }
.ab-plus::before { bottom: 100%; }
.ab-plus::after { top: 100%; }
.ab-plus:hover { border-color: var(--accent); color: var(--accent); background: var(--accent-tint); }
.ab-col > .ab-plus:first-child::before { display: none; }
.ab-node { position: relative; display: flex; align-items: flex-start; gap: 10px; width: 100%; max-width: 420px; background: var(--surface); border: 1.5px solid var(--border); border-radius: var(--radius-l); padding: 10px 36px 10px 12px; margin: 10px 0; box-shadow: var(--shadow-sm); cursor: pointer; text-align: left; transition: border-color .12s, box-shadow .12s; }
.ab-node:hover { box-shadow: var(--shadow); border-color: var(--border-strong); }
.ab-node.on { border-color: var(--accent); box-shadow: var(--ring); }
.ab-node.incomplete { border-style: dashed; }
.ab-node:focus-visible { outline: none; box-shadow: var(--ring); }
.ab-node-icon { width: 34px; height: 34px; border-radius: 9px; display: grid; place-items: center; flex: none; background: var(--fill); color: var(--text-2); }
.ab-node.type-send_email .ab-node-icon { background: var(--link-tint); color: var(--link); }
.ab-node.type-wait .ab-node-icon { background: var(--warn-bg); color: var(--warn-text); }
.ab-node.type-if_else .ab-node-icon, .ab-node.type-goal .ab-node-icon { background: var(--accent-tint); color: var(--accent-text); }
.ab-node.type-add_tag .ab-node-icon, .ab-node.type-subscribe .ab-node-icon { background: var(--green-tint); color: var(--green); }
.ab-node.type-remove_tag .ab-node-icon, .ab-node.type-unsubscribe .ab-node-icon, .ab-node.type-unsubscribe_all .ab-node-icon, .ab-node.type-end_automation .ab-node-icon { background: var(--red-tint); color: var(--red); }
.ab-node.type-end .ab-node-icon { background: var(--dark); color: #fff; }
.ab-node-body { min-width: 0; flex: 1; }
.ab-node-type { font-size: 11.5px; font-weight: 650; color: var(--muted); text-transform: uppercase; letter-spacing: .03em; }
.ab-node-sum { font-size: 14px; font-weight: 550; margin-top: 1px; word-break: break-word; }
.ab-node-counts { font-size: 12px; color: var(--muted); margin-top: 4px; font-variant-numeric: tabular-nums; }
.ab-node-counts .now { color: var(--link); font-weight: 600; }
.ab-node-warn { position: absolute; top: 8px; right: 36px; width: 18px; height: 18px; border-radius: 50%; background: var(--warn-bg); color: var(--warn-text); border: 1px solid var(--warn-border); font-size: 12px; font-weight: 700; display: grid; place-items: center; }
.ab-node-x { position: absolute; top: 7px; right: 7px; opacity: 0; }
.ab-node:hover .ab-node-x, .ab-node.on .ab-node-x { opacity: 1; }
.ab-branches { display: flex; gap: 18px; align-items: flex-start; justify-content: center; width: 100%; position: relative; padding-top: 14px; }
.ab-branches::before { content: ""; position: absolute; top: 0; left: 25%; right: 25%; height: 2px; background: var(--border-strong); }
.ab-branch { display: flex; flex-direction: column; align-items: center; flex: 1; min-width: 240px; position: relative; }
.ab-branch::before { content: ""; position: absolute; top: -14px; left: 50%; width: 2px; height: 14px; background: var(--border-strong); transform: translateX(-50%); }
.ab-branch-label { font-size: 12px; font-weight: 700; padding: 2px 10px; border-radius: 999px; margin-bottom: 2px; }
.ab-branch-label.yes { background: var(--green-tint); color: var(--green); }
.ab-branch-label.no { background: var(--red-tint); color: var(--red); }
.ab-branch .ab-col { width: 100%; }
.ab-branch .ab-node { max-width: 100%; }
.ab-merge { width: 50%; height: 14px; border: 2px solid var(--border-strong); border-top: 0; border-radius: 0 0 12px 12px; margin-top: -2px; }
.ab-end-mark { font-size: 12px; color: var(--muted); border: 1px solid var(--border); border-radius: 999px; padding: 2px 10px; margin: 4px 0 8px; background: var(--surface); }
.ab-end-mark.main { font-weight: 600; color: var(--text-2); }
.ab-empty { color: var(--muted); font-size: 13.5px; padding: 8px 0 20px; }

/* ---------------------------------------------------------------- builder: painel lateral */
.ab-side { width: 0; flex: none; overflow: hidden; transition: width .15s; }
.ab-side.open { width: 380px; background: var(--surface); border-radius: var(--radius-l); box-shadow: var(--shadow-sm); padding: 14px 16px 16px; position: sticky; top: calc(var(--topbar) + 96px); max-height: calc(100vh - var(--topbar) - 120px); overflow-y: auto; }
.ab-side-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 12px; }
.ab-side-head h3 { font-size: 16px; }
.ab-side-foot { display: flex; justify-content: space-between; gap: 8px; margin-top: 8px; padding-top: 12px; border-top: 1px solid var(--separator); }
.ab-group { margin-bottom: 14px; }
.ab-group-title { font-size: 11.5px; font-weight: 700; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 6px; }
.ab-action { display: flex; align-items: center; gap: 10px; width: 100%; text-align: left; border: 1px solid transparent; background: transparent; border-radius: var(--radius); padding: 7px 8px; font: inherit; font-size: 13.5px; color: var(--text); cursor: pointer; }
.ab-action:hover { background: var(--hover); border-color: var(--border); }
.ab-action-icon { width: 30px; height: 30px; border-radius: 8px; background: var(--fill); display: grid; place-items: center; color: var(--text-2); flex: none; }
.ab-side textarea.invalid { border-color: var(--red); }

/* ---------------------------------------------------------------- webhooks e URLs de entrada */
.events-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 6px; }
.events-grid .check { white-space: normal; align-items: flex-start; font-size: 13.5px; }
.events-grid .check input { margin-top: 3px; }
.table td.url-cell { max-width: 320px; }
.table td.url-cell code.inline { word-break: normal; overflow-wrap: anywhere; }
.map-row { display: flex; gap: 6px; align-items: center; }
.map-row .input { flex: 1; min-width: 0; }
.code-block { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 12px; line-height: 1.45; background: var(--surface-2); border-radius: var(--radius); padding: 10px 12px; overflow: auto; max-height: 340px; white-space: pre-wrap; word-break: break-word; margin: 8px 0; }
.steps { padding-left: 20px; font-size: 13.5px; line-height: 1.5; }
.steps li { margin-bottom: 4px; }
.panel h3 { font-size: 14px; margin-bottom: 6px; }
.logs-table td { font-size: 13px; }

@media (max-width: 900px) {
  .ab { margin: -14px -12px -24px; }
  .ab-bar-main { padding: 8px 12px 4px; }
  .ab-body { padding: 12px 12px 30px; }
  .ab-flow { flex-direction: column; }
  .ab-side.open { width: 100%; position: static; max-height: none; }
  .ab-branches { flex-direction: column; gap: 8px; }
  .ab-branches::before { display: none; }
  .ab-col, .ab-branch { min-width: 0; }
  .events-grid { grid-template-columns: 1fr; }
  .map-row { flex-wrap: wrap; }
}
