/* Da Vinci demo: flow diagram, data-in-flight, value callouts, before/after */

/* ----- Demo context (above EMR — not part of Epic); sticky so it stays visible when scrolling ----- */
.davinci-demo-context {
    display: block !important;
    box-sizing: border-box;
    padding: 8px 16px 10px;
    background: #c5cae9;
    border-top: 4px solid #3f51b5;
    border-bottom: 3px solid #3f51b5;
    flex-shrink: 0;
    overflow: visible;
    position: sticky;
    top: 0;
    z-index: 10;
}

.davinci-demo-label {
    display: block !important;
    margin: 0 0 8px 0;
    font-size: 12px;
    font-weight: 700;
    color: #1a237e;
    letter-spacing: 0.02em;
}

/* ----- Flow diagram: Provider → CRD → DTR → PAS → Payer ----- */
.davinci-demo-context .davinci-flow,
.davinci-flow {
    display: flex !important;
    align-items: center;
    justify-content: space-between;
    gap: 4px;
    margin-bottom: 0;
    padding: 10px 16px;
    min-height: 40px;
    background: linear-gradient(135deg, #e3f2fd 0%, #f3e5f5 100%);
    border: 1px solid #3f51b5;
    border-radius: 8px;
    visibility: visible !important;
    opacity: 1 !important;
}

.davinci-flow-node {
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 500;
    color: #37474f;
    background: #fff;
    border: 2px solid #e0e0e0;
    transition: border-color 0.35s ease, background 0.35s ease, box-shadow 0.35s ease;
}

.davinci-flow-node.pending {
    border-color: #e0e0e0;
    background: #fafafa;
    color: #9e9e9e;
}

.davinci-flow-node.active {
    border-color: #1565c0;
    background: #e3f2fd;
    color: #0d47a1;
    box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.2);
    animation: davinci-node-pulse 1.2s ease-in-out infinite;
}

.davinci-flow-node.done {
    border-color: #2e7d32;
    background: #e8f5e9;
    color: #1b5e20;
}

.davinci-flow-node.done::before {
    content: "✓ ";
    font-weight: 700;
}

.davinci-flow-arrow {
    flex-shrink: 0;
    color: #9e9e9e;
    font-size: 18px;
    transition: color 0.3s ease, transform 0.3s ease;
}

.davinci-flow-arrow.active {
    color: #1565c0;
    animation: davinci-arrow-move 0.8s ease-in-out infinite;
}

.davinci-flow-arrow.done {
    color: #2e7d32;
}

@keyframes davinci-node-pulse {
    0%, 100% { box-shadow: 0 0 0 3px rgba(21, 101, 192, 0.2); }
    50%  { box-shadow: 0 0 0 6px rgba(21, 101, 192, 0.1); }
}

@keyframes davinci-arrow-move {
    0%, 100% { transform: translateX(0); opacity: 0.7; }
    50%      { transform: translateX(4px); opacity: 1; }
}

/* ----- Data in flight (shown during API calls) ----- */
.davinci-inflight {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 16px;
    margin: 0;
    max-height: 0;
    overflow: hidden;
    background: #0d2137;
    color: #fff;
    border-radius: 6px;
    font-size: 13px;
    opacity: 0;
    pointer-events: none;
    transition: max-height 0.25s ease, opacity 0.25s ease, padding 0.25s ease;
}

.davinci-inflight.visible {
    max-height: 52px;
    padding: 10px 16px;
    opacity: 1;
}

.davinci-inflight-dots {
    display: flex;
    gap: 6px;
}

.davinci-inflight-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #64b5f6;
    animation: davinci-dot-bounce 0.6s ease-in-out infinite;
}

.davinci-inflight-dots span:nth-child(2) { animation-delay: 0.1s; }
.davinci-inflight-dots span:nth-child(3) { animation-delay: 0.2s; }

@keyframes davinci-dot-bounce {
    0%, 100% { transform: translateY(0); }
    50%      { transform: translateY(-6px); }
}

.davinci-inflight.received {
    background: #1b5e20;
}

.davinci-inflight.received .davinci-inflight-dots {
    display: none;
}

.davinci-inflight.received::before {
    content: "✓ ";
    font-weight: 700;
    margin-right: 4px;
}

/* ----- Value callouts (appear after each step) — no layout space until visible ----- */
.davinci-value-callout {
    margin-top: 0;
    padding: 0;
    max-height: 0;
    overflow: hidden;
    border-radius: 6px;
    font-size: 12px;
    border-left: 4px solid #1565c0;
    background: #e3f2fd;
    color: #0d47a1;
    opacity: 0;
    transition: max-height 0.3s ease, opacity 0.3s ease, margin 0.3s ease, padding 0.3s ease;
}

.davinci-value-callout.visible {
    margin-top: 12px;
    padding: 10px 14px;
    max-height: 120px;
    opacity: 1;
}

.davinci-value-callout strong {
    display: block;
    margin-bottom: 2px;
}

/* ----- Final value summary (before / after Da Vinci) — hidden until approved ----- */
.davinci-value-summary {
    display: none;
    margin-top: 24px;
    padding: 0;
    opacity: 0;
    transform: translateY(12px);
    transition: opacity 0.5s ease 0.2s, transform 0.5s ease 0.2s;
}

.davinci-value-summary.visible {
    display: block;
    opacity: 1;
    transform: translateY(0);
}

.davinci-value-summary h3 {
    font-size: 15px;
    color: #0d2137;
    margin: 0 0 12px 0;
    padding-bottom: 6px;
    border-bottom: 1px solid #e0e0e0;
}

.davinci-compare {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.davinci-compare-box {
    padding: 16px;
    border-radius: 8px;
    font-size: 13px;
    line-height: 1.5;
}

.davinci-compare-box.old {
    background: #ffebee;
    border: 1px solid #ef9a9a;
    color: #b71c1c;
}

.davinci-compare-box.new {
    background: #e8f5e9;
    border: 1px solid #81c784;
    color: #1b5e20;
}

.davinci-compare-box h4 {
    margin: 0 0 8px 0;
    font-size: 13px;
    font-weight: 600;
}

.davinci-compare-box ul {
    margin: 0;
    padding-left: 18px;
}

.davinci-compare-box li {
    margin-bottom: 4px;
}

/* ----- Step entrance (reveal next step) — visible immediately, subtle slide ----- */
.emr-workflow .step.reveal-next {
    animation: davinci-step-reveal 0.35s ease-out forwards;
}

@keyframes davinci-step-reveal {
    from {
        transform: translateY(-8px);
    }
    to {
        transform: translateY(0);
    }
}

/* ----- Data payload viewer (transmitted request/response blobs) ----- */
.payload-section {
    margin-top: 16px;
    border: 1px solid #b0bec5;
    border-radius: 6px;
    overflow: hidden;
    background: #fafafa;
}

.payload-section h4 {
    margin: 0;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #37474f;
    background: #eceff1;
    border-bottom: 1px solid #cfd8dc;
}

.payload-section .payload-block {
    border-bottom: 1px solid #e0e0e0;
}

.payload-section .payload-block:last-child {
    border-bottom: none;
}

.payload-section .payload-label {
    padding: 6px 14px;
    font-size: 11px;
    font-weight: 600;
    color: #1565c0;
    background: #e3f2fd;
    border-bottom: 1px solid #bbdefb;
}

.payload-section .payload-label.response {
    color: #2e7d32;
    background: #e8f5e9;
    border-bottom-color: #c8e6c9;
}

.payload-blob {
    padding: 12px 14px;
    max-height: 320px;
    overflow: auto;
    font-family: "Consolas", "Monaco", "Courier New", monospace;
    font-size: 11px;
    line-height: 1.45;
    white-space: pre-wrap;
    word-break: break-all;
}

.payload-blob .json-key { color: #7b1fa2; font-weight: 600; }
.payload-blob .json-string { color: #0d47a1; }
.payload-blob .json-number { color: #e65100; }
.payload-blob .json-boolean { color: #00695c; }
.payload-blob .json-null { color: #9e9e9e; }
.payload-blob .json-bracket { color: #37474f; }
