/* ============================================================================
   VERIJ WORKFLOW STUDIO - NODE CONFIG MODALS CSS
   ============================================================================
   File: wwwroot/css/workflow-node-config.css
   Styles for the enhanced node configuration modals
   ============================================================================ */

/* ============================================================================
   MODAL BASE STYLES
   ============================================================================ */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.75);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.modal-content {
    background: #1e1e2e;
    border: 1px solid #3a3a5c;
    border-radius: 12px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 1px solid #3a3a5c;
}

    .modal-header h3 {
        margin: 0;
        color: #ffffff;
        font-size: 18px;
    }

.close-btn {
    background: none;
    border: none;
    color: #a0a0c0;
    font-size: 24px;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

    .close-btn:hover {
        color: #ff6b6b;
    }

.modal-body {
    padding: 25px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 20px 25px;
    border-top: 1px solid #3a3a5c;
}

.btn-primary {
    background: #00bfff;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

    .btn-primary:hover {
        background: #00a0dd;
    }

.btn-secondary {
    background: #3a3a5c;
    color: #ffffff;
    border: 1px solid #4a4a6a;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
}

    .btn-secondary:hover {
        background: #4a4a6a;
    }

.btn-danger {
    background: #dc3545;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
}

    .btn-danger:hover {
        background: #c82333;
    }

.footer-spacer {
    flex: 1;
}

/* Test Workflow Styles */
.test-progress {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 30px;
    gap: 15px;
}

.spinner-large {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(255, 255, 255, 0.1);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

.test-result-box {
    padding: 20px;
    border-radius: 8px;
    margin-top: 15px;
}

    .test-result-box.success {
        background: rgba(34, 197, 94, 0.1);
        border: 1px solid rgba(34, 197, 94, 0.3);
    }

    .test-result-box.error {
        background: rgba(239, 68, 68, 0.1);
        border: 1px solid rgba(239, 68, 68, 0.3);
    }

    .test-result-box h4 {
        margin: 0 0 10px 0;
        font-size: 16px;
    }

    .test-result-box.success h4 {
        color: #22c55e;
    }

    .test-result-box.error h4 {
        color: #ef4444;
    }

    .test-result-box .error-message {
        color: #ef4444;
        margin: 10px 0;
        padding: 10px;
        background: rgba(239, 68, 68, 0.1);
        border-radius: 4px;
        font-family: monospace;
        font-size: 13px;
    }

.test-details {
    margin: 15px 0;
}

    .test-details p {
        margin: 5px 0;
        color: #a0a0c0;
    }

.node-results {
    margin-top: 15px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    padding-top: 15px;
}

    .node-results h5 {
        margin: 0 0 10px 0;
        font-size: 14px;
        color: #e0e0e0;
    }

.node-result-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 4px;
    margin-bottom: 6px;
}

    .node-result-item.success .node-status {
        color: #22c55e;
    }

    .node-result-item.error .node-status {
        color: #ef4444;
    }

    .node-result-item .node-name {
        flex: 1;
        font-weight: 500;
    }

    .node-result-item .node-error {
        font-size: 12px;
        color: #ef4444;
        margin-left: 10px;
    }

.form-group {
    margin-bottom: 15px;
}

    .form-group label {
        display: block;
        color: #a0a0c0;
        margin-bottom: 6px;
        font-size: 13px;
    }

    .form-group input,
    .form-group select,
    .form-group textarea {
        width: 100%;
        padding: 10px 12px;
        background: #2a2a4a;
        border: 1px solid #4a4a6a;
        border-radius: 6px;
        color: #ffffff;
        font-size: 14px;
    }

        .form-group input:focus,
        .form-group select:focus,
        .form-group textarea:focus {
            outline: none;
            border-color: #00bfff;
        }

    .form-group small {
        display: block;
        color: #6a6a8a;
        font-size: 12px;
        margin-top: 4px;
    }

/* ============================================================================
   CONFIG TABS
   ============================================================================ */

.config-tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 20px;
    border-bottom: 1px solid #3a3a5c;
    padding-bottom: 10px;
}

.tab-btn {
    padding: 8px 16px;
    background: transparent;
    border: 1px solid #4a4a6a;
    border-radius: 6px 6px 0 0;
    color: #a0a0c0;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .tab-btn:hover:not(:disabled) {
        background: #2a2a4a;
        color: #ffffff;
    }

    .tab-btn.active {
        background: #3a3a5c;
        color: #00bfff;
        border-color: #00bfff;
    }

    .tab-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
    }

/* ============================================================================
   FORM ENHANCEMENTS
   ============================================================================ */

.form-section {
    padding: 15px 0;
}

    .form-section h4 {
        color: #a0a0c0;
        margin: 20px 0 10px 0;
        padding-bottom: 5px;
        border-bottom: 1px solid #3a3a5c;
    }

.form-row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
}

.input-with-button {
    display: flex;
    gap: 8px;
}

    .input-with-button select,
    .input-with-button input {
        flex: 1;
    }

.btn-icon {
    width: 38px;
    height: 38px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #3a3a5c;
    border: 1px solid #4a4a6a;
    border-radius: 6px;
    color: #a0a0c0;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .btn-icon:hover {
        background: #4a4a6a;
        color: #ffffff;
    }

    .btn-icon.danger:hover {
        background: #cc4444;
        border-color: #cc4444;
        color: white;
    }

/* ============================================================================
   BUTTON GROUPS (Toggle buttons)
   ============================================================================ */

.button-group {
    display: flex;
    gap: 0;
}

.toggle-btn {
    flex: 1;
    padding: 10px 20px;
    background: #2a2a4a;
    border: 1px solid #4a4a6a;
    color: #a0a0c0;
    cursor: pointer;
    transition: all 0.2s ease;
}

    .toggle-btn:first-child {
        border-radius: 6px 0 0 6px;
    }

    .toggle-btn:last-child {
        border-radius: 0 6px 6px 0;
        border-left: none;
    }

    .toggle-btn:hover:not(.active) {
        background: #3a3a5c;
    }

    .toggle-btn.active {
        background: #00bfff;
        border-color: #00bfff;
        color: white;
    }

    .toggle-btn i {
        margin-right: 8px;
    }

/* ============================================================================
   CHECKBOX GROUPS
   ============================================================================ */

.checkbox-group {
    display: flex;
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 8px;
}

    .checkbox-group input[type="checkbox"] {
        width: 18px;
        height: 18px;
        margin: 0;
        cursor: pointer;
    }

    .checkbox-group label {
        margin: 0;
        cursor: pointer;
        flex: 1;
    }

    .checkbox-group small {
        width: 100%;
        padding-left: 26px;
        margin-top: 4px;
    }

.highlight-box {
    background: #2a2a4a;
    border: 1px solid #4a4a6a;
    border-radius: 8px;
    padding: 15px;
    margin: 10px 0;
}

    .highlight-box label strong {
        color: #00bfff;
    }

/* ============================================================================
   PREVIEW BOX
   ============================================================================ */

.preview-box {
    background: #1a1a2e;
    border: 1px solid #4a4a6a;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

    .preview-box label {
        display: block;
        color: #a0a0c0;
        font-size: 12px;
        margin-bottom: 8px;
    }

    .preview-box code {
        display: block;
        font-family: 'Consolas', 'Monaco', monospace;
        font-size: 14px;
        color: #00ff88;
        word-break: break-all;
    }

/* ============================================================================
   PARAMETER LIST (SQL parameters, etc.)
   ============================================================================ */

.parameter-list {
    background: #1a1a2e;
    border: 1px solid #3a3a5c;
    border-radius: 8px;
    padding: 15px;
}

.parameter-row {
    display: flex;
    gap: 10px;
    margin-bottom: 10px;
}

    .parameter-row input {
        flex: 1;
    }

    .parameter-row .btn-icon {
        flex-shrink: 0;
    }

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* ============================================================================
   CODE EDITOR (SQL, scripts)
   ============================================================================ */

.code-editor {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    line-height: 1.5;
    background: #0d0d1a;
    border-color: #3a3a5c;
    resize: vertical;
}

    .code-editor::placeholder {
        color: #5a5a7a;
    }

/* ============================================================================
   SCHEMA PREVIEW
   ============================================================================ */

.schema-preview {
    background: #1a1a2e;
    border: 1px solid #3a3a5c;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
}

    .schema-preview h4 {
        margin: 0 0 10px 0;
        font-size: 14px;
        color: #a0a0c0;
        border: none;
        padding: 0;
    }

    /* Field list for schema preview (tags that can wrap) */
    .schema-preview .field-list {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

.field-tag {
    background: #2a2a4a;
    border: 1px solid #4a4a6a;
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 12px;
    color: #c0c0e0;
}

    .field-tag.more {
        background: #4a4a6a;
        color: #ffffff;
    }

/* ============================================================================
   NODE SELECTOR (Multi-select checkboxes)
   ============================================================================ */

.node-selector {
    background: #1a1a2e;
    border: 1px solid #3a3a5c;
    border-radius: 8px;
    padding: 10px;
    max-height: 200px;
    overflow-y: auto;
}

.node-checkbox {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px;
    border-radius: 6px;
    transition: background 0.2s ease;
}

    .node-checkbox:hover {
        background: #2a2a4a;
    }

    .node-checkbox input[type="checkbox"] {
        width: 16px;
        height: 16px;
    }

    .node-checkbox label {
        display: flex;
        align-items: center;
        gap: 8px;
        cursor: pointer;
        flex: 1;
    }

.node-type-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: bold;
    text-transform: uppercase;
}

    .node-type-badge.sqlread {
        background: #6b5b95;
    }

    .node-type-badge.apiget {
        background: #88b04b;
    }

    .node-type-badge.file {
        background: #f7cac9;
        color: #333;
    }

    .node-type-badge.transformation {
        background: #92a8d1;
    }

    .node-type-badge.verijqueue {
        background: #955251;
    }

/* ============================================================================
   CONNECTION MANAGER
   ============================================================================ */

.connection-list {
    margin-bottom: 20px;
}

.connection-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px;
    background: #2a2a4a;
    border: 1px solid #3a3a5c;
    border-radius: 8px;
    margin-bottom: 10px;
}

    .connection-item.default {
        border-color: #00bfff;
    }

.connection-info {
    flex: 1;
}

    .connection-info strong {
        color: #ffffff;
        margin-right: 10px;
    }

.connection-string {
    font-family: monospace;
    font-size: 12px;
    color: #8080a0;
    margin-top: 5px;
    word-break: break-all;
}

.connection-actions {
    display: flex;
    gap: 8px;
}

.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 11px;
    font-weight: bold;
    background: #00bfff;
    color: white;
    margin-right: 5px;
}

    .badge.secondary {
        background: #4a4a6a;
    }

.test-result {
    font-size: 13px;
    padding: 5px 10px;
    border-radius: 4px;
}

    .test-result.success {
        color: #00ff88;
    }

    .test-result.error {
        color: #ff6b6b;
    }

/* ============================================================================
   ACTION BUTTONS
   ============================================================================ */

.action-buttons {
    display: flex;
    gap: 10px;
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #3a3a5c;
}

    .action-buttons .btn-secondary {
        display: flex;
        align-items: center;
        gap: 8px;
    }

/* ============================================================================
   INFO TEXT
   ============================================================================ */

.info-text {
    background: #2a3a4a;
    border-left: 3px solid #00bfff;
    padding: 10px 15px;
    margin: 15px 0;
    color: #a0c0e0;
    font-size: 13px;
    border-radius: 0 6px 6px 0;
}

/* ============================================================================
   SPINNER
   ============================================================================ */

.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #ffffff;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ============================================================================
   ICONS (Simple text-based icons)
   ============================================================================ */

.icon-download::before {
    content: "↓";
}

.icon-upload::before {
    content: "↑";
}

.icon-settings::before {
    content: "⚙";
}

.icon-edit::before {
    content: "✎";
}

.icon-delete::before {
    content: "×";
}

.icon-plus::before {
    content: "+";
}

.icon-external::before {
    content: "↗";
}

/* ============================================================================
   MODAL SIZE VARIANTS
   ============================================================================ */

.modal-large {
    max-width: 700px;
    width: 95%;
}

/* ============================================================================
   RESPONSIVE
   ============================================================================ */

@media (max-width: 600px) {
    .form-row {
        grid-template-columns: 1fr;
    }

    .button-group {
        flex-direction: column;
    }

    .toggle-btn:first-child {
        border-radius: 6px 6px 0 0;
    }

    .toggle-btn:last-child {
        border-radius: 0 0 6px 6px;
        border-left: 1px solid #4a4a6a;
        border-top: none;
    }

    .config-tabs {
        flex-wrap: wrap;
    }
}

/* ============================================================================
   WORKFLOW TRANSFORMATION MAPPER
   ============================================================================ */

.source-type-hint {
    display: block;
    margin-top: 8px;
    color: #8888aa;
    font-size: 12px;
}

.workflow-transform-container {
    margin-top: 20px;
    padding: 15px;
    background: #252538;
    border-radius: 8px;
    border: 1px solid #3a3a5c;
}

.transform-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #3a3a5c;
}

    .transform-header .form-group.inline {
        display: flex;
        align-items: center;
        gap: 10px;
        margin: 0;
    }

        .transform-header .form-group.inline label {
            margin: 0;
            white-space: nowrap;
        }

        .transform-header .form-group.inline input {
            width: 200px;
        }

.transform-actions {
    display: flex;
    gap: 8px;
}

.sample-data-input {
    margin-bottom: 15px;
    padding: 12px;
    background: #1e1e2e;
    border-radius: 6px;
    border: 1px solid #4a4a6a;
}

    .sample-data-input label {
        display: block;
        margin-bottom: 8px;
        font-size: 13px;
        color: #aaaacc;
    }

    .sample-data-input textarea {
        width: 100%;
        padding: 10px;
        background: #2a2a40;
        border: 1px solid #4a4a6a;
        border-radius: 4px;
        color: #ffffff;
        font-family: 'Monaco', 'Consolas', monospace;
        font-size: 12px;
        resize: vertical;
    }

.sample-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 10px;
}

/* Schema Mapper Layout */
.schema-mapper {
    display: grid;
    grid-template-columns: 1fr auto 1fr;
    gap: 20px;
    margin-bottom: 15px;
}

.schema-panel {
    background: #1e1e2e;
    border-radius: 8px;
    border: 1px solid #3a3a5c;
    overflow: hidden;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 15px;
    background: #2a2a45;
    border-bottom: 1px solid #3a3a5c;
}

    .panel-header h4 {
        margin: 0;
        font-size: 14px;
        color: #ffffff;
    }

    .panel-header .btn-icon {
        width: 24px;
        height: 24px;
        padding: 0;
        font-size: 16px;
        line-height: 1;
        border-radius: 4px;
        background: #3a3a5c;
        border: none;
        color: #aaaacc;
        cursor: pointer;
    }

        .panel-header .btn-icon:hover {
            background: #4a4a6a;
            color: #ffffff;
        }

/* Field list for schema panels (not mapper panels) */
.schema-panel .field-list {
    padding: 10px;
    min-height: 200px;
    max-height: 300px;
    overflow-y: auto;
}

.empty-state {
    text-align: center;
    padding: 30px 15px;
    color: #6666aa;
}

    .empty-state p {
        margin: 0 0 8px;
        font-size: 14px;
    }

    .empty-state small {
        font-size: 12px;
        opacity: 0.7;
    }

.schema-field {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    margin-bottom: 6px;
    background: #2a2a40;
    border: 1px solid #3a3a5c;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s ease;
}

    .schema-field:hover {
        background: #3a3a55;
        border-color: #5a5a8a;
    }

    .schema-field.mapped {
        background: #2a3a4a;
        border-color: #4a8aaa;
    }

    .schema-field .field-name {
        flex: 1;
        font-size: 13px;
        color: #ffffff;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .schema-field .field-type {
        font-size: 11px;
        color: #8888aa;
        padding: 2px 6px;
        background: #1e1e2e;
        border-radius: 4px;
        margin-left: 8px;
    }

    .schema-field .field-sample {
        font-size: 11px;
        color: #6666aa;
        margin-left: 8px;
        font-style: italic;
    }

    .schema-field .btn-icon-small {
        width: 20px;
        height: 20px;
        padding: 0;
        margin-left: 8px;
        font-size: 14px;
        line-height: 1;
        border-radius: 4px;
        background: transparent;
        border: none;
        color: #aa6666;
        cursor: pointer;
        opacity: 0;
        transition: opacity 0.15s;
    }

    .schema-field:hover .btn-icon-small {
        opacity: 1;
    }

    .schema-field .btn-icon-small:hover {
        background: #552222;
    }

/* Mapping Lines (center column) */
.mapping-lines {
    display: flex;
    flex-direction: column;
    gap: 6px;
    padding: 10px 0;
    min-width: 180px;
}

.empty-mapping {
    text-align: center;
    padding: 40px 10px;
    color: #6666aa;
    font-size: 13px;
}

.mapping-line {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    background: #2a3a4a;
    border: 1px solid #4a6a8a;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.15s;
}

    .mapping-line:hover,
    .mapping-line.selected {
        background: #3a4a5a;
        border-color: #6a8aaa;
    }

    .mapping-line .source-label,
    .mapping-line .target-label {
        flex: 1;
        font-size: 12px;
        color: #aaccee;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .mapping-line .arrow {
        margin: 0 8px;
        color: #6a8aaa;
    }

    .mapping-line .expr-badge {
        font-size: 10px;
        padding: 2px 5px;
        background: #6a4a8a;
        color: #ddaaff;
        border-radius: 3px;
        margin-left: 6px;
    }

/* Mapping Editor - Right side panel */
.mapping-editor-panel {
    background: #1e1e2e;
    border-radius: 8px;
    border: 1px solid #3a3a5c;
    padding: 16px;
    display: flex;
    flex-direction: column;
    min-height: 350px;
    max-height: 400px;
    overflow-y: auto;
}

    .mapping-editor-panel.empty-state-panel {
        justify-content: center;
        align-items: center;
    }

    .mapping-editor-panel .empty-state {
        text-align: center;
        color: #8888aa;
    }

        .mapping-editor-panel .empty-state p {
            font-size: 16px;
            margin-bottom: 8px;
        }

        .mapping-editor-panel .empty-state small {
            font-size: 12px;
            opacity: 0.7;
        }

    .mapping-editor-panel .editor-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 16px;
        padding-bottom: 12px;
        border-bottom: 1px solid #3a3a5c;
    }

        .mapping-editor-panel .editor-header h4 {
            margin: 0;
            font-size: 14px;
            color: #ffffff;
            display: flex;
            align-items: center;
            gap: 8px;
        }

    .mapping-editor-panel .editor-color-dot {
        width: 12px;
        height: 12px;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .mapping-editor-panel .editor-body {
        display: flex;
        flex-direction: column;
        gap: 12px;
    }

    .mapping-editor-panel .form-row {
        display: flex;
        gap: 12px;
    }

        .mapping-editor-panel .form-row .form-group {
            flex: 1;
        }

    .mapping-editor-panel .form-group {
        display: flex;
        flex-direction: column;
        gap: 4px;
    }

        .mapping-editor-panel .form-group label {
            font-size: 11px;
            color: #8888aa;
            text-transform: uppercase;
            letter-spacing: 0.5px;
        }

        .mapping-editor-panel .form-group select,
        .mapping-editor-panel .form-group input,
        .mapping-editor-panel .form-group textarea {
            background: #12121f;
            border: 1px solid #3a3a5c;
            border-radius: 4px;
            padding: 8px 10px;
            color: #ffffff;
            font-size: 13px;
        }

            .mapping-editor-panel .form-group select:focus,
            .mapping-editor-panel .form-group input:focus,
            .mapping-editor-panel .form-group textarea:focus {
                border-color: #4a8af4;
                outline: none;
            }

        .mapping-editor-panel .form-group small {
            font-size: 11px;
            color: #6a6a8a;
        }

    .mapping-editor-panel .btn-icon.danger {
        background: #552222;
        color: #ffaaaa;
        border: none;
        padding: 6px 8px;
        border-radius: 4px;
        cursor: pointer;
    }

        .mapping-editor-panel .btn-icon.danger:hover {
            background: #772222;
        }

/* Expression Maximizer */
.expression-container {
    position: relative;
}

    .expression-container .maximize-btn {
        position: absolute;
        top: 4px;
        right: 4px;
        background: #3a3a5c;
        border: none;
        color: #aaaacc;
        padding: 4px 8px;
        border-radius: 4px;
        cursor: pointer;
        font-size: 12px;
        z-index: 1;
    }

        .expression-container .maximize-btn:hover {
            background: #4a4a6c;
            color: #ffffff;
        }

/* Maximized expression overlay */
.expression-maximized-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.85);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.expression-maximized-content {
    background: #1a1a2e;
    border-radius: 12px;
    border: 1px solid #3a3a5c;
    width: 100%;
    max-width: 1200px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.expression-maximized-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #3a3a5c;
    color: #ffffff;
}

    .expression-maximized-header h3 {
        margin: 0;
        font-size: 18px;
    }

    .expression-maximized-header .minimize-btn {
        background: #4a8af4;
        border: none;
        color: white;
        padding: 8px 16px;
        border-radius: 6px;
        cursor: pointer;
        font-size: 14px;
    }

        .expression-maximized-header .minimize-btn:hover {
            background: #3a7ae4;
        }

.expression-maximized-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 20px;
    overflow: hidden;
    gap: 16px;
}

    .expression-maximized-body .code-editor-container {
        flex: 1;
        min-height: 300px;
    }

        .expression-maximized-body .code-editor-container.maximized .code-editor-wrapper {
            height: 100%;
            max-height: none;
        }

.expression-help {
    color: #8888aa;
    font-size: 13px;
    padding: 12px;
    background: #12121f;
    border-radius: 6px;
}

.expression-examples {
    color: #6a6a8a;
    font-size: 12px;
    line-height: 1.8;
}

    .expression-examples code {
        background: #12121f;
        padding: 2px 6px;
        border-radius: 3px;
        color: #56d4dd;
        font-family: 'Monaco', 'Consolas', monospace;
    }

/* Expression header with actions */
.expression-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

    .expression-header label {
        margin: 0;
    }

.expression-actions {
    display: flex;
    gap: 4px;
}

.expression-maximized-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

/* AI Generate button */
.btn-ai-generate {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border: none;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 4px;
}

    .btn-ai-generate:hover {
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(102, 126, 234, 0.4);
    }

.expression-maximized-actions .btn-ai-generate {
    padding: 8px 16px;
    font-size: 14px;
}

/* ===== AI GENERATOR MODAL ===== */
.ai-generator-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.8);
    z-index: 10001;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.ai-generator-modal {
    background: #1a1a2e;
    border-radius: 12px;
    border: 1px solid #3a3a5c;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

.ai-generator-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid #3a3a5c;
    background: linear-gradient(135deg, #667eea22 0%, #764ba222 100%);
}

    .ai-generator-header h3 {
        margin: 0;
        font-size: 18px;
        color: #ffffff;
    }

    .ai-generator-header .close-btn {
        background: transparent;
        border: none;
        color: #888;
        font-size: 20px;
        cursor: pointer;
        padding: 4px 8px;
    }

        .ai-generator-header .close-btn:hover {
            color: #fff;
        }

.ai-generator-body {
    padding: 20px;
    overflow-y: auto;
    flex: 1;
}

.ai-generator-context {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding: 10px 12px;
    background: #12121f;
    border-radius: 6px;
}

    .ai-generator-context label {
        color: #8888aa;
        font-size: 12px;
        margin: 0;
    }

    .ai-generator-context .target-field-name {
        color: #56d4dd;
        font-weight: 500;
    }

.ai-generator-fields {
    margin-bottom: 16px;
}

    .ai-generator-fields label {
        display: block;
        color: #8888aa;
        font-size: 12px;
        margin-bottom: 8px;
    }

.field-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    max-height: 120px;
    overflow-y: auto;
    padding: 8px;
    background: #12121f;
    border-radius: 6px;
}

.field-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 4px 10px;
    background: #2a2a45;
    border-radius: 4px;
    font-size: 12px;
    color: #56d4dd;
    cursor: pointer;
    transition: all 0.15s;
    font-family: 'Monaco', 'Consolas', monospace;
}

    .field-chip:hover {
        background: #3a3a5c;
        transform: translateY(-1px);
    }

    .field-chip small {
        color: #6a6a8a;
        font-size: 10px;
    }

    .field-chip.more {
        background: transparent;
        color: #6a6a8a;
        cursor: default;
    }

.ai-generator-prompt {
    margin-bottom: 16px;
}

    .ai-generator-prompt label {
        display: block;
        color: #ffffff;
        font-size: 14px;
        margin-bottom: 8px;
    }

    .ai-generator-prompt textarea {
        width: 100%;
        padding: 12px;
        background: #12121f;
        border: 1px solid #3a3a5c;
        border-radius: 6px;
        color: #ffffff;
        font-size: 14px;
        line-height: 1.5;
        resize: vertical;
    }

        .ai-generator-prompt textarea:focus {
            border-color: #667eea;
            outline: none;
            box-shadow: 0 0 0 2px rgba(102, 126, 234, 0.2);
        }

        .ai-generator-prompt textarea::placeholder {
            color: #5a5a7a;
        }

.ai-generator-error {
    padding: 12px;
    background: #3d1f1f;
    border: 1px solid #5a2a2a;
    border-radius: 6px;
    color: #ff8888;
    font-size: 13px;
    margin-bottom: 16px;
}

.ai-generator-result {
    padding: 16px;
    background: #1a2a1a;
    border: 1px solid #2a4a2a;
    border-radius: 6px;
    margin-bottom: 16px;
}

    .ai-generator-result label {
        display: block;
        color: #88cc88;
        font-size: 12px;
        margin-bottom: 8px;
    }

    .ai-generator-result pre {
        margin: 0 0 12px 0;
        padding: 12px;
        background: #12121f;
        border-radius: 4px;
        overflow-x: auto;
    }

    .ai-generator-result code {
        color: #56d4dd;
        font-family: 'Monaco', 'Consolas', monospace;
        font-size: 13px;
    }

.result-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.ai-generator-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 16px 20px;
    border-top: 1px solid #3a3a5c;
    background: #16161f;
}

/* Spinner animation */
.spinner {
    width: 14px;
    height: 14px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    display: inline-block;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Code editor container in mapping panel */
.code-editor-container {
    min-height: 80px;
}

/* Transform Options */
.transform-options {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #3a3a5c;
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
}

    .transform-options .form-group {
        flex: 1;
        min-width: 200px;
    }

/* Make modal wider for transformation mapper */
.modal-content:has(.workflow-transform-container) {
    max-width: 95vw;
    width: 2000px;
}

/* Workflow transform main layout - mapper left, editor right */
.workflow-transform-layout {
    display: grid;
    grid-template-columns: 1fr minmax(320px, 400px);
    gap: 16px;
    margin-bottom: 16px;
}

/* ============================================================================
   VISUAL MAPPER - Clean tree-style field mapping
   ============================================================================ */

.visual-mapper {
    display: grid;
    grid-template-columns: minmax(300px, 350px) minmax(200px, 1fr) minmax(300px, 600px);
    gap: 0;
    background: #12121f;
    border-radius: 8px;
    border: 1px solid #2a2a45;
    overflow: hidden;
    min-height: 350px;
    max-height: 400px;
}

/* ===== PANELS ===== */
.mapper-panel {
    display: flex;
    flex-direction: column;
    background: #1a1a2e;
    overflow: hidden;
    min-width: 0;
}

    /* Source panel */
    .mapper-panel.source-panel {
        border-right: none;
        max-height: 400px;
        min-width: 300px;
    }

    /* Target panel */
    .mapper-panel.target-panel {
        border-left: none;
        max-width: 600px;
        max-height: 400px;
    }

    .mapper-panel .panel-header {
        display: flex;
        align-items: center;
        gap: 8px;
        padding: 10px 12px;
        background: #222238;
        border-bottom: 1px solid #333355;
        flex-shrink: 0;
    }

    .mapper-panel .panel-icon {
        font-size: 14px;
        opacity: 0.8;
    }

    .mapper-panel .panel-title {
        flex: 1;
        font-size: 12px;
        font-weight: 600;
        color: #ffffff;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .mapper-panel .btn-icon {
        width: 22px;
        height: 22px;
        padding: 0;
        font-size: 16px;
        background: rgba(255,255,255,0.1);
        border: none;
        border-radius: 4px;
        color: #aaa;
        cursor: pointer;
    }

        .mapper-panel .btn-icon:hover {
            background: rgba(255,255,255,0.2);
            color: #fff;
        }

    /* ===== FIELD LIST - SCROLLABLE ===== */
    .mapper-panel .field-list {
        flex: 1;
        overflow-y: scroll !important; /* Always show scrollbar */
        overflow-x: hidden !important;
        min-height: 0;
        display: flex !important;
        flex-direction: column !important;
        flex-wrap: nowrap !important;
    }

        /* Force scrollbar styling */
        .mapper-panel .field-list::-webkit-scrollbar {
            width: 10px !important;
            display: block !important;
        }

        .mapper-panel .field-list::-webkit-scrollbar-track {
            background: #252538 !important;
        }

        .mapper-panel .field-list::-webkit-scrollbar-thumb {
            background: #4a4a6a !important;
            border-radius: 5px !important;
            border: 2px solid #252538 !important;
        }

            .mapper-panel .field-list::-webkit-scrollbar-thumb:hover {
                background: #6a6a8a !important;
            }

    /* Source panel: keep scrollbar on right (rtl breaks positioning) */
    .mapper-panel.source-panel {
        border-right: none;
    }

    .mapper-panel.target-panel {
        border-left: none;
        max-width: 100%;
    }

/* ===== TREE FIELD ROWS ===== */
.field-list.tree-view {
    padding: 4px 0;
    gap: 0;
    display: flex !important;
    flex-direction: column !important;
    flex-wrap: nowrap !important;
    align-content: flex-start !important;
}

.tree-field {
    display: flex !important;
    flex-wrap: nowrap !important;
    align-items: center;
    width: 100% !important;
    box-sizing: border-box !important;
    height: 36px;
    min-height: 36px;
    max-height: 36px;
    padding: 0 4px 0 10px;
    font-size: 13px;
    color: #c0c0d0;
    cursor: pointer;
    transition: background 0.1s;
    position: relative;
    gap: 6px;
    white-space: nowrap;
    flex-shrink: 0 !important;
    flex-grow: 0 !important;
}

    .tree-field:hover {
        background: rgba(255, 255, 255, 0.04);
    }

    .tree-field.mapped {
        color: #ffffff;
    }

    .tree-field.drag-over {
        background: rgba(74, 222, 128, 0.12) !important;
    }

/* Tree indentation */
.tree-indent {
    color: #3a3a5a;
    font-family: "Consolas", monospace;
    font-size: 11px;
    margin-right: 2px;
}

/* Drag handle */
.tree-icon {
    color: #4a4a6a;
    cursor: grab;
    font-size: 10px;
    letter-spacing: -2px;
    user-select: none;
    flex-shrink: 0;
}

.tree-field:hover .tree-icon {
    color: #7a7a9a;
}

/* Field name */
.field-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

/* Type tag (target side) */
.field-type-tag {
    font-size: 9px;
    color: #6a6a8a;
    background: rgba(255, 255, 255, 0.06);
    padding: 1px 5px;
    border-radius: 3px;
    text-transform: lowercase;
    flex-shrink: 0;
}

/* ===== CONNECTION JOINTS (Triangles) ===== */
.connector-dot {
    width: 0;
    height: 0;
    flex-shrink: 0;
    transition: all 0.15s;
}

/* Source side: triangle pointing RIGHT (▶) */
.source-field .connector-dot {
    order: 100;
    margin-left: auto;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-left: 10px solid #4a4a6a;
    border-right: none;
}

.source-field.mapped .connector-dot {
    border-left-color: #4ade80;
    filter: drop-shadow(0 0 4px rgba(74, 222, 128, 0.6));
}

.source-field:hover .connector-dot {
    border-left-color: #6a8aaa;
    transform: scale(1.2);
}

/* Target side: triangle pointing LEFT (◀) */
.target-field .connector-dot {
    order: -1;
    border-top: 6px solid transparent;
    border-bottom: 6px solid transparent;
    border-right: 10px solid #4a4a6a;
    border-left: none;
}

    .target-field.mapped .connector-dot,
    .target-field .connector-dot.connected {
        border-right-color: var(--dot-color, #4ade80);
        filter: drop-shadow(0 0 4px rgba(74, 222, 128, 0.6));
    }

.target-field:hover .connector-dot {
    border-right-color: #6a8aaa;
    transform: scale(1.2);
}

/* ===== MAPPED BADGE (source side) ===== */
.mapped-badge {
    font-size: 9px;
    font-weight: 500;
    color: #4ade80;
    background: rgba(74, 222, 128, 0.12);
    padding: 1px 6px;
    border-radius: 8px;
    flex-shrink: 0;
}

/* ===== SOURCE CHIP (target side - shows linked source) ===== */
.source-chip {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 10px;
    color: #ffffff;
    padding: 1px 6px 1px 4px;
    border-radius: 8px;
    max-width: 120px;
    overflow: hidden;
    flex-shrink: 0;
}

    .source-chip .chip-x {
        width: 12px;
        height: 12px;
        padding: 0;
        margin-left: 2px;
        font-size: 10px;
        line-height: 1;
        background: rgba(255, 255, 255, 0.25);
        border: none;
        border-radius: 50%;
        color: #ffffff;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        flex-shrink: 0;
    }

        .source-chip .chip-x:hover {
            background: rgba(255, 255, 255, 0.4);
        }

/* ===== FIELD DELETE BUTTON ===== */
.field-delete {
    opacity: 0;
    width: 16px;
    height: 16px;
    padding: 0;
    font-size: 12px;
    background: transparent;
    border: none;
    color: #666;
    cursor: pointer;
    transition: opacity 0.1s, color 0.1s;
    flex-shrink: 0;
}

.tree-field:hover .field-delete {
    opacity: 1;
}

.field-delete:hover {
    color: #ef4444;
}

/* Field edit button */
.field-edit-btn {
    opacity: 0;
    width: 18px;
    height: 18px;
    padding: 0;
    font-size: 10px;
    background: transparent;
    border: none;
    cursor: pointer;
    transition: opacity 0.1s;
    flex-shrink: 0;
    margin-left: 4px;
}

.tree-field:hover .field-edit-btn {
    opacity: 0.6;
}

.field-edit-btn:hover {
    opacity: 1 !important;
}

/* Field name inline input */
.field-name-input {
    background: #12121f;
    border: 1px solid #4a8af4;
    border-radius: 3px;
    padding: 2px 6px;
    color: #ffffff;
    font-size: 12px;
    font-family: inherit;
    width: 120px;
    outline: none;
}

    .field-name-input:focus {
        border-color: #6aa0f4;
        box-shadow: 0 0 0 2px rgba(74, 138, 244, 0.2);
    }

.tree-field.editing {
    background: rgba(74, 138, 244, 0.1);
}

/* SVG Canvas for lines */
.mapper-canvas {
    position: relative;
    background: linear-gradient(135deg, #1a1a2a 0%, #1e1e35 100%);
    overflow: hidden;
}

.mapping-lines-svg {
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
}

.mapping-path {
    cursor: pointer;
    transition: stroke-width 0.15s, opacity 0.15s;
}

    .mapping-path:hover,
    .mapping-path.selected {
        stroke-width: 3;
    }

.function-node {
    cursor: pointer;
    transition: transform 0.15s;
}

    .function-node:hover,
    .function-node.selected {
        transform: scale(1.15);
    }

    .function-node circle {
        filter: drop-shadow(0 2px 4px rgba(0,0,0,0.3));
    }

/* Mapping Editor Panel */
.mapping-editor-panel {
    margin-top: 12px;
    padding: 16px;
    background: #1e1e30;
    border-radius: 8px;
    border: 1px solid #3a3a5c;
}

    .mapping-editor-panel .editor-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
        padding-bottom: 10px;
        border-bottom: 1px solid #3a3a5c;
    }

        .mapping-editor-panel .editor-header h4 {
            margin: 0;
            font-size: 14px;
            color: #ffffff;
            display: flex;
            align-items: center;
            gap: 8px;
        }

.editor-color-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.mapping-editor-panel .editor-body {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.mapping-editor-panel .form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.mapping-editor-panel .form-group {
    margin-bottom: 0;
}

    .mapping-editor-panel .form-group label {
        font-size: 11px;
        color: #8a8aaa;
        margin-bottom: 4px;
    }

.mapping-editor-panel textarea {
    font-family: 'Monaco', 'Consolas', monospace;
    font-size: 12px;
}

.mapping-editor-panel small {
    font-size: 10px;
    color: #6a6a8a;
}

/* Transform header improvements */
.transform-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 12px;
    border-bottom: 1px solid #3a3a5c;
}

    .transform-header .form-group.inline {
        display: flex;
        align-items: center;
        gap: 8px;
    }

        .transform-header .form-group.inline label {
            margin-bottom: 0;
            white-space: nowrap;
        }

.transform-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.mapping-count {
    font-size: 12px;
    color: #6a8aaa;
    padding: 4px 10px;
    background: #1a2a3a;
    border-radius: 12px;
}

/* ===== DRAG AND DROP STATES ===== */
.tree-field.drag-over .connector-dot {
    background: #4ade80 !important;
    border-color: #4ade80 !important;
    transform: scale(1.3);
    box-shadow: 0 0 10px rgba(74, 222, 128, 0.7);
}

.empty-state {
    padding: 30px 16px;
    text-align: center;
    color: #6a6a8a;
    font-size: 12px;
}

    .empty-state.drop-zone {
        margin: 8px;
        border: 2px dashed #3a3a5c;
        border-radius: 6px;
        transition: all 0.15s;
    }

        .empty-state.drop-zone:hover {
            border-color: #5a7a9a;
            background: rgba(90, 122, 154, 0.08);
        }

    .empty-state p {
        margin: 0 0 4px 0;
        color: #888;
    }

    .empty-state small {
        color: #555;
    }

/* ===== MAPPER CANVAS (SVG Lines) ===== */
.mapper-canvas {
    position: relative;
    background: #0f0f1a;
    border-left: 1px solid #252540;
    border-right: 1px solid #252540;
    overflow: hidden;
}

.mapping-lines-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

    .mapping-lines-svg path {
        pointer-events: stroke;
        cursor: pointer;
    }

        .mapping-lines-svg path:hover {
            stroke-width: 3 !important;
        }

    .mapping-lines-svg .selected-line {
        stroke-width: 3 !important;
        filter: drop-shadow(0 0 4px currentColor);
    }
