/* Define Inter Font */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@100..900&display=swap');

body {
    font-family: 'Inter', sans-serif;
    transition: background-color 0.3s, color 0.3s;
}

/* --- BASE STYLES --- */
.text-accent {
    color: #0588e4;
}

.bg-node {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
}

.bg-node-merge {
    background-color: #e0f2fe;
    border: 1px solid #93c5fd;
}

.bg-interactive-pause {
    background-color: #fffbeb;
    border: 2px solid #fcd34d;
}

.input-bg {
    background-color: #ffffff;
    border-color: #d1d5db;
}

.log-bg {
    background-color: #e5e7eb;
    border-color: #d1d5db;
}

.shadow-custom {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.06);
}

.btn-accent {
    background-color: #0588e4;
    color: white;
    box-shadow: 0 4px 6px -1px rgba(5, 136, 228, 0.3);
}

.input-flow-start {
    animation: inputPulse 1.5s ease-out;
    border-color: #10b981 !important;
    opacity: 0.5;
}

/* --- DARK THEME --- */
body[data-theme="dark"] {
    background-color: #0d1117;
    color: #ffffff;
}

body[data-theme="dark"] .text-accent {
    color: #00ffff;
}

body[data-theme="dark"] .bg-node {
    background-color: #161b22;
    border: 1px solid #30363d;
}

body[data-theme="dark"] .bg-node-merge {
    background-color: #0a182e;
    border: 1px solid #00ffff;
}

body[data-theme="dark"] .bg-interactive-pause {
    background-color: #2e240a;
    border: 2px solid #fcd34d;
}

body[data-theme="dark"] .input-bg {
    background-color: #010409;
    border-color: #30363d;
    color: white;
}

body[data-theme="dark"] .log-bg {
    background-color: #161b22;
    border-color: #30363d;
    color: #c0c0c0;
}

body[data-theme="dark"] .shadow-custom {
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.5);
}

body[data-theme="dark"] .btn-accent {
    background-color: #00ffff;
    color: #161b22;
    box-shadow: 0 4px 6px -1px rgba(0, 255, 255, 0.3);
}

/* --- FLOWCHART LAYOUT --- */
#flowchart-container {
    position: relative;
    padding-top: 2rem;
    padding-bottom: 2rem;
}

#flow-connector-svg {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 5;
}

.flow-path {
    fill: none;
    stroke-width: 3;
    stroke-dasharray: 10 5;
    transition: stroke 0.5s;
}

.flow-path.animating {
    animation: dash-flow 1.5s linear infinite;
}

.flow-path.completed {
    animation: none;
    stroke-dashoffset: 0;
}

@keyframes dash-flow {
    to {
        stroke-dashoffset: -15;
    }
}

@keyframes inputPulse {
    0% {
        transform: scale(1);
        opacity: 1;
    }

    50% {
        transform: scale(1.02);
        opacity: 0.7;
    }

    100% {
        transform: scale(1);
        opacity: 0.5;
    }
}

.flow-step-container {
    display: flex;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 6rem;
    position: relative;
    z-index: 10;
}

.node-card {
    width: 300px;
    min-height: 120px;
    border-radius: 12px;
    position: relative;
    z-index: 10;
    transition: background-color 0.4s ease;
}

.parallel-group-card {
    width: 100%;
    min-height: 200px;
    border-radius: 12px;
    position: relative;
    z-index: 10;
    transition: background-color 0.4s ease;
    padding: 20px;
}

.parallel-tasks-container {
    display: flex;
    flex-wrap: wrap;
    gap: 30px;
    margin-top: 15px;
    justify-content: center;
}

.parallel-task-card {
    width: 200px;
    min-height: 80px;
    border-radius: 8px;
    padding: 12px;
    position: relative;
    border: 2px solid #e5e7eb;
    background: rgba(255, 255, 255, 0.9);
}

.parallel-task-card.task-idle {
    background: rgba(179, 229, 252, 0.9);
    border-color: #1976d2;
}

.parallel-task-card.task-pending {
    background: rgba(255, 236, 179, 0.9);
    border-color: #f57c00;
}

.parallel-task-card.task-running,
.parallel-task-card.task-in_progress {
    background: rgba(225, 190, 231, 0.9);
    border-color: #7b1fa2;
}

.parallel-task-card.task-completed {
    background: rgba(200, 230, 201, 0.9);
    border-color: #388e3c;
}

.parallel-task-card.task-error {
    background: rgba(255, 205, 210, 0.9);
    border-color: #dc2626;
}

.left-node {
    margin-right: auto;
}

.right-node {
    margin-left: auto;
}

/* Center the final module */
ofni-flow-module[final="true"] .flow-step-container,
ofni-flow-module[final="true"] .node-card {
    margin-left: auto;
    margin-right: auto;
}

.io-container {
    position: absolute;
    width: 100%;
    left: 0;
    display: flex;
    justify-content: space-around;
}

.input-slot {
    top: -10px;
}

.output-slot {
    bottom: -10px;
}

.io-label {
    position: absolute;
    font-size: 10px;
    font-weight: 500;
    color: #6b7280;
    white-space: nowrap;
    left: 50%;
    transform: translateX(-50%);
    pointer-events: none;
}

.input-label {
    top: 12px;
}

.output-label {
    bottom: 12px;
}

.io-point {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: #f59e0b;
    cursor: pointer;
    transition: transform 0.2s;
    position: relative;
    z-index: 20;
}

.io-point.has-default {
    background-color: #f97316 !important;
}

.default-value-label {
    font-weight: 600;
}

.output-point {
    background-color: #10b981;
}

/* Output point colors based on module status */
.output-point-idle {
    background-color: #3182ce;
}

.output-point-pending {
    background-color: #f59e0b;
}

.output-point-running,
.output-point-in_progress {
    background-color: #9333ea;
}

.output-point-receiving {
    background-color: #FFD580;
}

.output-point-completed {
    background-color: #10b981;
}

.output-point-error {
    background-color: #dc2626;
}

.io-point:hover {
    transform: scale(1.5);
}

#data-viewer-modal .json-content {
    white-space: pre-wrap;
    word-wrap: break-word;
    font-family: monospace;
}

/* --- OFNI-FLOW-MODULE CUSTOM ELEMENT STYLES --- */
ofni-flow-module {
    display: block;
}

/* --- MODULE BACKGROUND COLORS (Light, 80% Opacity) --- */
/* IDLE (Light Blue) */
.node-bg-idle {
    background-color: #E0F7FAcc;
}

/* PENDING (Light Yellow) */
.node-bg-pending {
    background-color: #FFFDE7cc;
}

/* IN_PROGRESS (Light Purple - Running) */
.node-bg-in_progress,
.node-bg-running {
    background-color: #E1BEE7cc;
    box-shadow: 0 0 0 4px rgba(225, 190, 231, 0.2);
}

/* RECEIVING (Light Orange/Amber - Interactive Wait State) */
.node-bg-receiving {
    background-color: #FFD580cc;
    box-shadow: 0 0 0 4px rgba(255, 213, 128, 0.5);
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

/* COMPLETED (Light Green - Finished/Approved) */
.node-bg-completed {
    background-color: #DCEDC8cc;
    box-shadow: 0 4px 6px -1px rgba(220, 237, 200, 0.3);
    animation: none;
}

/* ERROR (Light Red) */
.node-bg-error {
    background-color: #FFCDD2cc;
    box-shadow: 0 4px 6px -1px rgba(255, 205, 210, 0.3);
    animation: none;
}

/* --- STATUS DOT COLORS (Opaque for contrast) --- */
.status-idle {
    background-color: #3182ce;
}

.status-pending {
    background-color: #f59e0b;
    animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.6;
    }
}

.status-in_progress,
.status-running {
    background-color: #9333ea;
    box-shadow: 0 0 0 4px rgba(147, 51, 234, 0.2);
    animation: none;
}

.status-completed,
.status-receiving {
    background-color: #059669;
    box-shadow: 0 4px 6px -1px rgba(5, 150, 105, 0.3);
    animation: none;
}

.status-error {
    background-color: #dc2626;
    box-shadow: 0 4px 6px -1px rgba(220, 38, 38, 0.3);
    animation: none;
}

/* Hover tooltip styles */
.hover-tooltip {
    position: relative;
    cursor: pointer;
}

.tooltip-content {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 12px;
    white-space: pre-wrap;
    max-width: 300px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    font-family: monospace;
}

.hover-tooltip:hover .tooltip-content {
    opacity: 1;
}

/* Dark theme for parallel task cards */
body[data-theme="dark"] .parallel-task-card {
    background: rgba(22, 27, 34, 0.9);
    border-color: #30363d;
    color: #ffffff;
}

body[data-theme="dark"] .parallel-task-card.task-idle {
    background: rgba(25, 118, 210, 0.3);
    border-color: #1976d2;
}

body[data-theme="dark"] .parallel-task-card.task-pending {
    background: rgba(245, 124, 0, 0.3);
    border-color: #f57c00;
}

body[data-theme="dark"] .parallel-task-card.task-running,
body[data-theme="dark"] .parallel-task-card.task-in_progress {
    background: rgba(123, 31, 162, 0.3);
    border-color: #7b1fa2;
}

body[data-theme="dark"] .parallel-task-card.task-completed {
    background: rgba(56, 142, 60, 0.5);
    border-color: #388e3c;
}

body[data-theme="dark"] .parallel-task-card.task-error {
    background: rgba(220, 38, 38, 0.3);
    border-color: #dc2626;
}



/* Child module styling */
.child-module {
    width: 200px;
    margin: 10px;
}

.child-module .node-card {
    min-height: 80px;
    padding: 12px;
}

.child-module .node-card h3 {
    font-size: 0.875rem;
}

.child-module .node-card p {
    font-size: 0.75rem;
}


/* UNAVAILABLE module styling for debugging */
ofni-flow-module[status="UNAVAILABLE"] {
    opacity: 0.5;
}

ofni-flow-module[status="UNAVAILABLE"] .node-card {
    background-color: #f3f4f6 !important;
}


/* Fix child module layout inside container */
.child-module .flow-step-container {
    margin-bottom: 0;
    width: auto;
}


/* Child module background colors - darker shades */
.child-module .node-bg-idle {
    background-color: #B3E5FC !important;
}

.child-module .node-bg-pending {
    background-color: #FFF9C4 !important;
}

.child-module .node-bg-running {
    background-color: #E1BEE7 !important;
}

.child-module .node-bg-completed {
    background-color: #C8E6C9 !important;
}

.child-module .node-bg-error {
    background-color: #FFCDD2 !important;
}
