/*
 * Lo stile della simulazione di Beacon Studio, sopra la base comune di platform/shell.css. Misure e
 * colori da src/beacon/Corellix.Beacon.Studio: index.css (le variabili --bs-*), App.tsx (le tre
 * barre), CategoryRail.tsx, ConnectorPanel.tsx, TopNav.tsx, FlowNode.tsx e DeletableEdge.tsx.
 */

#bs-app { height: 100%; }

:root {
    --bs-app-bg: #EEF0F3;
    --bs-surface: #FFFFFF;
    --bs-border: #D0D5DD;
    --bs-text: #111827;
    --bs-text-muted: #9CA3AF;
    --bs-text-subtle: #6B7280;
    --bs-handle-border: #D1D5DB;
}
.dark {
    --bs-app-bg: #030712;
    --bs-surface: #111827;
    --bs-border: #1F2937;
    --bs-text: #F3F4F6;
    --bs-text-muted: #9CA3AF;
    --bs-text-subtle: #9CA3AF;
    --bs-handle-border: #374151;
}

/* ---------------------------------------------------------------- rail delle categorie */
.bs-rail { display: flex; flex-direction: column; flex-shrink: 0; width: 76px; background: var(--rail); }
.bs-rail-logo { display: flex; justify-content: center; padding: 12px 0 16px; }
.bs-rail-nav { display: flex; flex: 1; flex-direction: column; gap: 4px; min-height: 0; overflow-y: auto; padding: 4px 8px 12px; }
.bs-cat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    gap: 4px;
    width: 100%;
    padding: 9px 4px;
    border-radius: 3px;
    color: #94A3B8;
    transition: background-color 0.15s, color 0.15s;
}
.bs-cat:hover { color: #E2E8F0; background: rgba(255, 255, 255, 0.05); }
.bs-cat.on { background: var(--accent); color: #fff; }
.bs-cat span { font-size: 9.5px; font-weight: 500; line-height: 1.15; text-align: center; }
.bs-avatar { display: flex; justify-content: center; padding: 10px 8px; border-top: 1px solid rgba(255, 255, 255, 0.08); }
.bs-avatar span { display: flex; align-items: center; justify-content: center; width: 36px; height: 36px; border-radius: 3px; background: var(--accent); color: #fff; font-size: 12px; font-weight: 600; }

/* ---------------------------------------------------------------- pannello dei connettori */
.bs-cpanel { display: flex; flex-direction: column; flex-shrink: 0; width: 224px; background: var(--surface); border-right: 1px solid var(--line); }
.bs-cp-head { display: flex; align-items: center; flex-shrink: 0; gap: 9px; height: 56px; padding: 0 12px 0 18px; border-bottom: 1px solid var(--line); }
.bs-cp-title { font-size: 15px; font-weight: 600; }
.bs-count { padding: 2px 9px; border-radius: 999px; background: var(--line-soft); color: var(--muted); font-size: 11px; font-weight: 600; }
.dark .bs-count { background: #1F2937; }
.bs-search { display: flex; align-items: center; gap: 8px; margin: 12px 14px 8px; padding: 0 10px; border: 1px solid var(--line); border-radius: 3px; background: var(--line-soft); color: var(--faint); }
.dark .bs-search { background: #1F2937; border-color: #374151; }
.bs-search input { flex: 1; min-width: 0; padding: 9px 0; border: 0; background: transparent; color: var(--ink); font-size: 12.5px; }
.bs-search input::placeholder { color: var(--faint); }
.bs-cp-list { flex: 1; min-height: 0; overflow-y: auto; padding: 2px 10px 14px; }
.bs-conn { margin-bottom: 2px; }
.bs-conn-row { display: flex; align-items: center; gap: 10px; width: 100%; padding: 9px 10px; border-radius: 3px; text-align: left; }
.bs-conn-row:hover { background: var(--surface-2); }
.bs-conn-row.open { background: var(--line-soft); }
.dark .bs-conn-row.open { background: #1F2937; }
.bs-conn-row .grow { display: flex; flex-direction: column; gap: 2px; }
.bs-conn-tile { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 30px; height: 30px; border-radius: 3px; background: color-mix(in srgb, var(--acc) 10%, transparent); color: var(--acc); }
.bs-conn-row.open .bs-conn-tile { background: var(--acc); color: #fff; }
.bs-conn-name { display: block; font-size: 13.5px; font-weight: 600; line-height: 1.25; }
.bs-conn-cat { display: block; color: var(--faint); font-size: 10px; font-weight: 500; letter-spacing: 0.02em; }
.bs-conn-n { flex-shrink: 0; padding: 1px 6px; border: 1px solid var(--line-soft); border-radius: 3px; background: var(--surface-2); color: var(--faint); font-size: 10px; }
.bs-chev { color: var(--faint); transition: transform 0.15s; }
.bs-conn-row.open .bs-chev { transform: rotate(90deg); }
.bs-comps { display: flex; flex-direction: column; gap: 1px; margin: 2px 0 8px 15px; padding-left: 15px; border-left: 1.5px solid var(--line); }
.bs-comp { display: flex; align-items: center; gap: 9px; padding: 7px 9px; border-radius: 3px; color: var(--ink-2); font-size: 12.5px; font-weight: 500; cursor: grab; user-select: none; }
.bs-comp:hover { background: var(--surface-2); }
.bs-comp svg { color: var(--acc); }
.bs-comp-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--acc); flex-shrink: 0; }
.bs-comp-none { padding: 7px 9px; color: var(--faint); font-size: 11.5px; }
.bs-cp-foot { display: flex; align-items: center; justify-content: center; flex-shrink: 0; height: 56px; border-top: 1px solid var(--line); color: var(--faint); font-size: 11px; }

/* ---------------------------------------------------------------- le tre barre */
.bs-bar1 { position: relative; display: flex; align-items: center; flex-shrink: 0; gap: 16px; height: 56px; padding: 0 22px; background: var(--surface); border-bottom: 1px solid var(--line); }
.bs-menu { display: none; }
.bs-title { min-width: 120px; overflow: hidden; }
.bs-eyebrow { color: var(--bs-text-muted); font-size: 10px; font-weight: 600; letter-spacing: 0.14em; line-height: 1.3; text-transform: uppercase; }
.bs-title-row { gap: 8px; min-width: 0; }
.bs-flow-name { width: 220px; max-width: 100%; min-width: 0; padding: 0; border: 0; background: transparent; color: var(--bs-text); font-size: 15px; font-weight: 600; letter-spacing: -0.01em; }
.bs-view-title { color: var(--bs-text); font-size: 15px; font-weight: 600; }
.bs-status { flex-shrink: 0; padding: 4px 8px; border-radius: 3px; font-size: 12px; white-space: nowrap; }
.bs-status.gray { background: #D0D5DD; color: #4B5563; }
.bs-status.green { background: #D1FAE5; color: #047857; }
.bs-status.amber { background: #FEF3C7; color: #B45309; }
.bs-status.red { background: #FEE2E2; color: #B91C1C; }
.dark .bs-status.gray { background: #1F2937; color: #D1D5DB; }
.dark .bs-status.green { background: rgba(2, 44, 34, 0.5); color: #6EE7B7; }
.dark .bs-status.amber { background: rgba(69, 26, 3, 0.5); color: #FCD34D; }
.bs-tenant { position: absolute; left: 50%; top: 0; display: flex; align-items: center; height: 56px; transform: translateX(-50%); }
.bs-tenant-pill { display: flex; align-items: center; gap: 8px; padding: 7px 15px; border: 1px solid var(--bs-border); border-radius: 999px; background: var(--surface); box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06); font-size: 13px; white-space: nowrap; }
.bs-tenant-pill svg { color: var(--bs-text-muted); }
.bs-tenant-pill strong { color: var(--p-ink-soft); font-weight: 600; }
.bs-global { flex-shrink: 0; gap: 11px; }
.bs-theme { display: flex; gap: 2px; padding: 2px; border-radius: 3px; background: var(--line-soft); }
.dark .bs-theme { background: #1F2937; }
.bs-theme button { padding: 6px; border-radius: 3px; color: var(--faint); }
.bs-theme button.on { background: var(--surface); box-shadow: 0 1px 2px rgba(15, 23, 42, 0.12); }
.dark .bs-theme button.on { background: #374151; }
.bs-theme button.sun { color: #EAB308; }
.bs-theme button.moon { color: var(--p300); }
.bs-logout { display: flex; align-items: center; justify-content: center; width: 38px; height: 38px; border: 1px solid var(--bs-border); border-radius: 3px; color: var(--ink-3); }
.bs-logout:hover { border-color: #FCA5A5; background: #FEF2F2; color: #DC2626; }

.bs-bar2, .bs-bar3 { display: flex; align-items: center; flex-shrink: 0; gap: 8px; overflow-x: auto; padding: 0 16px; background: var(--surface); border-bottom: 1px solid var(--line); white-space: nowrap; }
.bs-bar2 { height: 50px; }
.bs-bar3 { height: 48px; }
.bs-topnav { display: flex; align-items: center; gap: 3px; }
.bs-tn { display: flex; align-items: center; gap: 6px; padding: 7px 10px; border-radius: 3px; color: var(--muted); font-size: 11.5px; font-weight: 500; line-height: 1; }
.bs-tn:hover { color: var(--ink); background: var(--line-soft); }
.dark .bs-tn:hover { background: rgba(255, 255, 255, 0.05); }
.bs-tn.on { background: var(--accent); color: #fff; font-weight: 600; }
.bs-btn { height: 34px; font-size: 12.5px; }
.bs-vsep { width: 1px; height: 20px; flex-shrink: 0; background: var(--bs-border); }
.bs-picker { display: inline-flex; align-items: center; gap: 6px; flex-shrink: 0; height: 30px; padding: 0 10px; border: 1px solid var(--input-line); border-radius: 3px; color: var(--muted); font-size: 12px; }
.bs-picker b { color: var(--ink-2); font-weight: 600; }
.bs-counts { flex-shrink: 0; color: var(--bs-text-muted); font-size: 11px; }

/* ---------------------------------------------------------------- tela */
.bs-body { position: relative; display: flex; flex: 1; min-height: 0; }
.bs-body:not(.editor) .bs-canvas { display: none; }
.bs-view { flex: 1; min-width: 0; overflow-y: auto; }
.bs-body.editor .bs-view { display: none; }
.bs-canvas {
    position: relative;
    flex: 1;
    min-width: 0;
    overflow: hidden;
    background-color: var(--bs-app-bg);
    background-image: radial-gradient(circle, var(--bs-border) 1.1px, transparent 1.2px);
    cursor: grab;
    touch-action: none;
}
.bs-world { position: absolute; left: 0; top: 0; transform-origin: 0 0; }
.bs-world.glide { transition: transform 0.45s cubic-bezier(0.4, 0, 0.2, 1); }
.bs-edges { position: absolute; left: 0; top: 0; overflow: visible; pointer-events: none; }
.bs-edge { fill: none; stroke: #C4CEDB; stroke-width: 1.8; vector-effect: non-scaling-stroke; }
.dark .bs-edge { stroke: #4B5563; }
.bs-edge.err { stroke: #DC2626; }
.bs-edge.wire { stroke: var(--accent); stroke-dasharray: 5 4; }
.bs-edge.live { stroke: var(--accent); stroke-width: 2.4; stroke-dasharray: 7 5; animation: bs-flow 0.6s linear infinite; }
.dark .bs-edge.live { stroke: #8FA3DB; }
.bs-edge.draw { stroke-dasharray: 600; stroke-dashoffset: 600; animation: bs-draw 0.6s ease forwards; }
@keyframes bs-flow { to { stroke-dashoffset: -12; } }
@keyframes bs-draw { to { stroke-dashoffset: 0; } }
.bs-spot { position: absolute; width: 2px; height: 2px; pointer-events: none; }

.bs-node {
    position: absolute;
    width: 248px;
    background: var(--bs-surface);
    border: 1px solid var(--bs-border);
    border-radius: 4px;
    box-shadow: 0 8px 22px -14px rgba(15, 23, 42, 0.32);
    cursor: pointer;
    transition: box-shadow 0.15s, border-color 0.15s;
    user-select: none;
}
.bs-node:hover { box-shadow: 0 10px 24px -14px rgba(15, 23, 42, 0.45); }
.bs-node.sel { border-color: var(--acc); box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 15%, transparent), 0 10px 26px -14px rgba(15, 23, 42, 0.4); }
.bs-node.running { border-color: var(--acc); animation: bs-glow 0.9s ease-in-out infinite; }
@keyframes bs-glow {
    0%, 100% { box-shadow: 0 0 0 3px color-mix(in srgb, var(--acc) 12%, transparent); }
    50% { box-shadow: 0 0 0 7px color-mix(in srgb, var(--acc) 22%, transparent); }
}
.bs-trigger-bar { position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: 4px 0 0 4px; background: var(--acc); }
.bs-node-body { display: flex; align-items: center; gap: 12px; padding: 13px 14px; }
.bs-tile { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 44px; height: 44px; border-radius: 13px; background: var(--acc); color: #fff; box-shadow: 0 4px 10px -4px color-mix(in srgb, var(--acc) 50%, transparent); }
.bs-tile.round { border-radius: 22px; }
.bs-node-title { color: var(--bs-text); font-size: 13.5px; font-weight: 650; letter-spacing: -0.01em; }
.bs-node-sub { margin-top: 2px; color: var(--bs-text-muted); font-size: 11.5px; }
.bs-node-sub .mono { font-size: 10.5px; }
.bs-dotsep { opacity: 0.5; }
.bs-node-spin { color: var(--acc); }
.bs-badge { position: absolute; top: -7px; right: -7px; z-index: 2; display: flex; border-radius: 50%; background: var(--bs-surface); }
.bs-badge.ok { color: #10B981; }
.bs-badge.bad { color: #EF4444; }
.bs-h { position: absolute; z-index: 1; width: 10px; height: 10px; border: 2px solid var(--bs-handle-border); border-radius: 50%; background: var(--bs-surface); }
.bs-h-tgt { left: -6px; top: 50%; margin-top: -5px; }
.bs-h-src { right: -6px; margin-top: -5px; border-color: var(--acc); cursor: crosshair; }
.bs-h-err { right: -5px; top: 68%; width: 8px; height: 8px; margin-top: -4px; border-color: #DC2626; cursor: crosshair; }

.bs-empty { position: absolute; left: 50%; top: 50%; display: flex; flex-direction: column; align-items: center; gap: 8px; max-width: 280px; color: var(--bs-text-subtle); font-size: 13px; text-align: center; transform: translate(-50%, -50%); pointer-events: none; }
.bs-empty p { margin: 0; }
.bs-zoom { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; overflow: hidden; border: 1px solid var(--bs-border); border-radius: 3px; background: var(--surface); box-shadow: 0 4px 14px -8px rgba(15, 23, 42, 0.3); }
.bs-zoom button { width: 36px; height: 34px; color: var(--ink-3); font-size: 18px; }
.bs-zoom button:hover { background: var(--line-soft); }
.bs-zoom span { height: 1px; background: var(--line-soft); }

.bs-ghost { display: inline-flex; align-items: center; gap: 6px; padding: 5px 9px; border: 1px solid var(--line); border-left: 3px solid var(--acc); border-radius: 3px; background: var(--surface); box-shadow: var(--shadow); color: var(--ink-2); font-size: 12px; font-weight: 500; }
.bs-ghost svg { color: var(--acc); }

/* ---------------------------------------------------------------- il pannello del nodo */
.bs-side { display: flex; flex-direction: column; flex-shrink: 0; width: 320px; min-height: 0; background: var(--surface); border-left: 1px solid var(--bs-border); }
.bs-side-head { display: flex; align-items: center; flex-shrink: 0; gap: 8px; height: 56px; padding: 0 16px; border-bottom: 1px solid var(--bs-border); }
.bs-side-title { flex: 1; color: var(--bs-text-subtle); font-size: 11px; font-weight: 600; letter-spacing: 0.12em; text-transform: uppercase; }
.bs-side-form { max-height: 55%; overflow-y: auto; padding: 16px; }
.bs-node-label { margin: 0 0 12px; color: var(--bs-text); font-size: 13px; font-weight: 600; }
.bs-field { display: block; margin-bottom: 12px; }
.bs-label { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 4px; color: var(--ink-3); font-size: 12px; font-weight: 500; }
.bs-label > span { display: inline-flex; align-items: center; gap: 4px; }
.bs-label em { margin-left: 2px; color: #EF4444; font-style: normal; }
.bs-map { color: var(--faint); }
.bs-field .input { height: 32px; font-size: 12.5px; }
.bs-area { height: 78px !important; padding: 6px 8px; resize: vertical; font-size: 11px !important; line-height: 1.4; }
.bs-secret { display: flex; align-items: center; gap: 6px; padding: 7px 8px; border: 1px dashed var(--input-line); border-radius: 3px; color: var(--muted); font-size: 10.5px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.bs-check { display: flex; align-items: center; gap: 8px; margin-bottom: 12px; color: var(--ink-3); font-size: 12px; }
.bs-applied { margin: 4px 0 0; color: #059669; font-size: 11px; }
.bs-retry { margin-top: 4px; border-top: 1px solid var(--line-soft); padding-top: 8px; }
.bs-retry summary { margin-bottom: 8px; color: var(--ink-3); font-size: 12px; font-weight: 600; cursor: pointer; }
.bs-grid2 { display: grid; grid-template-columns: 1fr 1fr; gap: 0 10px; }
.bs-side-runs { display: flex; flex: 1; flex-direction: column; min-height: 0; border-top: 1px solid var(--line-soft); }
.bs-tabs { padding: 12px 12px 0; }
.bs-runs { flex: 1; min-height: 0; overflow-y: auto; font-size: 12px; }
.bs-pad { padding: 12px; }
.bs-run { border-bottom: 1px solid var(--line); }
.bs-run-row { display: flex; align-items: center; gap: 8px; width: 100%; padding: 8px 12px; text-align: left; }
.bs-run-row:hover { background: var(--surface-2); }
.bs-run-log { padding: 0 12px 8px 32px; }
.bs-run-log > * + * { margin-top: 4px; }
.bs-log-row { display: flex; align-items: center; gap: 8px; }
.bs-log-row.click { cursor: pointer; }
.bs-log-row.click:hover .mono { text-decoration: underline; }
.bs-ok { color: #10B981; }
.bs-bad { color: #EF4444; }
.bs-wait { color: #F59E0B; }
.bs-sample { max-height: 200px; margin: 4px 0 4px 20px; padding: 8px; overflow: auto; border: 1px solid var(--line); border-radius: 3px; background: var(--surface-2); color: var(--ink-2); font-size: 10.5px; white-space: pre; }

/* ---------------------------------------------------------------- viste e finestre */
.bs-logs { padding: 24px; }
.bs-filter { width: 220px; height: 30px; font-size: 12px; }
.bs-modal { max-width: 620px; }
.bs-gallery { max-height: 420px; overflow-y: auto; }
.bs-group { margin: 12px 0 6px; color: var(--faint); font-size: 10px; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; }
.bs-group:first-child { margin-top: 0; }
.bs-gal-row { display: flex; align-items: center; gap: 8px; padding: 8px 10px; border: 1px solid var(--line-soft); border-radius: 3px; margin-bottom: 6px; }
.bs-gal-row.cur { border-color: var(--p200); background: var(--p50); }
.bs-gal-open { display: flex; flex-direction: column; gap: 2px; text-align: left; }
.bs-approval { display: flex; align-items: center; gap: 8px; margin-top: 10px; padding: 10px 12px; border: 1px solid var(--warn-line); border-radius: 3px; background: var(--warn-bg); }

/* ---------------------------------------------------------------- larghezze */
@media (max-width: 1320px) {
    .bs-tenant { display: none; }
}
@media (max-width: 1100px) {
    .bs-side { width: 280px; }
}
@media (max-width: 900px) {
    .bs-cpanel { display: none; }
    .bs-menu { display: inline-flex; margin-left: -8px; }
    .app.drawer .bs-cpanel { position: absolute; left: 76px; top: 0; bottom: 0; z-index: 40; display: flex; box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35); }
    .bs-side { position: absolute; right: 0; top: 0; bottom: 0; z-index: 20; box-shadow: var(--shadow); }
}
@media (max-width: 640px) {
    .bs-rail { width: 60px; }
    .bs-cat span { font-size: 8.5px; }
    .bs-bar1 { padding: 0 12px; }
    .bs-theme { display: none; }
    .bs-side { width: 100%; }
}

/* ---------------------------------------------------------------- la guida dei blocchi e il Data Store */
.bs-guide { height: 100%; overflow-y: auto; padding: 24px; background: var(--bs-app-bg); }
.bs-guide-title { display: flex; align-items: center; gap: 8px; margin: 0; color: var(--ink); font-size: 18px; font-weight: 600; }
.bs-guide-title svg { color: var(--p-ink-soft); }
.bs-guide-sub { margin: 4px 0 0; color: var(--muted); font-size: 13px; }
.bs-guide-search { position: relative; display: flex; align-items: center; gap: 8px; max-width: 420px; margin: 16px 0 8px; padding: 0 10px; border: 1px solid var(--input-line); border-radius: var(--radius-c); background: var(--surface); color: var(--faint); }
.bs-guide-search input { flex: 1; padding: 8px 0; border: 0; background: transparent; color: var(--ink); font-size: 13px; }
.bs-guide-sec { margin-top: 24px; }
.bs-guide-sec h2 { margin: 0; color: var(--muted); font-size: 13px; font-weight: 600; letter-spacing: 0.04em; text-transform: uppercase; }
.bs-guide-intro { margin: 4px 0 0; color: var(--faint); font-size: 12px; }
.bs-guide-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(260px, 1fr)); gap: 12px; margin-top: 12px; }
.bs-guide-block { padding: 14px; border: 1px solid var(--line); border-radius: var(--radius); background: var(--surface); }
.bs-guide-block .row { gap: 10px; }
.bs-guide-block b { color: var(--ink); font-size: 13.5px; }
.bs-guide-block p { margin: 10px 0 0; color: var(--ink-3); font-size: 12px; line-height: 1.5; }
.bs-guide-block p.bs-guide-meta { margin-top: 8px; color: var(--muted); font-size: 11px; }
.bs-guide-meta span { color: var(--ink-3); font-weight: 600; }
.bs-guide-icon { display: flex; align-items: center; justify-content: center; flex-shrink: 0; width: 32px; height: 32px; border-radius: var(--radius-c); color: #fff; }
.bs-ds-sub { margin: 0 0 10px; }
.bs-ds-val { max-width: 220px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
