/* ===== CI/CD Pipeline Visualizer — Design System ===== */
/* Palette: Emerald-Cyan | BG: #0A0F1C */

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

:root {
    --primary: #10B981;
    --primary-light: #34D399;
    --primary-dim: rgba(16, 185, 129, 0.12);
    --primary-glow: rgba(16, 185, 129, 0.25);
    --cyan: #06B6D4;
    --cyan-dim: rgba(6, 182, 212, 0.12);
    --amber: #F59E0B;
    --amber-dim: rgba(245, 158, 11, 0.12);
    --danger: #EF4444;
    --danger-dim: rgba(239, 68, 68, 0.12);
    --purple: #8B5CF6;
    --purple-dim: rgba(139, 92, 246, 0.12);
    --bg-base: #0A0F1C;
    --bg-surface: #111827;
    --bg-elevated: #1F2937;
    --bg-hover: #283548;
    --bg-input: #0D1320;
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --border: rgba(148, 163, 184, 0.1);
    --border-focus: rgba(16, 185, 129, 0.5);
    --radius: 10px;
    --radius-sm: 6px;
    --font-sans: 'Inter', -apple-system, sans-serif;
    --font-mono: 'JetBrains Mono', monospace;
    --transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

html {
    font-size: 15px;
    -webkit-font-smoothing: antialiased;
}

body {
    font-family: var(--font-sans);
    background: var(--bg-base);
    color: var(--text-primary);
    min-height: 100vh;
}

/* ===== App Layout ===== */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
}

/* ===== Header ===== */
.header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 24px;
    background: linear-gradient(180deg, rgba(17, 24, 39, 0.95), rgba(10, 15, 28, 0.98));
    border-bottom: 1px solid var(--border);
    backdrop-filter: blur(16px);
    z-index: 50;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}

.header-left h1 {
    font-size: 1.1rem;
    font-weight: 700;
    background: linear-gradient(135deg, var(--primary-light), var(--cyan));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.tagline {
    font-size: 0.72rem;
    color: var(--text-muted);
    margin-top: 1px;
}

.header-actions {
    display: flex;
    gap: 8px;
}

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    font-family: var(--font-sans);
    font-size: 0.8rem;
    font-weight: 500;
    border-radius: var(--radius-sm);
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--transition);
    white-space: nowrap;
}

.btn:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--cyan));
    color: #fff;
    border: none;
    box-shadow: 0 2px 8px var(--primary-glow);
}

.btn-primary:hover {
    box-shadow: 0 4px 16px var(--primary-glow);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-ghost:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.btn-xs {
    padding: 4px 8px;
    font-size: 0.7rem;
}

.btn-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 30px;
    height: 30px;
    border-radius: var(--radius-sm);
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    transition: var(--transition);
    font-size: 1rem;
}

.btn-icon:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

/* ===== Main Layout ===== */
.main-layout {
    flex: 1;
    display: grid;
    grid-template-columns: 420px 1fr;
    min-height: 0;
    overflow: hidden;
}

/* ===== Input Panel ===== */
.input-panel {
    display: flex;
    flex-direction: column;
    background: var(--bg-surface);
    border-right: 1px solid var(--border);
}

.panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-bottom: 1px solid var(--border);
}

.panel-title {
    font-size: 0.78rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.panel-actions {
    display: flex;
    gap: 4px;
}

.panel-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    border-top: 1px solid var(--border);
}

.detected-badge {
    font-size: 0.7rem;
    font-weight: 500;
    font-family: var(--font-mono);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    background: var(--primary-dim);
    color: var(--primary);
}

.editor-wrap {
    flex: 1;
    position: relative;
    overflow: hidden;
}

.code-editor {
    width: 100%;
    height: 100%;
    padding: 14px;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    line-height: 1.6;
    color: var(--text-primary);
    background: var(--bg-input);
    border: none;
    outline: none;
    resize: none;
    tab-size: 2;
    scrollbar-width: thin;
    scrollbar-color: var(--bg-hover) transparent;
}

.code-editor::placeholder {
    color: var(--text-muted);
    opacity: 0.6;
}

.code-editor::-webkit-scrollbar {
    width: 8px;
}

.code-editor::-webkit-scrollbar-thumb {
    background: var(--bg-hover);
    border-radius: 4px;
}

.error-bar {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    padding: 6px 16px;
    font-size: 0.72rem;
    font-family: var(--font-mono);
    background: rgba(239, 68, 68, 0.1);
    border-top: 1px solid rgba(239, 68, 68, 0.3);
    color: #FCA5A5;
    display: none;
}

.error-bar.visible {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

/* ===== Visualization Panel ===== */
.viz-panel {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.viz-container {
    flex: 1;
    overflow: auto;
    position: relative;
    background: var(--bg-base);
}

.viz-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    gap: 12px;
    color: var(--text-muted);
    text-align: center;
}

.viz-placeholder h3 {
    font-size: 1rem;
    color: var(--text-secondary);
}

.viz-placeholder p {
    font-size: 0.8rem;
}

/* ===== Pipeline Canvas ===== */
.pipeline-canvas {
    padding: 32px;
    min-height: 100%;
    transition: transform 0.1s ease;
    transform-origin: top left;
}

/* ===== Pipeline Stage ===== */
.pipeline-stages {
    display: flex;
    gap: 40px;
    align-items: flex-start;
    flex-wrap: nowrap;
    min-width: max-content;
}

.stage {
    display: flex;
    flex-direction: column;
    gap: 12px;
    min-width: 200px;
    position: relative;
}

.stage-label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--text-muted);
    padding: 6px 12px;
    background: var(--bg-elevated);
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border);
}

/* ===== Job Card ===== */
.job-card {
    padding: 14px 16px;
    background: var(--bg-surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    cursor: default;
    transition: var(--transition);
    position: relative;
}

.job-card:hover {
    border-color: rgba(16, 185, 129, 0.3);
    box-shadow: 0 4px 16px rgba(16, 185, 129, 0.08);
    transform: translateY(-1px);
}

.job-card .job-name {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.job-card .job-runner {
    font-size: 0.68rem;
    font-family: var(--font-mono);
    color: var(--text-muted);
    margin-bottom: 6px;
}

.job-card .job-steps {
    font-size: 0.7rem;
    color: var(--text-secondary);
}

.job-card .job-needs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-top: 8px;
}

.need-badge {
    font-size: 0.62rem;
    font-family: var(--font-mono);
    font-weight: 500;
    padding: 2px 6px;
    border-radius: 3px;
    background: var(--cyan-dim);
    color: var(--cyan);
}

/* ===== Stage Connector Arrow ===== */
.stage-connector {
    position: absolute;
    top: 50%;
    right: -26px;
    width: 20px;
    height: 2px;
    background: var(--primary-dim);
}

.stage-connector::after {
    content: '';
    position: absolute;
    right: -2px;
    top: -4px;
    border: 5px solid transparent;
    border-left-color: rgba(16, 185, 129, 0.3);
}

/* ===== Trigger Badge ===== */
.trigger-badge {
    margin-bottom: 20px;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.72rem;
    font-weight: 500;
    font-family: var(--font-mono);
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    background: var(--purple-dim);
    color: var(--purple);
    border: 1px solid rgba(139, 92, 246, 0.2);
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    padding: 10px 20px;
    background: var(--bg-elevated);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.82rem;
    color: var(--text-primary);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.5);
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s, transform 0.3s;
    z-index: 1000;
    backdrop-filter: blur(12px);
}

.toast.visible {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ===== Responsive ===== */
@media (max-width: 800px) {
    .main-layout {
        grid-template-columns: 1fr;
    }

    .input-panel {
        border-right: none;
        border-bottom: 1px solid var(--border);
        max-height: 40vh;
    }

    .header {
        flex-direction: column;
        gap: 8px;
        padding: 10px 16px;
    }

    .header-actions {
        flex-wrap: wrap;
    }
}