/* Shared chat styles used by AiChat and ReportGeneration chat panels */

.ai-chat-header {
    flex-shrink: 0;
    min-height: 2.5rem;
}

.ai-chat-model-selector {
    flex-shrink: 0;
}

.ai-chat-messages {
    flex: 1;
    min-height: 0;
    padding-bottom: 0.5rem;
}

.ai-chat-input {
    flex-shrink: 0;
    background-color: var(--rs-surface-subtle);
}

/* Message Styles */
.ai-chat-message {
    margin-bottom: 0.5rem;
}

.ai-chat-message.user .message-content {
    margin-left: 1rem;
}

.ai-chat-message.assistant .message-content {
    margin-right: 1rem;
}

/* Tool call message variant */
.ai-chat-message.tool .message-content {
    margin-right: 1rem;
    background-color: var(--rs-accent-fill);
    border: 1px dashed var(--rs-accent-border);
}
.ai-tool-message .message-text pre {
    background-color: var(--rs-surface-subtle);
}

.message-content {
    background-color: var(--rs-surface-panel);
    border-radius: var(--rs-radius-lg);
    padding: 0.5rem 0.625rem;
    position: relative;
    border: 1px solid var(--rs-border);
}

.ai-chat-message.user .message-content {
    /* Softer primary-tinted surface to align with overall design */
    background-color: var(--rs-accent-fill);
    color: var(--rs-text);
    border: 1px solid var(--rs-border);
}

.message-role {
    display: flex;
    align-items: center;
    margin-bottom: 0.25rem;
}

.message-text {
    word-wrap: break-word;
    line-height: 1.35;
}

.reasoning-summary {
    color: var(--rs-text-muted);
    font-size: 0.875em;
}

/* Code blocks - general styling */
.message-text pre {
    border-radius: var(--rs-radius-md);
    padding: 0.5rem;
    margin: 0.375rem 0;
    overflow-x: auto;
    font-size: 0.875rem;
    font-family: var(--rs-font-mono);
    line-height: 1.35;
    border: 1px solid var(--rs-border);
    background-color: var(--rs-surface-subtle);
    color: var(--rs-text);
}

/* Inline code - general styling */
.message-text code {
    padding: 0.125rem 0.375rem;
    border-radius: var(--rs-radius-sm);
    font-size: 0.875rem;
    font-family: var(--rs-font-mono);
    background-color: var(--rs-surface-subtle);
    color: var(--rs-accent-ink);
    border: 1px solid var(--rs-border-subtle);
}

.message-text .rs-chat-table > :not(caption) > * {
    border-width: 1px 0;
}

.message-text .rs-chat-table > :not(caption) > * > * {
    border-width: 0 1px;
}

.message-actions {
    display: flex;
    justify-content: flex-end;
    gap: 0.5rem;
}

/* Token Usage Indicator */
.ai-token-usage-indicator {
    cursor: help;
    display: flex;
    align-items: center;
    font-size: 0.75rem;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.ai-token-usage-indicator:hover {
    opacity: 1;
}

.ai-token-usage-indicator i {
    font-size: 0.625rem;
}

/* Streaming Animation */
.blinking-cursor {
    animation: blink 1s infinite;
    font-weight: bold;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0; }
}

/* Scrollbar styling for messages container */
.ai-chat-messages::-webkit-scrollbar {
    width: 6px;
}

.ai-chat-messages::-webkit-scrollbar-track {
    background: var(--rs-surface-subtle);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: var(--rs-border);
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: var(--rs-control-frame);
}

/* Input area styling */
.ai-chat-input textarea {
    resize: none;
    border: 1px solid var(--rs-border);
}

.ai-chat-input textarea:focus {
    border-color: var(--rs-accent);
    box-shadow: var(--rs-focus-ring);
}

/* Header sizing within chat messages */
.ai-chat-message .message-text h1 {
    font-size: 1.25rem;
    margin: 0.25rem 0;
}

.ai-chat-message .message-text h2 {
    font-size: 1.125rem;
    margin: 0.25rem 0;
}

.ai-chat-message .message-text h3 {
    font-size: 1rem;
    margin: 0.25rem 0;
}

.ai-chat-message .message-text h4 {
    font-size: 0.95rem;
    margin: 0.25rem 0;
}

.ai-chat-message .message-text h5 {
    font-size: 0.9rem;
    margin: 0.25rem 0;
}

.ai-chat-message .message-text h6 {
    font-size: 0.85rem;
    margin: 0.25rem 0;
}

/* Contenteditable Editor Styling */
.ai-chat-input .editor {
    min-height: 2.5rem;
    max-height: 7rem;
    overflow-y: auto;
    padding: 0.25rem 0.5rem;
    border: 1px solid var(--rs-control-frame);
    border-radius: var(--rs-radius-md);
    background-color: var(--rs-surface-panel);
    line-height: 1.4;
    resize: none;
}

.ai-chat-input .editor:focus {
    border-color: var(--rs-accent);
    box-shadow: var(--rs-focus-ring);
    outline: none;
}

.ai-chat-input .editor:empty:before {
    content: attr(data-placeholder);
    color: var(--rs-text-placeholder);
    pointer-events: none;
}


/* Mentions (command prompt chips) */
.ai-chat-input .editor .cp-chip,
.ai-chat-message .message-text .cp-chip {
    margin: 0 0.125rem;
    line-height: 1.25;
    user-select: none;
}

.ai-chat-input--report-generator .editor .cp-chip,
.rs-generator .rs-generator__timeline .message-text .cp-chip {
    max-width: 100%;
    font-size: 14px;
    font-weight: 600;
    line-height: 1.5;
    white-space: normal;
    overflow-wrap: anywhere;
}

/* Mentions palette dropdown tweaks */
.mentions-palette {
    width: min(900px, calc(100vw - 24px));
    height: min(520px, calc(100vh - 24px));
    padding: 0;
}

/* Compact palette for narrow containers (non-fullscreen AI chat panel) */
.mentions-palette--compact {
    width: min(352px, calc(100vw - 24px));
}

.mentions-palette-header {
    flex: 0 0 auto;
}

.mentions-palette-heading {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    min-width: 0;
}

.mentions-palette-heading strong {
    font-size: 13px;
    font-weight: 750;
    white-space: nowrap;
}

.mentions-palette-query {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mentions-palette-results {
    padding: 6px;
}

.mentions-palette-footer {
    justify-content: space-between;
    flex: 0 0 auto;
    font-size: 11px;
}

.mentions-palette-continuation-hint {
    text-align: right;
}

.mentions-palette--compact .mentions-palette-footer {
    align-items: flex-start;
    flex-direction: column;
}

.mentions-palette--compact .mentions-palette-continuation-hint {
    text-align: left;
}

.mentions-palette .dropdown-item {
    white-space: normal;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

.mentions-palette .mentions-continuation-result {
    display: grid;
    grid-template-columns: auto minmax(0, 1fr) auto 0.875rem;
    gap: 0.5rem;
    align-items: center;
    min-height: 0;
    margin: 0 0 4px;
    border: 1px solid transparent;
    border-radius: var(--rs-radius-sm);
    background: var(--rs-surface-panel);
    color: var(--rs-organ);
    padding: 0.18rem 0.5rem;
}

.mentions-palette .mentions-continuation-result:hover {
    border-color: var(--rs-accent);
}

.mentions-palette .mentions-continuation-kind {
    padding: 0.125rem 0.3125rem;
    font-size: 8px;
    font-weight: 800;
    letter-spacing: 0.06em;
}

.mentions-palette .mentions-continuation-name {
    overflow: hidden;
    min-width: 0;
    font-size: 12px;
    font-weight: 700;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.mentions-palette .mentions-continuation-count {
    border-radius: 999px;
    background: var(--rs-surface-panel);
    color: var(--rs-organ);
    padding: 0.125rem 0.375rem;
    font-size: 11px;
    white-space: nowrap;
}

.mentions-palette .mentions-continuation-arrow {
    color: var(--rs-organ);
    font-size: 0.875rem;
    text-align: center;
}

.mentions-palette .mentions-modification-result {
    border: 1px solid transparent;
    border-radius: var(--rs-radius-sm);
    background: var(--rs-surface-panel);
    color: inherit;
    min-height: 0;
    margin-bottom: 4px;
    padding: 0.18rem 0.5rem;
}

.mentions-palette .mentions-modification-result:hover {
    border-color: var(--rs-accent-border);
}

.mentions-palette .mentions-modification-name {
    margin-bottom: 0.125rem;
    font-size: 12px;
    font-weight: 650;
}

.mentions-palette .mentions-preview {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    max-height: 60px;
}

.mentions-palette .mentions-description {
    font-weight: 700;
    color: var(--rs-text);
    font-size: 12px;
    line-height: 18px;
    margin-bottom: 0.125rem;
}
