/* Flow Builder — tela cheia estilo node editor */

html.flowbuilder-page,
html.flowbuilder-page body.flowbuilder-body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
}

.flowbuilder-body {
    font-family: Inter, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: #0f172a;
}

.flow-app {
    display: flex;
    flex-direction: column;
    width: 100vw;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
}

.flow-app > form,
#flowSaveForm {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.flow-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: #1e293b;
    border-bottom: 1px solid #334155;
    flex-shrink: 0;
    z-index: 100;
}

.flow-toolbar-title {
    font-size: 15px;
    font-weight: 600;
    color: #f1f5f9;
    margin-right: auto;
    display: flex;
    align-items: center;
    gap: 8px;
    min-width: 0;
}

.flow-toolbar-title small {
    font-weight: 400;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.flow-toolbar .btn {
    font-size: 13px;
    flex-shrink: 0;
}

.flow-main {
    display: flex;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.flow-viewport-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    background-color: #0f172a;
    background-image: radial-gradient(circle, #334155 1px, transparent 1px);
    background-size: 24px 24px;
    cursor: grab;
}

.flow-viewport-wrap.is-panning {
    cursor: grabbing;
}

.flow-viewport {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    transform-origin: 0 0;
    will-change: transform;
}

.flow-edges {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
    pointer-events: none;
    overflow: visible;
}

.flow-edges path {
    fill: none;
    stroke: #6366f1;
    stroke-width: 2.5;
}

.flow-edges path.is-temp {
    stroke: #94a3b8;
    stroke-dasharray: 6 4;
}

.flow-nodes-layer {
    position: absolute;
    top: 0;
    left: 0;
    width: 10000px;
    height: 10000px;
}

.flow-node {
    position: absolute;
    width: 240px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
    border: 2px solid transparent;
    user-select: none;
}

.flow-node.is-selected {
    border-color: #6366f1;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.35), 0 8px 24px rgba(0, 0, 0, 0.3);
}

.flow-node.is-start .flow-node-header {
    background: linear-gradient(135deg, #059669, #10b981);
}

.flow-node-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 12px;
    background: linear-gradient(135deg, #4f46e5, #6366f1);
    border-radius: 10px 10px 0 0;
    color: #fff;
    cursor: grab;
    font-size: 12px;
    font-weight: 600;
}

.flow-node-header:active {
    cursor: grabbing;
}

.flow-node-type-icon {
    width: 24px;
    height: 24px;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
}

.flow-node-body {
    padding: 10px 12px 14px;
    font-size: 12px;
    color: #475569;
    line-height: 1.4;
    min-height: 48px;
}

.flow-node-preview {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.flow-node-ports-out {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px 10px;
}

.flow-port-row {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    font-size: 10px;
    color: #64748b;
}

.flow-port {
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: #6366f1;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #6366f1;
    cursor: crosshair;
    flex-shrink: 0;
    z-index: 5;
}

.flow-port-in {
    position: absolute;
    top: -7px;
    left: 50%;
    transform: translateX(-50%);
    background: #22c55e;
    box-shadow: 0 0 0 2px #22c55e;
}

.flow-port-out:hover {
    transform: scale(1.2);
    background: #818cf8;
}

.flow-port.is-connecting {
    background: #f59e0b;
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.5);
}

.flow-sidebar {
    width: 300px;
    background: #1e293b;
    border-left: 1px solid #334155;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    color: #e2e8f0;
    transition: width 0.2s, margin 0.2s;
    overflow: hidden;
}

.flow-sidebar.is-collapsed {
    width: 0;
    border-left: none;
}

.flow-sidebar-header {
    padding: 14px 16px;
    border-bottom: 1px solid #334155;
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
}

.flow-sidebar-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

.flow-sidebar-body .form-label {
    color: #94a3b8;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.flow-sidebar-body .form-control,
.flow-sidebar-body .form-select {
    background: #0f172a;
    border-color: #334155;
    color: #f1f5f9;
    font-size: 13px;
}

.flow-sidebar-empty {
    text-align: center;
    color: #64748b;
    padding: 40px 16px;
}

.flow-sidebar-empty i {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 12px;
}

.flow-btn-row {
    display: grid;
    gap: 6px;
    margin-bottom: 8px;
    padding: 8px;
    background: #0f172a;
    border-radius: 8px;
    border: 1px solid #334155;
}

.flow-sidebar-body .form-check-label {
    color: #e2e8f0;
    font-size: 13px;
    text-transform: none;
    letter-spacing: normal;
}

.flow-hint {
    position: absolute;
    bottom: 16px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(30, 41, 59, 0.92);
    color: #94a3b8;
    font-size: 12px;
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid #334155;
    pointer-events: none;
    z-index: 50;
    white-space: nowrap;
}

.flow-zoom-badge {
    font-size: 11px;
    color: #94a3b8;
    min-width: 48px;
    text-align: center;
}

.flow-app .alert {
    flex-shrink: 0;
    border-radius: 0;
    margin: 0;
}

@media (max-width: 768px) {
    .flow-sidebar {
        position: absolute;
        right: 0;
        top: 0;
        bottom: 0;
        z-index: 200;
        box-shadow: -4px 0 24px rgba(0, 0, 0, 0.4);
    }

    .flow-sidebar.is-collapsed {
        width: 0;
    }
}
