:root {
    /* Titanium Theme */
    --clr-bg: #0F1219;
    --clr-surface: #1E293B;
    --clr-surface-hover: #334155;
    --clr-border: #334155;
    
    --clr-primary: #64748B;
    --clr-secondary: #94A3B8;
    --clr-accent: #38BDF8;
    --clr-accent-glow: rgba(56, 189, 248, 0.4);
    
    --clr-text-main: #F8FAFC;
    --clr-text-muted: #94A3B8;
    
    --clr-error: #F43F5E;
    --clr-success: #10B981;
    
    --font-sans: 'Inter', system-ui, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    background-color: var(--clr-bg);
    color: var(--clr-text-main);
    font-family: var(--font-sans);
    line-height: 1.5;
    height: 100vh;
    overflow: hidden;
    /* Subtle dot pattern */
    background-image: radial-gradient(var(--clr-border) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Utilities */
.hidden { display: none !important; }
.flex { display: flex; }
.flex-col { flex-direction: column; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.flex-center { display: flex; justify-content: center; align-items: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.space-y-4 > * + * { margin-top: 1rem; }
.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-3 { margin-top: 0.75rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.ml-2 { margin-left: 0.5rem; }
.w-full { width: 100%; }
.text-main { color: var(--clr-text-main); }
.text-muted { color: var(--clr-text-muted); }
.text-xs { font-size: 0.75rem; }
.text-sm { font-size: 0.875rem; }
.text-primary { color: var(--clr-accent); }
.uppercase { text-transform: uppercase; }
.tracking-wider { letter-spacing: 0.05em; }
.mono { font-family: var(--font-mono); }

/* Layout */
.app-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.sidebar {
    width: 380px;
    height: 100%;
    padding: 1.5rem;
    overflow-y: auto;
    border-right: 1px solid var(--clr-border);
    background: rgba(15, 18, 25, 0.85);
    backdrop-filter: blur(12px);
    z-index: 10;
    display: flex;
    flex-direction: column;
}

.visualizer {
    flex: 1;
    position: relative;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Typography & Brand */
.brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--clr-accent);
}
.brand h1 { font-size: 1.2rem; font-weight: 600; color: var(--clr-text-main); }
.subtitle { font-size: 0.85rem; color: var(--clr-text-muted); }

/* Form Controls */
.label { font-size: 0.8rem; font-weight: 500; color: var(--clr-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }

.editor {
    flex-grow: 1;
    min-height: 250px;
    width: 100%;
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    color: var(--clr-text-main);
    padding: 1rem;
    font-size: 0.85rem;
    line-height: 1.5;
    resize: none;
    transition: var(--transition);
}
.editor:focus {
    outline: none;
    border-color: var(--clr-accent);
    box-shadow: 0 0 0 2px var(--clr-accent-glow);
}

.alert {
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
    border-radius: var(--radius-sm);
    font-size: 0.85rem;
    align-items: flex-start;
}
.alert-error {
    background: rgba(244, 63, 94, 0.1);
    border: 1px solid rgba(244, 63, 94, 0.2);
    color: var(--clr-error);
}

/* Buttons */
.btn {
    padding: 0.6rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-size: 0.85rem;
    font-family: inherit;
    cursor: pointer;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    transition: var(--transition);
}
.btn-sm { padding: 0.4rem 0.75rem; font-size: 0.75rem; }
.btn-primary { background: var(--clr-accent); color: #000; box-shadow: 0 4px 12px var(--clr-accent-glow); }
.btn-primary:hover { background: #0EA5E9; transform: translateY(-1px); }
.btn-outline { background: transparent; border: 1px solid var(--clr-border); color: var(--clr-text-main); }
.btn-outline:hover { background: var(--clr-surface-hover); border-color: var(--clr-secondary); }
.btn-icon { padding: 0.4rem; background: var(--clr-surface); color: var(--clr-text-muted); border: 1px solid var(--clr-border); border-radius: var(--radius-sm); cursor: pointer; }
.btn-icon:hover { color: var(--clr-text-main); border-color: var(--clr-accent); }

/* Glass Elements */
.glass {
    background: rgba(30, 41, 59, 0.5);
    backdrop-filter: blur(8px);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-md);
}

/* Stats */
.stats-card { padding: 1.25rem; }
.stats-title { font-size: 0.9rem; font-weight: 600; color: var(--clr-accent); margin-bottom: 0.5rem; }
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.stat-item { display: flex; flex-direction: column; }
.stat-lbl { font-size: 0.75rem; color: var(--clr-text-muted); text-transform: uppercase; letter-spacing: 0.05em; }
.stat-val { font-size: 1.25rem; font-weight: 700; color: var(--clr-text-main); margin-top: 0.25rem; }
.badge { background: rgba(255,255,255,0.1); padding: 0.2rem 0.6rem; border-radius: 12px; font-size: 0.75rem; font-weight: 500; }
.branch-lbl { font-size: 0.9rem; font-family: var(--font-mono); color: var(--clr-success); }


/* Right Canvas */
.vis-header {
    height: 60px;
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    background: rgba(15, 18, 25, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--clr-border);
    z-index: 20;
}
.workflow-name { font-size: 1.1rem; font-weight: 600; }
.vis-actions { display: flex; gap: 0.5rem; }

.canvas-container {
    flex: 1;
    position: relative;
    overflow: hidden; /* We'll use JS panning on the stage */
    cursor: grab;
}
.canvas-container:active { cursor: grabbing; }

.empty-layout {
    position: absolute; inset: 0;
    pointer-events: none;
}

/* Graph Stage */
.graph-stage {
    position: absolute;
    top: 50%; left: 50px;
    transform-origin: 0 0;
}

/* Grid Layout for DAG */
.nodes-layer {
    position: relative;
    display: flex;
    gap: 80px; /* distance between columns/layers */
    align-items: flex-start;
}

.dag-column {
    display: flex;
    flex-direction: column;
    gap: 40px; /* distance between nodes in the same layer */
}

/* Node Styling */
.job-node {
    width: 240px;
    background: var(--clr-surface);
    border: 1px solid var(--clr-secondary);
    border-radius: var(--radius-md);
    padding: 1rem;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    position: relative;
    cursor: pointer;
    transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.job-node:hover {
    border-color: var(--clr-accent);
    transform: translateY(-2px);
    box-shadow: 0 12px 30px rgba(56, 189, 248, 0.2);
}

.job-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 0.75rem; border-bottom: 1px solid var(--clr-border); padding-bottom: 0.5rem; }
.job-id { font-family: var(--font-mono); font-size: 0.9rem; font-weight: 600; color: var(--clr-accent); word-break: break-all; }
.job-status-icon { width: 14px; height: 14px; border-radius: 50%; border: 2px solid var(--clr-border); }

.job-meta { font-size: 0.75rem; color: var(--clr-text-muted); display: flex; align-items: center; gap: 0.5rem; margin-bottom: 0.5rem; }
.job-mini-steps { display: flex; gap: 2px; margin-top: 0.75rem; flex-wrap: wrap; }
.mini-step { width: 8px; height: 4px; background: var(--clr-border); border-radius: 2px; }

/* Arrows SVG Layer */
.arrows-layer {
    position: absolute;
    top: 0; left: 0;
    width: 100%; height: 100%;
    pointer-events: none;
    overflow: visible;
}
.edge-path {
    fill: none;
    stroke: var(--clr-border);
    stroke-width: 2px;
    stroke-dasharray: 4 4;
}
.edge-head { fill: var(--clr-border); }


/* Node Overlay Detail Panel */
.node-overlay {
    position: absolute;
    top: 60px; right: 0; bottom: 0;
    width: 360px;
    background: rgba(15, 18, 25, 0.95);
    backdrop-filter: blur(16px);
    border-left: 1px solid var(--clr-border);
    z-index: 30;
    padding: 1.5rem;
    overflow-y: auto;
    animation: slideLeft 0.3s ease;
}
@keyframes slideLeft { from { transform: translateX(100%); } to { transform: translateX(0); } }

.pn-title { font-size: 1.25rem; font-weight: 600; word-break: break-all; color: var(--clr-accent); }
.btn-icon { background: none; border: none; font-size: 1.5rem; color: var(--clr-text-muted); cursor: pointer; line-height: 1; }
.btn-icon:hover { color: var(--clr-error); }

.pn-steps-container { display: flex; flex-direction: column; gap: 0.5rem; }
.step-item {
    background: rgba(0,0,0,0.3);
    border: 1px solid var(--clr-border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 0.85rem;
    line-height: 1.4;
}
.step-name { font-weight: 600; color: var(--clr-text-main); }
.step-meta { display: flex; gap: 0.5rem; margin-top: 0.25rem; }
.step-meta span { color: var(--clr-secondary); font-family: var(--font-mono); font-size: 0.75em; }

@media (max-width: 968px) {
    .app-layout { flex-direction: column; }
    .sidebar { width: 100%; height: 45vh; border-right: none; border-bottom: 1px solid var(--clr-border); }
    .visualizer { height: 55vh; }
    .node-overlay { width: 100%; top: auto; bottom: 0; height: 50vh; border-left: none; border-top: 1px solid var(--clr-border); animation: slideUp 0.3s ease; }
    @keyframes slideUp { from { transform: translateY(100%); } to { transform: translateY(0); } }
}
