/* Playbook Studio Styles */

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

/* ============================================================================
   CSS Variables
   ============================================================================ */
:root {
    /* Light theme colors */
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --card-bg: #ffffff;
    --input-bg: #f8f9fa;
    --hover-bg: #e9ecef;
    --border-color: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --primary-color: #007bff;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    --shadow-hover: 0 4px 16px rgba(0, 0, 0, 0.15);
}

body {
    --card-bg: #ffffff;
    --input-bg: #f8f9fa;
    --hover-bg: #e9ecef;
    --border-color: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    --primary-color: #007bff;
    --success-color: #28a745;
    --warning-color: #ffc107;
    --error-color: #dc3545;
    background: #f0f0f0;
    color: #323130;
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    transition: background-color 0.3s, color 0.3s;
}

/* Dark theme - support both class and data-theme attribute */
body.dark-theme,
body[data-theme="dark"] {
    --bg-primary: #1e1e1e;
    --bg-secondary: #252526;
    --card-bg: #252526;
    --input-bg: #2d2d30;
    --hover-bg: #37373d;
    --border-color: #3e3e42;
    --text-primary: #e8e8e8;
    --text-secondary: #a0a0a0;
    background: #1e1e1e;
    color: #e8e8e8;
}

/* Explicit light theme support */
body[data-theme="light"] {
    --bg-primary: #ffffff;
    --bg-secondary: #f5f5f5;
    --card-bg: #ffffff;
    --input-bg: #f8f9fa;
    --hover-bg: #e9ecef;
    --border-color: #dee2e6;
    --text-primary: #212529;
    --text-secondary: #6c757d;
    background: #f0f0f0;
    color: #323130;
}

/* ============================================================================
   Top Bar
   ============================================================================ */
.top-bar {
    background: linear-gradient(135deg, #0078d4 0%, #106ebe 100%);
    height: 56px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
    position: sticky;
    top: 0;
    z-index: 1000;
}

body.dark-theme .top-bar,
body[data-theme="dark"] .top-bar {
    background: linear-gradient(135deg, #1e1e1e 0%, #2d2d30 100%);
    border-bottom: 1px solid #3e3e42;
}

.top-bar-left {
    display: flex;
    align-items: center;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo {
    height: 40px;
    width: auto;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}

.page-title-bar {
    color: rgba(255, 255, 255, 0.85);
    font-size: 16px;
    font-weight: 400;
    padding-left: 12px;
    border-left: 2px solid rgba(255, 255, 255, 0.3);
}

.top-bar-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

.top-bar-link {
    color: white;
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    border-radius: 4px;
    transition: all 0.2s;
    background: rgba(255, 255, 255, 0.1);
}

.top-bar-link:hover {
    background: rgba(255, 255, 255, 0.2);
}

.theme-toggle {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    padding: 6px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 16px;
    transition: all 0.2s;
}

.theme-toggle:hover {
    background: rgba(255, 255, 255, 0.25);
}

.theme-icon {
    display: inline-block;
}

/* ============================================================================
   Layout & Container
   ============================================================================ */
.container {
    max-width: 100%;
    padding: 0;
    height: auto;
}

.studio-container {
    display: flex;
    flex-direction: column;
    min-height: calc(100vh - 56px);
    height: auto;
    max-width: 100vw;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* ============================================================================
   Progress Indicator
   ============================================================================ */
.progress-steps {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0.75rem;
    background: var(--card-bg);
    border-bottom: 2px solid var(--border-color);
    max-width: 100%;
    box-sizing: border-box;
}

.progress-connector {
    width: 60px;
    height: 2px;
    background: var(--border-color);
    margin: 0 1rem;
}

.step-number {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--border-color);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    margin-bottom: 0.5rem;
    transition: all 0.3s ease;
}

.step-label {
    font-size: 0.9rem;
    color: var(--text-secondary);
    font-weight: 500;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.progress-step.active .step-number {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.3);
}

.progress-step.active .step-label {
    color: var(--primary-color);
    font-weight: 600;
}

.progress-step.completed .step-number {
    background: var(--success-color);
    color: white;
}

.progress-step.completed .step-label {
    color: var(--success-color);
}

.progress-arrow {
    font-size: 1.5rem;
    color: var(--text-secondary);
    margin: 0 1rem;
}

/* ============================================================================
   Step Content
   ============================================================================ */
.step-content {
    display: none;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    flex-direction: column;
    max-width: 100vw;
    box-sizing: border-box;
}

.step-content.active {
    display: flex;
}

/* ============================================================================
   STEP 1: Metadata Form
   ============================================================================ */
.metadata-form {
    max-width: min(900px, calc(100% - 4rem));
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
    box-sizing: border-box;
}

.form-card {
    max-width: min(900px, calc(100% - 4rem));
    width: 100%;
    margin: 0 auto;
    padding: 2rem;
    padding-bottom: 0;
    box-sizing: border-box;
}

.form-card h2 {
    color: var(--text-primary);
    margin-bottom: 2rem;
    font-size: 1.5rem;
}

.form-actions {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    padding: 0.75rem 1.5rem;
    background: var(--card-bg);
    border-top: 2px solid var(--border-color);
    gap: 1rem;
    position: sticky;
    bottom: 0;
    max-width: 100%;
    box-sizing: border-box;
    z-index: 100;
    box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.1);
}

.form-actions button {
    margin: 0;
}

.help-text {
    display: block;
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-top: 0.25rem;
}

.form-section {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    margin-bottom: 2rem;
    border: 2px solid var(--border-color);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.form-section h3 {
    margin-top: 0;
    margin-bottom: 1.5rem;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 1.25rem;
    font-weight: 600;
}

.form-group {
    margin-bottom: 2rem;
    max-width: 100%;
    box-sizing: border-box;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.625rem;
    font-weight: 600;
    color: var(--text-primary);
    font-size: 1rem;
}

.form-hint {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-secondary);
}

.field-error {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: #dc3545;
    font-weight: 500;
}

.field-error:empty {
    display: none;
}

.form-group.has-error input,
.form-group.has-error textarea,
.form-group.has-error select {
    border-color: #dc3545 !important;
    background-color: rgba(220, 53, 69, 0.05);
}

.form-group.has-error input:focus,
.form-group.has-error textarea:focus,
.form-group.has-error select:focus {
    box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

.form-group.is-valid input,
.form-group.is-valid textarea {
    border-color: #28a745;
}

input:invalid:not(:placeholder-shown) {
    border-color: #dc3545;
}

input:valid:not(:placeholder-shown) {
    border-color: #28a745;
}

.form-control {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    min-height: 44px;
    box-sizing: border-box;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--hover-bg);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

input[type="text"],
input[type="email"],
textarea,
select {
    width: 100%;
    padding: 0.875rem 1rem;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    font-size: 1rem;
    font-family: inherit;
    transition: all 0.2s ease;
    min-height: 44px;
}

input[type="text"]:focus,
input[type="email"]:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary-color);
    background: var(--hover-bg);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

textarea {
    resize: vertical;
    min-height: 180px;
    font-family: inherit;
    line-height: 1.5;
}

textarea.form-control {
    resize: vertical;
    min-height: 180px;
    font-family: inherit;
}

select.form-control {
    cursor: pointer;
}

/* Tag Input */
.tag-input-container {
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    min-height: 50px;
    transition: all 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.tag-input-container:focus-within {
    border-color: var(--primary-color);
    background: var(--hover-bg);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.tag-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}

.tag-input-container input {
    width: 100%;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    box-sizing: border-box;
}

.tag-input-container input:focus {
    outline: none;
}

.tag-input-container input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.tag-input {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    padding: 0.75rem;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    min-height: 50px;
    align-items: center;
    transition: all 0.2s ease;
}

.tag-input:focus-within {
    border-color: var(--primary-color);
    background: var(--hover-bg);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.tag-input input {
    flex: 1;
    min-width: 150px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
}

.tag-input input:focus {
    outline: none;
}

.tag-input input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.tag {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.75rem;
    background: var(--primary-color);
    color: white;
    border-radius: 16px;
    font-size: 0.85rem;
    font-weight: 500;
}

.tag-remove {
    background: none;
    border: none;
    color: white;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    opacity: 0.8;
    transition: opacity 0.2s;
}

.tag-remove:hover {
    opacity: 1;
}

/* ============================================================================
   STEP 2: Workflow Builder
   ============================================================================ */
.workflow-builder {
    display: flex;
    flex: 1;
    gap: 1rem;
    padding: 1rem;
    overflow: hidden;
    height: calc(100vh - 180px);
    max-height: calc(100vh - 180px);
}

/* Tool Palette (Left Panel) */
.tool-palette {
    width: 300px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

.palette-header {
    padding: 12px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    background: var(--card-bg);
}

.palette-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.palette-header h3 {
    margin: 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
}

.palette-search-box {
    display: flex;
    align-items: center;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0 10px;
    margin-bottom: 10px;
    transition: all 0.2s ease;
}

.palette-search-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.palette-search-box .search-icon {
    font-size: 12px;
    opacity: 0.5;
    margin-right: 8px;
}

.palette-search-box input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 8px 0;
    color: var(--text-primary);
    font-size: 13px;
    outline: none;
}

.palette-search-box input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

.palette-search-box .search-clear {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px;
    font-size: 12px;
    opacity: 0.6;
    transition: opacity 0.2s;
}

.palette-search-box .search-clear:hover {
    opacity: 1;
    color: var(--danger-color);
}

.palette-filter-pills {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    align-items: center;
}

.filter-pill {
    padding: 5px 12px;
    font-size: 11px;
    font-weight: 500;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    background: var(--input-bg);
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.filter-pill:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(0, 123, 255, 0.1);
}

.filter-pill.active {
    background: var(--primary-color);
    border-color: var(--primary-color);
    color: white;
}

.palette-actions {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.palette-action-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 4px 8px;
    font-size: 10px;
    transition: all 0.2s ease;
}

.palette-action-btn:hover {
    border-color: var(--primary-color);
    color: var(--primary-color);
    background: rgba(0, 123, 255, 0.1);
}

.palette-search {
    width: 100%;
    padding: 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.palette-filter {
    width: 100%;
    padding: 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
}

.palette-content {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    scrollbar-width: thin;
    scrollbar-color: var(--primary-color) var(--input-bg);
}

.palette-content::-webkit-scrollbar {
    width: 8px;
}

.palette-content::-webkit-scrollbar-track {
    background: var(--input-bg);
    border-radius: 4px;
}

.palette-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.palette-content::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}

.palette-section {
    margin-bottom: 0;
    padding: 0;
}

#builtinSteps {
    /* Built-in steps section - ensure same styling */
}

#catalogTools {
    /* Available tools section - ensure same styling as built-in */
}

.palette-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.5rem;
}

.palette-section-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    color: var(--text-secondary);
    letter-spacing: 0.5px;
    margin-bottom: 0.75rem;
}

#catalogToolsList {
    padding: 0;
    margin: 0;
    /* Ensure children render at same level as built-in steps */
}

#catalogToolsList > * {
    /* All direct children (headers and items) have no extra margin */
    margin-left: 0 !important;
    margin-right: 0 !important;
}

.btn-icon {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: all 0.2s ease;
}

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

.palette-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: grab;
    transition: all 0.2s ease;
    margin-bottom: 0.5rem;
}

.palette-item:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.palette-item:active {
    cursor: grabbing;
}

.palette-item.dragging {
    opacity: 0.5;
}

/* Tool Group Styles */
.palette-tool-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0;
    margin: 0 0 0.5rem 0;
    cursor: pointer;
    background: transparent;
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    transition: all 0.2s ease;
}

.palette-tool-header:hover {
    color: var(--primary-color);
}

.palette-tool-header.collapsed {
    border-bottom: none;
    margin-bottom: 0.5rem;
}

.palette-tool-name {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.palette-tool-name strong {
    color: var(--text-primary);
    font-size: 0.75rem;
}

.palette-tool-count {
    font-size: 0.65rem;
    color: var(--text-secondary);
}

.palette-toggle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

/* Category Section Styles (Local MCP, Remote MCP, Kernel) */
.palette-category-section {
    margin-bottom: 0.75rem;
    border: 1px solid rgba(128, 128, 128, 0.2);
    border-radius: 6px;
    overflow: hidden;
}

.palette-category-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.6rem 0.75rem;
    cursor: pointer;
    background: var(--bg-secondary, #f3f2f1);
    border-bottom: 1px solid rgba(128, 128, 128, 0.2);
    transition: all 0.2s ease;
}

.palette-category-header:hover {
    background: var(--bg-tertiary, #edebe9);
}

.palette-category-header.collapsed {
    border-bottom: none;
}

.palette-category-icon {
    font-size: 1rem;
}

.palette-category-title {
    flex: 1;
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary);
}

.palette-category-count {
    font-size: 0.65rem;
    color: var(--text-secondary);
    background: rgba(128, 128, 128, 0.15);
    padding: 2px 6px;
    border-radius: 10px;
}

.palette-category-toggle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.palette-category-content {
    padding: 0.5rem 0.75rem;
    background: var(--card-bg);
}

/* Dark mode palette overrides */
body.dark-theme .palette-category-header,
body[data-theme="dark"] .palette-category-header {
    background: #333;
    border-bottom-color: #444;
}

body.dark-theme .palette-category-header:hover,
body[data-theme="dark"] .palette-category-header:hover {
    background: #3a3a3a;
}

body.dark-theme .palette-category-content,
body[data-theme="dark"] .palette-category-content {
    background: #2a2a2a;
}

body.dark-theme .palette-item,
body[data-theme="dark"] .palette-item {
    background: #363636;
    border-color: #4a4a4a;
}

body.dark-theme .palette-item:hover,
body[data-theme="dark"] .palette-item:hover {
    background: #404040;
    border-color: var(--primary-color);
}

body.dark-theme .palette-tool-name strong,
body[data-theme="dark"] .palette-tool-name strong {
    color: #e8e8e8;
}

body.dark-theme .palette-tool-count,
body[data-theme="dark"] .palette-tool-count {
    color: #aaa;
}

body.dark-theme .palette-category-count,
body[data-theme="dark"] .palette-category-count {
    background: rgba(255, 255, 255, 0.1);
    color: #ccc;
}

body.dark-theme .palette-name,
body[data-theme="dark"] .palette-name {
    color: #fff;
}

body.dark-theme .palette-desc,
body[data-theme="dark"] .palette-desc {
    color: #bbb;
}

/* Light mode filter pills - ensure visibility */
body[data-theme="light"] .filter-pill {
    color: #333;
    background: #f0f0f0;
    border-color: #ccc;
}

body[data-theme="light"] .filter-pill:hover {
    background: #e0e8ff;
}

body[data-theme="light"] .filter-pill.active {
    color: white;
}

.palette-tool-header .palette-icon {
    font-size: 1.1rem;
}

/* Tool functions render as regular palette-items, no special styling needed */
.tool-function {
    /* Inherits all .palette-item styles - same as built-in steps */
}

.palette-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.palette-info {
    flex: 1;
    min-width: 0;
}

.palette-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.95rem;
    word-break: break-word;
}

/* Preview/Under Development Tag */
.preview-tag {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 5px;
    margin-left: 4px;
    border-radius: 3px;
    background: linear-gradient(135deg, #ff9800, #f57c00);
    color: #fff;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

/* Not Implemented Tag (Red) */
.not-implemented-tag {
    display: inline-block;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 1px 5px;
    margin-left: 4px;
    border-radius: 3px;
    background: linear-gradient(135deg, #f44336, #c62828);
    color: #fff;
    vertical-align: middle;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.palette-source {
    font-size: 0.75rem;
    color: var(--text-secondary);
}

.palette-desc {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 2px;
    line-height: 1.3;
}

/* Legacy palette-categories - kept for backwards compatibility */
.palette-categories {
    display: none;
}

.palette-categories select {
    width: 100%;
    padding: 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
    cursor: pointer;
}

/* Legacy search-mini - kept for backwards compatibility */
.search-mini {
    width: 100%;
    padding: 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    color: var(--text-primary);
}

.search-mini:focus {
    outline: none;
    border-color: var(--primary-color);
}

.palette-loading,
.palette-error,
.palette-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* Workflow Canvas (Center Panel) */
.workflow-canvas {
    flex: 1;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100%;
    overflow: hidden;
}

/* Input Parameters Section */
.input-params-section {
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-secondary);
}

.input-params-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.input-params-header:hover {
    background: var(--hover-color);
}

.input-params-header h3 {
    margin: 0;
    font-size: 0.95rem;
    color: var(--text-primary);
}

.input-params-toggle {
    color: var(--text-secondary);
    transition: transform 0.2s;
}

.input-params-section.collapsed .input-params-toggle {
    transform: rotate(-90deg);
}

.input-params-body {
    padding: 0 1rem 1rem 1rem;
    max-height: 300px;
    overflow-y: auto;
    transition: max-height 0.3s ease, padding 0.3s ease, opacity 0.2s ease;
}

.input-params-section.collapsed .input-params-body {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    overflow: hidden;
    opacity: 0;
}

.input-params-description {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
}

.input-params-description code {
    background: var(--input-bg);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    color: var(--primary-color);
}

/* Compact parameter cards for workflow view */
.input-param-compact {
    display: grid;
    grid-template-columns: 1fr 1fr auto;
    gap: 8px;
    align-items: center;
    padding: 8px 12px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 8px;
}

.input-param-compact .param-name {
    font-family: monospace;
    font-weight: 600;
    color: var(--primary-color);
}

.input-param-compact .param-type {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.input-param-compact .param-required {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--warning-color);
    color: white;
}

.input-param-compact .param-optional {
    font-size: 0.75rem;
    padding: 2px 6px;
    border-radius: 4px;
    background: var(--text-muted);
    color: white;
}

/* Variable Reference Section */
.variable-reference-section {
    border-bottom: 1px solid var(--border-color);
    background: var(--bg-dark);
}

.variable-ref-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    cursor: pointer;
    user-select: none;
    transition: background 0.2s;
}

.variable-ref-header:hover {
    background: var(--hover-color);
}

.variable-ref-header h3 {
    margin: 0;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.variable-ref-toggle {
    color: var(--text-secondary);
    transition: transform 0.2s;
    font-size: 0.7rem;
}

.variable-reference-section.expanded .variable-ref-toggle {
    transform: rotate(90deg);
}

.variable-ref-body {
    padding: 0 1rem 1rem 1rem;
    max-height: 250px;
    overflow-y: auto;
}

.variable-ref-description {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin: 0 0 12px 0;
}

/* Variable reference categories */
.var-ref-category {
    margin-bottom: 12px;
}

.var-ref-category-title {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.var-ref-items {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.var-ref-chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: var(--primary-color);
    cursor: pointer;
    transition: all 0.2s;
}

.var-ref-chip:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    transform: translateY(-1px);
}

.var-ref-chip .chip-icon {
    font-size: 0.7rem;
}

.var-ref-chip.category-input {
    border-color: rgba(76, 175, 80, 0.3);
}

.var-ref-chip.category-context {
    border-color: rgba(156, 39, 176, 0.3);
}

.var-ref-chip.category-output {
    border-color: rgba(33, 150, 243, 0.3);
}

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

.canvas-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.canvas-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    min-height: 0;
}

.canvas-content::-webkit-scrollbar {
    width: 8px;
}

.canvas-content::-webkit-scrollbar-track {
    background: var(--input-bg);
    border-radius: 4px;
}

.canvas-content::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 4px;
}

.canvas-content::-webkit-scrollbar-thumb:hover {
    background: #0056b3;
}

/* Empty State */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    padding: 2rem;
}

.empty-icon {
    font-size: 4rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state h3 {
    margin: 0 0 1rem 0;
    color: var(--text-primary);
}

.empty-state p {
    color: var(--text-secondary);
    margin: 0.5rem 0;
}

/* Stage Card */
.stage-card {
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    margin-bottom: 1rem;
    overflow: hidden;
}

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

.stage-title {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.stage-number {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: var(--primary-color);
    color: white;
    border-radius: 50%;
    font-weight: bold;
    font-size: 0.9rem;
}

.stage-name-input {
    flex: 1;
    padding: 0.5rem;
    background: var(--input-bg);
    border: 1px solid transparent;
    border-radius: 4px;
    color: var(--text-primary);
    font-weight: 500;
    font-size: 1rem;
}

.stage-name-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.stage-actions {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.stage-mode-select {
    padding: 0.5rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
    cursor: pointer;
}

/* Stage Condition Row - defined below with enhanced styling */

.condition-label {
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    white-space: nowrap;
}

.stage-condition-input {
    flex: 1;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    font-family: 'Consolas', 'Monaco', monospace;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 4px;
    color: var(--text-primary);
}

.stage-condition-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 122, 204, 0.2);
}

.stage-condition-input::placeholder {
    color: var(--text-secondary);
    opacity: 0.7;
}

/* Condition row with remove button */
.stage-condition-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
    border-top: 1px solid var(--border-color);
}

.btn-small {
    width: 24px !important;
    height: 24px !important;
    font-size: 0.75rem;
    padding: 0;
}

/* Condition button in header */
.btn-condition {
    opacity: 0.5;
}

.btn-condition:hover {
    opacity: 1;
}

.btn-condition.has-condition {
    opacity: 1;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.3) 0%, rgba(118, 75, 162, 0.3) 100%);
    border-color: #667eea;
}

.btn-icon {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

/* Stage Steps */
.stage-steps {
    padding: 1.25rem;
    min-height: 120px;
    transition: all 0.2s ease;
}

.stage-steps.drag-over {
    background: rgba(0, 122, 204, 0.1);
    border: 2px dashed var(--primary-color);
    border-radius: 6px;
    box-shadow: 0 0 16px rgba(0, 122, 204, 0.2);
}

.stage-card.drag-over {
    border: 2px solid var(--primary-color);
    box-shadow: 0 0 20px rgba(0, 122, 204, 0.25);
    transition: all 0.2s ease;
}

.steps-empty {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
    border: 2px dashed var(--border-color);
    border-radius: 6px;
    pointer-events: none; /* Allow drag events to pass through to stage container */
}

/* Step Card */
.step-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    cursor: move;
}

.step-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
}

.step-card.drag-over-step {
    border-color: var(--primary-color);
    border-width: 2px;
    border-style: dashed;
    background: rgba(0, 123, 255, 0.05);
}

.btn-icon:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Loop Container Styles */
.loop-container {
    margin-bottom: 0.75rem;
    border: 2px solid #6c63ff;
    border-radius: 8px;
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.05), rgba(108, 99, 255, 0.02));
    overflow: hidden;
    transition: all 0.2s ease;
}

.loop-container.drag-over {
    border-color: #6c63ff;
    border-width: 3px;
    border-style: solid;
    background: linear-gradient(135deg, rgba(108, 99, 255, 0.15), rgba(108, 99, 255, 0.08));
    box-shadow: 0 0 20px rgba(108, 99, 255, 0.3), inset 0 0 40px rgba(108, 99, 255, 0.1);
    animation: pulse-border 1s ease-in-out infinite;
}

@keyframes pulse-border {
    0%, 100% {
        box-shadow: 0 0 20px rgba(108, 99, 255, 0.3), inset 0 0 40px rgba(108, 99, 255, 0.1);
    }
    50% {
        box-shadow: 0 0 30px rgba(108, 99, 255, 0.5), inset 0 0 50px rgba(108, 99, 255, 0.15);
    }
}

.loop-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem;
    background: rgba(108, 99, 255, 0.1);
    border-bottom: 1px solid rgba(108, 99, 255, 0.2);
    cursor: pointer;
    transition: all 0.2s ease;
}

.loop-header:hover {
    background: rgba(108, 99, 255, 0.15);
}

/* Show drop target indication when dragging over loop header */
.loop-container.drag-over .loop-header {
    background: rgba(108, 99, 255, 0.2);
    border-bottom-color: rgba(108, 99, 255, 0.4);
}

.loop-header-content {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex: 1;
}

.loop-toggle {
    font-size: 0.9rem;
    color: #6c63ff;
    width: 20px;
    text-align: center;
}

.loop-body {
    padding: 0.75rem;
}

.loop-nested-steps {
    min-height: 80px;
    border: 2px dashed rgba(108, 99, 255, 0.3);
    border-radius: 6px;
    padding: 0.75rem;
    background: var(--card-bg);
    transition: all 0.2s ease;
    position: relative;
}

/* Add helper text when empty during drag */
.loop-nested-steps:empty::after {
    content: 'Drop steps here';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: rgba(108, 99, 255, 0.5);
    font-size: 0.9rem;
    font-weight: 500;
    pointer-events: none;
}

.loop-nested-steps.drag-over {
    border-color: #6c63ff;
    border-width: 3px;
    background: rgba(108, 99, 255, 0.08);
    min-height: 100px;
}

/* Nested loop styling - Level 2 */
.loop-depth-1 {
    border-color: #4ea8de;
    background: linear-gradient(135deg, rgba(78, 168, 222, 0.05), rgba(78, 168, 222, 0.02));
}

.loop-depth-1 .loop-header {
    background: rgba(78, 168, 222, 0.1);
    border-bottom-color: rgba(78, 168, 222, 0.2);
}

.loop-depth-1 .loop-header:hover {
    background: rgba(78, 168, 222, 0.15);
}

.loop-depth-1 .loop-toggle {
    color: #4ea8de;
}

.loop-depth-1 .loop-nested-steps {
    border-color: rgba(78, 168, 222, 0.3);
}

.loop-depth-1.drag-over {
    border-color: #4ea8de;
    background: linear-gradient(135deg, rgba(78, 168, 222, 0.15), rgba(78, 168, 222, 0.08));
    box-shadow: 0 0 20px rgba(78, 168, 222, 0.3);
}

.loop-depth-badge {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(78, 168, 222, 0.2);
    color: #4ea8de;
    border-radius: 3px;
    font-size: 0.7rem;
    font-weight: bold;
    margin-left: 0.5rem;
}

.loop-steps-empty {
    text-align: center;
    padding: 1.5rem;
    color: var(--text-secondary);
    font-size: 0.9rem;
    pointer-events: none; /* Allow drag events to pass through to parent */
}

.loop-step-card {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem;
    background: var(--card-bg);
    border: 1px solid rgba(108, 99, 255, 0.3);
    border-radius: 6px;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    cursor: move;
}

.loop-step-card:hover {
    border-color: #6c63ff;
    box-shadow: 0 2px 8px rgba(108, 99, 255, 0.2);
    transform: translateX(2px);
}

.loop-step-card:last-child {
    margin-bottom: 0;
}

.loop-step-card.drag-over-step {
    border-color: #6c63ff;
    border-width: 2px;
    border-style: dashed;
    background: rgba(108, 99, 255, 0.1);
    transform: translateX(4px);
}

/* End Loop Container Styles */

.step-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
}

.step-info {
    flex: 1;
    min-width: 0;
}

.step-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.step-id {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-family: 'Courier New', monospace;
}

.step-id code {
    background: var(--input-bg);
    padding: 2px 6px;
    border-radius: 3px;
    color: var(--primary-color);
    font-weight: 600;
}

.step-details {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.step-condition-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.3rem;
    margin-top: 0.35rem;
    padding: 0.2rem 0.5rem;
    background: linear-gradient(135deg, rgba(255, 193, 7, 0.15), rgba(255, 152, 0, 0.1));
    border: 1px solid rgba(255, 193, 7, 0.4);
    border-radius: 4px;
    font-size: 0.75rem;
    color: #e6a700;
}

.step-condition-badge .condition-text {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.7rem;
    color: rgba(255, 193, 7, 0.9);
    max-width: 180px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

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

/* Stage Footer */
.stage-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid var(--border-color);
}

.btn-add-step {
    width: 100%;
    padding: 0.5rem;
    background: var(--input-bg);
    border: 1px dashed var(--border-color);
    color: var(--text-secondary);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

/* Step Configuration Panel (Right Panel) */
.step-config-panel {
    width: 550px;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: none;
    flex-direction: column;
    overflow: hidden;
    z-index: 100;
    pointer-events: auto;
    height: 100%;
    max-height: 100%;
}

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

.config-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.config-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 1rem;
    padding-bottom: 2rem;
    min-height: 0;
    max-height: calc(100vh - 250px);
}

.config-form .form-group {
    margin-bottom: 1rem;
}

.config-form label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    font-size: 0.9rem;
    color: var(--text-primary);
}

.config-form .form-control {
    font-size: 0.9rem;
    pointer-events: auto;
    user-select: text;
    -webkit-user-select: text;
}

.config-form h4 {
    margin: 1.5rem 0 1rem 0;
    font-size: 0.95rem;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.config-actions {
    display: flex;
    gap: 0.5rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}

.config-actions button {
    flex: 1;
}

/* Input with variable picker button */
.input-with-vars {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

.input-with-vars .form-control {
    flex: 1;
}

.btn-var-picker {
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    font-size: 1.2rem;
    transition: all 0.2s ease;
    min-width: 44px;
    height: 44px;
}

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

/* Variable Picker Modal */
.var-picker-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.var-picker-modal {
    background: var(--card-bg);
    border-radius: 12px;
    border: 2px solid var(--border-color);
    max-width: 500px;
    width: 90%;
    max-height: 70vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
}

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

.var-picker-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1.1rem;
}

.var-picker-content {
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.var-item {
    padding: 0.75rem;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 6px;
    margin-bottom: 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.var-item:hover {
    background: var(--hover-bg);
    border-color: var(--primary-color);
    transform: translateX(4px);
}

.var-name {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
    margin-bottom: 0.25rem;
}

.var-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.var-category-header {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    padding: 0.5rem 0.75rem 0.25rem;
    background: var(--bg-dark);
    margin: 0 -1rem;
    padding-left: 1rem;
}

/* ============================================================================
   IntelliSense Autocomplete
   ============================================================================ */
.intellisense-container {
    position: relative;
    overflow: visible;
}

.intellisense-dropdown {
    position: fixed;
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
    z-index: 99999;
    max-height: 320px;
    overflow-y: auto;
}

.intellisense-header {
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--hover-bg);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.75rem;
    color: var(--text-secondary);
    position: sticky;
    top: 0;
}

.intellisense-header .shortcut {
    font-family: 'Courier New', monospace;
    background: var(--input-bg);
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.7rem;
}

.intellisense-category {
    padding: 0.4rem 0.75rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--text-secondary);
    background: var(--bg-dark);
    border-top: 1px solid var(--border-color);
    position: sticky;
    top: 32px;
}

.intellisense-category:first-child {
    border-top: none;
}

.intellisense-category-icon {
    margin-right: 0.4rem;
}

.intellisense-item {
    padding: 0.5rem 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    border-bottom: 1px solid var(--border-color);
    transition: background 0.15s ease;
}

.intellisense-item:last-child {
    border-bottom: none;
}

.intellisense-item:hover,
.intellisense-item.selected {
    background: var(--hover-bg);
}

.intellisense-item.selected {
    border-left: 3px solid var(--primary-color);
    padding-left: calc(0.75rem - 3px);
}

.intellisense-icon {
    font-size: 1rem;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.intellisense-info {
    flex: 1;
    min-width: 0;
}

.intellisense-name {
    font-family: 'Courier New', monospace;
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.9rem;
    word-break: break-all;
}

.intellisense-name .highlight {
    background: rgba(0, 122, 204, 0.3);
    border-radius: 2px;
}

.intellisense-desc {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 0.15rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.intellisense-type {
    font-size: 0.65rem;
    padding: 0.1rem 0.35rem;
    background: var(--input-bg);
    border-radius: 4px;
    color: var(--text-secondary);
    flex-shrink: 0;
    align-self: center;
}

.intellisense-type.type-input {
    color: #4caf50;
    background: rgba(76, 175, 80, 0.15);
}

.intellisense-type.type-context {
    color: #9c27b0;
    background: rgba(156, 39, 176, 0.15);
}

.intellisense-type.type-output {
    color: #2196f3;
    background: rgba(33, 150, 243, 0.15);
}

.intellisense-empty {
    padding: 1.5rem;
    text-align: center;
    color: var(--text-secondary);
}

.intellisense-empty .icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

/* Variable chip (for displaying in outputs) */
.var-chip {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.15rem 0.5rem;
    background: rgba(0, 122, 204, 0.15);
    border: 1px solid var(--primary-color);
    border-radius: 12px;
    font-family: 'Courier New', monospace;
    font-size: 0.8rem;
    color: var(--primary-color);
    margin: 0.15rem;
}

.var-chip .chip-icon {
    font-size: 0.7rem;
}

/* Output preview badges */
.output-preview-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding: 0.75rem;
    background: var(--bg-dark);
    border-radius: 6px;
    border: 1px dashed var(--border-color);
}

.output-preview-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.35rem 0.6rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 0.8rem;
    transition: all 0.2s ease;
}

.output-preview-badge:hover {
    border-color: var(--primary-color);
    cursor: pointer;
}

.output-preview-badge .badge-icon {
    font-size: 0.9rem;
}

.output-preview-badge .badge-var {
    font-family: 'Courier New', monospace;
    color: var(--primary-color);
}

.output-preview-badge .badge-copy {
    font-size: 0.7rem;
    color: var(--text-secondary);
    margin-left: 0.25rem;
}

/* Condition Row (for Decision step) */
.condition-row {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    margin-bottom: 0.5rem;
}

.condition-row input {
    flex: 1;
}

.condition-row span {
    color: var(--text-secondary);
}

/* ============================================================================
   STEP 3: Preview & Generate
   ============================================================================ */
.preview-container {
    display: flex;
    gap: 1rem;
    padding: 1rem;
    height: calc(100vh - 240px);
    max-height: calc(100vh - 240px);
    overflow: hidden;
}

.preview-flow {
    flex: 1;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    overflow-y: auto;
    padding: 1.5rem;
}

.preview-flow h3 {
    margin-top: 0;
    color: var(--text-primary);
}

.preview-yaml {
    flex: 1;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.yaml-header h2,
.yaml-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.yaml-actions {
    display: flex;
    gap: 0.5rem;
}

.yaml-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

.yaml-output {
    background: var(--input-bg);
    border-radius: 6px;
    overflow-x: auto;
}

.yaml-output pre {
    margin: 0;
    padding: 1rem;
}

.yaml-output code {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
}

.yaml-footer {
    padding: 0.75rem;
    border-top: 1px solid var(--border-color);
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
}

/* Flow Diagram */
.flow-enhanced {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Execution Info Banner - Card Grid Layout */
.flow-execution-info {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 1rem;
}

.execution-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.exec-card {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.75rem;
    text-align: center;
    transition: all 0.2s ease;
}

.exec-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.exec-card-icon {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.exec-card-label {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-weight: 500;
}

.exec-card-value {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
}

.exec-card-success {
    border-color: rgba(76, 175, 80, 0.3);
    background: rgba(76, 175, 80, 0.05);
}

.exec-card-success .exec-card-value {
    color: #4caf50;
}

.exec-card-warning {
    border-color: rgba(255, 152, 0, 0.3);
    background: rgba(255, 152, 0, 0.05);
}

.exec-card-warning .exec-card-value {
    color: #ff9800;
}

.exec-card-error {
    border-color: rgba(244, 67, 54, 0.3);
    background: rgba(244, 67, 54, 0.05);
}

.exec-card-error .exec-card-value {
    color: #f44336;
}

.exec-card-info {
    border-color: rgba(33, 150, 243, 0.3);
    background: rgba(33, 150, 243, 0.05);
}

.exec-card-info .exec-card-value {
    color: var(--primary-color);
}

/* Stats Panel */
    display: flex;
    gap: 1.5rem;
    padding: 1rem;
    background: linear-gradient(135deg, var(--primary-color) 0%, #1976d2 100%);
    border-radius: 8px;
    color: white;
    align-items: center;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    opacity: 0.9;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: bold;
}

.stat-badge {
    padding: 0.375rem 0.75rem;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 12px;
    font-size: 0.85rem;
    font-weight: 500;
}

.flow-vertical {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
}

.flow-node {
    padding: 1rem 2rem;
    border-radius: 8px;
    text-align: center;
    min-width: 200px;
}

.flow-start {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    color: white;
    font-weight: bold;
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
    transition: all 0.3s ease;
}

.flow-start:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.5);
}

.flow-start.executing {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 4px 20px rgba(76, 175, 80, 0.6);
    }
}

.flow-node-title {
    font-size: 1rem;
    font-weight: 700;
}

.flow-node-subtitle {
    font-size: 0.75rem;
    margin-top: 0.25rem;
    opacity: 0.9;
    font-weight: 500;
}

.flow-end {
    background: var(--success-color);
    color: white;
    font-weight: bold;
    padding: 1rem 1.5rem;
    min-width: 140px;
}

.flow-end-nodes {
    display: flex;
    gap: 2rem;
    justify-content: center;
    margin-top: 1rem;
}

.flow-success {
    background: linear-gradient(135deg, #4caf50 0%, #66bb6a 100%);
    box-shadow: 0 2px 8px rgba(76, 175, 80, 0.3);
}

.flow-failed {
    background: linear-gradient(135deg, #f44336 0%, #ef5350 100%);
    box-shadow: 0 2px 8px rgba(244, 67, 54, 0.3);
}

.flow-stage-container {
    width: 100%;
    max-width: 800px;
}

/* Alternative Path Grouping */
.alternative-path-group {
    margin: 1rem 0;
    padding: 1.5rem;
    background: rgba(255, 152, 0, 0.03);
    border: 2px dashed rgba(255, 152, 0, 0.3);
    border-radius: 12px;
    position: relative;
}

.alternative-path-label {
    position: absolute;
    top: -12px;
    left: 20px;
    background: var(--card-bg);
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--warning-color);
    border: 1px solid rgba(255, 152, 0, 0.3);
    border-radius: 12px;
}

.alternative-path-group .flow-stage-container {
    margin: 1rem 0;
}

.alternative-path-group .flow-stage-container:first-of-type {
    margin-top: 0.5rem;
}

.alternative-path-group .flow-stage-container:last-of-type {
    margin-bottom: 0.5rem;
}

.flow-stage-container.in-alternative-group .flow-stage {
    border-left: 4px solid var(--warning-color);
}

.flow-stage {
    background: var(--card-bg);
    border: 2px solid var(--primary-color);
    padding: 1rem;
    transition: all 0.2s ease;
}

.flow-stage.conditional-stage {
    border-color: var(--warning-color);
    border-style: dashed;
}

.flow-stage:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.flow-stage-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.stage-condition-badge {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 152, 0, 0.1);
    border-left: 3px solid var(--warning-color);
    border-radius: 4px;
    font-size: 0.85rem;
}

.stage-condition-badge code {
    color: var(--warning-color);
    font-weight: 600;
}

.expand-icon {
    font-size: 0.75rem;
    color: var(--text-secondary);
    transition: transform 0.2s ease;
}

.flow-stage-title {
    font-weight: bold;
    color: var(--text-primary);
    flex: 1;
}

.flow-stage-meta {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
    font-size: 0.85rem;
    flex-wrap: wrap;
}

.flow-stage-mode {
    color: var(--primary-color);
}

.flow-stage-steps {
    color: var(--text-secondary);
}

.stage-has-conditions {
    color: var(--warning-color);
    font-weight: 500;
}

.stage-continue-error {
    color: #ff9800;
    font-weight: 500;
}

.flow-stage-details {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}

.flow-step {
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 0.875rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
}

.flow-step:hover {
    border-color: var(--primary-color);
    box-shadow: 0 2px 8px rgba(33, 150, 243, 0.1);
}

.flow-step.indent-1 {
    margin-left: 2rem;
    border-left: 3px solid var(--warning-color);
}

.flow-step.indent-2 {
    margin-left: 4rem;
    border-left: 3px solid var(--error-color);
}

.flow-step-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.step-icon {
    font-size: 1.25rem;
}

.step-name {
    font-weight: 600;
    color: var(--text-primary);
    flex: 1;
}

.step-type-badge {
    padding: 0.25rem 0.625rem;
    background: var(--primary-color);
    color: white;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.flow-step-condition {
    margin-top: 0.625rem;
    padding: 0.75rem;
    background: rgba(255, 152, 0, 0.08);
    border: 2px solid rgba(255, 152, 0, 0.3);
    border-radius: 6px;
    font-size: 0.85rem;
}

.condition-header {
    margin-bottom: 0.5rem;
}

.condition-label {
    font-weight: 600;
    color: var(--warning-color);
    font-size: 0.9rem;
}

.condition-logic {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.condition-if {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: white;
    border-radius: 4px;
}

.condition-keyword {
    font-weight: 700;
    color: var(--warning-color);
    font-size: 0.75rem;
    padding: 0.25rem 0.5rem;
    background: rgba(255, 152, 0, 0.15);
    border-radius: 3px;
}

.condition-if code {
    flex: 1;
    color: #d32f2f;
    font-weight: 600;
    font-size: 0.85rem;
}

.condition-paths {
    display: flex;
    gap: 0.75rem;
    margin-top: 0.25rem;
}

.condition-path {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.5rem;
    border-radius: 4px;
    font-size: 0.8rem;
}

.path-true {
    background: rgba(76, 175, 80, 0.1);
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.path-false {
    background: rgba(158, 158, 158, 0.1);
    border: 1px solid rgba(158, 158, 158, 0.3);
}

.path-icon {
    font-weight: bold;
    font-size: 0.9rem;
}

.path-true .path-icon {
    color: #4caf50;
}

.path-false .path-icon {
    color: #9e9e9e;
}

.path-text {
    color: var(--text-secondary);
    font-size: 0.75rem;
}

/* Error Handler Styles */
.flow-step-error-handler {
    margin-top: 0.625rem;
    padding: 0.625rem;
    background: rgba(244, 67, 54, 0.08);
    border: 2px solid rgba(244, 67, 54, 0.3);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.error-handler-label {
    font-weight: 600;
    color: var(--error-color);
}

.error-handler-action {
    padding: 0.25rem 0.5rem;
    background: rgba(244, 67, 54, 0.15);
    border-radius: 4px;
    color: #d32f2f;
    font-weight: 600;
    font-family: 'Consolas', 'Monaco', monospace;
}

.error-handler-info {
    color: var(--text-secondary);
    font-size: 0.75rem;
    font-style: italic;
}

/* Conditional Arrow Styles */
.flow-conditional-arrow {
    display: flex;
    gap: 1.5rem;
    padding: 0.75rem 1rem;
    justify-content: center;
}

.conditional-path {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
}

.conditional-yes .path-label {
    color: #4caf50;
    font-weight: 600;
    font-size: 0.8rem;
}

.conditional-no .path-label {
    color: #9e9e9e;
    font-weight: 600;
    font-size: 0.8rem;
}

.conditional-yes .path-arrow {
    color: #4caf50;
    font-size: 1.5rem;
}

.conditional-no .path-arrow {
    color: #9e9e9e;
    font-size: 1.5rem;
}

.condition-label {
    font-weight: 600;
    color: var(--warning-color);
    margin-right: 0.5rem;
}

.flow-step-condition code {
    background: rgba(0, 0, 0, 0.05);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
    font-size: 0.8rem;
}

.flow-step-loop {
    margin-top: 0.625rem;
    padding: 0.5rem;
    background: rgba(156, 39, 176, 0.1);
    border-left: 3px solid #9c27b0;
    border-radius: 4px;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.loop-label {
    font-weight: 600;
    color: #9c27b0;
}

.loop-info {
    color: var(--text-primary);
}

.loop-count {
    padding: 0.125rem 0.5rem;
    background: #9c27b0;
    color: white;
    border-radius: 10px;
    font-size: 0.75rem;
    font-weight: 500;
}

.flow-loop-steps {
    margin-top: 0.625rem;
    padding-left: 1rem;
    border-left: 2px dashed #9c27b0;
}

.flow-step-details {
    margin-top: 0.625rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.detail-item {
    padding: 0.25rem 0.625rem;
    background: rgba(33, 150, 243, 0.1);
    border: 1px solid rgba(33, 150, 243, 0.3);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--primary-color);
}

.flow-step-io {
    margin-top: 0.625rem;
    display: flex;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.io-badge {
    padding: 0.25rem 0.625rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 500;
}

.io-input {
    background: rgba(76, 175, 80, 0.1);
    color: #4caf50;
    border: 1px solid rgba(76, 175, 80, 0.3);
}

.io-output {
    background: rgba(33, 150, 243, 0.1);
    color: var(--primary-color);
    border: 1px solid rgba(33, 150, 243, 0.3);
}

.flow-arrow {
    font-size: 1.5rem;
    color: var(--text-secondary);
    transition: all 0.3s ease;
}

.flow-arrow.flow-active {
    color: var(--primary-color);
    animation: arrowPulse 0.6s ease-in-out;
}

@keyframes arrowPulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.3);
        opacity: 0.7;
    }
}

/* Execution Walkthrough Animations */
.stage-executing {
    border-color: var(--primary-color) !important;
    background: rgba(33, 150, 243, 0.05) !important;
    box-shadow: 0 0 20px rgba(33, 150, 243, 0.3) !important;
    animation: stageExecuting 2s ease-in-out infinite;
}

@keyframes stageExecuting {
    0%, 100% {
        box-shadow: 0 0 20px rgba(33, 150, 243, 0.3);
    }
    50% {
        box-shadow: 0 0 30px rgba(33, 150, 243, 0.5);
    }
}

.stage-completed {
    border-color: #4caf50 !important;
    background: rgba(76, 175, 80, 0.05) !important;
}

.stage-skipped {
    border-color: #9e9e9e !important;
    opacity: 0.5;
}

.step-executing {
    border-color: var(--primary-color) !important;
    background: rgba(33, 150, 243, 0.1) !important;
    transform: scale(1.02);
    box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3) !important;
    animation: stepExecuting 1.5s ease-in-out infinite;
}

@keyframes stepExecuting {
    0%, 100% {
        box-shadow: 0 4px 12px rgba(33, 150, 243, 0.3);
    }
    50% {
        box-shadow: 0 4px 20px rgba(33, 150, 243, 0.5);
    }
}

.step-completed {
    border-left: 4px solid #4caf50 !important;
    background: rgba(76, 175, 80, 0.05) !important;
}

.step-skipped {
    opacity: 0.4;
    border-left: 4px solid #9e9e9e !important;
}

.flow-final-state {
    animation: finalState 0.8s ease-in-out;
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(76, 175, 80, 0.5) !important;
}

@keyframes finalState {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        transform: scale(1.1);
    }
}

.flow-conditional-arrow.flow-active .conditional-yes {
    animation: pathHighlight 0.6s ease-in-out;
}

@keyframes pathHighlight {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
        transform: scale(1.1);
    }
}

/* Execution Badges and Indicators */
.execution-condition-badge {
    position: absolute;
    top: -12px;
    right: 10px;
    padding: 0.375rem 0.75rem;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
    animation: badgeFadeIn 0.3s ease-in-out;
    display: flex;
    align-items: center;
    gap: 0.25rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

@keyframes badgeFadeIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.condition-met {
    background: #4caf50;
    color: white;
}

.condition-not-met {
    background: #ff9800;
    color: white;
}

.badge-icon {
    font-weight: bold;
    font-size: 0.9rem;
}

.execution-mode-indicator {
    margin-top: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(33, 150, 243, 0.1);
    border: 1px solid rgba(33, 150, 243, 0.3);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--primary-color);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: modeFadeIn 0.4s ease-in-out;
}

@keyframes modeFadeIn {
    from {
        opacity: 0;
        transform: scaleY(0);
    }
    to {
        opacity: 1;
        transform: scaleY(1);
    }
}

.mode-icon {
    font-size: 1rem;
}

.execution-loop-badge {
    position: absolute;
    top: -12px;
    right: 10px;
    padding: 0.375rem 0.75rem;
    background: #9c27b0;
    color: white;
    border-radius: 16px;
    font-size: 0.75rem;
    font-weight: 600;
    z-index: 10;
    animation: loopBadgePulse 1s ease-in-out infinite;
    box-shadow: 0 2px 8px rgba(156, 39, 176, 0.3);
}

@keyframes loopBadgePulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

/* Parallel execution visual cue */
.flow-stage.stage-executing .flow-step.step-executing {
    animation-delay: calc(var(--step-index, 0) * 0.1s);
}

.flow-empty {
    text-align: center;
    padding: 3rem;
    color: var(--text-secondary);
}

.flow-branches {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    justify-content: center;
    margin: 1rem 0;
}

.flow-branch {
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    min-width: 150px;
    text-align: center;
}

.flow-branch-default {
    border-color: var(--text-secondary);
    border-style: dashed;
}

.flow-branch-label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
    font-family: monospace;
}

.flow-branch-action {
    font-size: 0.85rem;
    color: var(--primary-color);
    font-weight: 500;
}

/* ============================================================================
   Navigation
   ============================================================================ */
.step-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: var(--card-bg);
    border-top: 1px solid var(--border-color);
}

.nav-left,
.nav-right {
    display: flex;
    gap: 0.5rem;
}

/* Buttons */
.btn-primary,
.btn-secondary {
    padding: 0.875rem 2rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    font-size: 1rem;
    min-height: 44px;
    white-space: nowrap;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 4px rgba(0, 123, 255, 0.3);
}

.btn-primary:hover {
    background: #0056b3;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 123, 255, 0.4);
}

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

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

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.btn-link {
    background: transparent;
    color: var(--primary-color);
    border: none;
    padding: 0.25rem 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    text-decoration: underline;
    transition: color 0.2s ease;
}

.btn-link:hover {
    color: var(--primary-hover);
    text-decoration: none;
}

.btn-success {
    background: var(--success-color);
    color: white;
    padding: 0.875rem 2rem;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    font-size: 1rem;
    min-height: 44px;
    transition: all 0.2s ease;
    box-shadow: 0 2px 4px rgba(40, 167, 69, 0.3);
    white-space: nowrap;
}

.btn-success:hover {
    background: #218838;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.4);
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--text-secondary);
    font-size: 1.5rem;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
}

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

.preview-panel {
    flex: 1;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    padding: 1rem;
    display: flex;
    flex-direction: column;
    min-height: 0;
    position: relative;
}

.preview-panel .flow-diagram {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.preview-panel .studio-controls-bar {
    flex-shrink: 0;
    position: sticky;
    bottom: 0;
    margin-top: auto;
    background: var(--card-bg);
    z-index: 10;
}

/* Fullscreen preview mode */
.preview-panel.fullscreen-preview {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    border-radius: 0;
    margin: 0;
    padding: 1rem;
}

/* Fullscreen yaml mode */
.yaml-panel.fullscreen-yaml {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 2000;
    border-radius: 0;
    margin: 0;
    max-height: 100vh;
}

.yaml-panel.fullscreen-yaml .yaml-preview {
    height: calc(100vh - 120px);
}

.yaml-panel.fullscreen-yaml .yaml-preview textarea {
    height: 100%;
    min-height: unset;
}

/* Preview header - always flex */
.preview-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-shrink: 0;
}

.fullscreen-btn {
    padding: 0.4rem 0.75rem;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    cursor: pointer;
    color: var(--text-primary);
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.fullscreen-btn:hover {
    background: var(--accent-color, #4a90d9);
    color: white;
    border-color: var(--accent-color, #4a90d9);
}

.preview-panel h2 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.yaml-panel {
    flex: 1;
    background: var(--card-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0;
}

.yaml-preview {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 0;
    background: var(--input-bg);
    min-height: 0;
    display: flex;
    flex-direction: column;
}

.yaml-preview pre {
    margin: 0;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
    line-height: 1.6;
    color: var(--text-primary);
    flex: 1;
    overflow: auto;
}

.yaml-preview textarea {
    flex: 1;
    min-height: 400px;
}

.step-type-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 1rem;
}

.step-type-option {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 1rem;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.step-type-option:hover {
    border-color: var(--primary-color);
    background: var(--hover-bg);
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.step-type-icon {
    font-size: 2rem;
}

.step-type-info {
    flex: 1;
}

.step-type-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.step-type-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.modal-large {
    max-width: 1200px !important;
}

.flow-diagram-large {
    min-height: 400px;
}

.btn-add-stage {
    padding: 0.75rem 1.5rem;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-weight: 500;
    transition: all 0.2s ease;
}

.btn-add-stage:hover {
    background: #0056b3;
}

/* ============================================================================
   Modals
   ============================================================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    max-width: 800px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-secondary);
    cursor: pointer;
}

.modal-body {
    margin-bottom: 1.5rem;
}

.step-type-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 1rem;
}

.step-type-card {
    padding: 1.5rem;
    background: var(--input-bg);
    border: 2px solid var(--border-color);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.step-type-card:hover {
    border-color: var(--primary-color);
    background: var(--hover-bg);
}

.step-type-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.step-type-name {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.step-type-desc {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* Large modal for flow preview */
.modal-content.large {
    max-width: 900px;
}

/* ============================================================================
   Condition & Validation Rows
   ============================================================================ */
.condition-row,
.validation-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.condition-row > div,
.validation-row > div {
    display: flex;
    flex-direction: column;
}

.condition-row label,
.validation-row label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.condition-row .form-control,
.validation-row .form-control {
    flex: 1;
}

.condition-row .btn-icon,
.validation-row .btn-icon,
.branch-row .btn-icon {
    flex-shrink: 0;
    padding: 0.5rem;
    height: 44px;
    min-width: 44px;
}

.branch-row {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
    margin-bottom: 0.75rem;
    padding: 0.75rem;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.branch-row > div {
    display: flex;
    flex-direction: column;
}

.branch-row label {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-bottom: 0.25rem;
}

.branch-row .form-control {
    flex: 1;
}

/* ============================================================================
   Responsive
   ============================================================================ */
@media (max-width: 1200px) {
    .workflow-builder {
        flex-direction: column;
    }
    
    .tool-palette,
    .step-config-panel {
        width: 100%;
        max-height: 300px;
    }
    
    .preview-container {
        flex-direction: column;
    }
    
    .form-card,
    .metadata-form {
        padding: 1rem;
        max-width: calc(100% - 2rem);
    }
    
    .form-actions {
        padding: 1rem;
    }
    
    .progress-steps {
        padding: 1rem 0.5rem;
    }
}

/* ============================================================================
   Step 0: Initial Selection Screen
   ============================================================================ */
.selection-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 3rem 2rem;
    min-height: calc(100vh - 100px);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.selection-cards {
    display: grid;
    grid-template-columns: repeat(3, minmax(320px, 380px));
    gap: 2rem;
    margin-top: 2rem;
    justify-content: center;
}

.selection-card {
    background: var(--card-bg);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 2rem;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    min-height: 520px;
}

.selection-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-hover);
    border-color: var(--primary-color);
}

.selection-icon {
    font-size: 64px;
    margin-bottom: 1rem;
}

.selection-card h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
}

.selection-card p {
    color: var(--text-secondary);
    margin-bottom: 1.5rem;
    font-size: 1rem;
    line-height: 1.5;
}

.feature-list {
    list-style: none;
    padding: 0;
    margin: 1.5rem 0;
    text-align: left;
    width: 100%;
}

.feature-list li {
    padding: 0.5rem 0;
    color: var(--text-secondary);
    position: relative;
    padding-left: 1.5rem;
}

.feature-list li:before {
    content: "✓";
    position: absolute;
    left: 0;
    color: var(--success-color);
    font-weight: bold;
}

.selection-card .btn-primary {
    margin-top: auto;
    width: 100%;
}

/* ============================================================================
   TSG Generation Page
   ============================================================================ */
.tsg-generation-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 2rem;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 200px);
}

.tsg-header {
    text-align: center;
    margin-bottom: 2rem;
}

.tsg-header h2 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.tsg-header p {
    color: var(--text-secondary);
}

.tsg-content-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    flex: 1;
    overflow: hidden;
    min-height: 0;
}

.tsg-input-panel,
.tsg-output-panel {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.panel-header h3 {
    margin: 0;
    color: var(--text-primary);
    font-size: 1rem;
    font-weight: 600;
}

.tsg-input-panel {
    padding: 1rem;
    overflow-y: auto;
}

.input-group {
    margin-bottom: 1.5rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
    font-weight: 600;
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    background: var(--input-bg);
    color: var(--text-primary);
    font-family: inherit;
    font-size: 14px;
    transition: border-color 0.2s;
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    outline: none;
    border-color: var(--primary-color);
}

.form-textarea {
    resize: vertical;
    font-family: 'Courier New', monospace;
}

.generation-status {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem;
}

.status-placeholder {
    text-align: center;
}

.status-placeholder h3 {
    color: var(--text-primary);
    margin-bottom: 0.5rem;
}

.status-placeholder p {
    color: var(--text-secondary);
}

.generating-loader {
    text-align: center;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid var(--border-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.generation-tabs {
    display: flex;
    border-bottom: 2px solid var(--border-color);
    padding: 0 1rem;
}

.tab-btn {
    padding: 0.75rem 1.5rem;
    background: transparent;
    border: none;
    border-bottom: 2px solid transparent;
    color: var(--text-secondary);
    cursor: pointer;
    font-weight: 500;
    margin-bottom: -2px;
    transition: all 0.2s;
}

.tab-btn:hover {
    color: var(--text-primary);
}

.tab-btn.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

.tab-content {
    display: none;
    padding: 1rem;
    overflow-y: auto;
    flex: 1;
}

.tab-content.active {
    display: block;
}

.analysis-content,
.recommendations-content {
    line-height: 1.6;
}

.analysis-section,
.recommendation-item {
    background: var(--input-bg);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 1rem;
}

.analysis-section h4,
.recommendation-item h4 {
    color: var(--text-primary);
    margin-top: 0;
    margin-bottom: 0.5rem;
}

.analysis-section p,
.recommendation-item p {
    color: var(--text-secondary);
    margin: 0.5rem 0;
}

.analysis-section ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.analysis-section li {
    color: var(--text-secondary);
    margin: 0.25rem 0;
}

.loading-message {
    color: var(--text-secondary);
    font-style: italic;
}

/* ============================================================================
   Theme Overrides (Already handled in main theme section above)
   ============================================================================ */

/* ============================================================================
   Modal Styles
   ============================================================================ */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-hover);
    max-width: 600px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(20px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

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

.modal-header h3 {
    margin: 0;
    color: var(--text-primary);
}

.modal-body {
    padding: 20px;
}

.modal-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%);
    background: var(--success-color, #4caf50);
    color: white;
    padding: 0.75rem 1.5rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 9999;
    animation: toastSlideUp 0.3s ease;
}

.toast-notification span {
    margin-right: 0.5rem;
}

@keyframes toastSlideUp {
    from {
        transform: translateX(-50%) translateY(20px);
        opacity: 0;
    }
    to {
        transform: translateX(-50%) translateY(0);
        opacity: 1;
    }
}
