/* App background jobs tray — sits left of the IVA FAB when both are visible */

.bg-jobs-dock {
    position: fixed;
    right: 92px;
    bottom: 22px;
    z-index: 10004;
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 10px;
}

.bg-jobs-fab {
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    color: #e2e8f0;
    background: linear-gradient(165deg, #1e293b 0%, #0f172a 55%, #334155 100%);
    box-shadow:
        0 4px 12px rgba(0, 0, 0, 0.4),
        0 0 0 2px rgba(148, 163, 184, 0.35);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    position: relative;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}

.bg-jobs-fab:hover {
    transform: scale(1.05);
    box-shadow:
        0 6px 18px rgba(0, 0, 0, 0.45),
        0 0 0 2px rgba(56, 189, 248, 0.45);
}

.bg-jobs-fab:focus-visible {
    outline: 3px solid #38bdf8;
    outline-offset: 2px;
}

.bg-jobs-fab--busy {
    animation: bg-jobs-pulse 1.4s ease-in-out infinite;
}

.bg-jobs-fab--attention {
    animation: bg-jobs-attention 0.55s ease-in-out 4;
}

@keyframes bg-jobs-pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(56, 189, 248, 0.4); }
    50% { box-shadow: 0 4px 16px rgba(0, 0, 0, 0.45), 0 0 0 3px rgba(56, 189, 248, 0.75); }
}

@keyframes bg-jobs-attention {
    0%, 100% {
        transform: scale(1);
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.4), 0 0 0 2px rgba(14, 165, 233, 0.45);
    }
    50% {
        transform: scale(1.12);
        box-shadow: 0 8px 22px rgba(14, 165, 233, 0.55), 0 0 0 4px rgba(56, 189, 248, 0.85);
    }
}

.bg-jobs-fab-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 9px;
    background: #0ea5e9;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    line-height: 18px;
    text-align: center;
    box-shadow: 0 0 0 2px #0f172a;
    pointer-events: none;
}

.bg-jobs-panel {
    width: min(380px, calc(100vw - 32px));
    max-height: min(520px, 70vh);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    border-radius: 12px;
    background: #0f172a;
    color: #e2e8f0;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.45);
    border: 1px solid rgba(148, 163, 184, 0.25);
}

.bg-jobs-panel__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 12px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.2);
    font-size: 14px;
}

.bg-jobs-panel__close {
    border: none;
    background: transparent;
    color: #94a3b8;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 6px;
}

.bg-jobs-panel__close:hover {
    color: #f8fafc;
    background: rgba(148, 163, 184, 0.15);
}

.bg-jobs-panel__body {
    overflow-y: auto;
    padding: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.bg-jobs-empty {
    margin: 12px 8px;
    font-size: 13px;
    color: #94a3b8;
}

.bg-jobs-row {
    border-radius: 8px;
    padding: 8px 10px;
    background: rgba(30, 41, 59, 0.9);
    border: 1px solid rgba(71, 85, 105, 0.5);
}

.bg-jobs-row--succeeded {
    border-color: rgba(34, 197, 94, 0.35);
}

.bg-jobs-row--failed {
    border-color: rgba(239, 68, 68, 0.4);
}

.bg-jobs-row--running {
    border-color: rgba(14, 165, 233, 0.45);
}

.bg-jobs-row__title {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 4px;
}

.bg-jobs-row__meta {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 11px;
    color: #94a3b8;
    margin-bottom: 4px;
}

.bg-jobs-row__status {
    font-weight: 600;
    color: #cbd5e1;
}

.bg-jobs-row__text {
    font-size: 12px;
    color: #cbd5e1;
    line-height: 1.35;
    margin-bottom: 6px;
}

.bg-jobs-row__bar {
    height: 4px;
    border-radius: 2px;
    background: rgba(51, 65, 85, 0.9);
    overflow: hidden;
    margin-bottom: 6px;
}

.bg-jobs-row__bar-fill {
    height: 100%;
    background: linear-gradient(90deg, #0ea5e9, #38bdf8);
    transition: width 0.25s ease;
}

.bg-jobs-row__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    align-items: center;
    margin-top: 2px;
}

.bg-jobs-row__toggle,
.bg-jobs-row__cancel {
    border: 1px solid rgba(148, 163, 184, 0.35);
    background: transparent;
    color: #e2e8f0;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 6px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.bg-jobs-row__toggle:hover {
    background: rgba(14, 165, 233, 0.12);
    border-color: rgba(14, 165, 233, 0.4);
}

.bg-jobs-row__toggle-count {
    min-width: 16px;
    padding: 0 5px;
    border-radius: 8px;
    background: rgba(14, 165, 233, 0.25);
    color: #e0f2fe;
    font-size: 10px;
    font-weight: 700;
    line-height: 16px;
    text-align: center;
}

.bg-jobs-row__cancel:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.15);
    border-color: rgba(239, 68, 68, 0.45);
}

.bg-jobs-row__cancel:disabled {
    opacity: 0.5;
    cursor: default;
}

.bg-jobs-log {
    margin-top: 8px;
    max-height: 220px;
    overflow-y: auto;
    padding: 6px 8px;
    border-radius: 6px;
    background: rgba(15, 23, 42, 0.85);
    border: 1px solid rgba(71, 85, 105, 0.55);
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.bg-jobs-log__empty {
    font-size: 11px;
    color: #94a3b8;
    padding: 4px 0;
}

.bg-jobs-log__line {
    display: grid;
    grid-template-columns: minmax(64px, 88px) 1fr;
    gap: 6px;
    font-size: 11px;
    line-height: 1.35;
    padding: 2px 0;
    border-bottom: 1px solid rgba(51, 65, 85, 0.45);
}

.bg-jobs-log__line:last-child {
    border-bottom: none;
}

.bg-jobs-log__phase {
    color: #94a3b8;
    font-weight: 600;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.bg-jobs-log__msg {
    color: #cbd5e1;
    word-break: break-word;
}

.bg-jobs-log__line--success .bg-jobs-log__msg {
    color: #86efac;
}

.bg-jobs-log__line--warning .bg-jobs-log__msg {
    color: #fde68a;
}

.bg-jobs-log__line--error .bg-jobs-log__msg {
    color: #fca5a5;
}

html[dir="rtl"] .bg-jobs-dock,
body.rtl .bg-jobs-dock {
    right: auto;
    left: 92px;
}

@media (max-width: 480px) {
    .bg-jobs-dock {
        right: 16px;
        bottom: 88px;
    }

    html[dir="rtl"] .bg-jobs-dock,
    body.rtl .bg-jobs-dock {
        left: 16px;
        right: auto;
    }
}
