:root {
    --bg-main: #0F172A;
    --bg-surface: rgba(30, 41, 59, 0.6);
    --bg-surface-hover: rgba(30, 41, 59, 0.8);
    --border-color: rgba(255, 255, 255, 0.1);
    
    --primary: #06B6D4;
    --primary-hover: #0891B2;
    --accent: #EC4899;
    
    --text-primary: #F8FAFC;
    --text-muted: #94A3B8;
    --danger: #EF4444;
    
    --radius-sm: 6px;
    --radius-md: 12px;
    --radius-lg: 24px;
    
    --shadow-glass: 0 8px 32px rgba(0, 0, 0, 0.4);
    --transition: 250ms cubic-bezier(0.4, 0, 0.2, 1);
}

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

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

/* Utilities */
.glass {
    background: var(--bg-surface);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-color);
}

.text-danger { color: var(--danger); }
.mt-4 { margin-top: 1rem; }
.hidden { display: none !important; }

/* Navbar */
.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 23, 42, 0.8);
    backdrop-filter: blur(8px);
    z-index: 10;
}

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

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.025em;
}

.actions {
    display: flex;
    gap: 1rem;
}

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

.btn.primary {
    background: var(--primary);
    color: white;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.3);
}

.btn.primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(6, 182, 212, 0.4);
}

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

.btn.secondary:hover {
    background: var(--bg-surface-hover);
    border-color: rgba(255, 255, 255, 0.2);
}

.btn.icon-btn {
    padding: 0.5rem;
    background: transparent;
    color: var(--text-muted);
    border: 1px solid transparent;
}

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

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

.sidebar {
    width: 320px;
    min-width: 320px;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
}

.preview-panel {
    border-right: none;
    border-left: 1px solid var(--border-color);
    width: 400px;
    min-width: 400px;
    background: #0B1121;
}

.main-editor {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 2rem;
    overflow-y: auto;
    background-image: radial-gradient(var(--border-color) 1px, transparent 1px);
    background-size: 24px 24px;
}

/* Sidebar structure */
.panel-header {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.panel-header h2 {
    font-size: 1rem;
    font-weight: 600;
}

.badge {
    background: rgba(255, 255, 255, 0.1);
    padding: 0.25rem 0.5rem;
    border-radius: 100px;
    font-size: 0.75rem;
    color: var(--text-muted);
}
.badge-accent {
    background: rgba(236, 72, 153, 0.2);
    color: var(--accent);
}

/* Steps List */
.steps-list {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.step-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all var(--transition);
}

.step-item:hover {
    border-color: rgba(255, 255, 255, 0.2);
    transform: translateX(4px);
}

.step-item.active {
    border-color: var(--primary);
    background: rgba(6, 182, 212, 0.1);
}

.step-drag-handle {
    cursor: grab;
    color: var(--text-muted);
    display: flex;
}

.step-number {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--bg-main);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--primary);
    border: 1px solid var(--border-color);
}

.step-info {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    overflow: hidden;
}

.step-info h4 {
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.step-info span {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: capitalize;
}

/* Main Editor */
.empty-state {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    text-align: center;
}

.empty-state svg {
    width: 48px;
    height: 48px;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.step-editor {
    max-width: 800px;
    width: 100%;
    margin: 0 auto;
    border-radius: var(--radius-md);
    display: flex;
    flex-direction: column;
}

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

.editor-content {
    padding: 2rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}
.input-group.row {
    flex-direction: row;
    gap: 1rem;
}

.input-group label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.help-text {
    font-size: 0.75rem;
    color: var(--text-muted);
}

input[type="text"],
textarea,
select {
    width: 100%;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    font-family: inherit;
    font-size: 0.875rem;
    transition: border-color var(--transition);
    resize: vertical;
}

input[type="text"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(6, 182, 212, 0.2);
}

/* Toggle Switch */
.toggle-switch {
    display: inline-flex;
    align-items: center;
    cursor: pointer;
    gap: 0.75rem;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 24px;
    background-color: rgba(255, 255, 255, 0.1);
    border-radius: 24px;
    transition: .4s;
    border: 1px solid var(--border-color);
}

.slider:before {
    position: absolute;
    content: "";
    height: 16px;
    width: 16px;
    left: 4px;
    bottom: 3px;
    background-color: var(--text-muted);
    transition: .4s;
    border-radius: 50%;
}

input:checked + .slider {
    background-color: var(--primary);
    border-color: var(--primary);
}

input:checked + .slider:before {
    transform: translateX(16px);
    background-color: white;
}

.label-text {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-primary);
}


/* Dummy App Preview */
.dummy-app {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    position: relative;
    height: 100%;
}

.dummy-header {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.dummy-logo {
    width: 32px;
    height: 32px;
    background: var(--primary);
    border-radius: 8px;
}

.dummy-nav {
    flex: 1;
    display: flex;
    gap: 1rem;
}

.dummy-nav-item {
    height: 12px;
    width: 60px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 6px;
}

.dummy-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
}

.dummy-content {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.dummy-card {
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid rgba(255, 255, 255, 0.05);
    border-radius: 12px;
    padding: 1.5rem;
}

.dummy-title {
    height: 16px;
    width: 50%;
    background: rgba(255, 255, 255, 0.15);
    border-radius: 8px;
    margin-bottom: 1rem;
}

.dummy-line {
    height: 8px;
    width: 100%;
    background: rgba(255, 255, 255, 0.08);
    border-radius: 4px;
    margin-bottom: 0.5rem;
}

.dummy-btn {
    margin-top: 1rem;
    height: 32px;
    width: 100px;
    background: var(--accent);
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

.dummy-fab {
    position: absolute;
    bottom: 2rem;
    right: 2rem;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--primary);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    box-shadow: 0 4px 12px rgba(6, 182, 212, 0.4);
}

/* Modal Styling */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 1;
    transition: opacity 0.3s ease;
}

.modal-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.modal {
    width: 90%;
    max-width: 600px;
    border-radius: var(--radius-md);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.5);
    transform: translateY(0);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.modal-overlay.hidden .modal {
    transform: translateY(20px);
}

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

.modal-body {
    padding: 1.5rem;
}

.modal-body p {
    color: var(--text-muted);
    margin-bottom: 1rem;
    line-height: 1.5;
}

.json-area {
    font-family: monospace;
    font-size: 0.875rem;
    color: var(--text-primary);
}

.code-block {
    position: relative;
    background: #000;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-sm);
    padding: 1rem;
    overflow-y: auto;
    max-height: 300px;
}

.code-block pre {
    font-family: monospace;
    font-size: 0.875rem;
    color: #A5B4FC;
    line-height: 1.5;
    white-space: pre-wrap;
}

.copy-btn {
    position: absolute;
    top: 0.5rem;
    right: 0.5rem;
    background: rgba(255, 255, 255, 0.1) !important;
}


/* Onboarding Runtime Engine Styles */
/* These will be injected into export but we need them for preview too */
.onboarding-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    pointer-events: none; /* Let clicks pass unless targeting popover */
}

.onboarding-overlay.active {
    pointer-events: auto;
}

.onboarding-highlight {
    position: absolute;
    background: transparent;
    box-shadow: 0 0 0 9999px rgba(0, 0, 0, 0.6);
    border-radius: 8px;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    pointer-events: none;
}

.onboarding-overlay.active .onboarding-highlight {
    opacity: 1;
}

.onboarding-popover {
    position: absolute;
    width: 320px;
    background: #1E293B;
    border: 1px solid rgba(255,255,255,0.1);
    box-shadow: 0 10px 40px rgba(0,0,0,0.5);
    border-radius: 12px;
    padding: 1.5rem;
    color: #fff;
    font-family: 'Inter', sans-serif;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0;
    transform: scale(0.95);
    pointer-events: auto;
    z-index: 10000;
}

.onboarding-overlay.active .onboarding-popover {
    opacity: 1;
    transform: scale(1);
}

.onboarding-close {
    position: absolute;
    top: 0.75rem;
    right: 0.75rem;
    background: transparent;
    border: none;
    color: #94A3B8;
    cursor: pointer;
}

.onboarding-close:hover {
    color: #fff;
}

.onboarding-content h3 {
    margin: 0 0 0.5rem 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.onboarding-content p {
    margin: 0 0 1.5rem 0;
    font-size: 0.875rem;
    color: #94A3B8;
    line-height: 1.5;
}

.onboarding-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.onboarding-progress {
    font-size: 0.75rem;
    color: #94A3B8;
}

.onboarding-controls {
    display: flex;
    gap: 0.5rem;
}

.onboarding-btn {
    padding: 0.5rem 1rem;
    border-radius: 6px;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
}

.onboarding-btn.secondary {
    background: transparent;
    color: #fff;
    border: 1px solid rgba(255,255,255,0.2);
}

.onboarding-btn.primary {
    background: #06B6D4;
    color: #fff;
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .sidebar {
        width: 100%;
        min-width: 100%;
        max-height: 200px;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .preview-panel {
        display: none; /* Hide preview on mobile */
    }
}
