/* ============================================================
   ShivX Flow Builder — Canvas & Node Styles
   Meta / WhatsApp-style visual flow builder
   ============================================================ */

/* ── Layout shell ────────────────────────────────────────── */
.fb-topbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    height: 50px;
    background: #1a1a2e;
    color: #fff;
    border-bottom: 1px solid #2d2d4e;
    position: sticky;
    top: 0;
    z-index: 200;
    flex-wrap: nowrap;
}

.fb-flow-name {
    font-weight: 600;
    font-size: 14px;
    color: #fff;
    background: transparent;
    border: 1px solid transparent;
    border-radius: 6px;
    padding: 3px 8px;
    max-width: 260px;
    transition: border-color .15s;
}
.fb-flow-name:hover,
.fb-flow-name:focus { border-color: #4a4a7a; background: rgba(255,255,255,.05); outline: none; }

.fb-shell {
    display: flex;
    height: calc(100vh - 50px);
    overflow: hidden;
}

/* ── Left palette ────────────────────────────────────────── */
.fb-palette {
    width: 230px;
    flex-shrink: 0;
    background: #fff;
    border-right: 1px solid #e0e0e0;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
}

.pal-section { border-bottom: 1px solid #f0f0f0; }

.pal-hdr {
    padding: 8px 14px 6px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .6px;
    color: #6c757d;
    background: #fafafa;
    border-bottom: 1px solid #f0f0f0;
    position: sticky;
    top: 0;
    z-index: 1;
}

.pal-node {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 14px;
    font-size: 12.5px;
    cursor: grab;
    border-bottom: 1px solid #f8f8f8;
    transition: background .1s;
    user-select: none;
    color: #222;
}
.pal-node:hover { background: #f0f8ff; }
.pal-node:active { cursor: grabbing; }
.pal-node .pal-dot {
    width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0;
}
.pal-node.pal-disabled { opacity: .4; cursor: not-allowed; }
.pal-node.pal-disabled:hover { background: transparent; }

/* ── Canvas ──────────────────────────────────────────────── */
.fb-canvas-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    background: #f0f2f5;
}

#drawflow-canvas {
    width: 100%;
    height: 100%;
    background: #f0f2f5;
    background-image:
        radial-gradient(circle, #d0d0d8 1px, transparent 1px);
    background-size: 22px 22px;
}

.fb-empty-hint {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    pointer-events: none;
    color: #9ba3af;
}
.fb-empty-hint i { font-size: 40px; display: block; margin-bottom: 10px; }
.fb-empty-hint p { font-size: 14px; margin: 0; }

/* ── Loading overlay ─────────────────────────────────────── */
.fb-loading-overlay {
    position: absolute; inset: 0;
    display: flex; align-items: center; justify-content: center;
    background: rgba(240,242,245,.85);
    z-index: 500;
}

/* ── MiniFlow / Drawflow node overrides (Meta-style) ─────── */
.drawflow { position: relative; overflow: hidden; }

.drawflow .drawflow-node {
    padding: 0 !important;
    background: transparent !important;
    border: 1.5px solid transparent !important;
    border-radius: 10px !important;
    box-shadow: 0 2px 10px rgba(0,0,0,.13) !important;
    width: 230px !important;          /* fixed width — position:absolute ignores min-width */
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    cursor: move;
}
.drawflow .drawflow-node.selected {
    border-color: #0d6efd !important;
    box-shadow: 0 0 0 2px #0d6efd55, 0 4px 14px rgba(0,0,0,.18) !important;
}
.drawflow .drawflow-node .drawflow_content_node {
    padding: 0 !important;
    width: 100%;
}

/* ── Port containers — positioned on left/right edges ────── */
.drawflow .drawflow-node .inputs {
    position: absolute;
    left: -7px;
    top: 0; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    z-index: 2;
}
.drawflow .drawflow-node .outputs {
    position: absolute;
    right: -7px;
    top: 0; height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 6px;
    z-index: 2;
}

/* ── Individual port circles ─────────────────────────────── */
.drawflow .drawflow-node .input,
.drawflow .drawflow-node .output {
    display: block;
    background: #fff !important;
    border: 2px solid #9ca3af !important;
    border-radius: 50% !important;
    width: 14px !important;
    height: 14px !important;
    cursor: crosshair;
    transition: transform .1s, background .1s, border-color .1s;
}
.drawflow .drawflow-node .input:hover,
.drawflow .drawflow-node .output:hover {
    background: #0d6efd !important;
    border-color: #0d6efd !important;
    transform: scale(1.35);
}
/* Trigger nodes: hide input port; End nodes: hide output */
.drawflow .dfn-cat-trigger .inputs { display: none !important; }
.drawflow .dfn-cat-flow_end .outputs { display: none !important; }

/* ── Node inner card ─────────────────────────────────────── */
.dfn-inner {
    border-radius: 9px;
    overflow: hidden;
    background: #fff;
    width: 100%;
}

.dfn-hdr {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 11px;
    color: #fff;
}
.dfn-icon { font-size: 14px; flex-shrink: 0; }
.dfn-title { font-weight: 600; font-size: 12.5px; flex: 1; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.dfn-off { font-size: 9px; background: rgba(0,0,0,.25); border-radius: 4px; padding: 1px 5px; }

.dfn-prev {
    padding: 7px 11px 9px;
    font-size: 11.5px;
    color: #444;
    line-height: 1.45;
    border-top: 1px solid rgba(0,0,0,.06);
    word-break: break-word;
}
.dfn-prev em { color: #9ca3af; font-style: normal; }
.dfn-prev code { background: #f0f0f0; border-radius: 3px; padding: 0 3px; font-size: 11px; }
.dfn-pill {
    display: inline-block;
    background: #e8f5e9;
    color: #1b5e20;
    border-radius: 10px;
    padding: 1px 7px;
    font-size: 11px;
    margin: 1px 1px 1px 0;
    border: 1px solid #a5d6a7;
}

.dfn-out-row {
    display: flex;
    justify-content: space-between;
    padding: 5px 10px 7px;
    border-top: 1px solid #f0f0f0;
    background: #fafafa;
}
.dfn-out-badge {
    font-size: 10px;
    font-weight: 600;
    border-radius: 8px;
    padding: 2px 8px;
    background: #f0f0f0;
    color: #555;
}
.dfn-yes { background: #dcfce7; color: #16a34a; }
.dfn-no  { background: #fee2e2; color: #dc2626; }

/* ── Right config panel ──────────────────────────────────── */
.fb-cfg {
    width: 0;
    flex-shrink: 0;
    overflow: hidden;
    background: #fff;
    border-left: 1px solid #e0e0e0;
    transition: width .2s ease;
    display: flex;
    flex-direction: column;
}
.fb-cfg.fb-cfg-open { width: 295px; overflow-y: auto; overflow-x: hidden; }

.cfg-hdr {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 12px 14px;
    color: #fff;
    flex-shrink: 0;
}
.cfg-hdr-icon { font-size: 16px; }
.cfg-hdr-title { font-weight: 600; font-size: 13px; flex: 1; }
.cfg-close { background: none; border: none; color: rgba(255,255,255,.7); cursor: pointer; padding: 2px; }
.cfg-close:hover { color: #fff; }

.cfg-body { flex: 1; overflow-y: auto; }
.cfg-section { padding: 12px 14px; border-bottom: 1px solid #f4f4f4; }
.cfg-label {
    display: block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .5px;
    color: #6c757d;
    margin-bottom: 5px;
    text-transform: uppercase;
}
.cfg-hint { font-size: 11px; color: #9ca3af; margin-top: 4px; }

.cfg-delete-row { padding: 14px; }
.cfg-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: #9ca3af;
    padding: 20px;
    text-align: center;
    font-size: 13px;
}
.cfg-empty i { font-size: 32px; margin-bottom: 8px; }

/* Form controls inside config */
.fb-cfg .form-control,
.fb-cfg .form-select { font-size: 12.5px; }

/* Active toggle */
.fb-active-toggle { display: flex; align-items: center; gap: 6px; cursor: pointer; }
.fb-active-toggle input { cursor: pointer; }

/* Toolbar badges */
.fb-badge {
    font-size: 11px;
    padding: 3px 9px;
    border-radius: 12px;
    font-weight: 600;
}
