/**
 * EASME Execution Styles
 * 
 * Styles for experiment execution (new-run, run monitoring).
 * Migrated from embedded <style> block in new-run.php
 */

/* ============================================================================
   EXECUTION FORM
   ============================================================================ */

.execution-form .form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.execution-form .form-row .form-group {
    min-width: 200px;
    flex: 1;
}

/* Remote options panel */
#remote-options {
    margin-top: 1rem;
    padding: 1rem;
    background: var(--gray-50, #f9fafb);
    border: 1px solid var(--gray-200, #e5e7eb);
    border-radius: 0.375rem;
}

#remote-options h4 {
    margin: 0 0 1rem 0;
    font-size: 0.9rem;
    color: var(--gray-600, #4b5563);
}

/* Scheduler options (nested) */
#scheduler-options {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--gray-200, #e5e7eb);
}

/* ============================================================================
   PROGRESS INDICATOR
   ============================================================================ */

.progress-steps {
    display: flex;
    justify-content: space-between;
    margin: 1.5rem 0;
    position: relative;
}

.progress-step {
    display: flex;
    flex-direction: column;
    align-items: center;
    flex: 1;
    position: relative;
    z-index: 1;
}

/* Connecting line between steps */
.progress-step:not(:last-child)::after {
    content: '';
    position: absolute;
    top: 12px;
    left: 50%;
    width: 100%;
    height: 2px;
    background: var(--gray-300, #d1d5db);
    z-index: -1;
}

.progress-step.active::after,
.progress-step.complete::after {
    background: var(--primary, #2563eb);
}

/* Step icon circle */
.step-icon {
    width: 24px;
    height: 24px;
    line-height: 24px;
    text-align: center;
    border-radius: 50%;
    background: white;
    border: 2px solid var(--gray-300, #d1d5db);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--gray-500, #6b7280);
    transition: all 0.3s ease;
}

.progress-step.pending .step-icon {
    border-color: var(--gray-300, #d1d5db);
    color: var(--gray-400, #9ca3af);
}

.progress-step.active .step-icon {
    border-color: var(--primary, #2563eb);
    color: var(--primary, #2563eb);
    animation: step-pulse 1.5s ease-in-out infinite;
}

.progress-step.complete .step-icon {
    background: var(--success, #16a34a);
    border-color: var(--success, #16a34a);
    color: white;
}

.progress-step.error .step-icon {
    background: var(--danger, #dc2626);
    border-color: var(--danger, #dc2626);
    color: white;
}

/* Step label */
.step-label {
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--gray-500, #6b7280);
    text-align: center;
}

.progress-step.active .step-label {
    color: var(--primary, #2563eb);
    font-weight: 500;
}

.progress-step.complete .step-label {
    color: var(--success, #16a34a);
}

.progress-step.error .step-label {
    color: var(--danger, #dc2626);
}

/* Progress detail log */
.progress-detail {
    padding: 0.75rem;
    font-family: 'SF Mono', Consolas, monospace;
    font-size: 0.8125rem;
    max-height: 200px;
    overflow-y: auto;
    background: var(--gray-100, #f3f4f6);
    border-radius: 0.375rem;
    border: 1px solid var(--gray-200, #e5e7eb);
    color: var(--gray-700, #374151);
}

/* ============================================================================
   BUTTON SPINNER
   ============================================================================ */

.btn-spinner {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.btn-spinner::before {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

/* ============================================================================
   EXECUTION PROGRESS CARD
   ============================================================================ */

#execution-progress {
    margin-top: 1.5rem;
}

#execution-progress h4 {
    margin-bottom: 1rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* ============================================================================
   ANIMATIONS
   ============================================================================ */

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

@keyframes step-pulse {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 0 0 0 rgba(10,108,108,0.35);
    }
    50% {
        transform: scale(1.05);
        box-shadow: 0 0 0 6px rgba(10,108,108,0);
    }
}

/* ============================================================================
   STAGING CONSOLE
   console output area for streaming staging/dry-run operations.
   uses design tokens: --console-bg, --console-text, --font-mono.
   ============================================================================ */

/* --- console output pane --- */
.console-output {
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.5;
    background: var(--console-bg);
    color: var(--console-text);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    max-height: 400px;
    overflow-y: auto;
}

/* pre block variant (directory previews, static output) */
.console-pre {
    font-family: var(--font-mono);
    font-size: 0.85em;
    background: var(--console-bg);
    color: var(--console-text);
    padding: 0.75rem;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    margin: 0;
    white-space: pre;
}

/* --- tab bar (reuses log-tab pattern for console context) --- */
.console-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border-default);
    margin-bottom: 0.75rem;
}

.console-tab {
    padding: 0.4rem 1rem;
    cursor: pointer;
    font-size: 0.85em;
    font-weight: 400;
    color: var(--text-muted);
    border-bottom: 2px solid transparent;
    transition: color 0.15s, border-color 0.15s;
}

.console-tab:hover {
    color: var(--text-secondary);
}

.console-tab.active {
    color: var(--brand-teal);
    border-bottom-color: var(--brand-teal);
    font-weight: 600;
}

/* --- step items rendered inside console --- */
.console-step {
    margin-bottom: 0.5rem;
}

.console-step-result {
    font-weight: bold;
    margin-right: 0.25rem;
}

.console-step-result.ok     { color: var(--color-success); }
.console-step-result.error  { color: var(--color-danger); }

.console-step-label {
    color: var(--color-success);
    font-weight: 600;
}

.console-step-label.error {
    color: var(--color-danger);
}

.console-step-detail {
    color: var(--console-text);
    opacity: 0.7;
}

/* command line inside console — subdued, not path-display */
.console-step-cmd {
    display: block;
    margin-left: 1.5rem;
    margin-top: 0.2rem;
    font-family: var(--font-mono);
    font-size: 0.85em;
    color: var(--brand-teal-viv);
    word-break: break-all;
}

.console-step-cwd {
    display: block;
    margin-left: 1.5rem;
    margin-top: 0.1rem;
    font-size: 0.75em;
    color: var(--console-text);
    opacity: 0.5;
}

/* --- log lines (timestamped entries) --- */
.console-log {
    color: var(--console-text);
}

.console-log.ok      { color: var(--color-success); }
.console-log.error   { color: var(--color-danger); }
.console-log.warn    { color: var(--color-warning); }
.console-log.info    { color: var(--brand-teal-viv); }

/* ============================================================================
   STEP CONSOLE — notebook-cell style step display
   reusable component for staging/run views.
   each step rendered as an individual terminal block with toolbar.
   ============================================================================ */

.step-console {
    margin-top: 1rem;
}

.step-console-toolbar {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
}

/* --- individual step cell --- */
.step-cell {
    background: var(--console-bg);
    border: 1px solid var(--border-default);
    border-radius: var(--radius);
    margin-bottom: 0.75rem;
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.step-cell.running {
    border-color: var(--brand-teal);
    box-shadow: 0 0 0 1px var(--brand-teal);
}

.step-cell.success {
    border-left: 3px solid var(--color-success);
}

.step-cell.error {
    border-left: 3px solid var(--color-danger);
}

.step-cell.pending {
    opacity: 0.6;
}

.step-cell.skipped {
    opacity: 0.4;
}

/* --- cell toolbar (top bar with label + actions) --- */
.step-cell-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0.75rem;
    background: rgba(255,255,255,0.04);
    border-bottom: 1px solid rgba(255,255,255,0.06);
}

.step-cell-title {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
    flex: 1;
}

.step-cell-index {
    font-family: var(--font-mono);
    font-size: 0.75rem;
    color: var(--text-muted);
    min-width: 2rem;
}

.step-cell-label {
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    color: var(--console-text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.step-cell-icon {
    font-size: 0.9rem;
    min-width: 1.2rem;
    text-align: center;
}

.step-cell-icon.ok      { color: var(--color-success); }
.step-cell-icon.error   { color: var(--color-danger); }
.step-cell-icon.warning { color: var(--color-warning); }
.step-cell-icon.running { color: var(--brand-teal-viv); animation: spin 0.8s linear infinite; }

.step-cell-detail {
    font-size: 0.8rem;
    color: var(--console-text);
    opacity: 0.6;
    margin-left: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

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

.step-cell-actions .btn-cell {
    padding: 0.2rem 0.5rem;
    font-size: 0.75rem;
    font-family: var(--font-body);
    border: 1px solid rgba(255,255,255,0.15);
    border-radius: var(--radius-sm);
    background: transparent;
    color: var(--console-text);
    cursor: pointer;
    transition: background 0.15s, border-color 0.15s;
}

.step-cell-actions .btn-cell:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.25);
}

.step-cell-actions .btn-cell:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* --- command display area --- */
.step-cell-command {
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    color: var(--brand-teal-viv);
    white-space: pre-wrap;
    word-break: break-all;
    line-height: 1.5;
}

.step-cell-cwd {
    padding: 0 0.75rem 0.25rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* --- output area (shown after execution) --- */
.step-cell-output {
    padding: 0.5rem 0.75rem;
    font-family: var(--font-mono);
    font-size: 0.8125rem;
    line-height: 1.5;
    border-top: 1px solid rgba(255,255,255,0.06);
    color: var(--console-text);
    max-height: 200px;
    overflow-y: auto;
    white-space: pre-wrap;
    word-break: break-all;
}

.step-cell-output:empty {
    display: none;
}

.step-cell-output .output-error {
    color: var(--color-danger);
}

.step-cell-output .output-ok {
    color: var(--color-success);
}

/* --- transfer/env metadata shown below command --- */
.step-cell-meta {
    padding: 0.25rem 0.75rem 0.5rem;
    font-size: 0.7rem;
    color: var(--text-muted);
}

.step-cell-meta code {
    font-family: var(--font-mono);
    font-size: inherit;
}
