/* ================================================================ Automações (estilo ManyChat) */
.view.full { padding: 0; display: flex; flex-direction: column; height: 100vh; overflow: hidden; }

/* ---------- lista */
.au-sub { color: var(--muted); margin: -12px 0 18px; }
.au-section { display: flex; align-items: baseline; gap: 10px; margin: 26px 0 12px; }
.au-section h2 { font-size: 16px; margin: 0; }
.au-section .muted { font-size: 13px; }
.tpl-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(250px, 1fr)); gap: 12px; }
.tpl {
  text-align: left; border: 1px solid var(--line); background: var(--card); border-radius: 12px; padding: 16px;
  cursor: pointer; display: flex; flex-direction: column; gap: 8px; box-shadow: var(--shadow); transition: .15s;
}
.tpl:hover { border-color: var(--accent); transform: translateY(-2px); box-shadow: 0 8px 24px rgba(109, 40, 217, .12); }
.tpl b { font-size: 14px; }
.tpl p { margin: 0; color: var(--muted); font-size: 12.5px; flex: 1; }
.tpl .tpl-foot { display: flex; align-items: center; gap: 6px; font-size: 12px; color: var(--muted); }
.tpl .tpl-use { margin-left: auto; color: var(--accent); font-weight: 700; }
.tpl-icon { width: 38px; height: 38px; border-radius: 10px; display: grid; place-items: center; color: #fff; }
.tpl-icon svg { width: 20px; height: 20px; }
.tpl.blank { border-style: dashed; box-shadow: none; background: transparent; align-items: center; justify-content: center; text-align: center; color: var(--muted); }
.tpl.blank .tpl-icon { background: var(--accent-soft); color: var(--accent); }

.au-list { display: flex; flex-direction: column; gap: 10px; }
.au-row {
  display: grid; grid-template-columns: 42px minmax(0, 1fr) auto auto auto; gap: 16px; align-items: center;
  background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 16px; box-shadow: var(--shadow); cursor: pointer;
}
.au-row:hover { border-color: #cfc6ea; }
.au-row .tpl-icon { width: 42px; height: 42px; }
.au-name { font-weight: 700; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.au-meta { display: flex; gap: 8px; align-items: center; flex-wrap: nowrap; white-space: nowrap; overflow: hidden; font-size: 12.5px; color: var(--muted); margin-top: 3px; }
.au-meta > * { flex: none; }
.au-meta > :last-child { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.au-stats { display: flex; gap: 18px; }
.au-stat { text-align: center; min-width: 54px; }
.au-stat b { display: block; font-size: 16px; }
.au-stat span { font-size: 11px; color: var(--muted); }
.au-pill { font-size: 11.5px; font-weight: 700; padding: 3px 10px; border-radius: 99px; }
.au-pill.ativo { background: #e5f6ec; color: var(--ok); }
.au-pill.pausado { background: #fff1e4; color: var(--warn); }
.au-pill.rascunho { background: #efeef4; color: var(--muted); }
.au-menu { display: flex; gap: 2px; }

.switch { position: relative; width: 38px; height: 22px; flex: none; display: inline-block; }
.switch input { opacity: 0; width: 0; height: 0; }
.switch span { position: absolute; inset: 0; background: #d6d3e0; border-radius: 99px; cursor: pointer; transition: .2s; }
.switch span::before { content: ""; position: absolute; width: 16px; height: 16px; left: 3px; top: 3px; background: #fff; border-radius: 99px; transition: .2s; box-shadow: 0 1px 3px rgba(0,0,0,.2); }
.switch input:checked + span { background: var(--ok); }
.switch input:checked + span::before { transform: translateX(16px); }

.howto { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 10px; margin-bottom: 14px; }
.howto div { background: var(--card); border: 1px solid var(--line); border-radius: 12px; padding: 12px 14px 12px 52px; position: relative; }
.howto span { position: absolute; left: 14px; top: 13px; width: 26px; height: 26px; border-radius: 99px; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 800; font-size: 13px; }
.howto b { display: block; font-size: 13.5px; }
.howto small { color: var(--muted); font-size: 12px; }
@media (max-width: 800px) { .howto { grid-template-columns: 1fr; } }
.master {display: flex; align-items: center; gap: 16px; justify-content: space-between; border-left: 4px solid #b5b2c3; margin-bottom: 14px; }
.master.on { border-left-color: var(--ok); }
.setup-card { border-left: 4px solid var(--info); }
.setup-card summary { cursor: pointer; font-weight: 700; display: flex; align-items: center; gap: 8px; list-style: none; }
.setup-card summary::-webkit-details-marker { display: none; }
.setup-card summary .muted { font-weight: 400; font-size: 13px; }
.setup-card .code { margin: 4px 0 10px; }
.setup-ok { border-left-color: var(--ok); }
.dot-live { width: 9px; height: 9px; border-radius: 99px; background: var(--ok); box-shadow: 0 0 0 3px #d9f2e3; flex: none; }
.dot-off { width: 9px; height: 9px; border-radius: 99px; background: #c8c5d3; flex: none; }

/* ---------- editor */
.ae-top {
  display: flex; align-items: center; gap: 10px; padding: 10px 18px; background: var(--card); border-bottom: 1px solid var(--line); flex-wrap: wrap;
}
.ae-crumb { color: var(--muted); text-decoration: none; font-weight: 600; font-size: 13px; }
.ae-crumb:hover { color: var(--accent); }
.ae-name { border: 1px solid transparent !important; font-weight: 700; font-size: 15px; padding: 5px 8px !important; width: 32ch; max-width: 34vw; background: transparent !important; }
.ae-name:hover { border-color: var(--line) !important; }
.ae-save { font-size: 12px; color: var(--muted); display: inline-flex; align-items: center; gap: 5px; }
.ae-save.err { color: var(--err); max-width: 420px; }
.ae-tabs { display: flex; gap: 2px; background: #f3f2f8; border-radius: 9px; padding: 3px; }
.ae-tabs button { border: 0; background: none; padding: 5px 14px; border-radius: 7px; cursor: pointer; font-weight: 600; color: var(--muted); font-size: 13px; }
.ae-tabs button.on { background: #fff; color: var(--accent); box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.ae-body { flex: 1; min-height: 0; display: grid; grid-template-columns: 340px minmax(0, 1fr); }
.ae-panel { background: var(--card); border-right: 1px solid var(--line); overflow-y: auto; padding: 16px 18px 40px; }
.ae-panel h3 { font-size: 15px; margin: 4px 0 4px; }
.ae-step { font-size: 11.5px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; font-weight: 700; }
.ae-progress { height: 3px; background: var(--line-soft); border-radius: 99px; margin: 6px 0 14px; overflow: hidden; }
.ae-progress span { display: block; height: 100%; background: var(--ok); }
.ae-q { font-weight: 700; font-size: 13.5px; margin: 18px 0 8px; }
.opt-card {
  display: flex; gap: 10px; align-items: flex-start; border: 1.5px solid var(--line); border-radius: 10px; padding: 10px 12px;
  cursor: pointer; background: #fff; margin-bottom: 8px; font-size: 13px;
}
.opt-card input { margin: 3px 0 0; accent-color: var(--accent); }
.opt-card.on { border-color: var(--accent); background: #fcfaff; }
.opt-card .ico { width: 30px; height: 30px; border-radius: 8px; display: grid; place-items: center; color: #fff; flex: none; }
.opt-card .ico svg { width: 16px; height: 16px; }
.opt-card small { display: block; color: var(--muted); font-size: 12px; }
.ae-panel textarea, .ae-panel input[type=text], .ae-panel input[type=url], .ae-panel select { width: 100%; }
.kw-box { display: flex; flex-wrap: wrap; gap: 6px; border: 1px solid var(--line); border-radius: 8px; padding: 6px; background: #fff; cursor: text; }
.kw-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.kw-box input { border: 0 !important; box-shadow: none !important; flex: 1; min-width: 120px; padding: 3px !important; width: auto !important; }
.kw { display: inline-flex; align-items: center; gap: 4px; background: var(--accent-soft); color: var(--accent); font-weight: 700; font-size: 12.5px; border-radius: 6px; padding: 3px 4px 3px 8px; }
.kw button { border: 0; background: none; color: inherit; cursor: pointer; font-size: 11px; }
.var-row { display: flex; gap: 6px; align-items: flex-start; margin-bottom: 6px; }
.var-row textarea { min-height: 38px; }
.toggle-row { display: flex; align-items: center; gap: 10px; justify-content: space-between; font-weight: 700; font-size: 13.5px; margin: 18px 0 6px; }
.toggle-row small { display: block; font-weight: 400; color: var(--muted); font-size: 12px; }
.check-row { display: flex; gap: 8px; align-items: flex-start; font-size: 13px; margin-top: 14px; cursor: pointer; }
.check-row input { accent-color: var(--accent); margin-top: 3px; }
.media-picked { display: flex; gap: 6px; flex-wrap: wrap; margin: 8px 0; }
.media-picked img, .media-picked .ph { width: 54px; height: 54px; border-radius: 7px; object-fit: cover; background: #eee; border: 1px solid var(--line); }
.tip { background: #fff8e6; border: 1px solid #f5e1a8; color: #6b5313; border-radius: 9px; padding: 9px 11px; font-size: 12.5px; margin-top: 14px; }
.tip.info { background: #f3f7ff; border-color: #cfdcfb; color: #23407a; }
.btn-edit { border: 1px solid var(--line); border-radius: 10px; padding: 10px; margin-bottom: 8px; background: #fcfcfe; }
.btn-edit .row { flex-wrap: nowrap; }
.btn-edit .seg { width: 100%; margin: 6px 0; }
.btn-edit .seg button { flex: 1; padding: 5px 8px; font-size: 12.5px; }
.char { font-size: 11.5px; color: var(--muted); text-align: right; margin-top: 3px; }
.panel-foot { margin-top: 22px; padding-top: 14px; border-top: 1px solid var(--line-soft); display: flex; gap: 8px; }

/* canvas */
.ae-canvas {
  position: relative; overflow: auto; background-color: #f4f3f8;
  background-image: radial-gradient(#d9d6e4 1.2px, transparent 1.2px); background-size: 22px 22px;
}
.ae-flow { position: relative; display: flex; gap: 110px; padding: 48px 60px 80px; align-items: flex-start; min-width: max-content; min-height: 100%; }
.ae-col { display: flex; flex-direction: column; gap: 34px; align-items: flex-start; }
.ae-svg { position: absolute; inset: 0; pointer-events: none; overflow: visible; }
.ae-svg path { fill: none; stroke: #9a95ad; stroke-width: 2; }
.fc {
  width: 300px; background: #fff; border-radius: 16px; box-shadow: 0 2px 4px rgba(20,16,40,.06), 0 10px 30px rgba(20,16,40,.07);
  border: 2px solid transparent; cursor: pointer; position: relative; transition: border-color .15s, box-shadow .15s;
}
.fc:hover { border-color: #d8d0f3; }
.fc.sel { border-color: var(--accent); box-shadow: 0 0 0 4px rgba(109, 40, 217, .12), 0 10px 30px rgba(20,16,40,.08); }
.fc-head { display: flex; align-items: center; gap: 9px; padding: 13px 15px 8px; }
.fc-head .kicker { font-size: 11px; color: var(--muted); line-height: 1.1; }
.fc-head b { font-size: 14px; display: block; }
.fc-head .ig { width: 28px; height: 28px; border-radius: 99px; display: grid; place-items: center; color: #fff;
  background: radial-gradient(circle at 30% 110%, #fdd65b 0%, #f5793a 30%, #d62976 60%, #962fbf 85%); flex: none; }
.fc-head .ig svg { width: 15px; height: 15px; }
.fc-tag { margin-left: auto; font-size: 10.5px; font-weight: 700; color: var(--accent); background: var(--accent-soft); padding: 2px 7px; border-radius: 99px; }
.fc-tag.warn { color: var(--warn); background: #fff1e4; }
.fc-body { padding: 4px 15px 15px; }
.fc-trig { border: 1.5px solid #9fd9b4; background: #f3fbf6; border-radius: 11px; padding: 10px 11px; display: flex; gap: 9px; font-size: 13px; }
.fc-trig .ig { width: 22px; height: 22px; }
.fc-trig small { display: block; color: var(--muted); font-size: 11.5px; margin-top: 2px; }
.fc-sub { margin-top: 8px; border: 1px dashed #d6d3e0; border-radius: 10px; padding: 8px 10px; font-size: 12.5px; color: var(--muted); display: flex; gap: 7px; align-items: center; }
.fc-sub svg { width: 15px; height: 15px; color: var(--accent); }
.fc-foot { display: flex; justify-content: flex-end; align-items: center; gap: 8px; padding: 0 0 14px; font-size: 12.5px; color: var(--muted); position: relative; }
.port { width: 13px; height: 13px; border-radius: 99px; background: #8b86a0; border: 2.5px solid #fff; box-shadow: 0 0 0 1px #c9c5d6; position: relative; right: -7px; flex: none; }
.bubble { background: #f3f2f7; border-radius: 14px; padding: 10px 12px; font-size: 13px; white-space: pre-wrap; word-wrap: break-word; color: #2a2638; }
.bubble.empty { color: #a7a3b5; font-style: italic; }
.fc-btn { margin-top: 7px; border: 1px solid #e3e1ea; background: #fff; border-radius: 11px; padding: 9px 12px; font-size: 13px; font-weight: 600; display: flex; align-items: center; justify-content: center; gap: 6px; position: relative; color: #2a2638; }
.fc-btn svg { width: 13px; height: 13px; color: var(--muted); }
.fc-btn .port { position: absolute; right: -22px; top: 50%; margin-top: -6.5px; }
.fc-add { width: 300px; border: 2px dashed #cdc8dd; border-radius: 16px; background: rgba(255,255,255,.6); padding: 16px; text-align: center; color: var(--accent); font-weight: 700; cursor: pointer; }
.fc-add:hover { background: #fff; border-color: var(--accent); }
.note {
  width: 300px; background: #fff3dc; border-radius: 14px; padding: 14px 16px; font-size: 13px; color: #5c4a1f; line-height: 1.5;
  box-shadow: 0 1px 2px rgba(0,0,0,.04);
}
.ae-hint { position: sticky; left: 0; top: 0; display: flex; justify-content: center; pointer-events: none; height: 0; z-index: 2; }
.ae-hint span { margin-top: 10px; background: #fff; border: 1px solid var(--line); border-radius: 99px; padding: 4px 12px; font-size: 12px; color: var(--muted); box-shadow: var(--shadow); }

/* escolher publicações */
.media-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(120px, 1fr)); gap: 10px; }
.mg-item { position: relative; border: 2px solid var(--line); border-radius: 10px; overflow: hidden; cursor: pointer; background: #fff; }
.mg-item input { position: absolute; top: 6px; left: 6px; accent-color: var(--accent); width: 18px; height: 18px; z-index: 1; }
.mg-item img, .mg-item .ph { width: 100%; aspect-ratio: 1; object-fit: cover; display: block; background: #eee; }
.mg-item.on { border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-soft); }
.mg-cap { display: block; font-size: 11.5px; padding: 5px 7px; color: var(--muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* histórico */
.ae-logs { padding: 20px 24px; overflow: auto; grid-column: 1 / -1; }
.log-detail { max-width: 420px; color: var(--muted); font-size: 12px; word-break: break-word; }

/* simulação (celular) */
.phone { width: 300px; margin: 0 auto; border: 9px solid #1f1b2d; border-radius: 34px; overflow: hidden; background: #fff; }
.phone-head { display: flex; align-items: center; gap: 8px; padding: 10px 12px; border-bottom: 1px solid var(--line-soft); font-weight: 700; font-size: 13px; }
.phone-head .pv-avatar { width: 26px; height: 26px; font-size: 12px; }
.phone-body { height: 380px; overflow-y: auto; padding: 12px; display: flex; flex-direction: column; gap: 8px; background: #fff; }
.ph-comment { font-size: 12.5px; background: #fafafa; border-radius: 10px; padding: 8px 10px; }
.ph-comment.reply { margin-left: 22px; }
.ph-sys { text-align: center; font-size: 11px; color: var(--muted); margin: 4px 0; }
.ph-msg { max-width: 82%; border-radius: 18px; padding: 8px 12px; font-size: 13px; white-space: pre-wrap; word-wrap: break-word; }
.ph-msg.in { align-self: flex-start; background: #efeff2; }
.ph-msg.out { align-self: flex-end; background: #7b3fe4; color: #fff; }
.ph-card { align-self: flex-start; max-width: 85%; border: 1px solid #e3e1ea; border-radius: 16px; overflow: hidden; }
.ph-card .ph-text { padding: 9px 12px; font-size: 13px; white-space: pre-wrap; background: #efeff2; }
.ph-card button { display: block; width: 100%; border: 0; border-top: 1px solid #e3e1ea; background: #fff; padding: 9px; font-weight: 700; color: #3b6fe0; cursor: pointer; font-size: 13px; }
.ph-card button:hover { background: #f6f8ff; }
.sim-form { display: grid; gap: 8px; margin-bottom: 14px; }
.sim-wrap { display: grid; grid-template-columns: minmax(0, 1fr) 318px; gap: 18px; align-items: start; }

@media (max-width: 1250px) {
  .au-stats { gap: 10px; }
  .au-stat:nth-child(n+3) { display: none; }
}
@media (max-width: 1000px) {
  .ae-body { grid-template-columns: 1fr; grid-template-rows: auto minmax(420px, 1fr); overflow-y: auto; }
  .ae-panel { border-right: 0; border-bottom: 1px solid var(--line); }
  .view.full { height: auto; min-height: 100vh; overflow: visible; }
  .au-row { grid-template-columns: 42px minmax(0, 1fr) auto auto; gap: 10px; }
  .au-stats { display: none; }
  .sim-wrap { grid-template-columns: 1fr; }
}
