/*
 * Execution Timeline tab (Transaction Flight Recorder)
 * Design tokens come from design-tokens.css + app.css :root variables.
 *
 * The Execution Timeline surfaces the structured pipeline trace recorded by
 * IPipelineTraceRecorder (G23, 2026-05-12). Layout matches the rest of TFR
 * (card-on-card with subtle borders + Inter typography) so the new tab feels
 * native alongside Routing Decision / Event Timeline / Processor Comms.
 */

/* ── Header ─────────────────────────────────────────────────────────── */
.exec-header {
    padding: 16px 4px 20px;
    border-bottom: 1px solid var(--gray-200);
    margin-bottom: 16px;
}

.exec-header__title {
    margin: 0 0 4px;
    font-size: 18px;
    font-weight: 600;
    color: var(--gray-900);
    letter-spacing: -0.01em;
}

.exec-header p {
    margin: 0 0 12px;
    font-size: 13px;
    color: var(--gray-500);
}

.exec-header__meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 18px;
    margin-bottom: 10px;
    font-size: 12.5px;
    color: var(--gray-600);
}

.exec-header__meta a {
    color: var(--primary-600, #ea580c);
    text-decoration: none;
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
}

.exec-header__meta a:hover { text-decoration: underline; }

.exec-header__narrative {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: var(--primary-50, #fff7ed);
    color: var(--primary-700, #c2410c);
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
}


/* ── Pivot (Canvas overlay / Step table) ────────────────────────────── */
.exec-pivot {
    display: inline-flex;
    gap: 0;
    margin-bottom: 12px;
    border: 1px solid var(--gray-200);
    border-radius: 8px;
    padding: 3px;
    background: var(--gray-50);
}

.exec-pivot .bp-tab {
    padding: 6px 14px;
    border: 0;
    background: transparent;
    color: var(--gray-600);
    font-size: 13px;
    font-weight: 500;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease;
}

.exec-pivot .bp-tab:hover {
    color: var(--gray-800);
}

.exec-pivot .bp-tab--active {
    background: #fff;
    color: var(--gray-900);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}

/* ── Body layout (main + side panel) ────────────────────────────────── */
.exec-body {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 16px;
}

.exec-body:has(.exec-body__side) {
    grid-template-columns: minmax(0, 1fr) 360px;
}

.exec-body__main { min-width: 0; }

.exec-body__side {
    border-left: 1px solid var(--gray-200);
    padding-left: 16px;
}

/* ── Filter chips (All / Checks / Decisions / System events) ────────── */
.exec-filter-chips {
    display: inline-flex;
    gap: 6px;
    margin-bottom: 10px;
}

.exec-filter-chips .bp-chip {
    padding: 5px 12px;
    border: 1px solid var(--gray-200);
    border-radius: 999px;
    background: #fff;
    color: var(--gray-700);
    font-size: 12px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.12s ease, color 0.12s ease, border-color 0.12s ease;
}

.exec-filter-chips .bp-chip:hover {
    background: var(--gray-50);
    color: var(--gray-900);
}

.exec-filter-chips .bp-chip--active {
    background: var(--primary-600, #ea580c);
    border-color: var(--primary-600, #ea580c);
    color: #fff;
}

/* ── Step table ─────────────────────────────────────────────────────── */
.exec-table {
    overflow: hidden;
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: #fff;
}

.exec-table .bp-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 13px;
}

.exec-table thead th {
    padding: 10px 14px;
    background: var(--gray-50);
    color: var(--gray-600);
    font-weight: 600;
    font-size: 11.5px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
    position: sticky;
    top: 0;
    z-index: 1;
}

.exec-table tbody td {
    padding: 8px 14px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-800);
    vertical-align: middle;
}

.exec-table tbody tr:last-child td { border-bottom: 0; }

.exec-table tbody tr {
    cursor: pointer;
    transition: background-color 0.08s ease;
}

.exec-table tbody tr:hover { background: var(--gray-50); }

/* Left accent bar per entry kind */
.exec-row td:first-child { position: relative; }

.exec-row td:first-child::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: transparent;
}

.exec-row--steptrace td:first-child::before        { background: var(--primary-300, #fdba74); }
.exec-row--nodeactivation td:first-child::before   { background: #60a5fa; }
.exec-row--decisionrationale td:first-child::before{ background: #a78bfa; }
.exec-row--statetransition td:first-child::before  { background: var(--gray-200); }

/* monospace cells */
.bp-mono {
    font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
    font-size: 12px;
    color: var(--gray-700);
}

/* ── Badges (result column) ─────────────────────────────────────────── */
.bp-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 9px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 600;
    line-height: 1.6;
    white-space: nowrap;
}

.bp-badge--success {
    background: #dcfce7;
    color: #166534;
}

.bp-badge--danger {
    background: #fee2e2;
    color: #991b1b;
}

.bp-badge--warning {
    background: #fef3c7;
    color: #92400e;
}

.bp-badge--info {
    background: #dbeafe;
    color: #1e40af;
}

.bp-badge--neutral {
    background: var(--gray-100);
    color: var(--gray-600);
}

/* ── Decision rationale side panel ──────────────────────────────────── */
.exec-rationale {
    border: 1px solid var(--gray-200);
    border-radius: 10px;
    background: #fff;
    padding: 14px;
}

.exec-rationale__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 4px;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--gray-100);
}

.exec-rationale__header strong {
    font-size: 14px;
    color: var(--gray-900);
}

.exec-rationale__header .bp-btn--ghost {
    border: 0;
    background: transparent;
    color: var(--gray-500);
    cursor: pointer;
    font-size: 16px;
    padding: 0 4px;
    border-radius: 4px;
}

.exec-rationale__header .bp-btn--ghost:hover {
    background: var(--gray-100);
    color: var(--gray-900);
}

.exec-rationale__meta {
    font-size: 12px;
    color: var(--gray-500);
    margin-bottom: 12px;
}

.exec-rationale__section-title {
    margin: 12px 0 4px;
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: var(--gray-500);
}

.exec-rationale__section-title:first-of-type {
    margin-top: 0;
}

.exec-rationale__key {
    color: var(--gray-700);
    font-weight: 500;
    width: 45%;
    white-space: nowrap;
}

.exec-rationale__table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    font-size: 12.5px;
    margin-bottom: 10px;
}

.exec-rationale__table thead th {
    padding: 6px 8px;
    background: var(--gray-50);
    color: var(--gray-600);
    font-weight: 600;
    font-size: 11px;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

.exec-rationale__table tbody td {
    padding: 6px 8px;
    border-bottom: 1px solid var(--gray-100);
    color: var(--gray-700);
    vertical-align: top;
}

.exec-rationale__footer {
    padding-top: 10px;
    border-top: 1px solid var(--gray-100);
    font-size: 12px;
    color: var(--gray-600);
}

.exec-rationale__blurb {
    margin: 0;
    font-size: 13px;
    color: var(--gray-600);
}

/* ── Canvas activation overlays (applied to bp-node containers) ─────── */
.exec-node--passed {
    box-shadow: 0 0 0 2px #22c55e, 0 6px 14px -4px rgba(34, 197, 94, 0.4);
    border-color: #22c55e !important;
}

.exec-node--rejected {
    box-shadow: 0 0 0 2px #ef4444, 0 6px 14px -4px rgba(239, 68, 68, 0.4);
    border-color: #ef4444 !important;
}

.exec-node--sent {
    box-shadow: 0 0 0 2px #3b82f6, 0 6px 14px -4px rgba(59, 130, 246, 0.4);
    border-color: #3b82f6 !important;
}

.exec-node--skipped {
    opacity: 0.45;
    filter: grayscale(0.5);
}

.exec-node--cb-open {
    box-shadow: 0 0 0 2px #f59e0b, 0 6px 14px -4px rgba(245, 158, 11, 0.4);
    border-color: #f59e0b !important;
}

.exec-node--inactive {
    opacity: 0.55;
}

/* Canvas host — dark background matching smart-routing-rules canvas */
.exec-canvas-host {
    height: 520px;
    min-height: 360px;
    border: 1px solid #1e293b;
    border-radius: 10px;
    overflow: hidden;
    background: #0f172a;
}

/* Allow pan cursor inside readonly canvas (overrides sr-diagram-host--readonly not-allowed) */
.exec-canvas-host .sr-diagram-host--readonly,
.exec-canvas-host .sr-diagram-host--readonly * {
    cursor: grab !important;
}

.exec-canvas-host .sr-diagram-host--readonly:active,
.exec-canvas-host .sr-diagram-host--readonly:active * {
    cursor: grabbing !important;
}

/* Zoom controls visibility on dark canvas */
.exec-canvas-host .zoom-controls button {
    color: #e2e8f0 !important;
}

.exec-canvas-host .zoom-controls button:hover {
    background: #1e293b !important;
    color: #fff !important;
}

/* ── Empty / loading states ─────────────────────────────────────────── */
.exec-empty {
    padding: 32px;
    text-align: center;
    color: var(--gray-500);
    font-size: 13px;
}

.exec-empty em { color: var(--gray-700); font-style: normal; font-weight: 500; }
