/* ============================================================
   Flow editor — WhatsApp Flows Studio design system
   Ported from wa-flows (preview.css): deep teal + vivid green,
   soft rounded surfaces, gentle depth. Node types are told apart
   by a category accent bar, not by loud fills.
   Scoped to .app-container so it can't leak into the rest of admin.
   ============================================================ */

@import url("https://fonts.googleapis.com/css2?family=Bricolage+Grotesque:opsz,wght@12..96,500;12..96,600;12..96,700&family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap");

.app-container {
    --teal: #075e54;
    --teal-700: #0a7163;
    --green: #25d366;
    --green-600: #1ebe5d;
    --green-700: #14a44d;
    --ink: #0c211d;
    --muted: #6b7c79;
    --faint: #9aa8a4;
    --line: #e7edea;
    --line-strong: #d6e0dc;
    --surface: #ffffff;
    --surface-2: #f7faf9;
    --canvas: #eef3f1;
    --danger: #d1453b;
    --amber: #d98a00;

    /* node category accents (mirror wa-flows palette dots) */
    --cat-text: #6366f1;
    --cat-input: #0ea5e9;
    --cat-selection: #f59e0b;
    --cat-media: #ec4899;
    --cat-navigation: #10b981;

    --r-sm: 8px;
    --r-md: 12px;
    --r-lg: 18px;
    --r-pill: 999px;

    --shadow-sm:
        0 1px 2px rgba(10, 40, 35, 0.06), 0 1px 3px rgba(10, 40, 35, 0.04);
    --shadow-md: 0 4px 14px rgba(10, 40, 35, 0.08);
    --shadow-lg: 0 18px 50px rgba(10, 40, 35, 0.18);

    --font-display: "Bricolage Grotesque", system-ui, sans-serif;
    --font-ui: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;

    display: flex;
    height: 100vh;
    overflow: hidden;
    font-family: var(--font-ui);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
}

.flow-and-buttons {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.react-flow {
    width: 100%;
    height: 100%;
    background:
        radial-gradient(120% 90% at 50% -10%, #f3f9f6 0%, var(--canvas) 55%),
        var(--canvas);
}

/* ---------------- Toolbar ---------------- */
.button-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 7px;
    padding: 10px 14px;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    box-shadow: var(--shadow-sm);
    overflow: visible; /* let the Add Component menu spill over the canvas */
    z-index: 100;
}

/* Base pill look. radius/padding/font forced so the few inline-colored
   action buttons (freeze / integration / language) become pills too,
   while keeping their accent color. Plain buttons get the ghost style. */
.button-container button {
    font-family: var(--font-ui) !important;
    font-weight: 600;
    font-size: 13px !important;
    line-height: 1.2;
    white-space: nowrap;
    border-radius: var(--r-pill) !important;
    padding: 8px 14px !important;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--ink);
    cursor: pointer;
    transition:
        background 0.15s,
        border-color 0.15s,
        transform 0.08s,
        box-shadow 0.15s;
}
.button-container button:hover {
    background: var(--surface-2);
    border-color: var(--green);
}
.button-container button:active {
    transform: translateY(1px);
}

.button-container .button-style-blue {
    background: var(--green) !important;
    color: #04231a !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.35);
}
.button-container .button-style-blue:hover {
    background: var(--green-600) !important;
}

/* ---------------- Add Component dropdown ----------------
   One primary trigger replaces the long wall of "Add … Node" pills.
   The menu groups node types and each row's dot matches that node's
   category accent on the canvas, so the menu also reads as a legend. */
.add-component {
    position: relative;
}

.button-container .add-component-trigger {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    background: var(--teal) !important;
    color: #eafff7 !important;
    border: none !important;
    box-shadow: 0 2px 8px rgba(7, 94, 84, 0.3);
}
.button-container .add-component-trigger:hover {
    background: var(--teal-700) !important;
}

/* secondary trigger — sits beside the primary teal one without competing */
.button-container .add-component-trigger.is-ghost {
    background: var(--surface) !important;
    color: var(--ink) !important;
    border: 1px solid var(--line-strong) !important;
    box-shadow: var(--shadow-sm);
}
.button-container .add-component-trigger.is-ghost:hover {
    background: var(--surface-2) !important;
    border-color: var(--teal) !important;
}
.add-component-trigger.is-ghost .add-component-plus {
    background: rgba(7, 94, 84, 0.1);
    color: var(--teal);
}
.add-component-trigger .add-component-plus {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.16);
}
.add-component-plus svg {
    display: block;
}
.add-component-trigger .add-component-caret {
    font-size: 10px;
    opacity: 0.85;
    transition: transform 0.18s ease;
}
.add-component-trigger.is-open .add-component-caret {
    transform: rotate(180deg);
}

.add-component-menu {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    z-index: 1000;
    width: 288px;
    max-height: min(70vh, 520px);
    overflow-y: auto;
    padding: 8px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    animation: add-menu-in 0.14s ease;
}
@keyframes add-menu-in {
    from {
        opacity: 0;
        transform: translateY(-6px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.add-component-group {
    padding: 4px 0;
}
.add-component-group + .add-component-group {
    border-top: 1px solid var(--line);
}
.add-component-group-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--faint);
    padding: 6px 10px 4px;
}

/* override the .button-container button pill recipe for menu rows */
.button-container .add-component-item {
    display: flex !important;
    align-items: center;
    gap: 10px;
    width: 100%;
    text-align: left;
    padding: 8px 10px !important;
    border: none !important;
    border-radius: var(--r-sm) !important;
    background: transparent;
    white-space: normal;
    cursor: pointer;
    transition: background 0.12s;
}
.button-container .add-component-item:hover {
    background: var(--surface-2);
    border: none !important;
}

.add-component-dot {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}
.add-component-item-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.add-component-item-name {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 13px;
    color: var(--ink);
    line-height: 1.25;
}
.add-component-item-desc {
    font-size: 11.5px;
    color: var(--muted);
    line-height: 1.3;
}

@media (prefers-reduced-motion: reduce) {
    .add-component-menu {
        animation: none;
    }
    .add-component-trigger .add-component-caret {
        transition: none;
    }
}

/* ---------------- Sidebar ---------------- */
.sidebar,
.variable-table-container2 {
    width: 300px;
    flex: none;
    padding: 14px;
    background: var(--surface-2);
    border-left: 1px solid var(--line);
    overflow-y: auto;
    height: 100%;
}

.config-table-container,
.variable-table-container {
    margin-bottom: 20px;
}

.config-table-container h3,
.variable-table-container h3 {
    margin: 0 0 12px 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--faint);
    text-align: left;
}

.config-table,
.variable-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    overflow: hidden;
}
.config-table th,
.config-table td,
.variable-table th,
.variable-table td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid var(--line);
}
.config-table th,
.variable-table th {
    background: var(--surface-2);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--muted);
}
.config-table tr:last-child td,
.variable-table tr:last-child td {
    border-bottom: none;
}

.config-table input[type="text"],
.table-input {
    width: 100%;
    padding: 7px 9px;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    font-size: 12.5px;
    font-family: var(--font-ui);
    color: var(--ink);
    background: var(--surface);
    box-sizing: border-box;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
.config-table input[type="checkbox"],
.variable-table input[type="checkbox"] {
    accent-color: var(--green);
    margin: 0;
}

/* ---------------- Inputs (shared) ---------------- */
.react-flow input[type="text"],
.react-flow input[type="number"],
.react-flow textarea,
.react-flow select,
.standard-input-style,
.short-input-style,
.medium-input-style,
.inline-input,
.inline-input2,
.if-condition-input {
    font-family: var(--font-ui);
    font-size: 13px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    padding: 7px 9px;
    box-sizing: border-box;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
.react-flow input:focus,
.react-flow textarea:focus,
.react-flow select:focus,
.standard-input-style:focus,
.if-condition-input:focus,
.text-node-textarea:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.14);
}
.react-flow textarea {
    width: 95%;
    height: 70px;
    margin-right: 5px;
    resize: vertical;
    white-space: pre-wrap;
}
.standard-input-style {
    width: 95%;
    margin-right: 5px;
}
.standard-input-style2 {
    width: 100px;
    font-size: 12px;
    padding: 6px 8px;
    margin: 5px 0;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
}
.short-input-style {
    width: 56px;
    margin-right: 5px;
    text-align: center;
}
.medium-input-style {
    width: 110px;
    margin-right: 5px;
}
.inline-input {
    width: 100%;
    margin-right: 5px;
}
.inline-input2 {
    flex: 1;
    min-width: 100px;
    font-size: 12.5px;
}

.text-node-preview {
    min-height: 20px;
    padding: 8px 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface-2);
    white-space: pre-wrap;
    font-size: 13px;
    color: var(--ink);
}

/* ---------------- Nodes ----------------
   One calm card recipe for every node; the type reads from a colored
   accent bar on the left instead of a different background per node. */
.text-node,
.button-reply-node,
.list-reply-node,
.image-node,
.url-node,
.consumer-response-node,
.product-recommendation-node,
.integration-node,
.language-preference-node,
.sticker-node,
.default-q-address-node,
.default-q-email-node,
.default-q-name-node,
.question-language-preference-node,
.question-open-ended-node {
    background: var(--surface);
    border: 1px solid var(--line);
    border-left: 3px solid var(--muted);
    border-radius: var(--r-md);
    padding: 12px 14px;
    box-shadow: var(--shadow-sm);
    position: relative;
    color: var(--ink);
    transition:
        box-shadow 0.15s,
        border-color 0.15s;
}
.text-node:hover,
.button-reply-node:hover,
.list-reply-node:hover,
.image-node:hover,
.url-node:hover,
.consumer-response-node:hover,
.product-recommendation-node:hover,
.integration-node:hover,
.language-preference-node:hover,
.sticker-node:hover,
.question-open-ended-node:hover {
    box-shadow: var(--shadow-md);
}

/* category accents */
.text-node {
    border-left-color: var(--cat-text);
    min-width: 150px;
}
.button-reply-node,
.list-reply-node {
    border-left-color: var(--cat-selection);
}
.button-reply-node {
    min-width: 160px;
}
.list-reply-node {
    min-width: 250px;
}
.image-node,
.sticker-node {
    border-left-color: var(--cat-media);
}
.image-node {
    min-width: 150px;
}
.sticker-node {
    min-width: 130px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.url-node {
    border-left-color: var(--cat-navigation);
    min-width: 200px;
}
.consumer-response-node {
    border-left-color: var(--faint);
    min-width: 160px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.product-recommendation-node {
    border-left-color: var(--cat-navigation);
    min-width: 210px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}
.product-recommendation-node .product-recommendation-note {
    color: var(--muted);
    font-size: 11.5px;
    margin-top: 6px;
    max-width: 210px;
}
.default-q-address-node,
.default-q-email-node,
.default-q-name-node,
.question-open-ended-node,
.question-language-preference-node {
    border-left-color: var(--cat-input);
    min-width: 170px;
}
.integration-node {
    border-left-color: var(--teal);
    min-width: 300px;
    background: linear-gradient(
        180deg,
        rgba(7, 94, 84, 0.035),
        var(--surface) 60%
    );
}
.language-preference-node {
    border-left-color: #9c27b0;
    min-width: 300px;
    background: linear-gradient(
        180deg,
        rgba(156, 39, 176, 0.04),
        var(--surface) 60%
    );
}

.consumer-response-node select {
    width: 95%;
    margin-right: 5px;
}

/* ---------------- Chat-preview nodes ----------------
   Message nodes (withChatPreview in flow.jsx) are one card: a header tinted
   with the node's category colour, a slice of the customer's WhatsApp chat
   showing what they receive, then the node's own editor. Only the fallback
   reply gets a solid (teal) header, so it stands out on a busy canvas. */
.chat-node {
    --node-accent: var(--muted);
    position: relative;
    min-width: 280px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    color: var(--ink);
    transition:
        box-shadow 0.15s,
        border-color 0.15s;
}
.chat-node:hover {
    box-shadow: var(--shadow-md);
}
.chat-node.selected {
    border-color: var(--green);
    box-shadow:
        0 0 0 3px rgba(37, 211, 102, 0.22),
        var(--shadow-md);
}

/* category accents (same palette as the old left bars) */
.chat-node--text {
    --node-accent: var(--cat-text);
}
.chat-node--button-reply,
.chat-node--list-reply {
    --node-accent: var(--cat-selection);
}
.chat-node--default-q-name,
.chat-node--default-q-email,
.chat-node--default-q-address,
.chat-node--question-open-ended,
.chat-node--question-language-preference,
.chat-node--flow-reply {
    --node-accent: var(--cat-input);
}
.chat-node--image,
.chat-node--video,
.chat-node--sticker {
    --node-accent: var(--cat-media);
}
.chat-node--url {
    --node-accent: var(--cat-navigation);
}
.chat-node--authentication {
    --node-accent: var(--teal);
}

/* The wrapped node's root is now the card body: it keeps its padding and
   `position: relative` (per-button / per-row handles are offset from it)
   but drops its own card look. */
.chat-node > :last-child,
.chat-node > :last-child:hover,
.chat-node > :last-child.selected {
    border: 0;
    border-radius: 0;
    box-shadow: none;
    background: transparent;
}

/* Solid header like the fallback reply's. Each category colour is
   darkened 35% so white text keeps at least ~5:1 contrast (the raw amber,
   sky, pink and green are too light for it). */
.chat-node-header {
    display: flex;
    flex-direction: column;
    gap: 1px;
    /* right: room for the delete button */
    padding: 11px 40px 11px 14px;
    border-radius: calc(var(--r-md) - 1px) calc(var(--r-md) - 1px) 0 0;
    background: var(--teal-700);
    background: color-mix(in srgb, var(--node-accent) 65%, #000);
}
.chat-node-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 15px;
    line-height: 1.2;
    color: #fff;
}
.chat-node-subtitle {
    font-family: var(--font-ui);
    font-size: 12px;
    line-height: 1.35;
    color: rgba(255, 255, 255, 0.78);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.chat-node-subtitle.is-unnamed {
    color: rgba(255, 255, 255, 0.55);
}

/* the fallback reply: WhatsApp teal as-is (already dark), slightly larger */
.chat-node--fallback-message {
    border-color: var(--line-strong);
    box-shadow: var(--shadow-md);
}
.chat-node--fallback-message .chat-node-header {
    padding-top: 12px;
    background: var(--teal);
}
.chat-node--fallback-message .chat-node-title {
    font-size: 16px;
}
.chat-node--fallback-message .chat-node-subtitle {
    white-space: normal;
}

/* Bold / Italic / Underline as one segmented control, each label showing
   its own effect. !important beats the inline styles CommonTextArea puts on
   the buttons; the blast editor's copy has no .chat-node around it. */
.chat-node .text-format-toolbar {
    display: inline-flex;
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    overflow: hidden;
    background: var(--surface);
}
.chat-node .text-format-toolbar button {
    margin: 0 !important;
    padding: 4px 11px !important;
    font-family: var(--font-ui);
    font-size: 12px;
    line-height: 1.3;
    color: var(--ink);
    background: transparent;
    border: 0;
    border-right: 1px solid var(--line);
    border-radius: 0;
    cursor: pointer;
    transition:
        background 0.12s,
        color 0.12s;
}
.chat-node .text-format-toolbar button:last-child {
    border-right: 0;
}
.chat-node .text-format-toolbar button:hover {
    background: var(--surface-2);
    color: var(--teal);
}
.chat-node .text-format-toolbar button:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: -2px;
}
.chat-node .text-format-toolbar button:nth-child(1) {
    font-weight: 700;
}
.chat-node .text-format-toolbar button:nth-child(2) {
    font-style: italic;
}
.chat-node .text-format-toolbar button:nth-child(3) {
    text-decoration: underline;
}

/* ---------------- Group node ----------------
   A frame/zone, not a node: a quiet translucent dashed area whose identity
   collapses into one solid floating card pinned to its top-left corner. */
.group-node {
    --group-accent: var(--teal);
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    box-sizing: border-box;
    /* Workspace-zone texture: a faint accent dot-grid over a soft tint, with
       an inner hairline highlight to keep the edge crisp at any zoom. */
    background-color: rgba(7, 94, 84, 0.03);
    background-image: radial-gradient(
        rgba(7, 94, 84, 0.1) 1.1px,
        transparent 1.2px
    );
    background-size: 18px 18px;
    background-position: 9px 9px;
    border: 1px solid rgba(10, 113, 99, 0.28);
    border-radius: var(--r-lg);
    padding: 14px;
    transition:
        border-color 0.15s,
        box-shadow 0.15s,
        background-color 0.15s;
}
.group-node.selected {
    border-color: var(--teal) !important;
    box-shadow: 0 0 0 4px rgba(37, 211, 102, 0.12);
}

/* Default / seeded groups read as system presets — amber, not teal. */
.group-node.group-node-default {
    --group-accent: var(--amber);
    background-color: rgba(217, 138, 0, 0.04);
    background-image: radial-gradient(
        rgba(217, 138, 0, 0.12) 1.1px,
        transparent 1.2px
    );
    border-color: rgba(217, 138, 0, 0.34);
}
.group-node.group-node-default.selected {
    border-color: var(--amber) !important;
    box-shadow: 0 0 0 4px rgba(217, 138, 0, 0.14);
}

/* React Flow gives type="group" nodes a default dark border + grey fill on
   the wrapper. Our styled frame lives on the inner .group-node, so strip the
   wrapper's chrome to avoid a second, square black border behind it. */
.app-container .react-flow__node-group {
    border: none;
    background: transparent;
    border-radius: 0;
    padding: 0;
}
/* Selecting a group adds React Flow's default dark outline on the wrapper,
   which sits offset from our inner frame. Our green glow already marks the
   active state, so suppress the default outline. */
.app-container .react-flow__node-group.selected {
    box-shadow: none;
    outline: none;
}

/* NodeResizer draws its own outline + handles on the node wrapper, which
   doubled the group border. Hide the outline; reveal the corner handles on
   hover only, so a selected (active) group stays a single clean frame. */
.app-container .react-flow__resize-control.line {
    border-color: transparent;
}
.app-container .react-flow__resize-control.handle {
    width: 10px;
    height: 10px;
    border-radius: 3px;
    background: var(--surface);
    border: 1.5px solid var(--teal);
    opacity: 0;
    transition: opacity 0.15s;
}
.app-container .react-flow__node:hover .react-flow__resize-control.handle {
    opacity: 1;
}

/* Floating identity card */
.group-head {
    position: relative;
    width: clamp(220px, 100%, 332px);
    box-sizing: border-box;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    padding: 12px 14px 13px 16px;
    display: flex;
    flex-direction: column;
    gap: 9px;
}
/* category accent stripe (teal / amber) */
.group-head::before {
    content: "";
    position: absolute;
    left: 0;
    top: 14px;
    bottom: 14px;
    width: 3px;
    border-radius: 0 3px 3px 0;
    background: var(--group-accent);
}

.group-head-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}
.group-kicker {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.12em;
    text-transform: uppercase;
    color: var(--group-accent);
}

.group-dup-btn {
    flex: none;
    width: 28px;
    height: 28px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--r-sm);
    color: var(--muted);
    cursor: pointer;
    transition:
        color 0.15s,
        border-color 0.15s,
        background 0.15s;
}
.group-dup-btn:hover {
    color: var(--teal);
    border-color: var(--line-strong);
    background: var(--surface-2);
}
.group-dup-btn:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 1px;
}

/* Editable title — reads as a heading, becomes an input on hover/focus */
.group-node .group-title-input {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: 15px;
    line-height: 1.25;
    color: var(--ink);
    width: 100%;
    margin: 0 !important;
    padding: 4px 7px;
    background: transparent;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
}
.group-node .group-title-input:hover:not([readonly]) {
    border-color: var(--line);
}
.group-node .group-title-input:focus {
    border-color: var(--green);
    background: var(--surface);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.14);
}
.group-node .group-title-input[readonly] {
    cursor: default;
}

.group-id-chip {
    align-self: flex-start;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    font-size: 10.5px;
    color: var(--muted);
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-pill);
    padding: 2px 9px;
}

.group-blast {
    display: flex;
    flex-direction: column;
    gap: 7px;
    margin-top: 2px;
    padding-top: 11px;
    border-top: 1px solid var(--line);
}
.group-blast-head {
    font-size: 10.5px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--faint);
}
.group-blast-empty {
    margin: 0;
    font-size: 12px;
    line-height: 1.4;
    color: var(--muted);
}
.group-blast-row {
    display: grid;
    grid-template-columns: 1fr 1fr 30px;
    gap: 6px;
    align-items: center;
}
.group-node .group-blast-select {
    width: 100%;
    margin: 0;
    font-size: 12px;
    padding: 6px 8px;
}
.group-blast-remove {
    width: 30px;
    height: 31px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1px solid var(--line);
    background: var(--surface);
    border-radius: var(--r-sm);
    color: var(--faint);
    cursor: pointer;
    transition:
        color 0.15s,
        border-color 0.15s,
        background 0.15s;
}
.group-blast-remove:hover {
    color: var(--danger);
    border-color: rgba(209, 69, 59, 0.4);
    background: rgba(209, 69, 59, 0.06);
}
.group-blast-remove:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 1px;
}
.group-blast-add {
    width: 100%;
    margin-top: 2px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    color: var(--teal);
    background: transparent;
    border: 1px dashed var(--line-strong);
    border-radius: var(--r-sm);
    padding: 8px;
    cursor: pointer;
    transition:
        color 0.15s,
        border-color 0.15s,
        background 0.15s;
}
.group-blast-add:hover {
    color: var(--green-700);
    border-color: var(--green);
    background: rgba(37, 211, 102, 0.06);
}
.group-blast-add:focus-visible {
    outline: 2px solid var(--green);
    outline-offset: 1px;
}

/* selected — green focus ring (no border reflow) replaces the old red box */
.selected,
.text-node.selected,
.button-reply-node.selected,
.list-reply-node.selected,
.image-node.selected,
.url-node.selected,
.consumer-response-node.selected,
.integration-node.selected,
.sticker-node.selected,
.default-q-address-node.selected,
.default-q-email-node.selected,
.default-q-name-node.selected,
.question-open-ended-node.selected,
.question-language-preference-node.selected {
    border-color: var(--green);
    box-shadow:
        0 0 0 3px rgba(37, 211, 102, 0.22),
        var(--shadow-md);
}
.language-preference-node.selected {
    border-color: #7b1fa2;
    box-shadow:
        0 0 0 3px rgba(156, 39, 176, 0.25),
        var(--shadow-md);
}

/* ---------------- IF condition (diamond) ---------------- */
.if-condition-node {
    background: rgba(37, 211, 102, 0.12);
    border: 2px solid var(--green-700);
    border-radius: 0;
    transform: rotate(45deg);
    width: 150px;
    height: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 10px;
    position: relative;
    box-sizing: border-box;
    box-shadow: var(--shadow-sm);
}
.if-condition-node.selected {
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.22);
}
.if-condition-content {
    transform: rotate(-45deg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}
.if-condition-title {
    font-family: var(--font-display);
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 5px;
    text-align: center;
    color: var(--teal);
}
.if-condition-field {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 5px;
    width: 100%;
}
.if-condition-field div {
    font-size: 12px;
    margin-bottom: 2px;
}
.if-condition-input {
    width: 100px;
    font-size: 12px;
    padding: 4px 6px;
    text-align: center;
}
.if-condition-node .node-metadata-fields {
    margin-bottom: 5px;
}
.if-condition-node .metadata-item {
    margin-top: 0;
}
.if-condition-node .metadata-item div {
    font-size: 12px;
    text-align: center;
}
.if-condition-node .react-flow__handle {
    transform: rotate(-45deg);
}

.handle-label {
    position: absolute;
    font-size: 12px;
    color: var(--muted);
    max-width: 25px;
    white-space: nowrap;
    text-align: right;
}
.handle-label-true {
    right: -50px;
    top: -30px;
    transform: rotate(-45deg);
}
.handle-label-false {
    right: -50px;
    top: 140px;
    transform: rotate(-45deg);
}

/* ---------------- Edges & handles ----------------
   Connecting lines carry the brand green. Resting lines are calm and
   deep; hover lifts them; the active (selected) line animates a flow of
   marching ants from source to target so the live path is unmistakable. */
.react-flow__edge-path {
    stroke: var(--green-700);
    stroke-width: 2px;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition:
        stroke 0.15s,
        stroke-width 0.15s,
        filter 0.15s;
}
.react-flow__edge:hover .react-flow__edge-path {
    stroke: var(--green-600);
    stroke-width: 2.5px;
    filter: drop-shadow(0 0 4px rgba(37, 211, 102, 0.35));
}
.react-flow__edge.selected .react-flow__edge-path {
    stroke: var(--green);
    stroke-width: 3px;
    stroke-dasharray: 9 7;
    filter: drop-shadow(0 0 6px rgba(37, 211, 102, 0.6));
    animation: edge-flow 0.55s linear infinite;
}

/* the line being dragged from a handle — same living green */
.react-flow__connection-path {
    stroke: var(--green);
    stroke-width: 2.5px;
    stroke-linecap: round;
    stroke-dasharray: 9 7;
    animation: edge-flow 0.55s linear infinite;
}

/* negative offset = dashes travel forward; sum(dasharray)*2 loops seamlessly */
@keyframes edge-flow {
    to {
        stroke-dashoffset: -32;
    }
}

@media (prefers-reduced-motion: reduce) {
    .react-flow__edge.selected .react-flow__edge-path,
    .react-flow__connection-path {
        animation: none;
    }
}

.react-flow__handle {
    width: 11px;
    height: 11px;
    background: var(--teal);
    border: 2px solid #fff;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}
.react-flow__handle.source {
    background: var(--green-700);
}
.react-flow__handle.target {
    background: var(--teal);
}

.react-flow__controls {
    border-radius: var(--r-md);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    border: 1px solid var(--line);
}
.react-flow__controls-button {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    color: var(--ink);
}
.react-flow__controls-button:hover {
    background: var(--surface-2);
}

/* ---------------- Button / URL / list sub-items ---------------- */
.button-list {
    display: flex;
    flex-direction: column;
    width: 100%;
    margin-top: 8px;
}
.button-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-bottom: 6px;
    gap: 5px;
}
.button-item > div {
    min-width: 30px;
    text-align: left;
    margin-right: 5px;
    font-size: 12px;
    color: var(--muted);
}

.list-reply-container {
    margin-top: 10px;
}
.section-item {
    margin-bottom: 12px;
    padding: 10px;
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    background: var(--surface-2);
}
.row-item {
    margin-top: 6px;
    padding: 8px;
    border: 1px solid var(--line);
    border-radius: var(--r-sm);
    background: var(--surface);
}

/* ---------------- Buttons (add / delete / duplicate) ---------------- */
.add-button {
    margin-top: 6px;
    padding: 7px 13px;
    background: var(--green);
    color: #04231a;
    border: none;
    border-radius: var(--r-pill);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 12.5px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
    transition:
        background 0.15s,
        transform 0.08s;
}
.add-button:hover {
    background: var(--green-600);
}
.add-button:active {
    transform: translateY(1px);
}

.delete-button {
    margin-top: 6px;
    padding: 7px 13px;
    background: var(--surface);
    color: var(--danger);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 12.5px;
    cursor: pointer;
    transition:
        background 0.15s,
        border-color 0.15s;
}
.delete-button:hover {
    background: rgba(209, 69, 59, 0.08);
    border-color: var(--danger);
}

.duplicate-node-button {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--surface);
    color: var(--teal);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-pill);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 12px;
    white-space: nowrap;
    cursor: pointer;
    transition:
        background 0.15s,
        border-color 0.15s,
        color 0.15s,
        transform 0.08s;
}
.duplicate-node-button:hover {
    background: rgba(7, 94, 84, 0.08);
    border-color: var(--teal);
}
.duplicate-node-button:active {
    transform: translateY(1px);
}
.duplicate-node-button:hover {
    background: var(--teal-700);
}

/* ---------------- Metadata fields ---------------- */
.node-metadata-fields {
    display: flex;
    flex-direction: column;
    width: 100%;
}
.metadata-item {
    display: flex;
    flex-direction: row;
    align-items: center;
    margin-top: 6px;
    gap: 6px;
}
.inline-field {
    display: flex;
    align-items: center;
    gap: 6px;
}
.inline-field span {
    white-space: nowrap;
    font-size: 12px;
    color: var(--muted);
}

/* ---------------- Delete-node corner button ---------------- */
.node-wrapper {
    position: relative;
}
.delete-node-button {
    position: absolute;
    top: 6px;
    right: 6px;
    background: var(--surface);
    color: var(--muted);
    border: 1px solid var(--line-strong);
    border-radius: 50%;
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 12px;
    line-height: 1;
    z-index: 10;
    box-shadow: var(--shadow-sm);
    transition:
        background 0.12s,
        color 0.12s,
        border-color 0.12s;
}
.delete-node-button:hover {
    background: rgba(209, 69, 59, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}
.delete-node-button.group-delete-button {
    left: auto;
    right: 10px;
    top: 10px;
    background: var(--danger);
    color: #fff;
    border-color: var(--danger);
}
.delete-node-button.group-delete-button:hover {
    background: #b53a31;
    color: #fff;
    border-color: #b53a31;
}

/* ---------------- Configuration modal ----------------
   The cramped right sidebar became a centered dialog: credentials get room
   to breathe in an auto-fit field grid instead of a two-column table. */
.button-container .config-open-button {
    display: inline-flex;
    align-items: center;
    gap: 7px;
}
.button-container .config-open-button svg {
    color: var(--teal);
}
.button-container .config-open-button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ---- arrange undo bar ---- */
.app-container .arrange-undo-bar {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 18px;
    padding: 9px 10px 9px 16px;
    border-radius: var(--r-pill);
    background: var(--teal);
    color: #fff;
    font-family: var(--font-ui);
    font-size: 13px;
    box-shadow: var(--shadow-lg);
}
.arrange-undo-bar button {
    border: 0;
    background: transparent;
    color: #fff;
    font: inherit;
    cursor: pointer;
}
.arrange-undo-action {
    font-weight: 700;
    text-decoration: underline;
    text-underline-offset: 3px;
}
.arrange-undo-dismiss {
    width: 26px;
    height: 26px;
    border-radius: 50%;
    opacity: 0.8;
}
.arrange-undo-dismiss:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.14);
}
.arrange-undo-bar button:focus-visible {
    outline: 2px solid #fff;
    outline-offset: 2px;
}

.config-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: rgba(7, 20, 17, 0.55);
    backdrop-filter: blur(2px);
    animation: config-overlay-in 0.16s ease;
}
.config-modal {
    display: flex;
    flex-direction: column;
    width: min(900px, 94vw);
    max-height: 90vh;
    background: var(--surface);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: config-modal-in 0.18s ease;
}
@keyframes config-overlay-in {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}
@keyframes config-modal-in {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.985);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.config-modal-head {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    padding: 18px 22px;
    border-bottom: 1px solid var(--line);
}
.config-modal-eyebrow {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--green-700);
}
.config-modal-title {
    margin: 2px 0 0;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 22px;
    color: var(--ink);
}
.config-modal-close {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    background: var(--surface);
    color: var(--muted);
    cursor: pointer;
    transition:
        background 0.12s,
        color 0.12s,
        border-color 0.12s;
}
.config-modal-close:hover {
    background: rgba(209, 69, 59, 0.1);
    color: var(--danger);
    border-color: var(--danger);
}

.config-modal-body {
    flex: 1;
    overflow-y: auto;
    padding: 22px;
    display: flex;
    flex-direction: column;
    gap: 26px;
}
/* SweetAlert dialogs must sit above the modals (overlay z-index 2000). */
.swal2-container {
    z-index: 10000 !important;
}

/* Preview banner (shown while viewing a past version) */
.version-preview-banner {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    flex-wrap: wrap;
    padding: 10px 16px;
    background: #fef3c7;
    border-bottom: 1px solid #f59e0b;
    color: #92400e;
    font-weight: 600;
    z-index: 120;
}
.version-preview-actions {
    display: flex;
    gap: 8px;
}
.version-preview-restore,
.version-preview-exit {
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    cursor: pointer;
    font-weight: 600;
}
.version-preview-restore {
    background: #007bff;
    color: #fff;
}
.version-preview-exit {
    background: #fff;
    color: #92400e;
    border: 1px solid #f59e0b;
}

/* Version history modal */
.version-actions {
    display: flex;
    gap: 8px;
    flex: none;
}
.version-preview-btn {
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    padding: 6px 12px;
    background: #fff;
    color: #111827;
    cursor: pointer;
}
.version-list {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.version-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 10px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: #fff;
}
.version-meta {
    display: flex;
    align-items: baseline;
    gap: 10px;
    min-width: 0;
    flex-wrap: wrap;
}
.version-number {
    font-weight: 600;
    color: #6b7280;
}
.version-date {
    font-weight: 500;
    color: #111827;
}
.version-editor {
    color: #6b7280;
    font-size: 13px;
}
.version-restore-btn {
    flex: none;
    border: none;
    border-radius: 6px;
    padding: 6px 12px;
    background: #007bff;
    color: #fff;
    cursor: pointer;
}
.version-restore-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
}

.config-modal-foot {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 22px;
    border-top: 1px solid var(--line);
    background: var(--surface-2);
}
.config-modal-done {
    padding: 9px 22px;
    background: var(--green);
    color: #04231a;
    border: none;
    border-radius: var(--r-pill);
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 13.5px;
    cursor: pointer;
    box-shadow: 0 2px 8px rgba(37, 211, 102, 0.3);
    transition:
        background 0.15s,
        transform 0.08s;
}
.config-modal-done:hover {
    background: var(--green-600);
}
.config-modal-done:active {
    transform: translateY(1px);
}

/* ---- config form ---- */
.config-section-title,
.config-modal-body .variable-table-container h3 {
    margin: 0 0 14px;
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.09em;
    color: var(--faint);
}
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px 18px;
}
.config-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
    min-width: 0;
}
.config-field--wide {
    grid-column: 1 / -1;
}

.config-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-family: var(--font-ui);
    font-size: 12px;
    font-weight: 600;
    color: var(--ink);
}
.config-info {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px;
    height: 15px;
    border-radius: 50%;
    border: 1px solid var(--line-strong);
    font-size: 10px;
    font-weight: 700;
    color: var(--faint);
    cursor: help;
}
.config-input {
    width: 100%;
    padding: 9px 11px;
    font-family: var(--font-ui);
    font-size: 13.5px;
    color: var(--ink);
    background: var(--surface);
    border: 1px solid var(--line-strong);
    border-radius: var(--r-sm);
    box-sizing: border-box;
    transition:
        border-color 0.15s,
        box-shadow 0.15s;
}
.config-input:focus {
    outline: none;
    border-color: var(--green);
    box-shadow: 0 0 0 3px rgba(37, 211, 102, 0.14);
}
.config-datepicker {
    width: 100%;
    display: block;
}
.react-datepicker-popper {
    z-index: 3000 !important;
}

.config-field--checkbox {
    padding: 12px 14px;
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
}
.config-check {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-ui);
    font-size: 13px;
    font-weight: 500;
    color: var(--ink);
    cursor: pointer;
}
.config-check input[type="checkbox"] {
    flex: none;
    width: 17px;
    height: 17px;
    accent-color: var(--green);
    cursor: pointer;
}
.config-shortlink-actions {
    display: flex;
    gap: 8px;
    margin-top: 16px;
}

@media (prefers-reduced-motion: reduce) {
    .config-modal-overlay,
    .config-modal {
        animation: none;
    }
}

/* ---- connect-to-node picker ---- */
.config-modal.is-sm {
    width: min(440px, 94vw);
}
.connect-search {
    margin-bottom: 4px;
}
.connect-empty {
    margin: 8px 2px;
    font-size: 13px;
    color: var(--muted);
    line-height: 1.45;
}
.connect-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.connect-item {
    display: flex;
    align-items: center;
    gap: 11px;
    width: 100%;
    text-align: left;
    padding: 9px 11px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
    transition:
        background 0.12s,
        border-color 0.12s;
}
.connect-item:hover {
    background: var(--surface-2);
    border-color: var(--line-strong);
}
.connect-dot {
    flex: none;
    width: 9px;
    height: 9px;
    border-radius: 50%;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.04);
}
.connect-item-text {
    display: flex;
    flex-direction: column;
    gap: 1px;
    min-width: 0;
}
.connect-item-name {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 13px;
    color: var(--ink);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.connect-item-meta {
    font-size: 11px;
    color: var(--faint);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ---- group lookup modal ---- */
.group-lookup-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 50vh;
    overflow-y: auto;
    margin-top: 8px;
}
.group-lookup-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 11px;
    width: 100%;
    text-align: left;
    padding: 9px 11px;
    border: 1px solid transparent;
    border-radius: var(--r-sm);
    background: var(--surface);
    cursor: pointer;
    transition:
        background 0.12s,
        border-color 0.12s;
}
.group-lookup-item:hover {
    background: var(--surface-2);
    border-color: var(--line-strong);
}
.group-lookup-item-name {
    font-family: var(--font-ui);
    font-weight: 600;
    font-size: 13px;
    color: var(--ink);
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.group-lookup-item-id {
    flex: none;
    font-size: 11px;
    color: var(--faint);
}

/* Constraint note on a seeded group whose runtime contract is narrower than
   the canvas allows (currently only "Default Agent Node"). */
.group-note {
    margin: 8px 0 0;
    padding: 7px 9px;
    border-left: 3px solid #e0a800;
    border-radius: 3px;
    background: #fff8e6;
    font-size: 11.5px;
    line-height: 1.45;
    color: #6b5200;
}
/* fallback reply, pinned first; same chat wallpaper as its node */
.group-lookup-item--pinned {
    background: #efeae2;
}
.group-lookup-item--pinned:hover {
    background: #e6e0d6;
}
.group-lookup-item--pinned .group-lookup-item-name {
    flex: none;
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--teal);
}
.group-lookup-item-preview {
    min-width: 0;
    font-size: 12px;
    color: var(--muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
