/* Shared chat styles used by AiChat and ReportGeneration chat panels */

.report-chat-panel {
    border: 1px solid var(--rs-border);
}

/* Keep a single separator under header; remove the one under model selector */
.report-chat-panel .ai-chat-header { border-bottom: 1px solid var(--rs-border) !important; }
.report-chat-panel .ai-chat-model-selector { border-bottom: 0 !important; }

.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: #f8f9fa;
}

/* 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: #eef6ff;
    border: 1px dashed #b6d4fe;
}
.ai-tool-message .message-text pre {
    background-color: #f8fafc;
}

.message-content {
    background-color: var(--rs-surface);
    border-radius: 0.5rem;
    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: color-mix(in srgb, rgb(var(--rs-primary)) 12%, var(--rs-surface));
    color: var(--rs-text);
    border: 1px solid var(--rs-border);
}

.ai-chat-message.user .message-role { color: var(--rs-muted); }

.message-role {
    display: flex;
    align-items: center;
    margin-bottom: 0.25rem;
    font-size: 0.8125rem;
}

.message-text {
    word-wrap: break-word;
    line-height: 1.35;
}

/* Code blocks - general styling */
.message-text pre {
    border-radius: 0.375rem;
    padding: 0.5rem;
    margin: 0.375rem 0;
    overflow-x: auto;
    font-size: 0.875rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    line-height: 1.35;
    border: 1px solid rgba(0, 0, 0, 0.1);
    background-color: #f8f9fa;
    color: #212529;
}

/* Code blocks in user messages (blue background) */
/* Match default code styling inside user messages */
.ai-chat-message.user .message-text pre {
    background-color: #f8f9fa;
    color: #212529;
    border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Inline code - general styling */
.message-text code {
    padding: 0.125rem 0.375rem;
    border-radius: 0.25rem;
    font-size: 0.875rem;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    background-color: rgba(0, 0, 0, 0.08);
    color: #d63384;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Inline code in user messages (blue background) */
/* Match default inline code styling inside user messages */
.ai-chat-message.user .message-text code {
    background-color: rgba(0, 0, 0, 0.08);
    color: #d63384;
    border: 1px solid rgba(0, 0, 0, 0.05);
}

.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: #f1f1f1;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 3px;
}

.ai-chat-messages::-webkit-scrollbar-thumb:hover {
    background: #a8a8a8;
}

/* Input area styling */
.ai-chat-input textarea {
    resize: none;
    border: 1px solid #dee2e6;
}

.ai-chat-input textarea:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

/* Button styling */
.ai-chat-input .btn-primary:disabled {
    opacity: 0.5;
}

/* Empty state styling */
.ai-chat-messages .text-center.text-muted {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
}

/* Ensure proper spacing in model selector */
.ai-chat-model-selector .form-select-sm {
    font-size: 0.875rem;
}

/* 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 #dee2e6;
    border-radius: 0.375rem;
    background-color: #fff;
    line-height: 1.4;
    resize: none;
}

.ai-chat-input .editor:focus {
    border-color: #007bff;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
    outline: none;
}

.ai-chat-input .editor:empty:before {
    content: attr(data-placeholder);
    color: #6c757d;
    pointer-events: none;
}


/* Mentions (command prompt chips) */
.ai-chat-input .editor .cp-chip,
.ai-chat-message .message-text .cp-chip,
.chip {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.5rem;
    margin: 0 0.125rem;
    border-radius: 999px;
    background-color: color-mix(in srgb, rgb(var(--rs-primary)) 12%, transparent);
    color: rgb(var(--rs-primary));
    border: 1px solid color-mix(in srgb, rgb(var(--rs-primary)) 30%, transparent);
    font-weight: 500;
    line-height: 1.25;
    white-space: nowrap;
    user-select: none;
}

/* Chips inside user (blue) messages — invert for contrast */
/* Align chips with default tinting inside user messages */
.ai-chat-message.user .message-text .cp-chip {
    background-color: color-mix(in srgb, rgb(var(--rs-primary)) 12%, transparent);
    color: rgb(var(--rs-primary));
    border: 1px solid color-mix(in srgb, rgb(var(--rs-primary)) 30%, transparent);
}

/* Mentions palette dropdown tweaks */
.mentions-palette {
    min-width: 28rem;
    max-width: 42rem;
    padding: 0.375rem;
}

/* Compact palette for narrow containers (non-fullscreen AI chat panel) */
.mentions-palette--compact {
    min-width: auto;
    max-width: 22rem;
}

.mentions-palette--compact .mentions-preview {
    display: none;
}

.mentions-palette .dropdown-item {
    white-space: normal;
    padding: 0.5rem 0.75rem;
    font-size: 0.8125rem;
}

.mentions-palette .dropdown-item .fw-medium {
    font-size: 0.875rem;
    margin-bottom: 0.25rem;
}

/* Improve readability of the currently selected mention */
.mentions-palette .dropdown-item.active,
.mentions-palette .dropdown-item.active .fw-medium {
    color: #fff !important;
}
.mentions-palette .dropdown-item.active small,
.mentions-palette .dropdown-item.active .text-muted {
    color: rgba(255, 255, 255, 0.9) !important;
    opacity: 1 !important;
}

.mentions-palette .mentions-preview {
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    line-height: 1.35;
    max-height: 4.05em;
    font-size: 0.75rem;
}

.mentions-palette .mentions-description {
    font-weight: 700;
    font-size: 0.8125rem;
    line-height: 1.25;
    margin-bottom: 0.125rem;
}
