/* --- Design System & CSS Variables --- */
:root {
    --bg-dark: #070a13;
    --bg-card: rgba(13, 20, 38, 0.45);
    --bg-card-hover: rgba(22, 32, 59, 0.6);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    /* Brand Accent Colors */
    --color-indigo: #6366f1;
    --color-indigo-glow: rgba(99, 102, 241, 0.15);
    --color-purple: #8b5cf6;
    --color-purple-glow: rgba(139, 92, 246, 0.15);
    --color-emerald: #10b981;
    --color-emerald-glow: rgba(16, 185, 129, 0.15);
    --color-blue: #3b82f6;
    --color-blue-glow: rgba(59, 130, 246, 0.15);
    --color-gold: #f59e0b;
    --color-gold-glow: rgba(245, 158, 11, 0.15);
    --color-pink: #ec4899;
    --color-red: #ef4444;
    
    --font-heading: 'Outfit', sans-serif;
    --font-sans: 'Plus Jakarta Sans', sans-serif;
    --font-mono: 'JetBrains Mono', sans-serif;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-primary);
    font-family: var(--font-sans);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
    position: relative;
}

/* --- Background Glow Effects --- */
.glow-bg {
    position: absolute;
    width: 600px;
    height: 600px;
    border-radius: 50%;
    filter: blur(140px);
    opacity: 0.12;
    pointer-events: none;
    z-index: 0;
}

.glow-bg.bg-indigo {
    background: var(--color-indigo);
    top: -200px;
    left: -200px;
}

.glow-bg.bg-emerald {
    background: var(--color-emerald);
    bottom: -200px;
    right: -200px;
}

/* --- Custom Scrollbar --- */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

/* --- Header --- */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 2.5rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(7, 10, 19, 0.8);
    backdrop-filter: blur(12px);
    z-index: 10;
    position: relative;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 0.85rem;
}

.logo-box {
    background: linear-gradient(135deg, var(--color-emerald), var(--color-indigo));
    width: 38px;
    height: 38px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.3);
}

.logo-text-a1 {
    font-family: var(--font-heading);
    font-weight: 800;
    font-size: 1.15rem;
    color: #fff;
    letter-spacing: -0.5px;
}

.logo-title h1 {
    font-family: var(--font-heading);
    font-size: 1.15rem;
    font-weight: 700;
    letter-spacing: -0.2px;
}

.agency-tag {
    font-size: 0.7rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.nav-back-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--text-secondary);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition-smooth);
    padding: 0.5rem 1rem;
    border-radius: 8px;
    border: 1px solid transparent;
}

.nav-back-btn:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.04);
    border-color: var(--border-color);
}

/* --- Layout Container --- */
.app-container {
    display: grid;
    grid-template-columns: 320px 1fr 380px;
    gap: 1.5rem;
    padding: 1.5rem 2rem;
    flex: 1;
    z-index: 5;
    position: relative;
    max-height: calc(100vh - 80px);
    overflow: hidden;
}

@media (max-width: 1200px) {
    .app-container {
        grid-template-columns: 300px 1fr;
        max-height: none;
        overflow: auto;
    }
    .inspector-panel {
        grid-column: span 2;
        height: 550px !important;
    }
}

@media (max-width: 900px) {
    .app-container {
        grid-template-columns: 1fr;
        padding: 1.5rem 1rem;
        gap: 1.25rem;
    }
    .config-panel, .canvas-panel, .inspector-panel {
        grid-column: span 1;
    }
}

@media (max-width: 600px) {
    .app-header {
        padding: 1rem;
        flex-direction: column;
        gap: 0.75rem;
        text-align: center;
    }
    .nav-back-btn {
        width: 100%;
        justify-content: center;
    }
    .node-canvas {
        padding: 1.5rem 1rem;
        overflow-x: auto;
        align-items: center;
        gap: 1.5rem;
    }
    .canvas-panel {
        min-height: auto;
    }
    .node {
        width: 280px;
        flex-shrink: 0;
    }
}

/* --- Glass Card Panels --- */
.glass-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    backdrop-filter: blur(16px);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
    transition: var(--transition-smooth);
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1.25rem;
    border-bottom: 1px solid var(--border-color);
}

.panel-icon {
    opacity: 0.85;
}

.panel-icon.icon-emerald { color: var(--color-emerald); filter: drop-shadow(0 0 5px var(--color-emerald-glow)); }
.panel-icon.icon-indigo { color: var(--color-indigo); filter: drop-shadow(0 0 5px var(--color-indigo-glow)); }
.panel-icon.icon-purple { color: var(--color-purple); filter: drop-shadow(0 0 5px var(--color-purple-glow)); }

.panel-header h2 {
    font-family: var(--font-heading);
    font-size: 1rem;
    font-weight: 600;
}

/* --- Configuration Panel (Left) --- */
.config-panel {
    padding: 1.25rem;
    gap: 1.25rem;
    overflow-y: auto;
}

.flex-fill {
    flex: 1;
    display: flex;
    flex-direction: column;
}

#payload-editor {
    flex: 1;
    min-height: 150px;
    font-family: var(--font-mono);
    font-size: 0.8rem;
    line-height: 1.4;
    resize: none;
    background: rgba(0, 0, 0, 0.3);
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

label {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
}

select {
    background: rgba(7, 10, 19, 0.5);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    color: var(--text-primary);
    padding: 0.75rem;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    outline: none;
    transition: var(--transition-smooth);
}

select:focus {
    border-color: var(--color-emerald);
    box-shadow: 0 0 10px rgba(16, 185, 129, 0.1);
}

/* --- Button Styling --- */
.btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.85rem;
    border-radius: 10px;
    border: none;
    font-family: var(--font-heading);
    font-weight: 700;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition-smooth);
    color: #fff;
    width: 100%;
}

.btn-emerald {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
}

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

.btn-glow {
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.25);
}

.btn-glow:hover {
    box-shadow: 0 6px 25px rgba(16, 185, 129, 0.4);
}

.btn:disabled {
    background: var(--text-muted);
    box-shadow: none;
    cursor: not-allowed;
    transform: none;
    opacity: 0.5;
}

/* --- Workflow Canvas (Center) --- */
.canvas-panel {
    position: relative;
}

.node-canvas {
    flex: 1;
    position: relative;
    overflow: hidden;
    background-image: radial-gradient(rgba(255, 255, 255, 0.04) 1px, transparent 1px);
    background-size: 24px 24px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    padding: 3rem 2rem;
}

.canvas-connections {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    z-index: 1;
}

.canvas-row {
    display: flex;
    position: relative;
    z-index: 2;
    width: 100%;
}

.justify-start { justify-content: flex-start; padding-left: 2rem; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }

/* Connection Lines */
.connection-line {
    fill: none;
    stroke: rgba(255, 255, 255, 0.08);
    stroke-width: 2.5;
    transition: var(--transition-smooth);
}

.connection-line.active {
    stroke: var(--color-indigo);
    stroke-dasharray: 8 5;
    animation: flowPulse 25s linear infinite;
    filter: drop-shadow(0 0 4px rgba(99, 102, 241, 0.5));
}

@keyframes flowPulse {
    to {
        stroke-dashoffset: -1000px;
    }
}

/* --- Workflow Node --- */
.w-node {
    display: flex;
    align-items: center;
    gap: 0.85rem;
    background: rgba(18, 25, 47, 0.9);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    width: 190px;
    position: relative;
    cursor: pointer;
    transition: var(--transition-smooth);
}

.w-node:hover {
    border-color: rgba(255, 255, 255, 0.15);
    transform: scale(1.02);
}

.w-node.active-exec {
    border-color: var(--color-indigo);
    box-shadow: 0 0 20px rgba(99, 102, 241, 0.25);
    animation: pulseBorder 1s infinite alternate;
}

@keyframes pulseBorder {
    0% { border-color: rgba(99, 102, 241, 0.3); }
    100% { border-color: var(--color-indigo); }
}

.w-node.success {
    border-color: var(--color-emerald);
    box-shadow: 0 0 15px rgba(16, 185, 129, 0.15);
}

.w-node.success .w-node-status {
    color: var(--color-emerald);
}

.w-node.error {
    border-color: var(--color-red);
    box-shadow: 0 0 15px rgba(239, 68, 68, 0.15);
}

.w-node.error .w-node-status {
    color: var(--color-red);
}

.w-node.selected {
    border-color: #fff;
    box-shadow: 0 0 15px rgba(255, 255, 255, 0.15);
}

.w-node-icon {
    width: 32px;
    height: 32px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    flex-shrink: 0;
}

.w-node-icon.bg-emerald { background: linear-gradient(135deg, #10b981, #059669); }
.w-node-icon.bg-purple { background: linear-gradient(135deg, #8b5cf6, #6d28d9); }
.w-node-icon.bg-blue { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.w-node-icon.bg-pink { background: linear-gradient(135deg, #ec4899, #be185d); }
.w-node-icon.bg-gold { background: linear-gradient(135deg, #f59e0b, #b45309); }

.w-node-info h3 {
    font-size: 0.8rem;
    font-weight: 600;
    margin-bottom: 0.1rem;
    color: var(--text-primary);
}

.w-node-status {
    font-size: 0.65rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
}

.w-node-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--bg-dark);
    border: 1px solid var(--border-color);
    top: 50%;
    transform: translateY(-50%);
}

.w-node-dot.left { left: -5px; }
.w-node-dot.right { right: -5px; }

/* --- Node Inspector (Right) --- */
.inspector-panel {
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 80px);
}

.inspector-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
}

.inspector-empty {
    margin: auto;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
    max-width: 240px;
}

.muted-icon {
    opacity: 0.35;
}

.inspector-empty p {
    font-size: 0.8rem;
    line-height: 1.45;
}

.hidden {
    display: none !important;
}

.meta-rows {
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    margin-bottom: 1.25rem;
}

.meta-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid var(--border-color);
}

.meta-label {
    color: var(--text-secondary);
}

.meta-value {
    font-weight: 500;
}

.meta-value.font-tag {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
}

.meta-value.status-badge {
    color: var(--color-emerald);
}

.data-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 0.5rem;
}

.data-tab {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 0.8rem;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: var(--transition-smooth);
}

.data-tab:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.03);
}

.data-tab.active {
    color: var(--color-indigo);
    background: rgba(99, 102, 241, 0.08);
}

.json-viewer {
    flex: 1;
    background: rgba(0, 0, 0, 0.25);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    overflow: auto;
    max-height: 300px;
}

.json-viewer pre {
    margin: 0;
}

.json-viewer code {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: #a7f3d0; /* Soft green */
    line-height: 1.4;
    white-space: pre-wrap;
    word-break: break-all;
}

/* --- Console / Log Outputs (Bottom Right) --- */
.pipeline-console {
    background: #04060b;
    border-top: 1px solid var(--border-color);
    height: 180px;
    display: flex;
    flex-direction: column;
}

.console-header {
    font-family: var(--font-heading);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: var(--text-muted);
    text-transform: uppercase;
    padding: 0.5rem 1rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(0, 0, 0, 0.2);
}

.console-lines {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem 1rem;
    font-family: var(--font-mono);
    font-size: 0.7rem;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.console-line {
    line-height: 1.4;
}

.console-line.system { color: var(--text-muted); }
.console-line.success { color: var(--color-emerald); }
.console-line.exec { color: var(--color-indigo); }
.console-line.error { color: var(--color-red); }

/* --- Footer --- */
.app-footer {
    text-align: center;
    padding: 1rem;
    font-size: 0.75rem;
    color: var(--text-muted);
    border-top: 1px solid var(--border-color);
    background: rgba(7, 10, 19, 0.9);
    z-index: 10;
    position: relative;
}

/* Height-based Responsiveness for Short Screens */
@media (max-height: 768px) {
    .app-container {
        max-height: none;
        overflow: visible;
    }
}

