﻿/* ============================================================
   Workflow Designer — Workflow.css
   Theme: matches XManagementPro blue/slate UI
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&display=swap');

:root {
    --wf-bg: #f0f2f8;
    --wf-surface: #ffffff;
    --wf-surface2: #f6f8fc;
    --wf-surface3: #edf0f7;
    --wf-border: #d4daea;
    --wf-border-light: #bcc5d9;
    --wf-accent: #5b8dee;
    --wf-accent-dark: #3a6fd8;
    --wf-accent-soft: #e8f0fd;
    --wf-accent2: #7c5cbf;
    --wf-accent2-soft: #f0ebfb;
    --wf-accent3: #27b08b;
    --wf-accent3-soft: #e6f7f3;
    --wf-danger: #e05c6a;
    --wf-danger-soft: #fdeef0;
    --wf-warning: #e8943a;
    --wf-warning-soft: #fef3e7;
    --wf-text: #1e2a45;
    --wf-text-muted: #6b7a99;
    --wf-text-dim: #a0aabf;
    --wf-task-h: 34px;
    --wf-task-gap: 5px;
    --wf-stage-w: 270px;
    --wf-stage-gap: 14px;
    --wf-radius: 6px;
    --wf-radius-lg: 10px;
    --wf-shadow-sm: 0 1px 4px rgba(30,42,69,0.08);
    --wf-shadow: 0 4px 16px rgba(30,42,69,0.12);
    --wf-transition: 0.16s ease;
}

.wf-root * {
    box-sizing: border-box;
}

.wf-root {
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    color: var(--wf-text);
    background: var(--wf-bg);
    display: flex;
    flex-direction: column;
    min-height: 400px;
    border-radius: var(--wf-radius-lg);
    overflow: visible;
    border: 1px solid var(--wf-border);
    box-shadow: var(--wf-shadow);
}

.wf-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 18px;
    background: linear-gradient(135deg, #2c3e72 0%, #3a5298 100%);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.wf-header-title {
    flex: 1;
    min-width: 0;
}

    .wf-header-title h1 {
        font-size: 15px;
        font-weight: 600;
        margin: 0;
        color: #ffffff;
        letter-spacing: 0.01em;
    }

    .wf-header-title p {
        font-size: 11px;
        color: rgba(255,255,255,0.65);
        margin: 2px 0 0;
    }

.wf-header-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.wf-toolbar {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 7px 18px;
    background: var(--wf-surface);
    border-bottom: 1px solid var(--wf-border);
    flex-shrink: 0;
    flex-wrap: wrap;
}

.wf-toolbar-sep {
    width: 1px;
    height: 18px;
    background: var(--wf-border);
    margin: 0 4px;
}

.wf-toolbar-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--wf-text-muted);
    letter-spacing: 0.07em;
    text-transform: uppercase;
}

.wf-btn {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 5px 11px;
    border-radius: var(--wf-radius);
    border: 1px solid var(--wf-border);
    background: var(--wf-surface);
    color: var(--wf-text);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background var(--wf-transition), border-color var(--wf-transition), color var(--wf-transition), box-shadow var(--wf-transition);
    white-space: nowrap;
    user-select: none;
    line-height: 1;
}

    .wf-btn:hover {
        background: var(--wf-surface3);
        border-color: var(--wf-border-light);
    }

    .wf-btn:active {
        transform: translateY(1px);
    }

.wf-btn-primary {
    background: var(--wf-accent);
    border-color: var(--wf-accent);
    color: #fff;
}

    .wf-btn-primary:hover {
        background: var(--wf-accent-dark);
        border-color: var(--wf-accent-dark);
    }

.wf-btn-danger {
    background: transparent;
    border-color: var(--wf-danger);
    color: var(--wf-danger);
}

    .wf-btn-danger:hover {
        background: var(--wf-danger-soft);
    }

.wf-btn-ghost {
    background: transparent;
    border-color: transparent;
    color: var(--wf-text-muted);
    padding: 5px 7px;
}

    .wf-btn-ghost:hover {
        background: var(--wf-surface3);
        color: var(--wf-text);
        border-color: var(--wf-border);
    }

.wf-header .wf-btn-ghost {
    color: rgba(255,255,255,0.8);
}

    .wf-header .wf-btn-ghost:hover {
        background: rgba(255,255,255,0.12);
        border-color: rgba(255,255,255,0.25);
        color: #fff;
    }

.wf-header .wf-btn-primary {
    background: #fff;
    border-color: #fff;
    color: var(--wf-accent-dark);
}

    .wf-header .wf-btn-primary:hover {
        background: rgba(255,255,255,0.88);
    }

.wf-btn-sm {
    padding: 4px 9px;
    font-size: 11px;
}

.wf-btn-icon {
    padding: 4px;
    min-width: 26px;
    justify-content: center;
}

.wf-btn-connect {
    border-color: var(--wf-accent2);
    color: var(--wf-accent2);
    background: var(--wf-accent2-soft);
}

    .wf-btn-connect:hover {
        background: #e8e0f8;
    }

    .wf-btn-connect.active {
        background: var(--wf-accent2);
        color: #fff;
        box-shadow: 0 0 0 3px rgba(124,92,191,0.2);
    }

.wf-btn-disconnect {
    border-color: var(--wf-warning);
    color: var(--wf-warning);
    background: var(--wf-warning-soft);
}

    .wf-btn-disconnect:hover {
        background: #fde8d4;
    }

    .wf-btn-disconnect.active {
        background: var(--wf-warning);
        color: #fff;
        box-shadow: 0 0 0 3px rgba(232,148,58,0.2);
    }

.wf-canvas-wrap {
    flex: 1;
    overflow: auto;
    position: relative;
    padding: 20px 18px 36px;
    background: var(--wf-bg);
}

.wf-canvas {
    position: relative;
    display: flex;
    align-items: flex-start;
    gap: var(--wf-stage-gap);
    min-width: max-content;
}

.wf-svg-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    overflow: visible;
    z-index: 20;
}

.wf-stage {
    width: var(--wf-stage-w);
    flex-shrink: 0;
    background: var(--wf-surface);
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-lg);
    display: flex;
    flex-direction: column;
    box-shadow: var(--wf-shadow-sm);
    transition: border-color var(--wf-transition), box-shadow var(--wf-transition);
}

    .wf-stage:hover {
        border-color: var(--wf-border-light);
        box-shadow: var(--wf-shadow);
    }

.wf-stage-header {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 9px 11px;
    background: linear-gradient(180deg, #f6f8fc 0%, #edf0f7 100%);
    border-bottom: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-lg) var(--wf-radius-lg) 0 0;
}

.wf-stage-badge {
    font-size: 10px;
    font-weight: 700;
    color: var(--wf-accent-dark);
    background: var(--wf-accent-soft);
    border: 1px solid #c5d8fb;
    border-radius: 4px;
    padding: 1px 5px;
    letter-spacing: 0.04em;
    flex-shrink: 0;
}

.wf-stage-name {
    flex: 1;
    font-weight: 600;
    font-size: 12px;
    color: var(--wf-text);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.wf-stage-name-input {
    flex: 1;
    background: #fff;
    border: 1px solid var(--wf-accent);
    border-radius: 4px;
    color: var(--wf-text);
    font-family: 'Inter', sans-serif;
    font-size: 12px;
    font-weight: 600;
    padding: 2px 6px;
    outline: none;
    box-shadow: 0 0 0 3px rgba(91,141,238,0.15);
}

.wf-stage-actions {
    display: flex;
    gap: 1px;
    opacity: 0;
    transition: opacity var(--wf-transition);
}

.wf-stage:hover .wf-stage-actions {
    opacity: 1;
}

.wf-stage-body {
    padding: 9px 9px 11px;
    display: flex;
    flex-direction: column;
    gap: var(--wf-task-gap);
    min-height: 56px;
}

.wf-stage-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 18px 0;
    color: var(--wf-text-dim);
    font-size: 11px;
}

.wf-task-row {
    position: relative;
    display: flex;
    align-items: center;
    gap: 4px;
}

.wf-task-indent {
    flex-shrink: 0;
    display: flex;
    align-items: center;
}

.wf-task-indent-line {
    width: 1px;
    height: var(--wf-task-h);
    background: var(--wf-border);
    margin-right: 6px;
}

.wf-task-bar {
    flex: 1;
    height: var(--wf-task-h);
    background: var(--wf-surface2);
    border: 1px solid var(--wf-border);
    border-left: 3px solid var(--wf-accent);
    border-radius: var(--wf-radius);
    display: flex;
    align-items: center;
    padding: 0 8px;
    gap: 6px;
    cursor: pointer;
    transition: background var(--wf-transition), border-color var(--wf-transition), box-shadow var(--wf-transition), transform var(--wf-transition);
    position: relative;
    overflow: hidden;
    user-select: none;
    min-width: 0;
    box-shadow: var(--wf-shadow-sm);
}

    .wf-task-bar::before {
        content: '';
        position: absolute;
        left: 0;
        top: 0;
        bottom: 0;
        width: var(--task-progress, 0%);
        background: rgba(91,141,238,0.07);
        pointer-events: none;
    }

    .wf-task-bar:hover {
        background: var(--wf-accent-soft);
        border-color: #c5d8fb;
        border-left-color: var(--wf-accent);
        box-shadow: 0 2px 8px rgba(91,141,238,0.15);
        transform: translateY(-1px);
    }

.wf-canvas.connect-mode .wf-task-bar {
    cursor: crosshair;
    border-left-color: var(--wf-accent2);
}

    .wf-canvas.connect-mode .wf-task-bar:hover {
        box-shadow: 0 0 0 2px var(--wf-accent2), 0 2px 8px rgba(124,92,191,0.15);
        border-color: var(--wf-accent2);
        background: var(--wf-accent2-soft);
    }

.wf-task-bar.connect-source {
    border-color: var(--wf-accent2) !important;
    background: var(--wf-accent2-soft) !important;
    box-shadow: 0 0 0 3px rgba(124,92,191,0.25) !important;
}

.wf-task-name {
    font-size: 12px;
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
    color: var(--wf-text);
}

.wf-task-duration {
    font-size: 10px;
    font-weight: 600;
    color: var(--wf-accent-dark);
    background: var(--wf-accent-soft);
    border-radius: 3px;
    padding: 1px 5px;
    flex-shrink: 0;
    border: 1px solid #c5d8fb;
}

.wf-task-actions {
    display: flex;
    gap: 1px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--wf-transition);
}

.wf-task-bar:hover .wf-task-actions {
    opacity: 1;
}

.wf-add-task-btn {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 4px 7px;
    border-radius: var(--wf-radius);
    border: 1px dashed var(--wf-border);
    background: transparent;
    color: var(--wf-text-dim);
    font-family: 'Inter', sans-serif;
    font-size: 11px;
    cursor: pointer;
    transition: all var(--wf-transition);
    width: 100%;
    margin-top: 3px;
}

    .wf-add-task-btn:hover {
        border-color: var(--wf-accent);
        color: var(--wf-accent);
        background: var(--wf-accent-soft);
    }

.wf-add-stage {
    width: 180px;
    flex-shrink: 0;
    border: 1px dashed var(--wf-border);
    border-radius: var(--wf-radius-lg);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 28px 14px;
    gap: 6px;
    cursor: pointer;
    transition: all var(--wf-transition);
    color: var(--wf-text-dim);
    font-size: 12px;
    background: transparent;
    align-self: stretch;
    min-height: 110px;
}

    .wf-add-stage:hover {
        border-color: var(--wf-accent3);
        color: var(--wf-accent3);
        background: var(--wf-accent3-soft);
    }

.wf-add-stage-icon {
    font-size: 20px;
    line-height: 1;
}

.wf-modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(30,42,69,0.45);
    backdrop-filter: blur(2px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: wf-fade-in 0.14s ease;
}

@keyframes wf-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.wf-modal {
    background: #fff;
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius-lg);
    box-shadow: 0 8px 40px rgba(30,42,69,0.18);
    width: 100%;
    max-width: 450px;
    animation: wf-slide-up 0.18s cubic-bezier(0.34,1.56,0.64,1);
}

@keyframes wf-slide-up {
    from {
        opacity: 0;
        transform: translateY(14px) scale(0.98);
    }

    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.wf-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 13px 16px;
    border-bottom: 1px solid var(--wf-border);
    background: linear-gradient(180deg, #f6f8fc 0%, #edf0f7 100%);
    border-radius: var(--wf-radius-lg) var(--wf-radius-lg) 0 0;
}

    .wf-modal-header h2 {
        font-size: 13px;
        font-weight: 600;
        margin: 0;
        color: var(--wf-text);
    }

.wf-modal-body {
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 13px;
}

.wf-modal-footer {
    padding: 11px 16px;
    border-top: 1px solid var(--wf-border);
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    background: var(--wf-surface2);
    border-radius: 0 0 var(--wf-radius-lg) var(--wf-radius-lg);
}

.wf-field {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

    .wf-field label {
        font-size: 11px;
        font-weight: 600;
        color: var(--wf-text-muted);
        letter-spacing: 0.05em;
        text-transform: uppercase;
    }

.wf-input, .wf-textarea, .wf-select {
    background: #fff;
    border: 1px solid var(--wf-border);
    border-radius: var(--wf-radius);
    color: var(--wf-text);
    font-family: 'Inter', sans-serif;
    font-size: 13px;
    padding: 7px 9px;
    transition: border-color var(--wf-transition), box-shadow var(--wf-transition);
    outline: none;
    width: 100%;
}

    .wf-input:focus, .wf-textarea:focus, .wf-select:focus {
        border-color: var(--wf-accent);
        box-shadow: 0 0 0 3px rgba(91,141,238,0.15);
    }

.wf-textarea {
    min-height: 64px;
    resize: vertical;
}

.wf-select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%236b7a99'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 9px center;
    padding-right: 26px;
    cursor: pointer;
}

.wf-row2 {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 11px;
}

.wf-check-row {
    display: flex;
    align-items: center;
    gap: 7px;
    cursor: pointer;
}

    .wf-check-row input[type=checkbox] {
        accent-color: var(--wf-accent);
        width: 14px;
        height: 14px;
        cursor: pointer;
    }

    .wf-check-row span {
        font-size: 12px;
        color: var(--wf-text);
    }

.wf-toast {
    position: fixed;
    bottom: 18px;
    right: 18px;
    background: var(--wf-text);
    color: #fff;
    border-radius: var(--wf-radius);
    padding: 9px 14px;
    font-size: 12px;
    font-weight: 500;
    box-shadow: var(--wf-shadow);
    z-index: 200;
    animation: wf-toast-in 0.18s ease;
    max-width: 260px;
    border-left: 3px solid var(--wf-accent3);
}

@keyframes wf-toast-in {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.wf-status-bar {
    padding: 5px 18px;
    background: var(--wf-surface);
    border-top: 1px solid var(--wf-border);
    font-size: 11px;
    color: var(--wf-text-muted);
    display: flex;
    align-items: center;
    gap: 7px;
    flex-shrink: 0;
}

.wf-status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--wf-accent3);
    flex-shrink: 0;
}

    .wf-status-dot.connect {
        background: var(--wf-accent2);
    }

    .wf-status-dot.disconnect {
        background: var(--wf-warning);
    }

.wf-confirm-modal {
    max-width: 350px;
}

.wf-canvas-wrap::-webkit-scrollbar {
    width: 5px;
    height: 5px;
}

.wf-canvas-wrap::-webkit-scrollbar-track {
    background: var(--wf-bg);
}

.wf-canvas-wrap::-webkit-scrollbar-thumb {
    background: var(--wf-border);
    border-radius: 3px;
}

    .wf-canvas-wrap::-webkit-scrollbar-thumb:hover {
        background: var(--wf-border-light);
    }

@media (max-width: 640px) {
    :root {
        --wf-stage-w: 220px;
    }

    .wf-canvas-wrap {
        padding: 12px 10px 28px;
    }

    .wf-header, .wf-toolbar {
        padding: 8px 12px;
    }
}

/* ── Drag & Drop ── */
.wf-task-row[draggable="true"] {
    cursor: grab;
}

.wf-task-row.wf-dragging {
    opacity: 0.4;
    pointer-events: none;
}

.wf-drop-indicator {
    height: 2px;
    background: var(--wf-accent);
    border-radius: 2px;
    margin: 1px 0;
    box-shadow: 0 0 0 2px rgba(91,141,238,0.25);
    animation: wf-drop-pulse 0.8s ease infinite alternate;
}

@keyframes wf-drop-pulse {
    from {
        opacity: 0.7;
    }

    to {
        opacity: 1;
    }
}

.wf-stage-body.drop-target-active {
    background: var(--wf-accent-soft);
    border-radius: 0 0 var(--wf-radius-lg) var(--wf-radius-lg);
}

.wf-stage-empty.drop-target-empty {
    border: 1px dashed var(--wf-accent);
    border-radius: var(--wf-radius);
    color: var(--wf-accent);
    background: var(--wf-accent-soft);
}

.wf-task-drag-handle {
    font-size: 13px;
    color: var(--wf-text-dim);
    cursor: grab;
    flex-shrink: 0;
    line-height: 1;
    padding-right: 2px;
    user-select: none;
}

.wf-task-bar:hover .wf-task-drag-handle {
    color: var(--wf-text-muted);
}
