/* ChatBI — sober terminal-style theme */

/* SQL Syntax Highlighting (dark, muted palette) */
.sql-highlight {
    font-family: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', 'Consolas', monospace;
    font-size: 0.8125rem;
    line-height: 1.6;
    tab-size: 2;
    white-space: pre-wrap;
    word-break: break-word;
}

.sql-keyword { color: #b392f0; font-weight: 600; }
.sql-function { color: #79b8ff; }
.sql-string { color: #9ecbff; }
.sql-number { color: #f8e3a1; }
.sql-comment { color: #6a737d; font-style: italic; }
.sql-table { color: #ffab70; }
.sql-operator { color: #8b949e; }

/* SQL Panel — flat dark block */
.chatbi-sql-panel {
    background: #161b22;
    border: 1px solid #30363d;
    border-radius: 0.375rem;
    overflow: hidden;
    margin-top: 0.5rem;
}

.chatbi-sql-panel .sql-highlight { color: #c9d1d9; }
.chatbi-sql-panel .sql-keyword { color: #d2a8ff; font-weight: 600; }
.chatbi-sql-panel .sql-function { color: #79b8ff; }
.chatbi-sql-panel .sql-string { color: #a5d6ff; }
.chatbi-sql-panel .sql-number { color: #f8e3a1; }
.chatbi-sql-panel .sql-comment { color: #6a737d; }
.chatbi-sql-panel .sql-table { color: #ffa657; }
.chatbi-sql-panel .sql-operator { color: #8b949e; }

/* Data Table — minimal, no rounded corners, thin borders */
.chatbi-data-table {
    border: 1px solid oklch(var(--b3));
    overflow: hidden;
}

.chatbi-data-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.8125rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

.chatbi-data-table thead {
    background: oklch(var(--b2));
    position: sticky;
    top: 0;
    z-index: 1;
}

.chatbi-data-table th {
    padding: 0.375rem 0.625rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: oklch(var(--bc) / 0.5);
    border-bottom: 1px solid oklch(var(--b3));
    white-space: nowrap;
}

.chatbi-data-table td {
    padding: 0.375rem 0.625rem;
    border-bottom: 1px solid oklch(var(--b3) / 0.3);
    max-width: 250px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chatbi-data-table tbody tr:hover {
    background: oklch(var(--b2) / 0.4);
}

.chatbi-data-table tbody tr:last-child td {
    border-bottom: none;
}

.chatbi-data-table td.num {
    text-align: right;
    font-variant-numeric: tabular-nums;
}

/* Chart container — flat, no gradient header */
.chatbi-chart-container {
    border: 1px solid oklch(var(--b3));
    overflow: hidden;
}

.chatbi-chart-header {
    background: oklch(var(--b2));
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid oklch(var(--b3));
}

.chatbi-chart-body {
    padding: 1rem;
    position: relative;
    min-height: 250px;
    max-height: 350px;
    background: oklch(var(--b1));
}

/* Messages — no avatars, no cards, minimal separation */
.chatbi-msg {
    padding: 0.75rem 0;
}

.chatbi-msg + .chatbi-msg {
    border-top: 1px solid oklch(var(--b3) / 0.2);
}

.chatbi-msg-label {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
    color: oklch(var(--bc) / 0.4);
}

.chatbi-msg-label.user {
    color: oklch(var(--p) / 0.7);
}

.chatbi-msg-content {
    font-size: 0.875rem;
    line-height: 1.7;
    color: oklch(var(--bc) / 0.85);
}

.chatbi-msg.user .chatbi-msg-content {
    color: oklch(var(--bc));
}

.chatbi-msg-content p { margin: 0.25rem 0; }
.chatbi-msg-content strong { color: oklch(var(--bc)); font-weight: 600; }

.chatbi-timing {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.4rem;
    font-size: 0.6875rem;
    color: oklch(var(--bc) / 0.35);
    font-variant-numeric: tabular-nums;
}

.chatbi-msg-content ul,
.chatbi-msg-content ol {
    padding-left: 1.25rem;
    margin: 0.25rem 0;
}

.chatbi-msg-content li { margin: 0.125rem 0; }

.chatbi-msg-content h1,
.chatbi-msg-content h2,
.chatbi-msg-content h3 {
    font-weight: 700;
    margin: 0.5rem 0 0.25rem 0;
    color: oklch(var(--bc));
}

.chatbi-msg-content h1 { font-size: 1.0625rem; }
.chatbi-msg-content h2 { font-size: 0.9375rem; }
.chatbi-msg-content h3 { font-size: 0.875rem; }

.chatbi-msg-content code {
    background: oklch(var(--b2));
    padding: 0.125rem 0.375rem;
    border-radius: 0.1875rem;
    font-size: 0.8125rem;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
}

/* Markdown table inside messages */
.chatbi-msg-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 0.5rem 0;
    font-size: 0.8125rem;
    border: 1px solid oklch(var(--b3));
}

.chatbi-msg-content table th {
    background: oklch(var(--b2));
    padding: 0.375rem 0.625rem;
    text-align: left;
    font-weight: 600;
    font-size: 0.75rem;
    border-bottom: 1px solid oklch(var(--b3));
}

.chatbi-msg-content table td {
    padding: 0.375rem 0.625rem;
    border-bottom: 1px solid oklch(var(--b3) / 0.3);
}

.chatbi-msg-content table tbody tr:hover {
    background: oklch(var(--b2) / 0.4);
}

/* Row count — plain text, no badge */
.chatbi-row-count {
    font-size: 0.6875rem;
    color: oklch(var(--bc) / 0.35);
    margin-left: 0.5rem;
}

/* Loading — simple dots animation */
.chatbi-loading {
    padding: 0.75rem 0;
}

.chatbi-loading-dots {
    display: inline-flex;
    gap: 0.25rem;
    align-items: center;
}

.chatbi-loading-dots span {
    width: 0.375rem;
    height: 0.375rem;
    background: oklch(var(--bc) / 0.3);
    border-radius: 50%;
    animation: chatbi-bounce 1.2s ease-in-out infinite;
}

.chatbi-loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.chatbi-loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatbi-bounce {
    0%, 80%, 100% { transform: scale(0.6); opacity: 0.3; }
    40% { transform: scale(1); opacity: 0.8; }
}

.chatbi-loading-elapsed {
    font-size: 0.6875rem;
    color: oklch(var(--bc) / 0.25);
    margin-left: 0.5rem;
    font-variant-numeric: tabular-nums;
}

/* Error messages — distinct red left border */
.chatbi-msg.error .chatbi-msg-label {
    color: oklch(var(--er) / 0.7);
}

.chatbi-msg.error .chatbi-msg-content {
    color: oklch(var(--er) / 0.85);
    border-left: 2px solid oklch(var(--er) / 0.4);
    padding-left: 0.625rem;
}

/* Agent confirm — minimal, no card chrome */
.chatbi-agent-confirm {
    border: 1px solid oklch(var(--wa) / 0.3);
    border-left: 3px solid oklch(var(--wa) / 0.6);
    padding: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.8125rem;
}

.chatbi-agent-confirm .label-text {
    font-size: 0.6875rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: oklch(var(--bc) / 0.4);
}
