/* Modern AI Tool Styles */
:root {
    --user-bubble-bg: #f8fafc;
    --assistant-bubble-bg: #ffffff;
    --reasoning-bg: #f8fafc;
    --border-subtle: #e2e8f0;
    --chat-bg: #f1f5f9;
    --user-border: #6366f1;
    --assistant-border: #10b981;
    --intermediate-border: #10b981;
}

@media (prefers-color-scheme: dark) {
    :root {
        --user-bubble-bg: #1e293b;
        --assistant-bubble-bg: #1e293b;
        --reasoning-bg: rgba(15, 23, 42, 0.3);
        --border-subtle: rgba(255, 255, 255, 0.05);
        --chat-bg: #0f172a;
    }
}

.dark {
    --user-bubble-bg: #1e293b;
    --assistant-bubble-bg: #1e293b;
    --reasoning-bg: rgba(15, 23, 42, 0.3);
    --border-subtle: rgba(255, 255, 255, 0.05);
    --chat-bg: #0f172a;
}

.assistant-message {
    background: var(--assistant-bubble-bg) !important;
    backdrop-filter: blur(8px);
    border: 1px solid var(--border-subtle) !important;
    border-left: 4px solid var(--assistant-border) !important;
    border-radius: 0.75rem !important;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    animation: slideInUp 0.3s ease-out;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06) !important;
}

.assistant-message.is-intermediate {
    border-left-color: var(--intermediate-border) !important;
}

.dark .assistant-message {
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    color: #f1f5f9 !important; 
}

.markdown-preview {
    white-space: normal;
    line-height: 1.625;
    letter-spacing: -0.011em;
    font-size: 0.9375rem; /* ~15px for better clarity */
    font-weight: 400;
}

.markdown-preview > *:last-child {
    margin-bottom: 0 !important;
}

.markdown-preview p {
    margin-bottom: 0.75em;
}

.markdown-preview ul, .markdown-preview ol {
    margin-bottom: 0.75em;
    margin-top: 0.25em;
    padding-left: 1.5em;
}

.markdown-preview li {
    margin-bottom: 0.35em;
}

.markdown-preview h1, .markdown-preview h2, .markdown-preview h3, .markdown-preview h4 {
    margin-top: 1.25em;
    margin-bottom: 0.5em;
    line-height: 1.35;
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Force light text color on all nested elements in dark mode */
.dark .assistant-message *,
.dark .assistant-message p,
.dark .assistant-message li,
.dark .assistant-message span,
.dark .assistant-message div:not(.thought-panel),
.dark .assistant-message .markdown-preview * {
    color: #e2e8f0 !important;
}

.dark .assistant-message .markdown-preview h1,
.dark .assistant-message .markdown-preview h2,
.dark .assistant-message .markdown-preview h3,
.dark .assistant-message .markdown-preview strong {
    color: #ffffff !important;
}

.user-message-container {
    background: var(--user-bubble-bg) !important;
    border: 1px solid var(--border-subtle) !important;
    border-left: 4px solid var(--user-border) !important;
    border-radius: 0.75rem !important;
    font-family: 'Inter', sans-serif;
    animation: slideInUp 0.3s ease-out;
    overflow-wrap: anywhere;
    word-break: break-word;
    white-space: pre-wrap;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1) !important;
}

.user-message-container *,
.user-message-container p,
.user-message-container span,
.user-message-container .markdown-preview * {
    color: #0f172a !important;
}

.dark .user-message-container *,
.dark .user-message-container p,
.dark .user-message-container span,
.dark .user-message-container .markdown-preview * {
    color: #f1f5f9 !important;
}

@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(10px) scale(0.98);
    }

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

.thought-panel {
    background: var(--reasoning-bg);
    border-left: 3px solid #6366f1;
    border-radius: 0 0.75rem 0.75rem 0;
    margin: 0.5rem 0;
}

.status-chip {
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

/* Scoped to .assistant-message */
.assistant-message code {
    color: #818cf8;
    font-size: 90%;
    background-color: rgba(99, 102, 241, 0.1);
    border-radius: 4px;
    padding: 2px 4px;
}

.assistant-message pre {
    background-color: #0f172a;
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #e2e8f0;
    padding: 1.25rem;
    border-radius: 0.75rem;
    max-width: 100%;
    overflow-x: auto;
}

.streaming-dots::after {
    content: '';
    animation: dots 1.5s steps(5, end) infinite;
}

@keyframes dots {
    0%, 20%, 40%, 60%, 80%, 100% {
        content: '';
    }
}

.assistant-message strong {
    font-weight: 700;
    color: #6366f1;
}

/* Sub-agent thought blocks */
.thought-panel blockquote {
    border-left: 2px solid rgba(99, 102, 241, 0.4) !important;
    background: rgba(99, 102, 241, 0.05) !important;
    margin: 0.5rem 0 0.5rem 0.5rem !important;
    padding: 0.4rem 0.6rem !important;
    border-radius: 0.5rem !important;
    font-size: 0.75rem !important;
    line-height: 1.4 !important;
    color: #4f46e5 !important;
}

.thought-panel .markdown-preview p {
    margin-bottom: 0.4em !important;
}

.dark .thought-panel blockquote {
    color: #818cf8 !important;
    background: rgba(129, 140, 248, 0.05) !important;
}

.thought-panel blockquote p {
    margin: 0 !important;
}

.thought-panel blockquote strong {
    color: #4338ca;
    text-transform: uppercase;
    letter-spacing: 0.025em;
    font-size: 0.65rem;
}

.dark .thought-panel blockquote strong {
    color: #a5b4fc;
}

.chat-history-container {
    background-color: var(--chat-bg) !important;
}
/* Table Styles - Added for Professional Technical Reports */
.markdown-preview table {
    width: 100% !important;
    border-collapse: collapse !important;
    margin: 1.25rem 0 !important;
    font-size: 0.8125rem !important;
    border: 1px solid var(--border-subtle) !important;
    border-radius: 0.75rem !important;
    overflow: hidden !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
}

.markdown-preview th {
    background: rgba(99, 102, 241, 0.05) !important;
    font-weight: 800 !important;
    text-transform: uppercase !important;
    letter-spacing: 0.05em !important;
    font-size: 0.7rem !important;
    padding: 0.875rem 1rem !important;
    text-align: left !important;
    border-bottom: 2px solid var(--border-subtle) !important;
    color: #4f46e5 !important;
}

.markdown-preview td {
    padding: 0.875rem 1rem !important;
    border-bottom: 1px solid var(--border-subtle) !important;
    line-height: 1.5 !important;
    vertical-align: top !important;
}

.dark .markdown-preview td {
    border-bottom-color: rgba(255, 255, 255, 0.05) !important;
}

.dark .markdown-preview th {
    background: rgba(255, 255, 255, 0.03) !important;
    color: #818cf8 !important;
}

/* Clear Hyperlink Styling */
.markdown-preview a {
    color: #4f46e5 !important;
    text-decoration: underline !important;
    font-weight: 600 !important;
    transition: opacity 0.2s;
    word-break: break-all;
}

.markdown-preview a:hover {
    opacity: 0.8 !important;
}

.dark .markdown-preview a {
    color: #818cf8 !important;
}

