/*
 * #9948 PRE-AI 7/10 — Right-panel pipeline styles.
 *
 * Scoped under .wcp-right-panel-pipeline so the Logistik child theme can't
 * leak into the panel, and so we never collide with the #9949 sibling agent's
 * top-of-DT filter chip styles.
 *
 * Production rules:
 *   - Bootstrap 5 .progress + .progress-bar are reused for the bar, BUT we
 *     attach color via .tier-* classes on .progress-bar (NOT .bg-success etc.)
 *     so the Logistik !important overrides can't win.
 *   - .wcp-badge / .dms-step-circle (NEVER Bootstrap .badge)
 *   - Mobile-first: bottom-sheet at <= 768px (M5)
 */

/* === Outer container =================================================== */
.wcp-right-panel-pipeline {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    height: 100vh;
    background: #ffffff;
    border-left: 1px solid #e5e7eb;
    box-shadow: -4px 0 14px rgba(0, 0, 0, 0.08);
    z-index: 1050;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1f2937;
}

.wcp-right-panel-pipeline[hidden] {
    display: none !important;
}

/* === Header ============================================================ */
.wcp-right-panel-pipeline__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    border-bottom: 1px solid #e5e7eb;
    background: #f9fafb;
    flex: 0 0 auto;
}

.wcp-right-panel-pipeline__title {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0; /* allow ellipsis */
    flex: 1 1 auto;
}

.wcp-right-panel-pipeline__ticket-id {
    font-size: 12px;
    color: #6b7280;
    font-weight: 500;
}

.wcp-right-panel-pipeline__short {
    font-size: 14px;
    font-weight: 600;
    color: #111827;
    text-overflow: ellipsis;
    overflow: hidden;
    white-space: nowrap;
}

/* M4 — custom close button (NEVER use Bootstrap .btn-close SVG: it ships
 * a baked-in `background-image: url(...svg…)` that the Logistik theme
 * overrides to invisible). Render a glyph instead. */
.wcp-right-panel-pipeline__close {
    background: transparent;
    border: 1px solid transparent;
    color: #6b7280;
    font-size: 24px;
    line-height: 1;
    padding: 0 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 150ms ease, color 150ms ease;
}
.wcp-right-panel-pipeline__close:hover {
    background: #f3f4f6;
    color: #111827;
}
.wcp-right-panel-pipeline__close:focus {
    outline: 2px solid #2563eb;
    outline-offset: 1px;
}

/* === Scroll body ======================================================= */
.wcp-right-panel-pipeline__section {
    padding: 12px 16px;
    border-bottom: 1px solid #f3f4f6;
    flex: 0 0 auto;
}
/* Middle (history) + bottom (AI recs) grow / shrink to fit */
.wcp-right-panel-pipeline__section[data-rpp-section="history"],
.wcp-right-panel-pipeline__section[data-rpp-section="ai-recs"] {
    flex: 1 1 auto;
    overflow-y: auto;
    min-height: 80px;
    max-height: 50vh;
}

.wcp-right-panel-pipeline__section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 0 0 8px 0;
}
.wcp-right-panel-pipeline__section-header h4 {
    font-size: 13px;
    font-weight: 700;
    text-transform: uppercase;
    color: #4b5563;
    margin: 0;
    letter-spacing: 0.04em;
}

/* === Progress bar (M9-M15) ============================================ */
.wcp-right-panel-pipeline .dms-pipeline-progress {
    background: #ffffff;
}

.wcp-right-panel-pipeline__step-name {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
    font-weight: 600;
    color: #111827;
    cursor: pointer;
}
.wcp-right-panel-pipeline__step-name:hover,
.wcp-right-panel-pipeline__step-name:focus {
    color: #2563eb;
}
.wcp-right-panel-pipeline__step-circle-slot {
    display: inline-flex;
    align-items: center;
}

.wcp-right-panel-pipeline__progress.progress {
    height: 10px;
    border-radius: 999px;
    overflow: hidden;
    background: #e5e7eb;
}
.wcp-right-panel-pipeline__progress-bar.progress-bar {
    height: 100%;
    background-color: #6b7280; /* base fallback */
    transition: width 500ms ease, background-color 250ms ease; /* M15 */
}
/* M11 color tiers — match the .dms-step-circle palette */
.wcp-right-panel-pipeline__progress-bar.tier-danger  { background-color: #ef4444 !important; }
.wcp-right-panel-pipeline__progress-bar.tier-warning { background-color: #f59e0b !important; }
.wcp-right-panel-pipeline__progress-bar.tier-info    { background-color: #2563eb !important; }
.wcp-right-panel-pipeline__progress-bar.tier-success { background-color: #16a34a !important; }
.wcp-right-panel-pipeline__progress-bar.rpp-flash {
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.wcp-right-panel-pipeline__eta {
    margin-top: 6px;
    font-size: 11px;
    color: #6b7280;
}

/* === History log (M16-M22) ============================================ */
.wcp-right-panel-pipeline__history-filter {
    width: 160px;
    font-size: 12px;
}

.wcp-right-panel-pipeline__history-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.wcp-rpp-history-day {
    position: sticky;
    top: 0;
    background: #f9fafb;
    color: #6b7280;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    padding: 4px 6px;
    margin: 8px 0 4px 0;
    border-bottom: 1px solid #e5e7eb;
    letter-spacing: 0.04em;
    z-index: 1;
}

.wcp-rpp-history-entry {
    padding: 6px 4px;
    border-bottom: 1px dashed #f3f4f6;
    transition: background 250ms ease;
}
.wcp-rpp-history-entry.rpp-flash-new {
    background: #fef3c7;
}

.wcp-rpp-history-meta {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 11px;
    margin-bottom: 2px;
}
.wcp-rpp-history-time { font-variant-numeric: tabular-nums; }
.wcp-rpp-history-action {
    font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
    color: #1f2937;
    background: #f3f4f6;
    padding: 1px 5px;
    border-radius: 4px;
    font-size: 10.5px;
}
.wcp-rpp-history-desc {
    font-size: 12px;
    color: #374151;
    line-height: 1.4;
    padding-left: 4px;
}
.wcp-rpp-history-toggle {
    font-size: 10px;
    padding: 0 4px;
    text-decoration: none;
}

.wcp-rpp-history-diff {
    margin: 6px 0 0 0;
    padding: 6px;
    background: #1f2937;
    color: #f3f4f6;
    border-radius: 4px;
    font-size: 11px;
    line-height: 1.4;
    max-height: 200px;
    overflow: auto;
    white-space: pre;
}

.wcp-right-panel-pipeline__load-more {
    width: 100%;
    margin-top: 8px;
}

.wcp-right-panel-pipeline__history-empty {
    padding: 12px;
    text-align: center;
    font-size: 12px;
}

/* === AI recommendation cards (M23-M29) ================================ */
.wcp-right-panel-pipeline__ai-rec-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.dms-ai-rec-card {
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    padding: 8px 10px;
    background: #ffffff;
}
.dms-ai-rec-card__head {
    display: flex;
    align-items: center;
    gap: 6px;
    flex-wrap: wrap;
    font-size: 11px;
    margin-bottom: 6px;
}
.dms-ai-rec-card__actions {
    margin-left: auto;
    display: inline-flex;
    gap: 4px;
}
.dms-ai-rec-card__body {
    font-size: 12px;
    line-height: 1.5;
    color: #1f2937;
}
.dms-ai-rec-card__body pre {
    background: #f3f4f6;
    padding: 6px;
    border-radius: 4px;
    font-size: 11px;
    overflow-x: auto;
}
.dms-ai-rec-card__foot {
    font-size: 10.5px;
    margin-top: 6px;
    border-top: 1px dashed #f3f4f6;
    padding-top: 4px;
}

.wcp-right-panel-pipeline__ai-rec-empty {
    padding: 12px;
    text-align: center;
    font-size: 12px;
}
.wcp-right-panel-pipeline__loading-dots span {
    display: inline-block;
    width: 4px; height: 4px;
    margin: 0 1px;
    background: #9ca3af;
    border-radius: 50%;
    opacity: 0.3;
    animation: rpp-dot 1.2s infinite ease-in-out;
}
.wcp-right-panel-pipeline__loading-dots span:nth-child(2) { animation-delay: 0.2s; }
.wcp-right-panel-pipeline__loading-dots span:nth-child(3) { animation-delay: 0.4s; }
.is-loading .wcp-right-panel-pipeline__loading-dots span {
    opacity: 1;
}
@keyframes rpp-dot {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 1; }
}

/* === Tier classes for any step-circle slot we render server-side ====== */
/* Defensive: we re-declare to ensure the slot picks up the canonical colors
 * if the dms-badges.css ever gets unloaded on this page. Source of truth
 * remains dms-badges.css — these are visual fallbacks only. */
.wcp-right-panel-pipeline .dms-step-circle.dms-step-circle--sm {
    width: 18px; height: 18px;
    font-size: 10px;
}

/* === Mobile (M5) — bottom-sheet at ≤ 768px ============================ */
@media (max-width: 768px) {
    .wcp-right-panel-pipeline {
        top: auto;
        bottom: 0;
        right: 0;
        left: 0;
        width: 100vw;
        height: 70vh;
        border-left: 0;
        border-top: 1px solid #e5e7eb;
        box-shadow: 0 -4px 14px rgba(0, 0, 0, 0.12);
        border-radius: 12px 12px 0 0;
    }
    .wcp-right-panel-pipeline__section[data-rpp-section="history"],
    .wcp-right-panel-pipeline__section[data-rpp-section="ai-recs"] {
        max-height: 40vh;
    }
}

/* === #9938 EXTERNAL TRACKING card ====================================== */
.wcp-right-panel-pipeline__section[data-rpp-section="external-tracking"] {
    flex: 0 0 auto;
    padding: 10px 14px;
    background: #fafbfc;
    border-bottom: 1px solid #e5e7eb;
}
.wcp-rpp-external__rows {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin: 8px 0 4px;
}
.wcp-rpp-external__row {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
    font-size: 13px;
}
.wcp-rpp-external__provider {
    min-width: 80px;
    font-weight: 600;
    color: #374151;
}
.wcp-rpp-external__id {
    font-family: "JetBrains Mono", "Consolas", monospace;
    color: #111827;
    background: #f3f4f6;
    padding: 1px 6px;
    border-radius: 4px;
}
.wcp-rpp-external__status {
    font-size: 11px;
}
.wcp-rpp-external__open {
    margin-left: auto;
    padding: 0;
    font-size: 12px;
}
.wcp-rpp-external__gen {
    margin-left: auto;
    font-size: 12px;
    padding: 2px 10px;
}
.wcp-rpp-external__synced {
    font-size: 11px;
    margin-top: 4px;
}
.wcp-rpp-external__icon {
    font-size: 14px;
    margin-left: 4px;
}
