﻿/* Workflow Designer Styles - Enhanced with Curved Connections, Pan/Zoom, and Updated Rules */

.workflow-designer-card {
    height: calc(100vh - 200px);
    min-height: 600px;
}

.workflow-toolbar {
    background: #f8f9fa;
    border-bottom: 1px solid #dee2e6;
}

.workflow-designer-container {
    display: flex;
    height: calc(100vh - 280px);
    min-height: 520px;
}

/* Simplified Sidebar */
.workflow-sidebar {
    width: 280px;
    background: #f8f9fa;
    border-right: 1px solid #dee2e6;
    overflow-y: auto;
    flex-shrink: 0;
}

.sidebar-section {
    padding: 15px 20px;
    border-bottom: 1px solid #dee2e6;
}

.sidebar-section-title {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #6c757d;
    margin-bottom: 10px;
}

/* Draggable Items */
.draggable-item {
    display: flex;
    align-items: center;
    padding: 12px;
    margin: 8px 0;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 8px;
    cursor: grab;
    transition: all 0.2s ease;
    user-select: none;
}

    .draggable-item:hover {
        border-color: #0d6efd;
        box-shadow: 0 2px 8px rgba(13, 110, 253, 0.15);
        transform: translateY(-1px);
    }

    .draggable-item:active {
        cursor: grabbing;
        transform: translateY(0);
    }

.item-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    margin-right: 12px;
    flex-shrink: 0;
}

/* GREEN for locations */
.location-icon {
    background: linear-gradient(135deg, #28a745, #20c997);
}

/* ORANGE for all reading points (reading-station, entrance, exit) */
.reading-point-icon,
.entrance-icon,
.exit-icon {
    background: linear-gradient(135deg, #ff5722, #fd7e14);
}

.item-info {
    flex-grow: 1;
}

.item-title {
    font-weight: 600;
    color: #212529;
    font-size: 14px;
    margin-bottom: 2px;
}

/* Enhanced Canvas Styles with Pan/Zoom Support */
.workflow-canvas {
    flex: 1;
    position: relative;
    background: white;
    background-image: radial-gradient(circle, #e9ecef 1px, transparent 1px);
    background-size: 20px 20px;
    overflow: hidden;
    min-height: 400px;
    cursor: grab;
}

    .workflow-canvas:active {
        cursor: grabbing;
    }

/* Canvas container for transform */
.canvas-container {
    position: relative;
    transform-origin: 0 0;
    transition: transform 0.1s ease-out;
    width: 100%;
    height: 100%;
}

.connection-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 10;
    transform-origin: 0 0;
    transition: transform 0.1s ease-out;
}

/* Canvas navigation hints */
.canvas-nav-hint {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    z-index: 20;
    pointer-events: none;
    opacity: 0.8;
}

/* Workflow Nodes */
.workflow-node {
    position: absolute;
    min-width: 160px;
    padding: 16px;
    background: white;
    border: 2px solid #e9ecef;
    border-radius: 12px;
    cursor: move;
    user-select: none;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
    transition: all 0.2s ease;
    z-index: 5;
}

    .workflow-node:hover {
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
        transform: translateY(-1px);
    }

    .workflow-node.selected {
        border-color: #0d6efd;
        box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.2);
    }

    /*Green for locations*/
    .workflow-node.location {
        border-left: 4px solid #28a745;
    }

    /*Orange for all reading points*/
    .workflow-node.reading-station,
    .workflow-node.entrance,
    .workflow-node.exit {
        border-left: 4px solid #ff5722;
    }

.node-header {
    display: flex;
    align-items: center;
    margin-bottom: 8px;
}

.node-type-badge {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 2px 6px;
    border-radius: 4px;
    color: white;
}

    /* GREEN badge for locations */
    .node-type-badge.location {
        background: #28a745;
    }

    /* ORANGE badges for all reading points */
    .node-type-badge.reading-station,
    .node-type-badge.entrance,
    .node-type-badge.exit {
        background: #ff5722;
        color: white;
    }

.node-title {
    font-weight: 600;
    color: #212529;
    margin-bottom: 4px;
    font-size: 14px;
}

/* Connection Points */
.connection-point {
    position: absolute;
    width: 14px;
    height: 14px;
    background: #0d6efd;
    border: 3px solid white;
    border-radius: 50%;
    cursor: crosshair;
    transition: all 0.2s ease;
    z-index: 10;
}

    .connection-point:hover {
        transform: scale(1.2);
        box-shadow: 0 0 0 3px rgba(13, 110, 253, 0.3);
    }

    .connection-point.invalid-target {
        background: #dc3545;
        cursor: not-allowed;
    }

.input-point {
    left: -7px;
    top: 50%;
    transform: translateY(-50%);
}

.output-point {
    right: -7px;
    top: 50%;
    transform: translateY(-50%);
}

/* Enhanced Connection Lines - Now supporting curved paths */
.connection-line {
    stroke: #0d6efd;
    stroke-width: 2.5;
    fill: none;
    marker-end: url(#arrowhead);
    transition: stroke-width 0.2s ease, stroke 0.2s ease;
    filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

    .connection-line:hover {
        stroke-width: 3.5;
        stroke: #0056b3;
        filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.15));
    }

.temp-connection-line {
    stroke: #0d6efd;
    stroke-width: 2.5;
    stroke-dasharray: 8,4;
    fill: none;
    opacity: 0.7;
    animation: dash-flow 1s linear infinite;
}

    .temp-connection-line.invalid {
        stroke: #dc3545;
        opacity: 0.8;
    }

/* Animation for temporary connection line */
@keyframes dash-flow {
    to {
        stroke-dashoffset: -12;
    }
}

/* Validation message */
.validation-message {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #dc3545;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    z-index: 1000;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(220, 53, 69, 0.3);
    opacity: 0;
    transition: opacity 0.3s ease;
}

    .validation-message.show {
        opacity: 1;
    }

/* Properties Panel - Enhanced */
.properties-panel {
    position: fixed;
    right: -400px;
    top: 0;
    width: 400px;
    height: 100vh;
    background: white;
    border-left: 1px solid #dee2e6;
    box-shadow: -4px 0 20px rgba(0, 0, 0, 0.1);
    transition: right 0.3s ease;
    z-index: 1000;
    overflow-y: auto;
}

    .properties-panel.open {
        right: 0;
    }

.properties-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #dee2e6;
    background: #f8f9fa;
}

.properties-content {
    padding: 20px;
}

.panel-content {
    /* This class is targeted by the JavaScript */
}

.connections-section {
    margin-top: 20px;
}

    .connections-section h5 {
        font-size: 14px;
        font-weight: 600;
        color: #495057;
        margin-bottom: 12px;
        padding-bottom: 6px;
        border-bottom: 1px solid #e9ecef;
    }

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

.connection-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 12px;
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 6px;
    margin-bottom: 6px;
}

    .connection-item span {
        flex: 1;
        font-size: 13px;
        color: #495057;
    }

.add-connection {
    display: flex;
    gap: 8px;
    margin-top: 12px;
}

    .add-connection select {
        flex: 1;
    }

/* Enhanced Page Layout */
.workflow-page {
    padding: 20px;
    min-height: 100vh;
    background-color: #f8f9fa;
}

.workflow-container {
    background: white;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    overflow: hidden;
    min-height: 600px;
}

.workflow-designer {
    display: flex;
    height: 600px;
}

/* Page Header */
.page-header {
    margin-bottom: 2rem;
}

    .page-header h2 {
        color: #212529;
        font-weight: 600;
    }

    .page-header .text-muted {
        font-size: 1rem;
    }

/* Button Styles */
.btn {
    border-radius: 6px;
    font-weight: 500;
    transition: all 0.2s ease;
}

    .btn:hover {
        transform: translateY(-1px);
    }

.btn-primary {
    background: #0d6efd;
    border-color: #0d6efd;
}

.btn-outline-secondary {
    color: #6c757d;
    border-color: #6c757d;
}

    .btn-outline-secondary:hover {
        background: #6c757d;
        border-color: #6c757d;
    }

/* Loading States */
.spinner-border-sm {
    width: 1rem;
    height: 1rem;
}

/* Alert Styles */
.alert-info {
    background-color: #d1ecf1;
    border-color: #bee5eb;
    color: #0c5460;
    font-size: 12px;
    padding: 8px 12px;
    margin: 0;
}

/* Material Icons */
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ADDED: Fix oversized delete buttons in properties panel */
.properties-content .connection-item .btn {
    padding: 4px 6px !important;
    min-width: 24px !important;
    height: 24px !important;
    font-size: 12px !important;
    line-height: 1 !important;
    border-radius: 4px !important;
    display: flex !important;
    align-items: center !important;
    justify-content: center !important;
}

    /* ADDED: Fix oversized icons in delete buttons */
    .properties-content .connection-item .btn i,
    .properties-content .connection-item .btn .material-symbols-outlined {
        font-size: 14px !important;
        width: 14px !important;
        height: 14px !important;
        line-height: 1 !important;
    }

/* ADDED: Fix add connection controls sizing */
.properties-content .add-connection select {
    font-size: 13px !important;
    padding: 6px 8px !important;
    height: 32px !important;
}

.properties-content .add-connection .btn {
    padding: 6px 12px !important;
    font-size: 13px !important;
    height: 32px !important;
}

/* ADDED: Fix save button in properties panel */
.properties-content .mt-3 .btn {
    padding: 8px 16px !important;
    font-size: 14px !important;
    height: 36px !important;
}

/* Responsive Design */
@media (max-width: 1200px) {
    .workflow-sidebar {
        width: 240px;
    }

    .properties-panel {
        width: 350px;
        right: -350px;
    }
}

@media (max-width: 992px) {
    .workflow-designer {
        flex-direction: column;
        height: auto;
    }

    .workflow-sidebar {
        width: 100%;
        height: 200px;
        border-right: none;
        border-bottom: 1px solid #dee2e6;
        overflow-x: auto;
        display: flex;
        gap: 20px;
    }

    .sidebar-section {
        min-width: 200px;
        margin-bottom: 0;
    }

    .workflow-canvas {
        height: 500px;
    }

    .properties-panel {
        width: 100%;
        right: -100%;
    }
}
.node-flash {
    animation: flashAnimation 1.5s ease-in-out;
}

@keyframes flashAnimation {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    }

    25%, 75% {
        transform: scale(1.1);
        box-shadow: 0 0 30px rgba(220, 53, 69, 0.8), 0 4px 20px rgba(0, 0, 0, 0.15);
        border-color: #dc3545;
    }

    50% {
        transform: scale(1.05);
        box-shadow: 0 0 20px rgba(220, 53, 69, 0.5), 0 4px 20px rgba(0, 0, 0, 0.15);
    }
}