/* ==========================================================================
   Workflow Designer Styles
   Extracted from Workflows.razor for maintainability
   Uses design tokens that match Tailwind config
   ========================================================================== */

/* --------------------------------------------------------------------------
   Workflow Page Container - Full height layout using flexbox
   Fills the available space in the flex parent (main element)
   -------------------------------------------------------------------------- */
.workflow-page-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Workflow Node Base Styles
   -------------------------------------------------------------------------- */
.workflow-node {
    cursor: move;
    user-select: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.workflow-node:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.workflow-node.dragging {
    transform: rotate(5deg);
    box-shadow: 0 8px 25px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

.workflow-node .node-header {
    display: flex;
    align-items: center;
    gap: 8px;
}

.workflow-node.start-node {
    border: 2px solid #22c55e; /* green-500 */
    box-shadow: 0 0 10px rgba(34, 197, 94, 0.3);
}

/* --------------------------------------------------------------------------
   Node Palette Styles
   -------------------------------------------------------------------------- */
.palette-node {
    cursor: grab;
    user-select: none;
    transition: transform 0.2s ease;
}

.palette-node:hover {
    transform: scale(1.05);
}

.palette-node:active {
    cursor: grabbing;
    transform: scale(0.95);
}

.palette-node[draggable="true"] {
    cursor: grab;
}

.palette-node[draggable="true"]:active {
    cursor: grabbing;
    opacity: 0.7;
}

/* --------------------------------------------------------------------------
   Designer Canvas Styles
   -------------------------------------------------------------------------- */
.designer-canvas {
    position: relative;
    background-image: radial-gradient(circle, #e5e7eb 1px, transparent 1px);
    background-size: 20px 20px;
    background-position: 0 0, 10px 10px;
}

.designer-canvas.drag-over {
    background-color: rgba(59, 130, 246, 0.1);
    border: 2px dashed #3b82f6;
}

.workflow-designer {
    position: relative;
    transition: all 0.2s ease;
}

.workflow-designer.drag-over {
    background-color: rgba(59, 130, 246, 0.05);
    border: 2px dashed #3b82f6;
    border-radius: 8px;
}

.workflow-designer.drag-over::before {
    content: "Drop node here";
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(59, 130, 246, 0.9);
    color: white;
    padding: 12px 24px;
    border-radius: 6px;
    font-weight: 500;
    z-index: 1000;
    pointer-events: none;
}

/* --------------------------------------------------------------------------
   Connection Styles
   -------------------------------------------------------------------------- */
.connections-layer {
    position: absolute;
    top: 0;
    left: 0;
    pointer-events: none;
    z-index: 1;
}

.connection {
    pointer-events: all;
    cursor: pointer;
}

.connection:hover path {
    stroke: #2563eb;
    stroke-width: 3;
}

.connection-label {
    font-size: 12px;
    fill: #6b7280;
    background: white;
    padding: 2px 4px;
    border-radius: 3px;
}

.connection-point {
    position: absolute;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #3b82f6;
    border: 2px solid white;
    cursor: crosshair;
    opacity: 0;
    transition: opacity 0.2s ease;
    z-index: 10;
}

.workflow-node:hover .connection-point {
    opacity: 1;
}

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

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

.connection-point:hover {
    background: #2563eb;
    transform: translateY(-50%) scale(1.2);
}

/* --------------------------------------------------------------------------
   Start Node Badge
   -------------------------------------------------------------------------- */
.start-badge {
    background: #22c55e;
    color: white;
    font-size: 10px;
    padding: 2px 6px;
    border-radius: 10px;
    margin-left: auto;
    font-weight: bold;
}

/* --------------------------------------------------------------------------
   Diagram Node Styles (Syncfusion/Z.Blazor.Diagrams)
   -------------------------------------------------------------------------- */
.node-header-diagram {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 4px 8px;
    width: 100%;
    font-size: 12px;
    font-weight: bold;
}

.node-icon-diagram {
    font-size: 14px;
    margin-right: 6px;
}

.node-title-diagram {
    flex: 1;
    text-align: left;
    font-size: 11px;
    font-weight: bold;
}

.start-badge-diagram {
    background: rgba(255, 255, 255, 0.3);
    color: white;
    font-size: 8px;
    padding: 2px 4px;
    border-radius: 8px;
    font-weight: bold;
}

.node-content-diagram {
    padding: 4px 8px;
    font-size: 9px;
    line-height: 1.2;
    text-align: left;
    width: 100%;
    word-wrap: break-word;
    overflow: hidden;
}

/* --------------------------------------------------------------------------
   Syncfusion Diagram Overrides
   These require !important to override framework defaults
   -------------------------------------------------------------------------- */
.e-diagram .e-node {
    border-radius: 8px !important;
    cursor: pointer;
    transition: all 0.2s ease;
}

.e-diagram .e-node rect {
    border-radius: 8px !important;
    rx: 8 !important;
    ry: 8 !important;
}

.e-diagram .e-node:hover {
    transform: translateY(-1px);
}

/* Node color borders using CSS custom properties */
.e-diagram .e-node rect {
    box-shadow:
        -4px 0 0 0 var(--node-color, #3b82f6) inset,
        4px 0 0 0 var(--node-color, #3b82f6) inset !important;
}

/* Node type color mapping - using Tailwind color palette */
.e-diagram .e-node[id*="message"] { --node-color: #3b82f6; } /* blue-500 */
.e-diagram .e-node[id*="question"] { --node-color: #22c55e; } /* green-500 */
.e-diagram .e-node[id*="textinput"],
.e-diagram .e-node[id*="emailinput"],
.e-diagram .e-node[id*="dateinput"],
.e-diagram .e-node[id*="numberinput"],
.e-diagram .e-node[id*="currencyinput"],
.e-diagram .e-node[id*="phoneinput"] { --node-color: #eab308; } /* yellow-500 */
.e-diagram .e-node[id*="dropdown"],
.e-diagram .e-node[id*="multiselect"] { --node-color: #06b6d4; } /* cyan-500 */
.e-diagram .e-node[id*="fileupload"] { --node-color: #22c55e; } /* green-500 */
.e-diagram .e-node[id*="condition"] { --node-color: #f97316; } /* orange-500 */
.e-diagram .e-node[id*="handoff"] { --node-color: #ef4444; } /* red-500 */
.e-diagram .e-node[id*="end"] { --node-color: #6b7280; } /* gray-500 */

/* Enhanced start node styling */
.e-diagram .e-node.start-node rect {
    box-shadow:
        -5px 0 0 0 var(--node-color, #3b82f6) inset,
        5px 0 0 0 var(--node-color, #3b82f6) inset,
        0 0 0 2px var(--node-color, #3b82f6) !important;
}

/* Port interaction styles */
.e-diagram .e-port {
    cursor: crosshair !important;
    transition: all 0.2s ease;
    z-index: 1000;
}

.e-diagram .e-port:hover {
    transform: scale(1.3) !important;
    box-shadow: 0 0 10px rgba(59, 130, 246, 0.7) !important;
}

/* Connection mode cursor */
.connection-mode .e-diagram-canvas {
    cursor: crosshair !important;
}

.connection-mode .e-diagram .e-port {
    opacity: 1 !important;
    visibility: visible !important;
}

/* --------------------------------------------------------------------------
   Syncfusion Toast Overrides
   -------------------------------------------------------------------------- */
.e-toast-container {
    z-index: 9999 !important;
    position: fixed !important;
    top: 20px !important;
    right: 20px !important;
}

.e-toast {
    min-width: 300px !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important;
}

.e-toast.success {
    background-color: #22c55e !important;
    color: white !important;
    border: 2px solid #16a34a !important;
    z-index: 9999 !important;
}

.e-toast.error {
    background-color: #ef4444 !important;
    color: white !important;
    border: 2px solid #dc2626 !important;
    z-index: 9999 !important;
}

/* --------------------------------------------------------------------------
   Workflow Loading State
   -------------------------------------------------------------------------- */
.workflow-loading-state {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
    padding: 2rem;
}

.workflow-loading-content {
    text-align: center;
    max-width: 400px;
}

.workflow-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f4f6;
    border-top: 4px solid #3b82f6;
    border-radius: 50%;
    animation: workflow-spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes workflow-spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.workflow-loading-content h2 {
    color: #374151;
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.workflow-loading-content p {
    color: #6b7280;
    font-size: 1rem;
}

/* --------------------------------------------------------------------------
   Dialog Styles (using existing Modal component patterns)
   -------------------------------------------------------------------------- */
.dialog-content {
    padding: 20px;
}

.dialog-content .form-group {
    margin-bottom: 20px;
}

.dialog-content .form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
}

/* --------------------------------------------------------------------------
   Node Icons using Lucide Font
   -------------------------------------------------------------------------- */
.node-icon-diagram::before {
    font-family: 'lucide';
    font-style: normal;
    font-weight: normal;
    font-size: 14px;
}

/* Map node types to Lucide icons */
.node-icon-diagram.icon-message::before { content: "\e11b"; } /* message-square */
.node-icon-diagram.icon-question::before { content: "\e0f4"; } /* help-circle */
.node-icon-diagram.icon-text-input::before { content: "\e198"; } /* type */
.node-icon-diagram.icon-email-input::before { content: "\e114"; } /* mail */
.node-icon-diagram.icon-phone-input::before { content: "\e137"; } /* phone */
.node-icon-diagram.icon-date-input::before { content: "\e067"; } /* calendar */
.node-icon-diagram.icon-number-input::before { content: "\e0f3"; } /* hash */
.node-icon-diagram.icon-currency-input::before { content: "\e0b5"; } /* dollar-sign */
.node-icon-diagram.icon-dropdown-select::before { content: "\e107"; } /* list */
.node-icon-diagram.icon-multi-select::before { content: "\e55e"; } /* square-check */
.node-icon-diagram.icon-file-upload::before { content: "\e19e"; } /* upload */
.node-icon-diagram.icon-form-group::before { content: "\e0d0"; } /* file-text */
.node-icon-diagram.icon-condition::before { content: "\e0e8"; } /* git-branch */
.node-icon-diagram.icon-handoff-to-human::before { content: "\e1a1"; } /* user-check */
.node-icon-diagram.icon-end-conversation::before { content: "\e0dd"; } /* flag */
