:root {
    /* Flame Theme for GitHub Actions Builder */
    --bg-main: #0c0604;
    --bg-panel: #1A0D08;
    --bg-input: #29150E;
    --bg-hover: rgba(232, 65, 24, 0.1);

    --border: #3D2214;
    --border-hover: #59311D;

    --primary: #E84118;
    --primary-hover: #C23616;
    --secondary: #FF6348;
    --accent: #FFC312;

    --text-main: #F5F6FA;
    --text-muted: #A4B0BE;

    --radius: 12px;
    --radius-sm: 6px;
    --transition: 200ms ease;
}

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

body {
    font-family: 'Inter', system-ui, sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hidden {
    display: none !important;
}

/* --- Top Nav --- */
.top-nav {
    height: 60px;
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    background: var(--bg-panel);
    z-index: 10;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary);
}

.nav-brand h1 {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.01em;
}

.nav-actions {
    display: flex;
    gap: 0.75rem;
}

/* --- Buttons --- */
.btn {
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    border: none;
    transition: all var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-size: 0.85rem;
}

.btn.primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn.primary:hover {
    box-shadow: 0 4px 15px rgba(232, 65, 24, 0.4);
    transform: translateY(-1px);
}

.btn.secondary {
    background: var(--bg-input);
    color: var(--text-main);
    border: 1px solid var(--border);
}

.btn.secondary:hover {
    background: var(--bg-hover);
    border-color: var(--primary);
}

.btn.icon-btn {
    background: transparent;
    color: var(--text-muted);
    padding: 0.5rem;
    border-radius: 50%;
    width: 32px;
    height: 32px;
}

.btn.icon-btn:hover {
    background: var(--border);
    color: var(--text-main);
}

.btn.danger {
    background: rgba(232, 65, 24, 0.2);
    color: var(--primary);
}

.btn.danger:hover {
    background: var(--primary);
    color: white;
}

/* --- Main Layout --- */
.app-container {
    display: flex;
    flex: 1;
    overflow: hidden;
    height: calc(100vh - 60px);
}

/* Sidebar */
.sidebar {
    width: 250px;
    background: var(--bg-panel);
    border-right: 1px solid var(--border);
    padding: 1rem;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.sidebar-section h3 {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.template-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.template-card {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem;
    font-size: 0.85rem;
    cursor: grab;
    transition: border 0.2s;
    user-select: none;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.template-card::before {
    content: '⋮⋮';
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1;
    letter-spacing: -2px;
}

.template-card:hover {
    border-color: var(--primary);
}

.template-card.trigger {
    border-left: 3px solid var(--accent);
}

.template-card.step {
    border-left: 3px solid var(--secondary);
}

.template-card.advanced {
    border-left: 3px solid var(--primary);
}


/* Builder Node Item (when dropped) */
.builder-node {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: grab;
    transition: border-color var(--transition);
}

.builder-node:hover {
    border-color: var(--text-muted);
}

.builder-node.sortable-ghost {
    opacity: 0.4;
    border: 2px dashed var(--primary);
    background: transparent;
}

.builder-node .node-title {
    font-weight: 600;
    font-size: 0.9rem;
    font-family: 'JetBrains Mono', monospace;
}

.builder-node .node-summary {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-left: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 200px;
    display: inline-block;
    vertical-align: bottom;
}

.node-actions {
    display: flex;
    gap: 0.25rem;
}


/* Builder Area */
.builder-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-main);
    border-right: 1px solid var(--border);
    position: relative;
    overflow-y: auto;
    padding: 2rem;
}

.builder-header {
    margin-bottom: 2rem;
}

.workflow-title-input {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    width: 100%;
    outline: none;
    border-bottom: 1px solid transparent;
    padding-bottom: 0.25rem;
}

.workflow-title-input:hover,
.workflow-title-input:focus {
    border-bottom-color: var(--border);
}

.dropzone-label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.dropzone {
    min-height: 80px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-sm);
    padding: 1rem;
    margin-bottom: 2rem;
    transition: background 0.3s, border-color 0.3s;
}

.dropzone.drag-active {
    background: rgba(232, 65, 24, 0.05);
    border-color: var(--primary);
}

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 0.85rem;
    padding: 1rem;
    pointer-events: none;
}

.job-config {
    margin-bottom: 1rem;
    padding: 1rem;
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    display: flex;
    gap: 1rem;
    align-items: center;
}

.job-config label {
    font-size: 0.8rem;
    color: var(--text-muted);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.job-config select {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    outline: none;
}

/* Preview Area */
.preview-area {
    width: 450px;
    background: var(--bg-panel);
    display: flex;
    flex-direction: column;
}

.preview-header {
    height: 48px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    background: var(--bg-input);
    flex-shrink: 0;
}

.preview-header h3 {
    font-size: 0.85rem;
    font-weight: 600;
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge.success {
    background: rgba(16, 185, 129, 0.2);
    color: #10B981;
}

.badge.error {
    background: rgba(239, 68, 68, 0.2);
    color: #EF4444;
}

.yaml-output {
    flex: 1;
    margin: 0;
    padding: 1.5rem;
    overflow: auto;
    background: transparent;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.85rem;
    line-height: 1.5;
    color: var(--text-main);
}

.yaml-output code {
    background: transparent;
    padding: 0;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal {
    background: var(--bg-panel);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    width: 450px;
    max-width: 90vw;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
}

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

.modal-body {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    max-height: 60vh;
    overflow-y: auto;
}

.modal-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

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

.form-group label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
}

.form-control {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-main);
    padding: 0.5rem;
    border-radius: var(--radius-sm);
    font-family: 'Inter', sans-serif;
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s;
}

.form-control:focus {
    border-color: var(--primary);
}

textarea.form-control {
    resize: vertical;
    min-height: 80px;
    font-family: 'JetBrains Mono', monospace;
}

/* Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%);
    background: var(--text-main);
    color: var(--bg-main);
    padding: 0.75rem 1.5rem;
    border-radius: 99px;
    font-weight: 600;
    font-size: 0.9rem;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    z-index: 1000;
    transition: opacity 0.3s, transform 0.3s;
}

.toast.hidden {
    opacity: 0;
    transform: translateX(-50%) translateY(20px);
    pointer-events: none;
}

/* Sortable Utility classes */
.sortable-fallback {
    opacity: 1 !important;
}

.sortable-drag {
    cursor: grabbing !important;
}