/* ============================================================================
   RECIPE BUILDER CONVERSATION STYLES
   Message bubbles, conversation container, typing indicator, markdown rendering.
   
   Dependencies: variables.css (for animations and CSS custom properties)
   ============================================================================ */

/* ----------------------------------------------------------------------------
   CONVERSATION CONTAINER
   ---------------------------------------------------------------------------- */

.rb-conversation {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    max-height: 400px;
    overflow-y: auto;
    padding: 1rem;
    background: var(--rb-bg-base);
    border-radius: 8px;
    border: 1px solid var(--rb-border-dark);
    scroll-behavior: smooth;
}

.rb-conversation-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    min-height: 120px;
    padding: 2rem;
    text-align: center;
    color: var(--rb-text-muted);
}

.rb-conversation-empty-icon {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    opacity: 0.5;
}

.rb-conversation-empty-text {
    font-size: 0.875rem;
}

/* Conversation Panel Layout */
.rb-conversation-panel {
    display: flex;
    flex-direction: column;
    background: var(--rb-bg-surface);
    border: 1px solid var(--rb-border-default);
    border-radius: 8px;
    overflow: hidden;
    height: 100%;
}

/* State: No messages - center input at top */
.rb-conversation-panel.no-messages {
    justify-content: flex-start;
}

.rb-conversation-panel.no-messages .rb-input-area {
    margin-top: 0;
}

.rb-conversation-panel.no-messages .rb-conversation-thread {
    flex: 1;
    min-height: 0;
}

/* State: Has messages - input at bottom, chat-style */
.rb-conversation-panel.has-messages {
    justify-content: flex-start;
}

.rb-conversation-panel.has-messages .rb-conversation-thread {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
}

.rb-conversation-panel.has-messages .rb-input-area {
    flex-shrink: 0;
    border-top: 1px solid var(--rb-border-dark);
    margin-top: 0;
}

.rb-conversation-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1rem;
    background: var(--rb-bg-base);
    border-bottom: 1px solid var(--rb-border-dark);
    flex-shrink: 0;
}

.rb-conversation-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.rb-conversation-messages {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    padding: 0.5rem;
    /* No overflow here - let the thread container handle scrolling for sticky to work */
}

/* Tighter spacing between user message and its response */
.rb-message-user+.rb-message-assistant {
    margin-top: -0.5rem;
}

/* Spacer at bottom allows scrolling last message to top */
.rb-conversation-spacer {
    min-height: 80vh;
    flex-shrink: 0;
    overflow-anchor: none;
}

.rb-conversation-input-area {
    padding: 0.75rem 1rem;
    background: var(--rb-bg-base);
    border-top: 1px solid var(--rb-border-dark);
    flex-shrink: 0;
}

.rb-conversation-thread {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
    overflow-y: auto;
    padding: 0.35rem;
    /* This is the scroll container for sticky positioning */
}


/* Active conversation thread - takes remaining space */
.rb-conversation-thread.rb-conversation-active {
    flex: 1;
    min-height: 100px;
    max-height: none;
    overflow-y: auto;
}

/* AI content area state styles */
.rb-ai-content-condensed.has-messages {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.rb-ai-content-condensed.has-messages .rb-conversation-thread {
    flex: 1;
    min-height: 100px;
    max-height: 250px;
    overflow-y: auto;
}

.rb-ai-content-condensed.no-messages .rb-conversation-thread {
    min-height: 0;
    flex: 0;
}

/* Section conversation state styles */
.rb-section-conversation.has-messages {
    display: flex;
    flex-direction: column;
}

.rb-section-conversation.has-messages .rb-conversation-thread {
    flex: 1;
    min-height: 100px;
}

.rb-section-conversation.no-messages .rb-conversation-thread {
    min-height: 0;
    flex: 0;
}

/* ----------------------------------------------------------------------------
   MESSAGE BUBBLES
   ---------------------------------------------------------------------------- */

.rb-message {
    font-size: 0.8rem;
    line-height: 1.4;
    animation: rb-message-appear var(--rb-transition-normal) ease-out;
}

/* User messages: full width, sticky header style */
.rb-message-user {
    position: sticky;
    top: 0;
    z-index: 10;
    background: linear-gradient(135deg, var(--rb-color-purple-dark) 0%, #312e81 100%);
    border: 1px solid var(--rb-border-purple);
    border-radius: 6px;
    padding: 0.4rem 0.75rem;
    width: 100%;
    box-shadow: 0 4px 12px -2px rgba(0, 0, 0, 0.4);
}

/* Stacked sticky: older user messages hidden behind the most recent one */
.rb-message-user--stacked {
    opacity: 0;
    pointer-events: none;
}

/* History context row - shows focus context chips in conversation history */
.rb-history-context-row {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
    margin-bottom: 0.3rem;
}

.rb-history-context-chip {
    display: inline-flex;
    align-items: center;
    background: rgba(99, 102, 241, 0.3);
    border: 1px solid rgba(99, 102, 241, 0.5);
    border-radius: 3px;
    padding: 0.05rem 0.35rem;
    font-size: 0.6rem;
    color: #a5b4fc;
}

/* Fade gradient underneath sticky user message */
.rb-message-user::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -12px;
    height: 12px;
    background: linear-gradient(to bottom, rgba(15, 23, 42, 0.6) 0%, transparent 100%);
    pointer-events: none;
}

/* Assistant messages: plain text, no bubble, left-aligned */
.rb-message-assistant {
    background: transparent;
    border: none;
    padding: 0.25rem 0;
    width: 100%;
    color: var(--rb-text-primary);
}

/* Message Header - hidden but preserves spacing */
.rb-message-header {
    display: block;
    height: 0.5rem;
    /* Small spacing instead of showing role/time */
    margin-bottom: 0.15rem;
}

/* Hide the role and timestamp text */
.rb-message-role,
.rb-message-time {
    display: none;
}

/* Message Mode Badge */
.rb-message-mode {
    font-size: 0.55rem;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    background: var(--rb-bg-elevated);
    color: var(--rb-text-muted);
}

.rb-message-mode.mode-generate {
    background: rgba(124, 58, 237, 0.2);
    color: #a78bfa;
}

.rb-message-mode.mode-ask {
    background: rgba(14, 165, 233, 0.2);
    color: #38bdf8;
}

/* Message Content */
.rb-message-content {
    color: var(--rb-text-primary);
    word-wrap: break-word;
    line-height: 1.4;
}

.rb-message-content p {
    margin: 0;
}

.rb-message-content p+p {
    margin-top: 0.3rem;
}

/* Assistant message content - plain text style */
.rb-message-assistant .rb-message-content {
    color: var(--rb-text-secondary);
    font-size: 0.78rem;
}

/* ----------------------------------------------------------------------------
   MARKDOWN STYLING
   ---------------------------------------------------------------------------- */

.rb-message-content.rb-markdown {
    font-size: 0.78rem;
}

.rb-message-content.rb-markdown h1,
.rb-message-content.rb-markdown h2,
.rb-message-content.rb-markdown h3,
.rb-message-content.rb-markdown h4 {
    margin-top: 0.5rem;
    margin-bottom: 0.25rem;
    font-weight: 600;
    font-size: 0.85rem;
    color: var(--rb-text-primary);
}

.rb-message-content.rb-markdown h1:first-child,
.rb-message-content.rb-markdown h2:first-child,
.rb-message-content.rb-markdown h3:first-child {
    margin-top: 0;
}

.rb-message-content.rb-markdown ul,
.rb-message-content.rb-markdown ol {
    margin: 0.25rem 0;
    padding-left: 1.25rem;
}

.rb-message-content.rb-markdown li {
    margin: 0.1rem 0;
}

.rb-message-content.rb-markdown li::marker {
    color: var(--rb-text-secondary);
}

.rb-message-content.rb-markdown strong {
    color: var(--rb-text-primary);
    font-weight: 600;
}

.rb-message-content.rb-markdown em {
    font-style: italic;
    color: var(--rb-text-secondary);
}

.rb-message-content.rb-markdown code {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Consolas', monospace;
    font-size: 0.85em;
}

.rb-message-content.rb-markdown pre {
    background: rgba(0, 0, 0, 0.3);
    padding: 0.75rem;
    border-radius: 6px;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.rb-message-content.rb-markdown pre code {
    background: none;
    padding: 0;
}

.rb-message-content.rb-markdown blockquote {
    border-left: 3px solid var(--rb-accent);
    margin: 0.5rem 0;
    padding-left: 0.75rem;
    color: var(--rb-text-secondary);
}

.rb-message-content.rb-markdown a {
    color: var(--rb-accent);
    text-decoration: none;
}

.rb-message-content.rb-markdown a:hover {
    text-decoration: underline;
}

/* ----------------------------------------------------------------------------
   TYPING INDICATOR
   ---------------------------------------------------------------------------- */

.rb-typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 1rem;
    background: var(--rb-bg-surface);
    border: 1px solid var(--rb-border-default);
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    max-width: 60px;
}

.rb-typing-dot {
    width: 6px;
    height: 6px;
    background: var(--rb-text-muted);
    border-radius: 50%;
    animation: rb-typing-bounce 1.4s ease-in-out infinite;
}

.rb-typing-dot:nth-child(1) {
    animation-delay: 0s;
}

.rb-typing-dot:nth-child(2) {
    animation-delay: 0.2s;
}

.rb-typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

/* ----------------------------------------------------------------------------
   CONDENSED HISTORY
   ---------------------------------------------------------------------------- */

.rb-history-condensed {
    padding: 0.75rem;
    background: var(--rb-bg-surface);
    border: 1px solid var(--rb-border-default);
    border-radius: 6px;
    margin-bottom: 0.75rem;
}

.rb-history-summary {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--rb-text-muted);
    font-size: 0.8rem;
    cursor: pointer;
    transition: color var(--rb-transition-fast);
}

.rb-history-summary:hover {
    color: var(--rb-text-secondary);
}

.rb-history-summary-icon {
    font-size: 1rem;
}

.rb-history-summary-count {
    font-weight: 500;
}

.rb-condensed-history {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: var(--rb-bg-hover);
    border-radius: 6px;
    font-size: 0.8rem;
    color: var(--rb-text-secondary);
}

.rb-condensed-count {
    font-weight: 600;
    color: var(--rb-text-primary);
}

.rb-condensed-preview {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-style: italic;
    opacity: 0.8;
}

.rb-condensed-empty {
    color: var(--rb-text-muted);
    font-style: italic;
}

/* ----------------------------------------------------------------------------
   EMPTY CHAT STATE
   ---------------------------------------------------------------------------- */

.rb-empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    text-align: center;
    color: var(--rb-text-muted);
    min-height: 150px;
}

.rb-empty-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    opacity: 0.4;
}

.rb-empty-text {
    font-size: 0.9rem;
    max-width: 250px;
}

/* ----------------------------------------------------------------------------
   DIFF LINE STYLES
   For displaying text diffs with removed, added, and unchanged lines
   ---------------------------------------------------------------------------- */

.rb-diff-lines {
    border-radius: 6px;
    overflow-x: auto;
    overflow-y: hidden;
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    margin-top: 0.5rem;
}

.rb-diff-lines--scrollable {
    max-height: 300px;
    overflow-x: auto;
    overflow-y: auto;
}

/* Expanded state - grows taller to show ~3 more lines, then scrollable */
.rb-diff-lines--expanded {
    max-height: 280px;
    overflow-x: auto;
    overflow-y: auto;
}

.rb-diff-line {
    display: flex;
    align-items: flex-start;
}

.rb-diff-line-prefix {
    flex-shrink: 0;
    width: 1.2rem;
    text-align: center;
    user-select: none;
    font-family: var(--rb-font-mono);
    font-weight: 600;
    font-size: 0.7rem;
}

.rb-diff-line-content {
    flex: 1;
    min-width: 0;
}

.rb-diff-line--removed,
.rb-diff-line--added,
.rb-diff-line--unchanged {
    padding: 0.05rem 0.4rem;
    font-family: var(--rb-font-mono);
    font-size: 0.7rem;
    line-height: 1.35;
    white-space: pre;
    border-left: 2px solid transparent;
}

.rb-diff-line--removed {
    background: var(--rb-diff-removed-bg);
    color: var(--rb-diff-removed-text);
    border-left-color: var(--rb-diff-removed-border);
}

.rb-diff-line--added {
    background: var(--rb-diff-added-bg);
    color: var(--rb-diff-added-text);
    border-left-color: var(--rb-diff-added-border);
}

.rb-diff-line--unchanged {
    color: var(--rb-diff-unchanged-text);
}

/* ----------------------------------------------------------------------------
   WORD DIFF STYLES
   For inline word-level diffs on short strings
   ---------------------------------------------------------------------------- */

.rb-diff-words {
    font-family: var(--rb-font-mono);
    font-size: 0.85rem;
    line-height: 1.5;
    padding: 0.5rem;
    border-radius: 4px;
    background: var(--rb-bg-base);
    border: 1px solid var(--rb-border-default);
    margin-top: 0.5rem;
}

.rb-diff-word--removed {
    background: var(--rb-diff-removed-bg);
    color: var(--rb-diff-removed-text);
    text-decoration: line-through;
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    margin: 0 0.05rem;
}

.rb-diff-word--added {
    background: var(--rb-diff-added-bg);
    color: var(--rb-diff-added-text);
    font-weight: 500;
    padding: 0.1rem 0.2rem;
    border-radius: 3px;
    margin: 0 0.05rem;
}

/* ----------------------------------------------------------------------------
   SELECT/VALUE DIFF STYLES
   For inline old → new value display
   ---------------------------------------------------------------------------- */

.rb-diff-value--old,
.rb-diff-value--new {
    white-space: pre-wrap;
    font-family: var(--rb-font-mono);
    font-size: 0.85rem;
    display: block;
    padding: 0.5rem;
    border-radius: 4px;
    max-height: 150px;
    overflow-y: auto;
}

.rb-diff-value--old {
    color: var(--rb-diff-removed-text);
    text-decoration: line-through;
    opacity: 0.8;
    background: var(--rb-diff-removed-bg);
    margin-bottom: 0.25rem;
}

.rb-diff-value--new {
    color: var(--rb-diff-added-text);
    font-weight: 500;
    background: var(--rb-diff-added-bg);
}

.rb-diff-arrow {
    color: var(--rb-text-muted);
    margin: 0.25rem 0;
    text-align: center;
    display: block;
}

/* ----------------------------------------------------------------------------
   PARAMETER DIFF STYLING
   Individual parameter change rows within effect change cards
   ---------------------------------------------------------------------------- */

.rb-effect-change-card-params {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.5rem;
}

.rb-param-diff {
    background: var(--rb-bg-elevated);
    border-radius: 4px;
    padding: 0.4rem 0.5rem;
    border-left: 2px solid var(--rb-border-default);
}

.rb-param-diff-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: var(--rb-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.03em;
    margin-bottom: 0.25rem;
}

.rb-param-diff-content {
    font-size: 0.75rem;
}

/* Inline diff for select/simple values - old → new on same line */
.rb-diff-inline {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
    font-size: 0.75rem;
}

.rb-diff-inline-old {
    color: var(--rb-diff-removed-text);
    background: var(--rb-diff-removed-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    text-decoration: line-through;
    font-family: var(--rb-font-mono);
}

.rb-diff-inline-arrow {
    color: var(--rb-text-muted);
    font-weight: 500;
}

.rb-diff-inline-new {
    color: var(--rb-diff-added-text);
    background: var(--rb-diff-added-bg);
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-weight: 500;
    font-family: var(--rb-font-mono);
}

/* Hide old value and arrow in inline diff when applied */
.rb-effect-change-card.applied .rb-diff-inline-old,
.rb-effect-change-card.applied .rb-diff-inline-arrow {
    display: none;
}

.rb-effect-change-card.applied .rb-diff-inline-new {
    background: transparent;
    color: var(--rb-text-secondary);
}

/* ----------------------------------------------------------------------------
   EXPANDABLE DIFF SECTIONS
   For collapsible unchanged sections
   ---------------------------------------------------------------------------- */

.rb-diff-expandable {
    cursor: pointer;
    overflow: hidden;
    max-height: 100px;
    position: relative;
    transition: max-height var(--rb-transition-normal) ease;
}

.rb-diff-expandable:focus-visible {
    outline: 2px solid var(--rb-primary);
    outline-offset: 2px;
}

.rb-diff-expandable::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 30px;
    background: linear-gradient(to bottom, transparent, var(--rb-bg-surface));
    pointer-events: none;
}

.rb-diff-expandable.expanded {
    max-height: 2000px;
    overflow: auto;
}

.rb-diff-expandable.expanded::after {
    display: none;
}

.rb-diff-collapsed-marker {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem;
    background: var(--rb-bg-elevated);
    color: var(--rb-text-muted);
    font-size: 0.65rem;
    cursor: pointer;
    border-radius: 3px;
    margin: 0.15rem 0;
    transition: background var(--rb-transition-fast);
}

.rb-diff-collapsed-marker:hover {
    background: var(--rb-bg-hover);
    color: var(--rb-text-secondary);
}

.rb-diff-collapsed-marker:focus-visible {
    outline: 2px solid var(--rb-primary);
    outline-offset: 2px;
}

.rb-diff-collapsed-marker[data-expanded="true"] {
    position: sticky;
    bottom: 0;
    background: linear-gradient(to bottom, transparent, var(--rb-bg-surface) 30%);
    border: none;
    margin: 0;
    padding: 1.5rem 0.5rem 0.5rem;
    border-radius: 0;
    color: var(--rb-text-muted);
    font-size: 0.7rem;
    opacity: 0.9;
}

.rb-diff-collapsed-marker[data-expanded="true"]:hover {
    background: linear-gradient(to bottom, transparent, var(--rb-bg-elevated) 30%);
    opacity: 1;
}

.rb-diff-expand-arrow {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-top: 0.4rem;
    padding: 0.2rem 0;
    color: var(--rb-text-muted);
    font-size: 0.6rem;
    cursor: pointer;
    border-radius: 3px;
    transition: color var(--rb-transition-fast), background var(--rb-transition-fast);
}

.rb-diff-expand-arrow:hover {
    color: var(--rb-text-secondary);
    background: var(--rb-bg-hover);
}

/* ----------------------------------------------------------------------------
   EFFECT CHANGE CARD
   Container for AI-suggested parameter changes
   ---------------------------------------------------------------------------- */

.rb-effect-changes {
    margin-bottom: 1rem;
}

.rb-effect-change-card {
    position: relative;
    background: var(--rb-bg-surface);
    border: 1px solid var(--rb-border-default);
    border-radius: 6px;
    padding: 0.5rem;
    margin-top: 0.5rem;
    transition: opacity var(--rb-transition-fast), border-color var(--rb-transition-fast);
}

.rb-effect-change-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.35rem;
    gap: 0.5rem;
}

.rb-effect-change-card-title {
    font-weight: 500;
    color: var(--rb-text-primary);
    font-size: 0.75rem;
    flex: 1;
}

.rb-line-stats {
    display: flex;
    gap: 0.35rem;
    font-size: 0.65rem;
    font-weight: 600;
    font-family: var(--rb-font-mono);
}

.rb-line-stat--added {
    color: var(--rb-color-success);
}

.rb-line-stat--removed {
    color: var(--rb-color-error);
}

.rb-effect-change-card-actions {
    display: flex;
    gap: 0.5rem;
}

/* State: Applying */
.rb-effect-change-card.applying {
    opacity: 0.7;
    pointer-events: none;
}

.rb-effect-change-card.applying::after {
    content: '';
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.1);
    border-radius: 8px;
}

/* State: Applied */
.rb-effect-change-card.applied {
    border-color: var(--rb-border-default);
    background: var(--rb-bg-surface);
    transition: border-color 0.3s ease, background 0.3s ease;
}

.rb-effect-change-card.applied .rb-effect-change-card-actions {
    display: none;
}

/* Fade removed lines (don't hide - show what was removed but greyed out) */
.rb-effect-change-card.applied .rb-diff-line--removed {
    opacity: 0.35;
    background: transparent;
    border-left-color: rgba(239, 68, 68, 0.3);
    transition: opacity 0.3s ease;
}

.rb-effect-change-card.applied .rb-diff-value--old {
    opacity: 0.35;
    background: transparent;
    transition: opacity 0.3s ease;
}

/* Hide expand controls when applied */
.rb-effect-change-card.applied .rb-diff-arrow,
.rb-effect-change-card.applied .rb-diff-collapsed-marker,
.rb-effect-change-card.applied .rb-diff-expand-arrow {
    display: none;
}

/* Make added lines look like normal content when applied */
.rb-effect-change-card.applied .rb-diff-line--added {
    background: transparent;
    border-left-color: transparent;
    color: var(--rb-text-secondary);
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.rb-effect-change-card.applied .rb-diff-value--new {
    text-decoration: none;
    color: var(--rb-text-secondary);
    background: transparent;
    transition: color 0.3s ease, background 0.3s ease;
}

/* Applied inline diff: fade old, normalize new */
.rb-effect-change-card.applied .rb-diff-inline-old {
    opacity: 0.35;
    transition: opacity 0.3s ease;
}

.rb-effect-change-card.applied .rb-diff-inline-arrow {
    opacity: 0.35;
    transition: opacity 0.3s ease;
}

.rb-effect-change-card.applied .rb-diff-inline-new {
    background: transparent;
    color: var(--rb-text-secondary);
    font-weight: normal;
    transition: background 0.3s ease, color 0.3s ease;
}

/* State: Rejected */
.rb-effect-change-card.rejected {
    opacity: 0.5;
    border-color: var(--rb-border-dark);
    background: var(--rb-bg-surface);
    transition: opacity 0.3s ease, border-color 0.3s ease, background 0.3s ease;
}

.rb-effect-change-card.rejected .rb-effect-change-card-actions {
    display: none;
}

/* Grey out and cross out added lines (rejected - these won't be applied) */
.rb-effect-change-card.rejected .rb-diff-line--added {
    opacity: 0.5;
    background: transparent;
    border-left-color: transparent;
    color: var(--rb-text-muted);
    text-decoration: line-through;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.rb-effect-change-card.rejected .rb-diff-line--added .rb-diff-line-content {
    text-decoration: line-through;
}

.rb-effect-change-card.rejected .rb-diff-value--new {
    opacity: 0.5;
    background: transparent;
    color: var(--rb-text-muted);
    text-decoration: line-through;
    transition: opacity 0.3s ease, color 0.3s ease;
}

/* Make removed lines look like normal content when rejected (kept as-is) */
.rb-effect-change-card.rejected .rb-diff-line--removed {
    background: transparent;
    border-left-color: transparent;
    color: var(--rb-text-secondary);
    text-decoration: none;
    transition: background 0.3s ease, border-color 0.3s ease, color 0.3s ease;
}

.rb-effect-change-card.rejected .rb-diff-value--old {
    text-decoration: none;
    color: var(--rb-text-secondary);
    background: transparent;
    opacity: 1;
    transition: color 0.3s ease, background 0.3s ease;
}

/* Rejected inline diff: grey out and cross out new, normalize old */
.rb-effect-change-card.rejected .rb-diff-inline-new {
    opacity: 0.5;
    background: transparent;
    color: var(--rb-text-muted);
    text-decoration: line-through;
    transition: opacity 0.3s ease, color 0.3s ease;
}

.rb-effect-change-card.rejected .rb-diff-inline-arrow {
    opacity: 0.35;
    transition: opacity 0.3s ease;
}

.rb-effect-change-card.rejected .rb-diff-inline-old {
    opacity: 1;
    background: transparent;
    color: var(--rb-text-secondary);
    text-decoration: none;
    transition: opacity 0.3s ease, background 0.3s ease, color 0.3s ease;
}

/* Word-level diffs in rejected state */
.rb-effect-change-card.rejected .rb-diff-word--added {
    opacity: 0.5;
    background: transparent;
    color: var(--rb-text-muted);
    text-decoration: line-through;
    font-weight: normal;
}

.rb-effect-change-card.rejected .rb-diff-word--removed {
    background: transparent;
    color: var(--rb-text-secondary);
    text-decoration: none;
}

/* State: Stale */
.rb-effect-change-card.stale {
    border-color: var(--rb-color-warning);
    background: var(--rb-color-warning-bg);
}

.rb-effect-change-card.stale .rb-effect-change-card-actions {
    opacity: 0.5;
    pointer-events: none;
}

/* ----------------------------------------------------------------------------
   CHANGE BADGES
   Type indicators for update/create operations
   ---------------------------------------------------------------------------- */

.rb-change-badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.375rem;
    border-radius: 4px;
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.rb-change-badge--update {
    background: rgba(234, 179, 8, 0.2);
    color: #facc15;
}

.rb-change-badge--create {
    background: rgba(16, 185, 129, 0.2);
    color: #34d399;
}

/* Create Summary - condensed view for new effects */
.rb-create-summary {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    padding: 0.4rem 0.5rem;
    background: rgba(16, 185, 129, 0.08);
    border-radius: 4px;
    border-left: 2px solid var(--rb-color-success);
}

.rb-create-summary-item {
    display: flex;
    gap: 0.4rem;
    font-size: 0.7rem;
    line-height: 1.3;
}

.rb-create-summary-label {
    color: var(--rb-text-muted);
    flex-shrink: 0;
}

.rb-create-summary-value {
    color: var(--rb-text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.rb-create-summary-more {
    font-size: 0.65rem;
    color: var(--rb-text-muted);
    font-style: italic;
}

.rb-create-summary-note {
    font-size: 0.7rem;
    color: var(--rb-text-muted);
    font-style: italic;
}

.rb-create-preview-line {
    font-size: 0.65rem;
    color: var(--rb-text-secondary);
    padding-left: 0.5rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.rb-create-preview-more {
    font-size: 0.65rem;
    color: var(--rb-text-muted);
    padding-left: 0.5rem;
}

/* ----------------------------------------------------------------------------
   CHANGE ACTION BUTTONS
   Buttons for Apply, Reject, View actions on effect changes
   ---------------------------------------------------------------------------- */

.rb-change-action {
    padding: 0.15rem 0.4rem;
    border-radius: 3px;
    font-size: 0.65rem;
    font-weight: 500;
    cursor: pointer;
    transition: all var(--rb-transition-fast);
    border: 1px solid var(--rb-border-default);
    background: var(--rb-bg-surface);
    color: var(--rb-text-secondary);
}

.rb-change-action:hover:not(:disabled) {
    background: var(--rb-bg-elevated);
    color: var(--rb-text-primary);
}

.rb-change-action:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.rb-change-action:focus-visible {
    outline: 2px solid var(--rb-primary);
    outline-offset: 2px;
}

.rb-change-action-primary {
    background: var(--rb-color-success);
    border-color: var(--rb-color-success);
    color: white;
}

.rb-change-action-primary:hover:not(:disabled) {
    background: #059669;
    border-color: #059669;
    color: white;
}

.rb-change-action-primary:focus-visible {
    outline: 2px solid white;
    outline-offset: 2px;
}

.rb-change-action-reject {
    background: transparent;
    border-color: var(--rb-color-error, #ef4444);
    color: var(--rb-color-error, #ef4444);
}

.rb-change-action-reject:hover:not(:disabled) {
    background: rgba(239, 68, 68, 0.1);
    color: var(--rb-color-error, #ef4444);
}

.rb-change-action-view {
    font-size: 0.85rem;
    padding: 0.1rem 0.3rem;
    background: transparent;
    border: none;
    opacity: 0.7;
}

.rb-change-action-view:hover:not(:disabled) {
    opacity: 1;
    background: var(--rb-bg-elevated);
}

/* ----------------------------------------------------------------------------
   DIFF STATS DISPLAY
   For large text showing summary instead of full diff
   ---------------------------------------------------------------------------- */

.rb-diff-stats {
    display: flex;
    gap: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--rb-bg-elevated);
    border-radius: 4px;
    font-size: 0.8rem;
}

.rb-diff-stats-added {
    color: var(--rb-diff-added-text);
}

.rb-diff-stats-removed {
    color: var(--rb-diff-removed-text);
}

/* Preview modal changed field highlighting */
.rb-preview-changed {
    border-left: 3px solid var(--rb-diff-added-border, #10b981);
    padding-left: 0.75rem;
    background: rgba(6, 78, 59, 0.1);
    border-radius: 4px;
}

/* ============================================================================
   Streaming Updates UI
   ============================================================================ */

.rb-streaming-message {
    animation: rb-pulse 1.5s ease-in-out infinite;
}

@keyframes rb-pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.7;
    }
}

.rb-streaming-header {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.75rem;
    font-size: 0.8rem;
    color: #a5b4fc;
}

.rb-streaming-indicator {
    color: #10b981;
    animation: rb-blink 1s ease-in-out infinite;
}

@keyframes rb-blink {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.3;
    }
}

.rb-streaming-status {
    font-style: italic;
}

/* Streaming content container - items appear in stream order */
.rb-streaming-content {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

/* Streaming update cards - full cards rendered during streaming */
.rb-streaming-card {
    animation: rb-card-slide-in 0.3s ease-out;
}

@keyframes rb-card-slide-in {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Streaming thinking container - scrollable box that shows latest thinking */
.rb-streaming-thinking-container {
    max-height: 80px;
    overflow-y: auto;
    background: rgba(165, 180, 252, 0.05);
    border-radius: 8px;
    border-left: 2px solid #a5b4fc;
    padding: 0.5rem 0.75rem;
    font-size: 0.8rem;
    color: #9ca3af;
    font-style: italic;
    animation: rb-fade-in 0.3s ease-out;
}

.rb-streaming-thinking-container::-webkit-scrollbar {
    width: 4px;
}

.rb-streaming-thinking-container::-webkit-scrollbar-track {
    background: transparent;
}

.rb-streaming-thinking-container::-webkit-scrollbar-thumb {
    background: rgba(165, 180, 252, 0.3);
    border-radius: 2px;
}

/* Individual thinking lines inside the container */
.rb-streaming-thought {
    padding: 0.25rem 0;
    color: #9ca3af;
    white-space: pre-wrap;
    word-break: break-word;
}

.rb-streaming-thought:not(:last-child) {
    opacity: 0.5;
}

@keyframes rb-fade-in {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Collapsed thinking summary - shown after thinking completes */
.rb-thinking-collapsed {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.6rem;
    background: rgba(165, 180, 252, 0.1);
    border-radius: 6px;
    font-size: 0.75rem;
    color: #a5b4fc;
    cursor: pointer;
    transition: background 0.2s;
}

.rb-thinking-collapsed:hover {
    background: rgba(165, 180, 252, 0.2);
}

.rb-thinking-collapsed-icon {
    font-size: 0.85rem;
}

.rb-thinking-collapsed-text {
    font-style: italic;
}

.rb-streaming-thought-icon {
    margin-right: 0.5rem;
}

/* Streaming text message - shown when Claude answers a question */
.rb-streaming-text-message {
    padding: 0.75rem 1rem;
    color: #e2e8f0;
    line-height: 1.5;
    animation: rb-fade-in 0.3s ease-out;
}

/* World query pill - @world indicator */
.rb-world-pill-container {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.25rem 0;
    margin-bottom: 0.25rem;
}

.rb-world-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.5rem;
    background: linear-gradient(135deg, #3b82f6 0%, #8b5cf6 100%);
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    box-shadow: 0 2px 4px rgba(59, 130, 246, 0.3);
    animation: rb-pill-appear 0.2s ease-out;
}

@keyframes rb-pill-appear {
    from {
        opacity: 0;
        transform: scale(0.8);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

.rb-world-pill-icon {
    font-size: 0.85rem;
}

.rb-world-pill-text {
    font-family: 'SF Mono', 'Menlo', monospace;
}

.rb-world-pill-remove {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 16px;
    height: 16px;
    padding: 0;
    margin-left: 0.15rem;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 0.75rem;
    line-height: 1;
    cursor: pointer;
    transition: background 0.15s ease;
}

.rb-world-pill-remove:hover {
    background: rgba(255, 255, 255, 0.4);
}

.rb-world-pill-hint {
    font-size: 0.7rem;
    color: #9ca3af;
    font-style: italic;
}