/* ============================================================================
   Flow Diagram - Shared Styles for Playbook Flow Visualization
   Used by: playbook-studio.html, playbooks-catalog.html
   ============================================================================ */

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

.flow-empty {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary, #666);
    font-size: 1rem;
}

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

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

.exec-card {
    background: var(--input-bg, var(--bg-secondary, #f5f5f5));
    border: 1px solid var(--border-color, #e0e0e0);
    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.25rem;
    margin-bottom: 0.25rem;
}

.exec-card-label {
    font-size: 0.7rem;
    color: var(--text-secondary, #666);
    margin-bottom: 0.25rem;
    font-weight: 500;
    text-transform: uppercase;
}

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

.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, #2196f3);
}

/* Flow Vertical Layout */
.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;
}

/* START Node */
.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: flowPulse 1.5s ease-in-out infinite;
}

@keyframes flowPulse {
    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;
}

/* END Nodes */
.flow-end {
    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);
}

/* Stage Container */
.flow-stage-container {
    width: 100%;
    max-width: 800px;
}

.flow-stage {
    background: var(--card-bg, var(--bg-card, #fff));
    border: 2px solid var(--primary-color, var(--accent-color, #2196f3));
    padding: 1rem;
    border-radius: 8px;
    transition: all 0.2s ease;
}

.flow-stage.conditional-stage {
    border-color: var(--warning-color, #ff9800);
    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;
}

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

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

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

.stage-condition-badge code {
    color: var(--warning-color, #ff9800);
    font-weight: 600;
    background: rgba(0, 0, 0, 0.05);
    padding: 0.125rem 0.375rem;
    border-radius: 3px;
}

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

.flow-stage-mode {
    color: var(--primary-color, var(--accent-color, #2196f3));
}

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

.stage-has-conditions {
    color: var(--warning-color, #ff9800);
    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, #e0e0e0);
}

/* Step Styles */
.flow-step {
    background: var(--input-bg, var(--bg-secondary, #f5f5f5));
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    padding: 0.875rem;
    margin-bottom: 0.75rem;
    transition: all 0.2s ease;
    position: relative;
}

.flow-step:hover {
    border-color: var(--primary-color, var(--accent-color, #2196f3));
    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, #ff9800);
}

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

.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, #333);
    flex: 1;
}

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

/* Step Condition */
.flow-step-condition {
    margin-top: 0.625rem;
    padding: 0.75rem;
    background: rgba(255, 152, 0, 0.08);
    border: 1px 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, #ff9800);
    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: rgba(255, 255, 255, 0.8);
    border-radius: 4px;
}

.condition-keyword {
    font-weight: 700;
    color: var(--warning-color, #ff9800);
    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, #666);
    font-size: 0.75rem;
}

/* Error Handler */
.flow-step-error-handler {
    margin-top: 0.625rem;
    padding: 0.625rem;
    background: rgba(244, 67, 54, 0.08);
    border: 1px 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, #f44336);
}

.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, #666);
    font-size: 0.75rem;
    font-style: italic;
}

/* Loop Styles */
.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, #333);
}

.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;
}

/* Step Details */
.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, #2196f3);
}

/* Input/Output Badges */
.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, #2196f3);
    border: 1px solid rgba(33, 150, 243, 0.3);
}

/* Flow Arrows */
.flow-arrow {
    font-size: 1.5rem;
    color: var(--text-secondary, #666);
    transition: all 0.3s ease;
    line-height: 1;
}

.flow-arrow.flow-active {
    color: var(--primary-color, var(--accent-color, #2196f3));
    animation: flowArrowPulse 0.6s ease-in-out;
}

@keyframes flowArrowPulse {
    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, var(--accent-color, #2196f3)) !important;
    background: rgba(33, 150, 243, 0.05) !important;
    box-shadow: 0 0 20px rgba(33, 150, 243, 0.3) !important;
    animation: flowStageExecuting 2s ease-in-out infinite;
}

@keyframes flowStageExecuting {
    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, var(--accent-color, #2196f3)) !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: flowStepExecuting 1.5s ease-in-out infinite;
}

@keyframes flowStepExecuting {
    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: flowFinalState 0.8s ease-in-out;
    transform: scale(1.1);
    box-shadow: 0 6px 24px rgba(76, 175, 80, 0.5) !important;
}

@keyframes flowFinalState {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.15);
    }
    100% {
        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: flowBadgeFadeIn 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 flowBadgeFadeIn {
    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, #2196f3);
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    animation: flowModeFadeIn 0.4s ease-in-out;
}

@keyframes flowModeFadeIn {
    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: flowBadgeFadeIn 0.3s ease-in-out;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

/* Step Arrow (between steps) */
.flow-step-arrow {
    text-align: center;
    color: var(--text-secondary, #666);
    font-size: 0.9rem;
    padding: 4px 0;
}

/* ============================================================================
   Controls Bar - Speed, Playback, Export
   ============================================================================ */

.flow-controls-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--card-bg, var(--bg-card, #fff));
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 8px;
    align-items: center;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
}

/* Sticky Controls Bar - Fixed at bottom of modal/container */
.flow-controls-bar.sticky-controls {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1000;
    border-radius: 0;
    border-left: none;
    border-right: none;
    border-bottom: none;
    margin: 0;
    justify-content: center;
}

/* Studio Controls Bar - Sticky at bottom of preview panel */
.flow-controls-bar.studio-controls-bar {
    position: sticky;
    bottom: 0;
    margin-top: 1rem;
    border-radius: 8px;
    background: var(--card-bg, #fff);
    z-index: 10;
}

.controls-group {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

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

.sim-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
    font-weight: 500;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 6px;
    background: var(--input-bg, var(--bg-secondary, #f5f5f5));
    color: var(--text-primary, #333);
    cursor: pointer;
    transition: all 0.2s ease;
}

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

.sim-btn:active {
    transform: scale(0.95);
}

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

.sim-speed-btn {
    min-width: 45px;
    justify-content: center;
}

.sim-pause-btn, .sim-resume-btn {
    background: #ff9800;
    color: white;
    border-color: #ff9800;
}

.sim-pause-btn:hover, .sim-resume-btn:hover {
    background: #f57c00;
    border-color: #f57c00;
}

.sim-stop-btn {
    background: #f44336;
    color: white;
    border-color: #f44336;
}

.sim-stop-btn:hover {
    background: #d32f2f;
    border-color: #d32f2f;
}

/* Pause toggle button */
.sim-pause-toggle-btn {
    background: #ff9800;
    color: white;
    border-color: #ff9800;
}

.sim-pause-toggle-btn:hover {
    background: #f57c00;
    border-color: #f57c00;
}

.sim-pause-toggle-btn.paused {
    background: #4caf50;
    border-color: #4caf50;
}

.sim-pause-toggle-btn.paused:hover {
    background: #43a047;
    border-color: #43a047;
}

.sim-export-btn {
    background: var(--input-bg, #f8f9fa);
    color: var(--text-primary, #333);
}

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

/* Dark Mode Export Button Fixes */
body[data-theme="dark"] .sim-export-btn {
    background: var(--bg-secondary, #2d2d2d);
    color: var(--text-primary, #e0e0e0);
    border-color: var(--border-color, #444);
}

body[data-theme="dark"] .sim-export-btn:hover {
    background: var(--accent-color, #4a90d9);
    color: white;
    border-color: var(--accent-color, #4a90d9);
}

body[data-theme="dark"] .sim-btn {
    background: var(--bg-secondary, #2d2d2d);
    color: var(--text-primary, #e0e0e0);
    border-color: var(--border-color, #444);
}

body[data-theme="dark"] .sim-btn:hover {
    background: var(--accent-color, #4a90d9);
    color: white;
}

body[data-theme="dark"] .sim-btn.active {
    background: var(--accent-color, #4a90d9);
    color: white;
}

body[data-theme="dark"] .flow-controls-bar {
    background: var(--bg-card, #1e1e1e);
    border-color: var(--border-color, #444);
}

/* Playback Controls Separator */
.playback-controls {
    padding-right: 1rem;
    border-right: 1px solid var(--border-color, #e0e0e0);
}

.speed-controls {
    padding-right: 1rem;
    border-right: 1px solid var(--border-color, #e0e0e0);
}

/* ============================================================================
   Export Modal
   ============================================================================ */

.export-modal {
    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: 10000;
    animation: fadeIn 0.2s ease;
}

.export-modal-content {
    background: var(--card-bg, #fff);
    border-radius: 12px;
    width: 90%;
    max-width: 700px;
    max-height: 80vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

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

.export-modal-header h3 {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-primary, #333);
}

.export-modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-secondary, #666);
    padding: 0;
    line-height: 1;
}

.export-modal-close:hover {
    color: var(--text-primary, #333);
}

.export-modal-body {
    padding: 1.5rem;
    overflow-y: auto;
}

.export-hint {
    font-size: 0.9rem;
    color: var(--text-secondary, #666);
    margin-bottom: 1rem;
}

.export-hint a {
    color: var(--accent-color, #4a90d9);
    text-decoration: none;
}

.export-hint a:hover {
    text-decoration: underline;
}

.mermaid-code {
    width: 100%;
    min-height: 300px;
    padding: 1rem;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.85rem;
    border: 1px solid var(--border-color, #ddd);
    border-radius: 8px;
    background: var(--input-bg, #f8f9fa);
    color: var(--text-primary, #333);
    resize: vertical;
    line-height: 1.5;
}

.export-actions {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
    justify-content: flex-end;
}

/* Export Loading Overlay */
.export-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10001;
    color: white;
    font-size: 1.1rem;
    gap: 0.75rem;
}

.export-loading .spinner {
    width: 24px;
    height: 24px;
    border: 3px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

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

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

/* Responsive Controls */
@media (max-width: 768px) {
    .flow-controls-bar {
        flex-direction: column;
        align-items: stretch;
    }
    
    .controls-group {
        justify-content: center;
        padding: 0.5rem 0;
        border-right: none !important;
        border-bottom: 1px solid var(--border-color, #e0e0e0);
    }
    
    .controls-group:last-child {
        border-bottom: none;
    }
}

/* Dark Mode - Export Modal */
body[data-theme="dark"] .export-modal-content {
    background: var(--bg-card, #1e1e1e);
    color: var(--text-primary, #e0e0e0);
}

body[data-theme="dark"] .export-modal-header {
    border-bottom-color: var(--border-color, #444);
}

body[data-theme="dark"] .export-modal-header h3 {
    color: var(--text-primary, #e0e0e0);
}

body[data-theme="dark"] .export-modal-close {
    color: var(--text-secondary, #888);
}

body[data-theme="dark"] .export-modal-close:hover {
    color: var(--text-primary, #e0e0e0);
}

body[data-theme="dark"] .mermaid-code {
    background: var(--bg-secondary, #2d2d2d);
    color: var(--text-primary, #e0e0e0);
    border-color: var(--border-color, #444);
}

body[data-theme="dark"] .export-hint {
    color: var(--text-secondary, #888);
}

body[data-theme="dark"] .export-actions .sim-btn {
    background: var(--bg-secondary, #2d2d2d);
    color: var(--text-primary, #e0e0e0);
    border-color: var(--border-color, #444);
}

body[data-theme="dark"] .export-actions .sim-btn:hover {
    background: var(--accent-color, #4a90d9);
    color: white;
}

/* Dark Mode - Mermaid Code Textarea */
body[data-theme="dark"] .export-modal {
    background: rgba(0, 0, 0, 0.8);
}

body[data-theme="dark"] .export-modal .mermaid-code {
    background: #1e1e1e;
    color: #d4d4d4;
    border-color: #444;
}

body[data-theme="dark"] .export-modal .export-hint {
    color: #aaa;
}

body[data-theme="dark"] .export-modal .export-hint a {
    color: #6bb3f8;
}

/* ============================================================================
   Call-Playbook Step Styles
   ============================================================================ */

/* Call-playbook block within a step */
.flow-step-call-playbook {
    margin-top: 0.625rem;
    padding: 0.75rem;
    border-radius: 8px;
    border: 2px solid;
    position: relative;
}

.flow-step-call-playbook.call-sync {
    background: rgba(33, 150, 243, 0.06);
    border-color: rgba(33, 150, 243, 0.4);
    border-style: solid;
}

.flow-step-call-playbook.call-async {
    background: rgba(255, 152, 0, 0.06);
    border-color: rgba(255, 152, 0, 0.4);
    border-style: dashed;
}

.call-playbook-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    flex-wrap: wrap;
}

.call-playbook-icon {
    font-size: 1.1rem;
}

.call-playbook-label {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-secondary, #666);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.call-playbook-mode {
    margin-left: auto;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    font-size: 0.72rem;
    font-weight: 600;
}

.call-sync .call-playbook-mode {
    background: rgba(33, 150, 243, 0.15);
    color: #1976d2;
}

.call-async .call-playbook-mode {
    background: rgba(255, 152, 0, 0.15);
    color: #e65100;
}

.call-playbook-target {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--bg-primary, #fff);
    border-radius: 6px;
    border: 1px solid var(--border-color, #e0e0e0);
}

.call-target-arrow {
    color: var(--primary-color, #2196f3);
    font-size: 1.1rem;
    font-weight: bold;
}

.call-target-name {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--primary-color, #2196f3);
    flex: 1;
}

.call-preview-btn {
    padding: 0.25rem 0.6rem;
    background: var(--primary-color, #2196f3);
    color: white;
    border: none;
    border-radius: 4px;
    font-size: 0.72rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.call-preview-btn:hover {
    background: #1565c0;
}

.preview-btn-icon {
    font-size: 0.65rem;
}

/* Variables passed to child */
.call-playbook-variables {
    margin-top: 0.5rem;
    padding: 0.5rem;
    background: rgba(76, 175, 80, 0.05);
    border-radius: 4px;
    border: 1px solid rgba(76, 175, 80, 0.2);
}

.call-vars-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-secondary, #666);
    display: block;
    margin-bottom: 0.375rem;
}

.call-vars-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.375rem;
}

.call-var-item {
    padding: 0.15rem 0.5rem;
    background: rgba(76, 175, 80, 0.1);
    border-radius: 3px;
    font-size: 0.75rem;
}

.call-var-item code {
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.72rem;
    color: #2e7d32;
}

.call-playbook-timeout {
    margin-top: 0.375rem;
    font-size: 0.75rem;
    color: var(--text-secondary, #666);
}

.call-playbook-async-opts {
    margin-top: 0.375rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.async-opt {
    font-size: 0.75rem;
    color: var(--text-secondary, #666);
}

.async-opt strong {
    color: var(--text-primary, #333);
}

/* ============================================================================
   Call Chain Panel
   ============================================================================ */

.flow-call-chain {
    margin-bottom: 1rem;
    padding: 0.875rem;
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.04), rgba(156, 39, 176, 0.04));
    border: 1px solid rgba(33, 150, 243, 0.2);
    border-radius: 10px;
}

.call-chain-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 0.9rem;
    color: var(--text-primary, #333);
    margin-bottom: 0.75rem;
}

.call-chain-icon {
    font-size: 1.1rem;
}

.call-chain-tree {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 0.85rem;
}

.call-chain-node {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    border-radius: 5px;
    margin-bottom: 0.125rem;
}

.call-chain-root {
    background: rgba(33, 150, 243, 0.08);
    border: 1px solid rgba(33, 150, 243, 0.25);
}

.call-chain-child {
    background: rgba(156, 39, 176, 0.06);
    border: 1px solid rgba(156, 39, 176, 0.2);
}

.chain-node-icon {
    font-size: 1rem;
}

.chain-node-name {
    font-weight: 600;
    color: var(--text-primary, #333);
    flex: 1;
}

.chain-node-badge {
    padding: 0.125rem 0.5rem;
    border-radius: 8px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.chain-badge-parent {
    background: rgba(33, 150, 243, 0.15);
    color: #1565c0;
}

.chain-badge-sync {
    background: rgba(76, 175, 80, 0.15);
    color: #2e7d32;
}

.chain-badge-async {
    background: rgba(255, 152, 0, 0.15);
    color: #e65100;
}

.call-chain-branch {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding-left: 1rem;
}

.chain-branch-line {
    color: var(--text-secondary, #999);
    font-weight: bold;
    -webkit-user-select: none;
    user-select: none;
    min-width: 2rem;
}

.chain-preview-btn {
    padding: 0.125rem 0.375rem;
    background: transparent;
    color: var(--primary-color, #2196f3);
    border: 1px solid var(--primary-color, #2196f3);
    border-radius: 3px;
    font-size: 0.65rem;
    cursor: pointer;
    transition: all 0.2s;
    margin-left: 0.25rem;
}

.chain-preview-btn:hover {
    background: var(--primary-color, #2196f3);
    color: white;
}

/* ============================================================================
   Child Playbook Inline Preview
   ============================================================================ */

.child-preview-loading {
    padding: 0.75rem;
    text-align: center;
    color: var(--text-secondary, #666);
    font-size: 0.85rem;
}

.loading-spinner {
    display: inline-block;
    animation: spin 1s linear infinite;
}

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

.child-preview-error {
    padding: 0.625rem;
    background: rgba(244, 67, 54, 0.06);
    border: 1px solid rgba(244, 67, 54, 0.2);
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
    color: var(--text-secondary, #666);
    flex-wrap: wrap;
}

.child-preview-error .error-icon {
    font-size: 1rem;
}

.child-preview-error .error-detail {
    font-size: 0.72rem;
    color: #999;
    font-style: italic;
    flex-basis: 100%;
}

.child-preview-empty {
    padding: 0.625rem;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-secondary, #666);
}

.child-preview-panel {
    margin-top: 0.625rem;
    border: 1px solid rgba(156, 39, 176, 0.25);
    border-radius: 8px;
    overflow: hidden;
    background: var(--bg-primary, #fff);
}

.child-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.625rem 0.875rem;
    background: linear-gradient(135deg, rgba(156, 39, 176, 0.08), rgba(33, 150, 243, 0.06));
    border-bottom: 1px solid rgba(156, 39, 176, 0.15);
    flex-wrap: wrap;
    gap: 0.5rem;
}

.child-preview-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

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

.child-name {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--text-primary, #333);
}

.child-preview-stats {
    display: flex;
    gap: 0.5rem;
}

.child-stat {
    padding: 0.125rem 0.5rem;
    background: rgba(0, 0, 0, 0.05);
    border-radius: 8px;
    font-size: 0.7rem;
    color: var(--text-secondary, #666);
    font-weight: 500;
}

.child-stat-nested {
    background: rgba(156, 39, 176, 0.1);
    color: #7b1fa2;
}

.child-preview-stages {
    padding: 0.5rem 0.75rem;
}

.child-stage {
    margin-bottom: 0.5rem;
}

.child-stage:last-child {
    margin-bottom: 0;
}

.child-stage-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 0.5rem;
    background: rgba(0, 0, 0, 0.025);
    border-radius: 5px;
    margin-bottom: 0.25rem;
}

.child-stage-num {
    width: 1.25rem;
    height: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color, #2196f3);
    color: white;
    border-radius: 50%;
    font-size: 0.65rem;
    font-weight: 700;
}

.child-stage-name {
    font-weight: 600;
    font-size: 0.8rem;
    color: var(--text-primary, #333);
    flex: 1;
}

.child-stage-count {
    font-size: 0.7rem;
    color: var(--text-secondary, #999);
}

.child-stage-steps {
    padding-left: 1rem;
    border-left: 2px solid rgba(33, 150, 243, 0.15);
}

.child-step {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.25rem 0.375rem;
    font-size: 0.75rem;
    border-radius: 3px;
    transition: background 0.15s;
}

.child-step:hover {
    background: rgba(0, 0, 0, 0.03);
}

.child-step-call {
    background: rgba(156, 39, 176, 0.04);
    border-left: 2px solid rgba(156, 39, 176, 0.3);
    padding-left: 0.5rem;
}

.child-step-icon {
    font-size: 0.8rem;
}

.child-step-name {
    flex: 1;
    color: var(--text-primary, #333);
}

.child-step-type {
    padding: 0.1rem 0.375rem;
    background: rgba(0, 0, 0, 0.06);
    border-radius: 3px;
    font-size: 0.65rem;
    color: var(--text-secondary, #888);
    font-family: monospace;
}

.child-step-ref {
    font-size: 0.7rem;
    color: #7b1fa2;
    font-weight: 600;
    font-family: monospace;
}

.child-stage-arrow {
    text-align: center;
    font-size: 0.85rem;
    color: var(--text-secondary, #999);
    padding: 0.125rem 0;
}

/* Exec Card - Call Chain variant */
.exec-card-call-chain {
    border-color: rgba(156, 39, 176, 0.3);
    background: rgba(156, 39, 176, 0.04);
}

.exec-card-call-chain .exec-card-value {
    color: #7b1fa2;
}

/* ============================================================================
   Dark Mode - Call Playbook
   ============================================================================ */

body[data-theme="dark"] .flow-step-call-playbook.call-sync {
    background: rgba(33, 150, 243, 0.08);
    border-color: rgba(33, 150, 243, 0.35);
}

body[data-theme="dark"] .flow-step-call-playbook.call-async {
    background: rgba(255, 152, 0, 0.08);
    border-color: rgba(255, 152, 0, 0.35);
}

body[data-theme="dark"] .call-playbook-target {
    background: var(--input-bg, #2c2c2c);
    border-color: #444;
}

body[data-theme="dark"] .call-target-name {
    color: #64b5f6;
}

body[data-theme="dark"] .call-var-item code {
    color: #81c784;
}

body[data-theme="dark"] .flow-call-chain {
    background: linear-gradient(135deg, rgba(33, 150, 243, 0.06), rgba(156, 39, 176, 0.06));
    border-color: rgba(33, 150, 243, 0.25);
}

body[data-theme="dark"] .call-chain-root {
    background: rgba(33, 150, 243, 0.12);
    border-color: rgba(33, 150, 243, 0.3);
}

body[data-theme="dark"] .call-chain-child {
    background: rgba(156, 39, 176, 0.1);
    border-color: rgba(156, 39, 176, 0.3);
}

body[data-theme="dark"] .chain-node-name {
    color: #e0e0e0;
}

body[data-theme="dark"] .child-preview-panel {
    background: var(--bg-secondary, #2c2c2c);
    border-color: rgba(156, 39, 176, 0.3);
}

body[data-theme="dark"] .child-preview-header {
    background: linear-gradient(135deg, rgba(156, 39, 176, 0.12), rgba(33, 150, 243, 0.08));
}

body[data-theme="dark"] .child-name {
    color: #e0e0e0;
}

body[data-theme="dark"] .child-stage-header {
    background: rgba(255, 255, 255, 0.04);
}

body[data-theme="dark"] .child-step-name {
    color: #d0d0d0;
}

body[data-theme="dark"] .child-step-ref {
    color: #ce93d8;
}

body[data-theme="dark"] .async-opt strong {
    color: #e0e0e0;
}
