/* CSS Variables for Workflow Editor */
:root {
    --wf-color-border: #e5e7eb;
    --wf-color-surface: #ffffff;
    --wf-color-surface-secondary: #f9fafb;
    --wf-color-surface-hover: #f3f4f6;
    --wf-color-text-primary: #1f2937;
    --wf-color-text-secondary: #6b7280;
    --wf-color-text-tertiary: #9ca3af;
    --wf-color-primary: #3b82f6;
    --wf-color-primary-alpha: rgba(59, 130, 246, 0.2);
    --wf-color-warning: #f59e0b;
    --wf-color-danger: #ef4444;
    --wf-color-success: #10b981;
    --wf-color-success-bg: #d1fae5;
    --wf-color-warning-bg: #fef3c7;
    --wf-color-danger-bg: #fee2e2;
    --wf-spacing-xs: 4px;
    --wf-spacing-sm: 8px;
    --wf-spacing-md: 16px;
    --wf-spacing-lg: 24px;
    --wf-spacing-xl: 32px;
    --wf-border-radius-sm: 4px;
    --wf-border-radius-md: 8px;
    --wf-border-radius-pill: 9999px;
    --wf-font-size-xs: 11px;
    --wf-font-size-sm: 13px;
    --wf-font-size-md: 15px;
    --wf-font-weight-medium: 500;
    --wf-font-weight-semibold: 600;
    --wf-font-family-mono: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    --wf-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --wf-shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
}

/* Workflow Editor Layout - using !important to override Bootstrap */
.workflow-editor-layout {
    display: grid !important;
    grid-template-columns: 220px 1fr 280px !important;
    grid-template-rows: 1fr !important;
    grid-template-areas: "palette canvas config" !important;
    height: 100% !important;
    min-height: 600px !important;
    border: 1px solid var(--wf-color-border) !important;
    border-radius: var(--wf-border-radius-md) !important;
    overflow: hidden !important;
    background: var(--wf-color-surface) !important;
    width: 100% !important;
}

/* Palette */
.workflow-palette {
    grid-area: palette !important;
    background: var(--wf-color-surface-secondary);
    border-right: 1px solid var(--wf-color-border);
    padding: var(--wf-spacing-md);
    overflow-y: auto;
}

.palette-section {
    margin-bottom: var(--wf-spacing-lg);
}

.palette-section h4 {
    font-size: var(--wf-font-size-sm);
    font-weight: var(--wf-font-weight-semibold);
    color: var(--wf-color-text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: var(--wf-spacing-sm);
}

.palette-item {
    display: flex;
    align-items: center;
    gap: var(--wf-spacing-sm);
    padding: var(--wf-spacing-sm) var(--wf-spacing-md);
    margin-bottom: var(--wf-spacing-xs);
    border-radius: var(--wf-border-radius-sm);
    border-left: 3px solid transparent;
    background: var(--wf-color-surface);
    cursor: grab;
    font-size: var(--wf-font-size-sm);
    user-select: none;
    transition: background 0.15s ease;
}

.palette-item:hover {
    background: var(--wf-color-surface-hover);
}

.palette-trigger {
    border-left-color: var(--wf-color-warning);
}

.palette-action {
    border-left-color: var(--wf-color-primary);
}

.palette-icon {
    font-size: var(--wf-font-size-md);
}

.palette-label {
    color: var(--wf-color-text-primary);
}

/* Canvas */
.workflow-canvas-area {
    grid-area: canvas !important;
    position: relative;
    background: var(--wf-color-surface-secondary);
    background-image:
        radial-gradient(circle, var(--wf-color-border) 1px, transparent 1px);
    background-size: 24px 24px;
    overflow: hidden;
    min-height: 400px;
}

.workflow-edges-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.workflow-edge {
    fill: none;
    stroke: var(--wf-color-primary);
    stroke-width: 2px;
    stroke-dasharray: none;
    cursor: pointer;
    pointer-events: stroke;
    transition: stroke 0.15s;
}

.workflow-edge:hover {
    stroke: var(--wf-color-danger);
    stroke-width: 3px;
}

/* Workflow Node */
.workflow-node {
    position: absolute;
    width: 160px;
    border: 2px solid var(--wf-color-border);
    border-radius: var(--wf-border-radius-md);
    background: var(--wf-color-surface);
    cursor: pointer;
    z-index: 2;
    display: flex;
    align-items: center;
    gap: var(--wf-spacing-xs);
    box-shadow: var(--wf-shadow-sm);
    transition: border-color 0.15s, box-shadow 0.15s;
}

.workflow-node:hover {
    box-shadow: var(--wf-shadow-md);
}

.workflow-node.selected {
    border-color: var(--wf-color-primary);
    box-shadow: 0 0 0 3px var(--wf-color-primary-alpha);
}

.workflow-node.node-type-trigger {
    border-top: 3px solid var(--wf-color-warning);
}

.workflow-node.node-type-action {
    border-top: 3px solid var(--wf-color-primary);
}

.node-content {
    flex: 1;
    padding: var(--wf-spacing-sm) var(--wf-spacing-md);
}

.node-type-label {
    font-size: 10px;
    font-weight: var(--wf-font-weight-semibold);
    text-transform: uppercase;
    color: var(--wf-color-text-secondary);
    letter-spacing: 0.05em;
}

.node-label {
    font-size: var(--wf-font-size-sm);
    font-weight: var(--wf-font-weight-medium);
    color: var(--wf-color-text-primary);
    margin-top: 2px;
}

.node-input-port,
.node-output-port {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: var(--wf-color-border);
    border: 2px solid var(--wf-color-surface);
    cursor: crosshair;
    flex-shrink: 0;
    transition: background 0.15s;
}

.node-input-port {
    margin-left: -6px;
}

.node-output-port {
    margin-right: -6px;
}

.node-input-port:hover,
.node-output-port:hover {
    background: var(--wf-color-primary);
}

/* Config Panel */
.workflow-config-panel {
    grid-area: config !important;
    border-left: 1px solid var(--wf-color-border);
    background: var(--wf-color-surface);
    padding: var(--wf-spacing-md);
    overflow-y: auto;
}

.no-selection {
    color: var(--wf-color-text-secondary);
    font-size: var(--wf-font-size-sm);
    text-align: center;
    padding-top: var(--wf-spacing-xl);
}

.config-header {
    margin-bottom: var(--wf-spacing-md);
}

.config-header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.delete-node-btn {
    width: 24px;
    height: 24px;
    padding: 0;
    border: 1px solid var(--wf-color-border);
    border-radius: var(--wf-border-radius-sm);
    background: var(--wf-color-surface);
    color: var(--wf-color-text-secondary);
    cursor: pointer;
    font-size: var(--wf-font-size-sm);
    font-weight: var(--wf-font-weight-semibold);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s;
}

.delete-node-btn:hover {
    background: var(--wf-color-danger-bg);
    border-color: var(--wf-color-danger);
    color: var(--wf-color-danger);
}

.config-node-type {
    font-size: 10px;
    font-weight: var(--wf-font-weight-semibold);
    text-transform: uppercase;
    color: var(--wf-color-text-secondary);
    letter-spacing: 0.05em;
}

.config-node-label {
    font-size: var(--wf-font-size-md);
    font-weight: var(--wf-font-weight-semibold);
    color: var(--wf-color-text-primary);
    margin: var(--wf-spacing-xs) 0;
}

.config-type-key {
    font-size: 11px;
    color: var(--wf-color-text-tertiary);
    font-family: var(--wf-font-family-mono);
}

.config-fields {
    display: flex;
    flex-direction: column;
    gap: var(--wf-spacing-md);
}

.config-field label {
    display: block;
    font-size: var(--wf-font-size-sm);
    font-weight: var(--wf-font-weight-medium);
    color: var(--wf-color-text-secondary);
    margin-bottom: var(--wf-spacing-xs);
}

.config-input,
.config-textarea {
    width: 100%;
    padding: var(--wf-spacing-sm);
    border: 1px solid var(--wf-color-border);
    border-radius: var(--wf-border-radius-sm);
    background: var(--wf-color-surface-secondary);
    color: var(--wf-color-text-primary);
    font-size: var(--wf-font-size-sm);
    box-sizing: border-box;
}

.config-input:focus,
.config-textarea:focus {
    outline: none;
    border-color: var(--wf-color-primary);
    box-shadow: 0 0 0 2px var(--wf-color-primary-alpha);
}

.config-textarea {
    resize: vertical;
    min-height: 80px;
}

.no-config {
    font-size: var(--wf-font-size-sm);
    color: var(--wf-color-text-secondary);
}

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: var(--wf-border-radius-pill);
    font-size: var(--wf-font-size-xs);
    font-weight: var(--wf-font-weight-semibold);
}

.status-active {
    background: var(--wf-color-success-bg);
    color: var(--wf-color-success);
}

.status-paused {
    background: var(--wf-color-warning-bg);
    color: var(--wf-color-warning);
}

/* Workflow List */
.workflow-list {
    width: 100%;
}

.workflow-list .data-table {
    width: 100%;
    border-collapse: collapse;
}

.workflow-list .data-table th,
.workflow-list .data-table td {
    padding: var(--wf-spacing-sm) var(--wf-spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--wf-color-border);
}

.workflow-list .data-table th {
    font-weight: var(--wf-font-weight-semibold);
    color: var(--wf-color-text-secondary);
    font-size: var(--wf-font-size-sm);
}

.workflow-list .workflow-name {
    font-weight: var(--wf-font-weight-medium);
}

.workflow-list .actions-cell {
    display: flex;
    gap: var(--wf-spacing-xs);
}

.workflow-list .action-btn {
    padding: var(--wf-spacing-xs) var(--wf-spacing-sm);
    border: 1px solid var(--wf-color-border);
    border-radius: var(--wf-border-radius-sm);
    background: var(--wf-color-surface);
    cursor: pointer;
    font-size: var(--wf-font-size-xs);
    transition: all 0.15s;
}

.workflow-list .action-btn:hover {
    background: var(--wf-color-surface-hover);
}

.workflow-list .delete-btn:hover {
    background: var(--wf-color-danger-bg);
    border-color: var(--wf-color-danger);
    color: var(--wf-color-danger);
}

.workflow-list .empty-state {
    text-align: center;
    padding: var(--wf-spacing-xl);
    color: var(--wf-color-text-secondary);
}

.workflow-list .loading {
    text-align: center;
    padding: var(--wf-spacing-lg);
    color: var(--wf-color-text-secondary);
}

/* Editor Page Container */
.workflow-canvas-container {
    height: calc(100vh - 280px) !important;
    min-height: 500px !important;
    border-radius: var(--wf-border-radius-md);
    overflow: hidden;
    display: block !important;
}

.workflow-canvas-container > .workflow-editor-layout {
    height: 100% !important;
}

/* Editor Form Header */
.workflow-form-header {
    display: flex;
    align-items: flex-end;
    gap: var(--wf-spacing-md);
    margin-bottom: var(--wf-spacing-lg);
    flex-wrap: wrap;
}

.workflow-form-header .form-group {
    flex: 1;
    min-width: 200px;
}

.workflow-form-header .form-group label {
    display: block;
    font-size: var(--wf-font-size-sm);
    font-weight: var(--wf-font-weight-medium);
    color: var(--wf-color-text-secondary);
    margin-bottom: var(--wf-spacing-xs);
}

.workflow-form-header .form-control {
    width: 100%;
    padding: var(--wf-spacing-sm) var(--wf-spacing-md);
    border: 1px solid var(--wf-color-border);
    border-radius: var(--wf-border-radius-sm);
    background: var(--wf-color-surface);
    color: var(--wf-color-text-primary);
    font-size: var(--wf-font-size-md);
}

.workflow-form-header .form-control:focus {
    outline: none;
    border-color: var(--wf-color-primary);
    box-shadow: 0 0 0 2px var(--wf-color-primary-alpha);
}
