html, body {
    font-family: 'Helvetica Neue', Helvetica, Arial, sans-serif;
    background-color: #1a1a2e;
    color: #e0e0e0;
    height: 100%;
    margin: 0;
    padding: 0;
}

#app {
    height: 100vh;
    display: flex;
    flex-direction: column;
}

h1:focus {
    outline: none;
}

/* ==================== WORKFLOW LAYOUT ==================== */
.workflow-layout-wrapper {
    height: 100vh;
    overflow: hidden;
}

.editor-layout {
    display: flex;
    height: 100vh;
    background-color: #1a1a2e;
    overflow: hidden;
}

/* ==================== SIDEBAR ==================== */
.sidebar {
    width: 280px;
    min-width: 280px;
    background-color: #16213e;
    border-right: 1px solid #0f3460;
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
}

.sidebar-header {
    padding: 16px;
    background-color: #0f3460;
    border-bottom: 1px solid #1a4a80;
}

.sidebar-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: #e0e0e0;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.sidebar-section {
    padding: 12px 16px;
    border-top: 1px solid #0f3460;
}

.sidebar-section h3 {
    margin: 0 0 8px 0;
    font-size: 0.85rem;
    color: #a0a0c0;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

/* ==================== NODE PALETTE ==================== */
.node-palette {
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 0 0 auto;
}

.palette-item {
    background-color: #1e2d50;
    border: 1px solid #2a4080;
    border-radius: 6px;
    padding: 10px 12px;
    cursor: grab;
    transition: background-color 0.2s, border-color 0.2s, transform 0.1s;
    user-select: none;
}

.palette-item:hover {
    background-color: #253560;
    border-color: #4a7fc0;
    transform: translateX(2px);
}

.palette-item:active {
    cursor: grabbing;
    transform: scale(0.98);
}

.palette-item-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: #c0d0f0;
    display: block;
    margin-bottom: 4px;
}

.palette-ports {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 4px;
}

.port-badge {
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 10px;
    font-weight: 500;
}

/* ==================== DATA TYPE COLORS ==================== */
.port-table, .port-badge.port-table { background-color: #1a4a8a; color: #60b0ff; border: 1px solid #2060b0; }
.port-string, .port-badge.port-string { background-color: #1a6a30; color: #60e880; border: 1px solid #208040; }
.port-text, .port-badge.port-text { background-color: #0e5a60; color: #40d8e0; border: 1px solid #107880; }
.port-number, .port-badge.port-number { background-color: #8a4a10; color: #ffb060; border: 1px solid #b06020; }
.port-boolean, .port-badge.port-boolean { background-color: #6a1a7a; color: #e060ff; border: 1px solid #9030a0; }
.port-object, .port-badge.port-object { background-color: #6a5a10; color: #ffe060; border: 1px solid #a08020; }

/* ==================== JSON TEXTAREA ==================== */
.json-textarea {
    width: 100%;
    min-height: 140px;
    background-color: #0d1830;
    border: 1px solid #2a4080;
    border-radius: 4px;
    color: #a0c8ff;
    font-family: 'Courier New', Courier, monospace;
    font-size: 0.75rem;
    padding: 8px;
    resize: vertical;
    box-sizing: border-box;
    margin-bottom: 8px;
}

.json-textarea:focus {
    outline: none;
    border-color: #4a80c0;
}

.export-output {
    min-height: 160px;
    color: #80ff80;
    background-color: #0a180a;
    border-color: #206020;
}

.error-message {
    color: #ff6060;
    font-size: 0.8rem;
    margin-top: 4px;
    padding: 4px 8px;
    background-color: #3a1010;
    border-radius: 4px;
    border: 1px solid #802020;
}

/* ==================== BUTTONS ==================== */
.btn {
    padding: 8px 16px;
    border-radius: 4px;
    border: none;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background-color 0.2s;
    width: 100%;
    margin-bottom: 4px;
}

.btn-primary {
    background-color: #1b6ec2;
    color: #fff;
}

.btn-primary:hover { background-color: #2a82d8; }

.btn-secondary {
    background-color: #404060;
    color: #e0e0e0;
}

.btn-secondary:hover { background-color: #505080; }

.btn-export {
    background-color: #1a6a30;
    color: #80ff80;
    border: 1px solid #208040;
}

.btn-export:hover { background-color: #208040; }

/* ==================== CANVAS AREA ==================== */
.canvas-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background-color: #1a1a2e;
}

.canvas-header {
    padding: 12px 20px;
    background-color: #0f3460;
    border-bottom: 1px solid #1a4a80;
    flex-shrink: 0;
}

.canvas-header h2 {
    margin: 0;
    font-size: 1.1rem;
    color: #e0e0e0;
    font-weight: 600;
}

.canvas-container {
    flex: 1;
    background-color: #12122a;
    background-image:
        linear-gradient(rgba(255,255,255,0.03) 1px, transparent 1px),
        linear-gradient(90deg, rgba(255,255,255,0.03) 1px, transparent 1px);
    background-size: 20px 20px;
    position: relative;
    overflow: hidden;
}

/* ==================== LINK / CONNECTION LINES ==================== */
/* SVG presentation attributes are overridden by CSS — no !important needed.      */
/* .selection-helper is the wide transparent hit-test path; skip it.              */
.diagram-svg-layer .diagram-link path:not(.selection-helper) {
    stroke: #5090e0;
    stroke-width: 3;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.diagram-svg-layer .diagram-link.selected path:not(.selection-helper) {
    stroke: #80c0ff;
    stroke-width: 4;
}

/* Arrow markers (if any) inherit the same color */
.diagram-svg-layer .diagram-link marker path {
    fill: #5090e0;
}

/* ==================== CUSTOM NODE WIDGET ==================== */
.workflow-node {
    background-color: #1e2d50;
    border: 2px solid #2a4080;
    border-radius: 8px;
    min-width: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4);
    font-size: 0.82rem;
    color: #c0d0f0;
    overflow: visible;
}

.workflow-node.selected {
    border-color: #4a90e2;
    box-shadow: 0 0 0 2px rgba(74,144,226,0.3), 0 4px 12px rgba(0, 0, 0, 0.4);
}

.node-header {
    background-color: #0f3460;
    padding: 7px 10px;
    border-radius: 6px 6px 0 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.node-type-badge {
    font-size: 0.68rem;
    background-color: #1a4a80;
    color: #80b0ff;
    padding: 2px 6px;
    border-radius: 10px;
    white-space: nowrap;
}

.node-title {
    font-weight: 600;
    color: #d0e0ff;
    font-size: 0.88rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.node-body {
    display: flex;
    align-items: flex-start;
    padding: 8px 0;
    gap: 0;
    min-height: 40px;
}

.ports-column {
    display: flex;
    flex-direction: column;
    gap: 10px;
    padding: 4px 0;
    min-width: 16px;
}

.ports-left {
    padding-left: 0;
    padding-right: 4px;
    align-items: flex-start;
}

.ports-right {
    padding-left: 4px;
    padding-right: 0;
    align-items: flex-end;
}

.port-row {
    display: flex;
    align-items: center;
    gap: 4px;
    position: relative;
    height: 22px;
}

.port-row-right {
    flex-direction: row-reverse;
}

.port-label {
    font-size: 0.72rem;
    color: #8090a8;
    white-space: nowrap;
    padding: 0 4px;
}

/* Override diagram-port styles for custom nodes */
.workflow-node .diagram-port {
    width: 14px !important;
    height: 14px !important;
    margin: 0 !important;
    border-radius: 50% !important;
    border: 2px solid #4a80c0 !important;
    background-color: #1e2d50 !important;
    cursor: crosshair !important;
    position: relative !important;
    flex-shrink: 0;
    transition: background-color 0.15s;
}

.workflow-node .diagram-port:hover,
.workflow-node .diagram-port.has-links {
    background-color: #4a80c0 !important;
}

/* Port colors based on data type */
.workflow-node .diagram-port.port-table { border-color: #2a80e0 !important; }
.workflow-node .diagram-port.port-table:hover,
.workflow-node .diagram-port.port-table.has-links { background-color: #2a80e0 !important; }

.workflow-node .diagram-port.port-string { border-color: #30a060 !important; }
.workflow-node .diagram-port.port-string:hover,
.workflow-node .diagram-port.port-string.has-links { background-color: #30a060 !important; }

.workflow-node .diagram-port.port-text { border-color: #20a0a8 !important; }
.workflow-node .diagram-port.port-text:hover,
.workflow-node .diagram-port.port-text.has-links { background-color: #20a0a8 !important; }

.workflow-node .diagram-port.port-number { border-color: #e08030 !important; }
.workflow-node .diagram-port.port-number:hover,
.workflow-node .diagram-port.port-number.has-links { background-color: #e08030 !important; }

/* Config fields area */
.config-fields {
    flex: 1;
    padding: 0 8px;
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.field-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.field-label {
    font-size: 0.72rem;
    color: #8090a8;
    font-weight: 500;
}

.field-input,
.field-select {
    background-color: #0d1830;
    border: 1px solid #2a4080;
    border-radius: 3px;
    color: #c0d0ff;
    padding: 3px 6px;
    font-size: 0.78rem;
    width: 100%;
    box-sizing: border-box;
}

.field-input:focus,
.field-select:focus {
    outline: none;
    border-color: #4a80c0;
    background-color: #0f1e3a;
}

.field-select option {
    background-color: #0d1830;
    color: #c0d0ff;
}

/* ==================== BLAZOR ERROR UI ==================== */
#blazor-error-ui {
    color-scheme: dark;
    background: #3a1010;
    color: #ff8080;
    bottom: 0;
    box-shadow: 0 -1px 2px rgba(0, 0, 0, 0.4);
    box-sizing: border-box;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
}

#blazor-error-ui .dismiss {
    cursor: pointer;
    position: absolute;
    right: 0.75rem;
    top: 0.5rem;
}

/* ==================== LOADING ==================== */
.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: #2a3a60;
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: #4a80c0;
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
    color: #a0b0d0;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Laden...");
}

