/* ═══════════════════════════════════════════════════════════════════
   Workflow Builder — Embedded Runner Panel (phone emulator)
   ═══════════════════════════════════════════════════════════════════ */

/* ── Canvas push-right when runner panel is open ───────────────────── */

.canvas-main-area.has-runner {
    margin-right: 420px;
}

/* ── Runner panel shell (fixed, right edge) ─────────────────────────── */

.runner-panel {
    position: fixed;
    top: 3.5rem;
    right: 0;
    bottom: 0;
    width: 420px;
    z-index: 1030;
    background: var(--theme-background-subtle);
    border-left: 1px solid var(--theme-border);
    box-shadow: -2px 0 12px rgba(0, 0, 0, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow: hidden;
}

/* ── Panel header ──────────────────────────────────────────────────── */

.runner-panel-header {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.4rem 0.75rem;
    border-bottom: 1px solid var(--theme-border);
    background: var(--theme-background-raised);
    flex-shrink: 0;
}

.runner-panel-title {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--theme-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.runner-panel-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.runner-panel-btn {
    width: 28px;
    height: 28px;
    border: none;
    border-radius: var(--theme-radius-sm, 4px);
    background: transparent;
    color: var(--theme-text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 150ms ease, color 150ms ease;
    text-decoration: none;
    flex-shrink: 0;
}

.runner-panel-btn:hover {
    background: var(--theme-background-hover);
    color: var(--theme-text);
}

.runner-panel-btn.active {
    background: var(--theme-primary-muted);
    color: var(--theme-primary);
}

.runner-panel-btn.close {
    color: var(--theme-text-muted);
    margin-left: 0.25rem;
    border-left: 1px solid var(--theme-border);
    border-radius: 0 var(--theme-radius-sm, 4px) var(--theme-radius-sm, 4px) 0;
    width: 32px;
}

.runner-panel-btn.close:hover {
    background: var(--theme-danger-muted, rgba(220, 38, 38, 0.12));
    color: var(--theme-danger, #dc2626);
}

.runner-panel-lang {
    height: 28px;
    padding: 0 0.4rem;
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius-sm, 4px);
    background: var(--theme-bg);
    color: var(--theme-text);
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: lowercase;
    margin-right: 0.25rem;
    cursor: pointer;
}

.runner-panel-lang:hover {
    border-color: var(--theme-primary);
    color: var(--theme-primary);
}

/* ── Phone scroll container ─────────────────────────────────────────── */

.runner-phone-wrap {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 1rem 0 0.75rem;
    overflow-y: auto;
    overflow-x: hidden;
    min-height: 0;
    width: 100%;
}

/* ── Phone frame ──────────────────────────────────────────────────── */

.phone-frame {
    width: 375px;
    height: min(calc(100vh - 9rem), 720px);
    background: #1c1c1e;
    border-radius: 44px;
    box-shadow:
        0 0 0 1px #3a3a3c,
        0 0 0 3px #1c1c1e,
        0 16px 48px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex-shrink: 0;
}

/* Dynamic island notch */
.phone-notch {
    height: 36px;
    background: #1c1c1e;
    display: flex;
    align-items: flex-end;
    justify-content: center;
    padding-bottom: 2px;
    flex-shrink: 0;
    position: relative;
    z-index: 1;
}

.phone-notch-pill {
    width: 126px;
    height: 34px;
    background: #000;
    border-radius: 0 0 20px 20px;
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
}

/* Screen — component fills and scrolls within */
.phone-screen {
    flex: 1;
    background: var(--theme-background);
    overflow-y: auto;
    position: relative;
}

.phone-screen .wf-run-page {
    min-height: 100%;
}

/* Home indicator */
.phone-home-bar {
    height: 30px;
    background: #1c1c1e;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.phone-home-bar::after {
    content: '';
    width: 120px;
    height: 5px;
    background: rgba(255, 255, 255, 0.3);
    border-radius: 3px;
}

/* ── Dev mode info bar ─────────────────────────────────────────────── */

.runner-dev-bar {
    width: 375px;
    margin-top: 0.75rem;
    background: var(--theme-background-raised);
    border: 1px solid var(--theme-border);
    border-radius: var(--theme-radius);
    padding: 0.5rem 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
    flex-shrink: 0;
}

.runner-dev-row {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
    min-width: 0;
}

.runner-dev-label {
    font-size: 0.68rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--theme-text-muted);
    flex-shrink: 0;
    width: 3.5rem;
}

.runner-dev-value {
    font-family: var(--theme-font-mono, ui-monospace, "Cascadia Code", monospace);
    font-size: 0.78rem;
    color: var(--theme-text);
    background: var(--theme-background-subtle);
    padding: 0.1rem 0.35rem;
    border-radius: 3px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}

.runner-dev-value.path {
    color: var(--theme-primary);
    font-size: 0.72rem;
}

.runner-dev-empty {
    font-size: 0.75rem;
    color: var(--theme-text-muted);
    font-style: italic;
}

/* ── Canvas step highlight when runner is on that step ─────────────── */

.wf-step-card.runner-active {
    border-color: var(--theme-primary);
    background: var(--theme-primary-muted);
    box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb), 0.22);
    animation: runner-active-arrive 0.4s ease forwards;
}

.wf-step-card.runner-active .wf-step-name {
    color: var(--theme-primary);
    font-weight: 600;
}

@keyframes runner-active-arrive {
    0%   { box-shadow: 0 0 0 0   rgba(var(--theme-primary-rgb), 0.55); }
    55%  { box-shadow: 0 0 0 7px rgba(var(--theme-primary-rgb), 0.08); }
    100% { box-shadow: 0 0 0 3px rgba(var(--theme-primary-rgb), 0.22); }
}

/* ── Test Data Panel ────────────────────────────────────────────── */

.test-data-panel {
    flex: 1;
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 0;
    overflow: hidden;
}

.test-data-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0.75rem;
    border-bottom: 1px solid var(--theme-border);
    flex-shrink: 0;
}

.test-data-title {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--theme-text);
    letter-spacing: 0.02em;
}

.test-data-header-actions {
    display: flex;
    align-items: center;
    gap: 0.15rem;
}

.test-data-body {
    flex: 1;
    overflow-y: auto;
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-height: 0;
}

.test-data-section-label {
    font-size: 0.67rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--theme-text-muted);
    margin-bottom: 0.35rem;
}

.test-data-empty,
.test-data-instance-empty {
    font-size: 0.78rem;
    color: var(--theme-text-muted);
    font-style: italic;
    padding: 0.25rem 0;
}

.test-data-error {
    font-size: 0.78rem;
    color: var(--theme-danger, #dc2626);
    padding: 0.25rem 0;
}

/* ── Entity row ──────────────────────────────────────────────────── */

.test-data-entity {
    display: flex;
    flex-direction: column;
}

.test-data-entity-btn {
    display: flex;
    align-items: center;
    gap: 0.4rem;
    width: 100%;
    padding: 0.35rem 0.5rem;
    border: none;
    border-radius: var(--theme-radius-sm, 4px);
    background: transparent;
    color: var(--theme-text);
    font-size: 0.82rem;
    font-weight: 500;
    text-align: left;
    cursor: pointer;
    transition: background 120ms ease;
}

.test-data-entity-btn:hover {
    background: var(--theme-background-hover);
}

.test-data-chevron {
    font-size: 0.65rem;
    color: var(--theme-text-muted);
    flex-shrink: 0;
}

.test-data-entity-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.test-data-badge {
    flex-shrink: 0;
    background: var(--theme-primary);
    color: #fff;
    font-size: 0.65rem;
    font-weight: 700;
    padding: 0.1rem 0.45rem;
    border-radius: 10px;
    line-height: 1.4;
}

/* ── Instance list ───────────────────────────────────────────────── */

.test-data-instance-list {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.2rem 0 0.4rem 1.4rem;
}

.test-data-instance {
    display: flex;
    align-items: center;
    gap: 0.45rem;
    width: 100%;
    padding: 0.3rem 0.5rem;
    border: 1px solid transparent;
    border-radius: var(--theme-radius-sm, 4px);
    background: transparent;
    color: var(--theme-text);
    font-size: 0.78rem;
    text-align: left;
    cursor: pointer;
    transition: background 120ms ease, border-color 120ms ease;
}

.test-data-instance:hover {
    background: var(--theme-background-hover);
}

.test-data-instance.selected {
    background: var(--theme-primary-muted);
    border-color: var(--theme-primary-border, var(--theme-primary));
    color: var(--theme-primary);
}

.test-data-instance.selected i {
    color: var(--theme-primary);
}

.test-data-instance i {
    flex-shrink: 0;
    font-size: 0.82rem;
    color: var(--theme-text-muted);
}

.test-data-instance span {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Footer apply button ─────────────────────────────────────────── */

.test-data-footer {
    padding: 0.6rem 0.75rem;
    border-top: 1px solid var(--theme-border);
    flex-shrink: 0;
}

.test-data-apply-btn {
    width: 100%;
    padding: 0.45rem 0;
    border: none;
    border-radius: var(--theme-radius-sm, 4px);
    background: var(--theme-primary);
    color: #fff;
    font-size: 0.82rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 150ms ease, opacity 150ms ease;
}

.test-data-apply-btn:hover:not(:disabled) {
    background: var(--theme-primary-hover, var(--theme-primary));
    filter: brightness(1.08);
}

.test-data-apply-btn:active:not(:disabled) {
    filter: brightness(0.95);
}

.test-data-apply-btn:disabled {
    opacity: 0.55;
    cursor: default;
}
