/* ============================================================
   AI Chatbot Test Page — aitesting.css
   Redesigned to match EffectStats design language.
   All new selectors scoped to .aitest-* to avoid collisions.
   ============================================================ */

/* ------------------------------------------------------------
   Page layout
   ------------------------------------------------------------ */

.aitest-page {
    max-width: 1000px;
}

/* ------------------------------------------------------------
   Page header
   ------------------------------------------------------------ */

.aitest-page-header {
    padding-bottom: 28px;
}

.aitest-page-title {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text, #0f172a);
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 4px;
    line-height: 1.3;
}

.aitest-beta-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 10px;
    background: #dbeafe;
    color: #1d4ed8;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 700;
    letter-spacing: 0.06em;
    text-transform: uppercase;
    vertical-align: middle;
    line-height: 1.8;
    margin-top: 2px;
}

.aitest-page-subtitle {
    color: var(--muted, #6b7280);
    font-size: 0.9rem;
    margin: 0;
    max-width: 680px;
    line-height: 1.6;
}

/* ------------------------------------------------------------
   Chat card
   ------------------------------------------------------------ */

.aitest-chat-card {
    overflow: hidden;
    margin-bottom: 24px;
}

.aitest-chat-heading {
    font-size: 1rem;
    font-weight: 600;
    color: #2d3748;
}

/* Chat messages scroll area */
.aitest-chat-window {
    min-height: 400px;
    height: 480px;
    overflow-y: auto;
    padding: 16px;
    background: #f8fafc;
    display: flex;
    flex-direction: column;
    gap: 10px;
    scroll-behavior: smooth;
}

.aitest-chat-window::-webkit-scrollbar {
    width: 4px;
}

.aitest-chat-window::-webkit-scrollbar-track {
    background: transparent;
}

.aitest-chat-window::-webkit-scrollbar-thumb {
    background: #e2e8f0;
    border-radius: 4px;
}

.aitest-chat-window::-webkit-scrollbar-thumb:hover {
    background: #cbd5e1;
}

/* Welcome state */
.aitest-welcome {
    align-self: center;
    text-align: center;
    color: #64748b;
    font-size: 0.875rem;
    padding: 32px 20px;
    max-width: 400px;
    margin: auto;
    line-height: 1.6;
}

.aitest-welcome-icon {
    font-size: 2.5rem;
    color: #93c5fd;
    display: block;
    margin-bottom: 14px;
}

/* Message bubbles */
.aitest-msg {
    font-size: 0.9rem;
    line-height: 1.55;
    max-width: 82%;
    word-break: break-word;
}

/* User bubble — right-aligned, primary blue */
.aitest-msg-user {
    align-self: flex-end;
    background: var(--primary, #2563eb);
    color: #fff;
    border-radius: 14px 14px 4px 14px;
    padding: 10px 14px;
}

.aitest-msg-user b {
    display: block;
    font-size: 0.7rem;
    opacity: 0.75;
    margin-bottom: 3px;
}

.aitest-msg-user .dash-markdown {
    color: #fff;
    font-size: 0.9rem;
}

.aitest-msg-user .dash-markdown p:last-child {
    margin-bottom: 0;
}

/* Bot bubble — left-aligned, light surface */
.aitest-msg-bot {
    align-self: flex-start;
    background: #f1f5f9;
    color: #1e293b;
    border-radius: 14px 14px 14px 4px;
    padding: 10px 14px;
}

.aitest-msg-bot b {
    display: block;
    font-size: 0.7rem;
    color: #64748b;
    margin-bottom: 3px;
}

.aitest-msg-bot .dash-markdown {
    font-size: 0.9rem;
    color: #1e293b;
}

.aitest-msg-bot .dash-markdown p:last-child {
    margin-bottom: 0;
}

.aitest-msg-bot .dash-markdown table {
    font-size: 0.8rem;
    width: 100%;
    border-collapse: collapse;
    margin: 6px 0;
}

.aitest-msg-bot .dash-markdown th,
.aitest-msg-bot .dash-markdown td {
    border: 1px solid #e2e8f0;
    padding: 4px 8px;
    text-align: left;
}

.aitest-msg-bot .dash-markdown th {
    background: #e8edf4;
    font-weight: 600;
}

.aitest-msg-bot .dash-markdown blockquote {
    border-left: 3px solid #93c5fd;
    padding-left: 10px;
    margin: 6px 0;
    color: #475569;
    font-style: italic;
}

/* Thinking indicator */
.aitest-thinking {
    align-self: flex-start;
    color: #94a3b8;
    font-size: 0.82rem;
    padding: 8px 12px;
    background: #ffffff;
    border-radius: 14px 14px 14px 4px;
    border: 1px solid #e2e8f0;
}

/* Tool notification */
.aitest-tool-note {
    align-self: flex-start;
    font-size: 0.78rem;
    padding: 2px 0;
}

/* Error bubble */
.aitest-msg-error {
    align-self: flex-start;
    background: #fef2f2;
    color: #b91c1c;
    border: 1px solid #fecaca;
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 0.9rem;
    max-width: 92%;
}

/* Input bar */
.aitest-chat-input-bar {
    padding: 12px 16px;
    border-top: 1px solid #edf2f7;
    background: #ffffff;
}

.aitest-chat-input-bar .input-group {
    align-items: stretch;
}

.aitest-chat-input-bar .input-group .btn {
    height: auto;
}

.aitest-chat-input-bar textarea {
    border-radius: 10px !important;
    border-color: #e2e8f0 !important;
    background: #f8fafc !important;
    transition: border-color 0.15s ease, box-shadow 0.15s ease, background 0.15s ease !important;
}

.aitest-chat-input-bar textarea:focus {
    border-color: #93c5fd !important;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.12) !important;
    background: #ffffff !important;
}

/* ------------------------------------------------------------
   Conversation list (offcanvas sidebar)
   ------------------------------------------------------------ */

.conv-date-group {
    font-size: 0.72rem;
    color: #6c757d;
    margin: 12px 0 4px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
}

.conv-item-wrap {
    display: flex;
    align-items: center;
    padding: 6px 8px;
    border-radius: 8px;
    margin-bottom: 2px;
    cursor: pointer;
    transition: background 0.12s;
}

.conv-item-wrap:hover {
    background: rgba(0, 0, 0, 0.05);
}

.conv-item-active {
    background: #eff6ff !important;
    border-left: 3px solid var(--primary, #2563eb);
}

.conv-item-title {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-size: 0.875rem;
    color: #212529;
    cursor: pointer;
}

.conv-item-actions {
    display: flex;
    gap: 2px;
    opacity: 0;
    transition: opacity 0.12s;
    flex-shrink: 0;
}

.conv-item-wrap:hover .conv-item-actions {
    opacity: 1;
}

.conv-action-btn {
    padding: 1px 5px !important;
    font-size: 0.72rem !important;
    line-height: 1.5 !important;
    border: 1px solid #dee2e6 !important;
}

/* ------------------------------------------------------------
   Custom Dashboard / SQL panel
   ------------------------------------------------------------ */

.aitest-sql-card {
    margin-top: 8px;
}

.aitest-sql-placeholder {
    text-align: center;
    color: var(--muted, #6b7280);
    padding: 32px 16px;
    font-size: 0.9rem;
}

.aitest-sql-placeholder-icon {
    font-size: 2rem;
    color: #cbd5e1;
    display: block;
    margin-bottom: 12px;
}

.aitest-sql-error {
    color: #dc3545;
    font-size: 0.85rem;
    margin-top: 8px;
}

/* ------------------------------------------------------------
   Responsive adjustments
   ------------------------------------------------------------ */

@media (max-width: 768px) {
    .aitest-chat-window {
        height: 380px;
    }

    .aitest-msg {
        max-width: 95%;
    }

    .aitest-page-title {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .aitest-chat-window {
        height: 320px;
    }
}

