/* Nena Flow Designer */
:root {
  --wa-green: #00a884;
  --wa-deep: #008069;
  --wa-header: #008069;
  --wa-chat-bg: #efe7dd;
  --ink: #111b21;
  --ink-2: #54656f;
  --ink-3: #8696a0;
  --line: #e2e8f0;
  --panel: #ffffff;
  --bg: #f0f2f5;
  --err: #dc2626;
  --warn: #b45309;
  font-size: 14px;
}
* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: "Segoe UI", system-ui, -apple-system, Helvetica, Arial, sans-serif;
  background: var(--bg);
  color: var(--ink);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* ---------- top bar ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  background: var(--wa-deep); color: #fff;
  padding: 8px 16px; flex: 0 0 auto;
}
.brand { display: flex; align-items: center; gap: 10px; }
.brand-logo {
  width: 36px; height: 36px; border-radius: 50%;
  background: #fff; color: var(--wa-deep);
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 20px;
}
.brand-name { font-weight: 700; font-size: 15px; }
.brand-sub { font-size: 11px; opacity: 0.85; }
.topbar-mid { display: flex; align-items: center; gap: 8px; margin-left: 12px; }
.topbar-mid select {
  background: rgba(255,255,255,0.15); color: #fff; border: 1px solid rgba(255,255,255,0.35);
  border-radius: 8px; padding: 6px 10px; font-size: 13px; max-width: 220px;
}
.topbar-mid select option { color: var(--ink); }
.save-dot { width: 9px; height: 9px; border-radius: 50%; background: rgba(255,255,255,0.35); transition: background .2s; }
.save-dot.saved { background: #7CFC9E; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: 8px; }
.tb-btn {
  background: rgba(255,255,255,0.12); border: 1px solid rgba(255,255,255,0.35);
  color: #fff; border-radius: 8px; padding: 7px 12px; font-size: 13px; cursor: pointer;
}
.tb-btn:hover { background: rgba(255,255,255,0.22); }
.tb-btn.primary { background: var(--wa-green); border-color: var(--wa-green); font-weight: 600; }
.tb-btn.primary:hover { filter: brightness(1.07); }
.tb-btn.ghost { padding: 7px 9px; }
.tb-btn.on { background: #fff; color: var(--wa-deep); }
.badge { border-radius: 999px; padding: 4px 10px; font-size: 12px; font-weight: 600; }
.badge.ok { background: #d1fae5; color: #065f46; }
.badge.warn { background: #fef3c7; color: var(--warn); }
.badge.err { background: #fee2e2; color: var(--err); }

/* ---------- screens bar ---------- */
.screens-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 8px 16px; background: var(--panel); border-bottom: 1px solid var(--line);
  overflow-x: auto; flex: 0 0 auto;
}
.scr-tab {
  display: flex; align-items: center; gap: 6px;
  padding: 6px 12px; border-radius: 8px; cursor: pointer;
  border: 1px solid var(--line); background: var(--bg);
  font-size: 13px; font-weight: 600; color: var(--ink-2);
  font-family: ui-monospace, Consolas, monospace; white-space: nowrap;
}
.scr-tab.on { background: #e7f8f3; border-color: var(--wa-green); color: var(--wa-deep); }
.scr-term { font-size: 11px; }
.scr-del { border: 0; background: none; cursor: pointer; color: var(--ink-3); font-size: 11px; padding: 0 2px; }
.scr-del:hover { color: var(--err); }
.scr-add {
  width: 30px; height: 30px; border-radius: 8px; border: 1px dashed var(--ink-3);
  background: none; cursor: pointer; color: var(--ink-2); font-size: 16px;
}
.scr-add:hover { border-color: var(--wa-green); color: var(--wa-deep); }

/* ---------- layout ---------- */
.layout { flex: 1; display: flex; min-height: 0; }
.palette {
  width: 220px; flex: 0 0 auto; background: var(--panel);
  border-right: 1px solid var(--line); overflow-y: auto; padding: 10px;
}
.pal-group-title {
  font-size: 11px; text-transform: uppercase; letter-spacing: 0.06em;
  color: var(--ink-3); margin: 12px 4px 6px; font-weight: 700;
}
.pal-item {
  display: flex; align-items: center; gap: 9px;
  padding: 8px 10px; border-radius: 8px; cursor: grab;
  border: 1px solid transparent; font-size: 13px; color: var(--ink);
}
.pal-item:hover { background: #e7f8f3; border-color: #b9e8dc; }
.pal-icon {
  width: 26px; height: 26px; flex: 0 0 auto; border-radius: 6px;
  background: #e9edef; color: var(--ink-2);
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 700;
}

.canvas {
  flex: 1; display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 22px 12px;
}

.props {
  width: 300px; flex: 0 0 auto; background: var(--panel);
  border-left: 1px solid var(--line); overflow-y: auto; padding: 14px;
}

/* ---------- properties panel ---------- */
.pp-section { margin-bottom: 18px; }
.pp-title { font-weight: 700; font-size: 14px; margin-bottom: 10px; display: flex; align-items: center; gap: 8px; }
.pp-type { font-size: 11px; font-weight: 600; color: var(--ink-3); font-family: ui-monospace, Consolas, monospace; }
.pp-field { display: block; margin-bottom: 10px; }
.pp-field > span { display: block; font-size: 12px; color: var(--ink-2); margin-bottom: 4px; font-weight: 600; }
.pp-field input[type="text"], .pp-field input:not([type]), .pp-field input[type="number"], .pp-field input[type="file"],
.pp-field select, .pp-field textarea {
  width: 100%; border: 1px solid var(--line); border-radius: 8px;
  padding: 7px 9px; font-size: 13px; font-family: inherit; background: #fff; color: var(--ink);
}
.pp-field textarea { resize: vertical; }
.pp-field .mono, textarea.mono { font-family: ui-monospace, Consolas, monospace; font-size: 12px; }
.pp-field input:focus, .pp-field select:focus, .pp-field textarea:focus { outline: 2px solid #9be3d2; border-color: var(--wa-green); }
.pp-check { display: flex; align-items: center; gap: 8px; margin-bottom: 9px; font-size: 13px; cursor: pointer; }
.pp-check input { accent-color: var(--wa-deep); width: 16px; height: 16px; }
.pp-err { color: var(--err); font-size: 11px; display: block; margin-top: 3px; }
.pp-hint { font-size: 12px; color: var(--ink-3); margin-top: 6px; display: block; }
.pp-mini {
  border: 1px dashed var(--ink-3); background: none; border-radius: 8px;
  padding: 6px 10px; font-size: 12px; cursor: pointer; color: var(--ink-2); width: 100%;
}
.pp-mini:hover { border-color: var(--wa-green); color: var(--wa-deep); }
.pp-back {
  border: 0; background: none; color: var(--wa-deep); cursor: pointer;
  font-size: 13px; font-weight: 600; padding: 6px 0;
}

/* data-source editor */
.ds-list { display: flex; flex-direction: column; gap: 8px; margin-bottom: 8px; }
.ds-row {
  display: grid; grid-template-columns: 16px 16px 1fr 22px; gap: 4px; align-items: center;
  border: 1px solid var(--line); border-radius: 8px; padding: 6px;
}
.ds-grip { cursor: pointer; color: var(--ink-3); font-size: 9px; text-align: center; }
.ds-grip:hover { color: var(--wa-deep); }
.ds-inputs { display: flex; flex-direction: column; gap: 4px; }
.ds-inputs input { width: 100%; border: 1px solid var(--line); border-radius: 6px; padding: 5px 7px; font-size: 12px; }
.ds-del { border: 0; background: none; cursor: pointer; color: var(--ink-3); }
.ds-del:hover { color: var(--err); }

/* ---------- JSON drawer ---------- */
.json-drawer {
  width: 0; flex: 0 0 auto; background: #0b141a; color: #e9edef;
  overflow: hidden; display: flex; flex-direction: column;
  transition: width 0.2s ease;
}
body.json-open .json-drawer { width: 380px; }
.json-head {
  padding: 10px 14px; font-weight: 700; font-size: 13px;
  border-bottom: 1px solid #1f2c33; flex: 0 0 auto;
}
.json-hint { font-weight: 400; font-size: 11px; color: #8696a0; margin-left: 6px; }
#issues { flex: 0 0 auto; max-height: 30%; overflow-y: auto; }
.issue { padding: 6px 14px; font-size: 12px; border-bottom: 1px solid #1f2c33; }
.issue.error { color: #f87171; }
.issue.warn { color: #fbbf24; }
#jsonOut {
  flex: 1; margin: 0; padding: 12px 14px; overflow: auto;
  font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; line-height: 1.45;
  white-space: pre; color: #a5f3dc;
}

/* ---------- phone ---------- */
.phone {
  width: 375px; height: 760px; background: #000; border-radius: 38px;
  padding: 10px; box-shadow: 0 18px 50px rgba(0,0,0,0.3);
  position: relative; display: flex; flex-direction: column; overflow: hidden;
}
.phone-notch {
  position: absolute; top: 10px; left: 50%; transform: translateX(-50%);
  width: 120px; height: 22px; background: #000; border-radius: 0 0 14px 14px; z-index: 30;
}
.wa-statusbar {
  background: var(--wa-header); color: #fff; font-size: 11px;
  display: flex; justify-content: space-between; padding: 6px 18px 2px;
  border-radius: 28px 28px 0 0;
}
.sb-icons { letter-spacing: 1px; font-size: 9px; }
.wa-chat-header {
  background: var(--wa-header); color: #fff;
  display: flex; align-items: center; gap: 10px; padding: 8px 12px;
}
.wa-avatar {
  width: 34px; height: 34px; border-radius: 50%; background: #fff; color: var(--wa-deep);
  display: flex; align-items: center; justify-content: center; font-weight: 800;
}
.wa-chat-name { font-weight: 600; font-size: 15px; line-height: 1.1; }
.wa-chat-sub { font-size: 11px; font-weight: 400; opacity: 0.85; }
.wa-chat-bg {
  height: 36px; flex: 0 0 auto;
  background-color: var(--wa-chat-bg);
  background-image: radial-gradient(#d9cfc2 0.8px, transparent 0.8px);
  background-size: 14px 14px;
}

/* flow bottom sheet */
.wa-sheet {
  flex: 1; background: #fff; border-radius: 18px 18px 0 0;
  margin-top: -8px; display: flex; flex-direction: column; min-height: 0;
  box-shadow: 0 -3px 12px rgba(0,0,0,0.18);
}
.wa-sheet-header {
  display: flex; align-items: center; gap: 8px;
  padding: 14px 14px 10px; flex: 0 0 auto;
}
.wa-close { border: 0; background: none; font-size: 16px; color: var(--ink-2); cursor: pointer; width: 28px; }
.wa-sheet-title { flex: 1; text-align: center; font-weight: 600; font-size: 16px; color: var(--ink); }
.wa-sheet-menu { width: 28px; text-align: center; color: var(--ink-2); }
.wa-sheet-body { flex: 1; overflow-y: auto; padding: 4px 18px 12px; min-height: 0; }
.wa-sheet-footer { flex: 0 0 auto; padding: 8px 18px 12px; border-top: 1px solid #f0f2f5; }
.wa-managed { text-align: center; font-size: 10.5px; color: var(--ink-3); margin-top: 8px; }
.wa-managed span { color: var(--wa-deep); }
.wa-empty { text-align: center; color: var(--ink-3); font-size: 13px; padding: 60px 10px; line-height: 1.7; }

/* ---------- WhatsApp components ---------- */
.wa-heading { font-size: 22px; font-weight: 700; color: var(--ink); margin: 10px 0 4px; line-height: 1.25; }
.wa-subheading { font-size: 16px; font-weight: 700; color: var(--ink); margin: 8px 0 4px; }
.wa-body { font-size: 14.5px; color: var(--ink); margin: 6px 0; line-height: 1.45; }
.wa-body.b { font-weight: 700; } .wa-body.i { font-style: italic; } .wa-body.s { text-decoration: line-through; }
.wa-caption { font-size: 12.5px; color: var(--ink-2); margin: 4px 0; line-height: 1.4; }
.wa-rich { font-size: 14px; color: var(--ink); line-height: 1.5; margin: 6px 0; }
.wa-rich-h1 { font-size: 21px; font-weight: 700; margin: 8px 0 4px; }
.wa-rich-h2 { font-size: 17px; font-weight: 700; margin: 6px 0 3px; }
.wa-rich-h3 { font-size: 15px; font-weight: 700; margin: 5px 0 2px; }
.wa-rich-gap { height: 8px; }
.wa-rich ul { margin: 4px 0; padding-left: 20px; }

.wa-field-label { font-size: 13.5px; font-weight: 600; color: var(--ink); margin: 12px 0 6px; }
.wa-helper { font-size: 11.5px; color: var(--ink-3); margin: 4px 2px; }
.wa-input {
  display: flex; align-items: center; gap: 8px;
  border: 1px solid #c5ccd1; border-radius: 10px; padding: 0 12px; background: #fff;
}
.wa-input:focus-within { border-color: var(--wa-deep); box-shadow: 0 0 0 1px var(--wa-deep); }
.wa-input input, .wa-input textarea {
  flex: 1; border: 0; outline: none; padding: 13px 0; font-size: 14.5px;
  font-family: inherit; background: none; color: var(--ink); min-width: 0;
}
.wa-input textarea { resize: none; padding: 11px 0; }
.wa-select { padding: 13px 12px; cursor: pointer; justify-content: space-between; }
.wa-select-ph { color: var(--ink-2); font-size: 14.5px; }

.wa-opts { display: flex; flex-direction: column; }
.wa-opt {
  display: flex; align-items: flex-start; gap: 12px; padding: 11px 2px;
  border-bottom: 1px solid #f0f2f5; cursor: pointer;
}
.wa-opt:last-child { border-bottom: 0; }
.wa-opt-title { font-size: 14.5px; color: var(--ink); }
.wa-opt-desc { font-size: 12.5px; color: var(--ink-2); margin-top: 1px; }
.wa-radio {
  width: 20px; height: 20px; border-radius: 50%; border: 2px solid #aebac1;
  flex: 0 0 auto; margin-top: 1px; position: relative;
}
.wa-radio.on { border-color: var(--wa-deep); }
.wa-radio.on::after {
  content: ""; position: absolute; inset: 3px; border-radius: 50%; background: var(--wa-deep);
}
.wa-check {
  width: 20px; height: 20px; border-radius: 4px; border: 2px solid #aebac1;
  flex: 0 0 auto; margin-top: 1px; display: flex; align-items: center; justify-content: center;
}
.wa-check.on { background: var(--wa-deep); border-color: var(--wa-deep); }

.wa-chips { display: flex; flex-wrap: wrap; gap: 8px; margin: 8px 0; }
.wa-chip {
  border: 1px solid #c5ccd1; border-radius: 999px; padding: 8px 14px;
  font-size: 13.5px; color: var(--ink); cursor: pointer; user-select: none;
}
.wa-chip.on { background: #e7f8f3; border-color: var(--wa-deep); color: var(--wa-deep); font-weight: 600; }

.wa-navlist { display: flex; flex-direction: column; }
.wa-navitem {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 2px; border-bottom: 1px solid #f0f2f5; cursor: pointer;
}
.wa-navitem:last-child { border-bottom: 0; }

.wa-image { width: 100%; border-radius: 10px; display: block; margin: 8px 0; }
.wa-image-ph { background: #e9edef; display: flex; align-items: center; justify-content: center; }

.wa-upload {
  display: flex; align-items: center; gap: 10px; justify-content: center;
  border: 1.5px dashed #aebac1; border-radius: 10px; padding: 16px;
  color: var(--wa-deep); font-size: 13.5px; margin: 8px 0; cursor: pointer;
}

.wa-link { color: var(--wa-deep); font-size: 14px; margin: 8px 0; text-align: center; cursor: pointer; font-weight: 500; }

.wa-cond { border: 1.5px dashed #c4b5fd; border-radius: 10px; padding: 8px; margin: 8px 0; }
.wa-cond-tag {
  display: inline-block; background: #ede9fe; color: #6d28d9; font-size: 11px;
  border-radius: 6px; padding: 2px 8px; margin: 2px 0 6px; font-family: ui-monospace, Consolas, monospace;
}

.wa-footer-caps { display: flex; justify-content: space-between; font-size: 11px; color: var(--ink-2); margin-bottom: 6px; }
.wa-footer-btn {
  width: 100%; border: 0; border-radius: 24px; padding: 13px;
  background: var(--wa-deep); color: #fff; font-size: 15px; font-weight: 600;
  cursor: pointer; font-family: inherit;
}
.wa-footer-btn:hover { filter: brightness(1.06); }
.wa-footer-btn.off { background: #d1d7db; color: #fff; }
.wa-footer-btn.ghost { background: none; border: 1.5px dashed #aebac1; color: var(--ink-2); font-weight: 500; }

/* calendar */
.cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; text-align: center; margin: 6px 0; }
.cal-h { font-size: 10px; color: var(--ink-3); font-weight: 700; padding: 4px 0; }
.cal-d { font-size: 12px; color: var(--ink); padding: 6px 0; border-radius: 50%; cursor: pointer; }
.cal-d:hover { background: #e7f8f3; }
.cal-d.sel { background: var(--wa-deep); color: #fff; }
.wa-calendar { border: 1px solid var(--line); border-radius: 10px; padding: 8px; }

/* ---------- builder chrome over components ---------- */
.cmp { position: relative; border: 1.5px solid transparent; border-radius: 8px; margin: 1px -8px; padding: 1px 8px; }
.cmp:hover { border-color: #b9e8dc; }
.cmp.selected { border-color: var(--wa-green); background: rgba(0, 168, 132, 0.04); }
.cmp.drop-before { box-shadow: 0 -3px 0 0 var(--wa-green); }
.cmp-toolbar {
  position: absolute; top: -11px; right: 4px; z-index: 5;
  display: none; align-items: center; gap: 2px;
  background: var(--wa-deep); border-radius: 6px; padding: 1px 4px;
}
.cmp:hover .cmp-toolbar, .cmp.selected .cmp-toolbar { display: flex; }
.cmp-type { font-size: 9.5px; color: #d1fae5; font-family: ui-monospace, Consolas, monospace; padding: 0 4px; }
.cmp-act { border: 0; background: none; color: #fff; cursor: pointer; font-size: 11px; padding: 2px 4px; border-radius: 4px; }
.cmp-act:hover { background: rgba(255,255,255,0.2); }

/* responsive-ish */
@media (max-width: 1180px) {
  .props { width: 260px; }
  .palette { width: 190px; }
  body.json-open .json-drawer { width: 320px; }
}
