/* ═══════════════════════════════════════════════════════════════════════
   Pipeline Monitor — Jobs Panel
   Full-screen overlay modal: running jobs, Windmill flow shortcuts,
   and compact recent history.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Pill (topbar) ──────────────────────────────────────────────────── */

.jobs-pill {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 11px 5px 9px;
    border-radius: 999px;
    border: 1px solid var(--border, #2a3347);
    background: var(--surface, #161b27);
    color: var(--text-muted, #7a8eab);
    font-size: 12px;
    cursor: pointer;
    transition: border-color 0.15s, color 0.15s, background 0.15s;
    white-space: nowrap;
    user-select: none;
}
.jobs-pill:hover {
    border-color: var(--border-active, #3d5580);
    background: var(--elevated, #1e2535);
    color: var(--text, #dce6f5);
}
.jobs-pill--running {
    border-color: var(--accent, #3b7dd8);
    color: var(--accent, #3b7dd8);
}
.jobs-pill--hidden { display: none !important; }

.jobs-pill-spinner {
    width: 10px; height: 10px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: jobs-spin 0.8s linear infinite;
    flex-shrink: 0;
}
@keyframes jobs-spin { to { transform: rotate(360deg); } }

.jobs-pill-dot {
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
    opacity: 0.5;
}

.jobs-pill--running   .jobs-pill-dot     { display: none; }
.jobs-pill--idle      .jobs-pill-spinner { display: none; }
.jobs-pill:not(.jobs-pill--running):not(.jobs-pill--idle) .jobs-pill-spinner { display: none; }

/* ── Overlay backdrop ───────────────────────────────────────────────── */

.jobs-overlay {
    position: fixed;
    inset: 0;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(2px);
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 48px 16px 32px;
    overflow-y: auto;
    transition: opacity 0.15s ease;
}
.jobs-overlay--hidden {
    display: none;
}

/* ── Modal card ─────────────────────────────────────────────────────── */

.jobs-modal {
    width: 100%;
    max-width: 1000px;
    background: var(--surface, #161b27);
    border: 1px solid var(--border, #2a3347);
    border-radius: 12px;
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.6);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ── Modal header ───────────────────────────────────────────────────── */

.jobs-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 20px;
    border-bottom: 1px solid var(--border, #2a3347);
    flex-shrink: 0;
}
.jobs-modal-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text, #dce6f5);
    letter-spacing: -0.01em;
}
.jobs-modal-header-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}
.jobs-modal-refresh-btn,
.jobs-modal-close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-muted, #7a8eab);
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 16px;
    line-height: 1;
    transition: color 0.1s, background 0.1s;
}
.jobs-modal-refresh-btn:hover,
.jobs-modal-close-btn:hover {
    color: var(--text, #dce6f5);
    background: var(--hover-bg, rgba(255,255,255,0.06));
}
.jobs-refresh-icon {
    display: inline-block;
    font-size: 16px;
    line-height: 1;
}

/* ── Modal body ─────────────────────────────────────────────────────── */

.jobs-modal-body {
    padding: 0 0 12px;
    overflow-y: auto;
}

/* ── Sections ───────────────────────────────────────────────────────── */

.jobs-section {
    padding: 24px 24px 8px;
    border-bottom: 1px solid var(--border, #2a3347);
}
.jobs-section:last-child {
    border-bottom: none;
    padding-bottom: 20px;
}
.jobs-section-title {
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-muted, #7a8eab);
    margin: 0 0 16px;
}

/* ── Scans divider (between running and recent) ─────────────────────── */

.jobs-scans-divider {
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.07em;
    text-transform: uppercase;
    color: var(--text-muted, #7a8eab);
    padding: 14px 0 8px;
    opacity: 0.7;
}

/* ── Active job cards ───────────────────────────────────────────────── */

.jobs-active-card {
    background: var(--elevated, #1e2535);
    border: 1px solid var(--border, #2a3347);
    border-radius: 8px;
    padding: 16px 18px;
    margin-bottom: 12px;
}
.jobs-active-card:last-child { margin-bottom: 4px; }

.jobs-active-card-top {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 10px;
}
.jobs-active-card-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--text, #dce6f5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1;
    min-width: 0;
}
.jobs-active-card-spacer { flex: 1; }
.jobs-active-card-pct {
    font-size: 12px;
    font-weight: 700;
    color: var(--accent, #3b7dd8);
    white-space: nowrap;
}
.jobs-active-card-meta {
    font-size: 11px;
    color: var(--text-muted, #7a8eab);
    margin-top: 8px;
}

/* ── Progress track ─────────────────────────────────────────────────── */

.jobs-progress-track {
    height: 8px;
    background: var(--border, #2a3347);
    border-radius: 4px;
    overflow: hidden;
}
.jobs-progress-fill {
    height: 100%;
    background: var(--accent, #3b7dd8);
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* ── Cancel button ──────────────────────────────────────────────────── */

.jobs-cancel-btn {
    background: none;
    border: 1px solid var(--border, #2a3347);
    color: var(--text-muted, #7a8eab);
    font-size: 11px;
    font-weight: 600;
    padding: 3px 10px;
    border-radius: 5px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: color 0.1s, border-color 0.1s, background 0.1s;
}
.jobs-cancel-btn:hover {
    color: var(--danger, #e05a47);
    border-color: var(--danger, #e05a47);
    background: rgba(224, 90, 71, 0.08);
}

/* ── Type badge ─────────────────────────────────────────────────────── */

.jobs-type-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 0.04em;
    padding: 2px 7px;
    border-radius: 4px;
    text-transform: uppercase;
    flex-shrink: 0;
}
.jobs-type-badge--session_prep { background: rgba(122,142,171,0.15); color: #9aadc5; }
.jobs-type-badge--scan_daily   { background: rgba(59,125,216,0.12);  color: #5a9ae0; }
.jobs-type-badge--scan_full    { background: rgba(139,92,246,0.12);  color: #a87fff; }

/* ── Flows grid ─────────────────────────────────────────────────────── */

.jobs-flows-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 14px;
    margin-bottom: 20px;
}
@media (max-width: 560px) {
    .jobs-flows-grid { grid-template-columns: 1fr; }
}

/* ── Flow card ──────────────────────────────────────────────────────── */

.jobs-flow-card {
    background: var(--elevated, #1e2535);
    border: 1px solid var(--border, #2a3347);
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.15s;
}
.jobs-flow-card:hover {
    border-color: var(--border-active, #3d5580);
}

/* ── Flow card — running state ──────────────────────────────────────── */

.jobs-flow-card--running {
    border-color: var(--accent, #3b7dd8);
    animation: jobs-flow-pulse 2s ease-in-out infinite;
}
.jobs-flow-card--running:hover {
    border-color: var(--accent, #3b7dd8);
}
@keyframes jobs-flow-pulse {
    0%, 100% { box-shadow: 0 0 0 0 rgba(59, 125, 216, 0); }
    50%       { box-shadow: 0 0 0 4px rgba(59, 125, 216, 0.15); }
}

/* ── Flow running indicator ─────────────────────────────────────────── */

.jobs-flow-running-indicator {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    font-weight: 600;
    color: var(--accent, #3b7dd8);
}
.jobs-flow-running-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--accent, #3b7dd8);
    animation: jobs-dot-pulse 1.2s ease-in-out infinite;
    flex-shrink: 0;
}
@keyframes jobs-dot-pulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.4; transform: scale(0.75); }
}

.jobs-flow-card-body {
    padding: 16px 16px 14px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: 100%;
    box-sizing: border-box;
}
.jobs-flow-card-title {
    font-size: 13px;
    font-weight: 700;
    color: var(--text, #dce6f5);
}
.jobs-flow-card-desc {
    font-size: 11px;
    color: var(--text-muted, #7a8eab);
    line-height: 1.4;
    flex: 1;
}
.jobs-flow-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
}

/* ── Flow param input ───────────────────────────────────────────────── */

.jobs-flow-param-label {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 11px;
    color: var(--text-muted, #7a8eab);
}
.jobs-flow-param-input {
    background: var(--surface, #161b27);
    border: 1px solid var(--border, #2a3347);
    border-radius: 5px;
    color: var(--text, #dce6f5);
    font-size: 12px;
    padding: 5px 8px;
    outline: none;
    transition: border-color 0.1s;
}
.jobs-flow-param-input:focus {
    border-color: var(--accent, #3b7dd8);
}

/* ── Flow run button ────────────────────────────────────────────────── */

.jobs-flow-run-btn {
    background: var(--accent, #3b7dd8);
    border: none;
    border-radius: 5px;
    color: #fff;
    font-size: 11px;
    font-weight: 700;
    padding: 5px 12px;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
    transition: background 0.15s, opacity 0.15s;
}
.jobs-flow-run-btn:hover:not(:disabled) {
    background: #4d8ee0;
}
.jobs-flow-run-btn--busy,
.jobs-flow-run-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ── Last run badge ─────────────────────────────────────────────────── */

.jobs-flow-last-run {
    font-size: 11px;
    font-weight: 500;
}
.jobs-flow-last-run--ok      { color: var(--success, #2ea043); }
.jobs-flow-last-run--err     { color: var(--danger, #e05a47); }
.jobs-flow-last-run--running { color: var(--accent, #3b7dd8); }
.jobs-flow-last-run--none,
.jobs-flow-last-run--canceled { color: var(--text-muted, #7a8eab); }

/* ── Recent job list ─────────────────────────────────────────────────── */

.jobs-recent-list {
    display: flex;
    flex-direction: column;
    gap: 0;
    margin-bottom: 12px;
}
.jobs-recent-row {
    display: grid;
    grid-template-columns: auto 1fr auto auto;
    align-items: center;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border, #2a3347);
    font-size: 12px;
}
.jobs-recent-row:last-child { border-bottom: none; }

.jobs-recent-label {
    color: var(--text, #dce6f5);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.jobs-recent-meta {
    font-size: 11px;
    color: var(--text-muted, #7a8eab);
    white-space: nowrap;
}

/* ── Status chip ────────────────────────────────────────────────────── */

.jobs-status-chip {
    font-size: 10px;
    font-weight: 700;
    padding: 2px 7px;
    border-radius: 999px;
    white-space: nowrap;
}
.jobs-status-chip--running   { background: rgba(59,125,216,0.15); color: #5a9ae0; }
.jobs-status-chip--done      { background: rgba(46,160,67,0.15);  color: #4ac264; }
.jobs-status-chip--error     { background: rgba(224,90,71,0.15);  color: #e05a47; }
.jobs-status-chip--cancelled { background: rgba(122,142,171,0.1); color: var(--text-muted, #7a8eab); }
