﻿/* Ensure full-page layout */
html, body {
    height: 100%;
    margin: 0;
    padding: 0;
    overflow: hidden;
}

/* Chat container fills available space while leaving room for footer */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px); /* Leaves space for footer */
    background-color: #FFFFFF;
}

/* Messages area takes up all space between header & input */
.chat-messages {
    flex-grow: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    padding: 20px;
}

/* Chat message wrapper */
.chat-message-container {
    display: flex;
    align-items: flex-start;
    width: 100%;
    margin-bottom: 10px;
}

/* Align AI messages to the left */
.ai-message-container {
    justify-content: flex-start;
}

/* Align User messages to the right */
.user-message-container {
    justify-content: flex-end;
}

/* Chat message bubbles */
.chat-message {
    max-width: 60%;
    padding: 12px;
    border-radius: 10px;
    word-wrap: break-word;
}

/* User messages */
.user-message {
    background-color: #f1f1f1;
    color: black;
    border-bottom-right-radius: 5px;
    align-self: flex-end;
}

/* Ensure AI messages are stacked correctly */
.ai-message-container {
    display: flex;
    flex-direction: column; /* Stack avatar above response */
    align-items: flex-start;
    width: 100%;
    margin-bottom: 15px;
}

/* AI Message Header (Holds Avatar or Animation) */
.ai-message-header {
    display: flex;
    align-items: center;
    margin-bottom: 5px; /* Adds spacing between avatar and response */
}

/* AI Message Bubble */
.ai-message {
    background-color: #f1f1f1;
    color: black;
    padding: 12px;
    border-radius: 10px;
    max-width: 60%;
    word-wrap: break-word;
    border-bottom-left-radius: 5px;
}

/* AI Avatar */
.ai-avatar {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

/* AI Thinking Animation (Same Size as Avatar) */
.ai-animation {
    width: 40px; /* Match avatar size */
    height: 40px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    overflow: hidden;
}

.ai-animation video {
    width: 100%; /* Half the avatar size */
    height: 100%;
    object-fit: cover;
    border-radius: 50%;
}

.highchart-container {
    width: 100%;
    min-width: 500px;
    margin: 10px 0;
    border-radius: 8px;
    overflow: hidden;
}

.highchart {
    min-height: 400px;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

/* Chat input bar */
.chat-input-container {
    display: flex;
    align-items: center;
    padding: 10px;
    background-color: white;
    border-top: 1px solid #ddd;
    gap: 10px;
    width: 100%;
    position: relative;
}

/* Siri-style AI typing animation */
.ai-wave-container {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 40px;
    margin-top: 10px;
}

.wave {
    width: 6px;
    height: 20px;
    margin: 0 4px;
    background-color: #007aff;
    border-radius: 10px;
    animation: wave-animation 1.2s infinite ease-in-out;
}

.ai-disclaimer {
    font-size: 0.8rem;
    color: #888;
    margin-top: 8px;
    font-style: italic;
}

@keyframes wave-animation {
    0%, 100% { transform: scaleY(0.3); opacity: 0.5; }
    50% { transform: scaleY(1); opacity: 1; }
}

.initial-greeting {
    text-align: center;
    padding: 15px;
}

.logo-container {
    margin-bottom: 10px;
}

.beatcortex-logo {
    height: 35px;
    width: auto;
    vertical-align: middle;
    margin-left: 8px;
}

.website-link {
    display: inline-block;
    margin-top: 10px;
    color: #3f51b5;
    text-decoration: none;
    font-weight: bold;
}

.website-link:hover {
    text-decoration: underline;
}

/* ============================================ */
/* AI RESPONSE CONTENT FORMATTING */
/* ============================================ */

/* Typography for AI responses - targeting MudBlazor chat bubbles */
.chat-messages .mud-chat-bubble p,
.chat-messages .ai-message p {
    margin: 0.75em 0 !important;
    line-height: 1.6 !important;
    color: #333 !important;
}

.chat-messages .mud-chat-bubble p:first-child,
.chat-messages .ai-message p:first-child {
    margin-top: 0 !important;
}

.chat-messages .mud-chat-bubble p:last-child,
.chat-messages .ai-message p:last-child {
    margin-bottom: 0 !important;
}

/* Headings in AI responses */
.chat-messages .mud-chat-bubble h1,
.chat-messages .mud-chat-bubble h2,
.chat-messages .mud-chat-bubble h3,
.chat-messages .mud-chat-bubble h4,
.chat-messages .mud-chat-bubble h5,
.chat-messages .mud-chat-bubble h6,
.chat-messages .ai-message h1,
.chat-messages .ai-message h2,
.chat-messages .ai-message h3,
.chat-messages .ai-message h4,
.chat-messages .ai-message h5,
.chat-messages .ai-message h6 {
    margin-top: 1.5em !important;
    margin-bottom: 0.75em !important;
    font-weight: 600 !important;
    line-height: 1.3 !important;
    color: #1a1a1a !important;
}

.chat-messages .mud-chat-bubble h1,
.chat-messages .ai-message h1 {
    font-size: 2em !important;
    border-bottom: 2px solid #e0e0e0 !important;
    padding-bottom: 0.3em !important;
}

.chat-messages .mud-chat-bubble h2,
.chat-messages .ai-message h2 {
    font-size: 1.75em !important;
    border-bottom: 1px solid #e0e0e0 !important;
    padding-bottom: 0.3em !important;
}

.chat-messages .mud-chat-bubble h3,
.chat-messages .ai-message h3 {
    font-size: 1.5em !important;
}

.chat-messages .mud-chat-bubble h4,
.chat-messages .ai-message h4 {
    font-size: 1.25em !important;
}

.chat-messages .mud-chat-bubble h5,
.chat-messages .ai-message h5 {
    font-size: 1.1em !important;
}

.chat-messages .mud-chat-bubble h6,
.chat-messages .ai-message h6 {
    font-size: 1em !important;
    color: #666 !important;
}

/* Lists in AI responses - CRITICAL SPACING */
.chat-messages .mud-chat-bubble ul,
.chat-messages .mud-chat-bubble ol,
.chat-messages .ai-message ul,
.chat-messages .ai-message ol {
    margin: 1em 0 !important;
    padding-left: 2.5em !important;
    line-height: 1.8 !important;
}

.chat-messages .mud-chat-bubble ul,
.chat-messages .ai-message ul {
    list-style-type: disc !important;
}

.chat-messages .mud-chat-bubble ol,
.chat-messages .ai-message ol {
    list-style-type: decimal !important;
}

.chat-messages .mud-chat-bubble li,
.chat-messages .ai-message li {
    margin: 0.75em 0 !important;
    padding-left: 0.5em !important;
    display: list-item !important;
}

/* Nested lists */
.chat-messages .mud-chat-bubble ul ul,
.chat-messages .ai-message ul ul {
    list-style-type: circle !important;
    margin-top: 0.5em !important;
    margin-left: 1em !important;
}

.chat-messages .mud-chat-bubble ul ul ul,
.chat-messages .ai-message ul ul ul {
    list-style-type: square !important;
}

.chat-messages .mud-chat-bubble ol ol,
.chat-messages .ai-message ol ol {
    list-style-type: lower-alpha !important;
}

.chat-messages .mud-chat-bubble ol ol ol,
.chat-messages .ai-message ol ol ol {
    list-style-type: lower-roman !important;
}

/* Code blocks */
.chat-messages .mud-chat-bubble pre,
.chat-messages .ai-message pre {
    background-color: #f5f5f5 !important;
    border: 1px solid #ddd !important;
    border-radius: 4px !important;
    padding: 1em !important;
    margin: 1em 0 !important;
    overflow-x: auto !important;
    font-family: 'Courier New', Courier, monospace !important;
    font-size: 0.9em !important;
    line-height: 1.4 !important;
}

.chat-messages .mud-chat-bubble code,
.chat-messages .ai-message code {
    background-color: #f5f5f5 !important;
    padding: 0.2em 0.4em !important;
    border-radius: 3px !important;
    font-family: 'Courier New', Courier, monospace !important;
    font-size: 0.9em !important;
    color: #d73a49 !important;
}

.chat-messages .mud-chat-bubble pre code,
.chat-messages .ai-message pre code {
    background-color: transparent !important;
    padding: 0 !important;
    color: inherit !important;
}

/* Blockquotes */
.chat-messages .mud-chat-bubble blockquote,
.chat-messages .ai-message blockquote {
    margin: 1em 0 !important;
    padding: 0.5em 1em !important;
    border-left: 4px solid #27315e !important;
    background-color: #f9f9f9 !important;
    color: #666 !important;
    font-style: italic !important;
}

.chat-messages .mud-chat-bubble blockquote p,
.chat-messages .ai-message blockquote p {
    margin: 0.5em 0 !important;
}

/* Tables */
.chat-messages .mud-chat-bubble table,
.chat-messages .ai-message table {
    border-collapse: collapse !important;
    width: 100% !important;
    margin: 1em 0 !important;
    font-size: 0.95em !important;
}

.chat-messages .mud-chat-bubble table th,
.chat-messages .mud-chat-bubble table td,
.chat-messages .ai-message table th,
.chat-messages .ai-message table td {
    border: 1px solid #ddd !important;
    padding: 0.75em !important;
    text-align: left !important;
}

.chat-messages .mud-chat-bubble table th,
.chat-messages .ai-message table th {
    background-color: #27315e !important;
    color: white !important;
    font-weight: 600 !important;
}

.chat-messages .mud-chat-bubble table tr:nth-child(even),
.chat-messages .ai-message table tr:nth-child(even) {
    background-color: #f9f9f9 !important;
}

.chat-messages .mud-chat-bubble table tr:hover,
.chat-messages .ai-message table tr:hover {
    background-color: #f5f5f5 !important;
}

/* Horizontal rules */
.chat-messages .mud-chat-bubble hr,
.chat-messages .ai-message hr {
    border: none !important;
    border-top: 2px solid #e0e0e0 !important;
    margin: 2em 0 !important;
}

/* Links */
.chat-messages .mud-chat-bubble a,
.chat-messages .ai-message a {
    color: #27315e !important;
    text-decoration: underline !important;
}

.chat-messages .mud-chat-bubble a:hover,
.chat-messages .ai-message a:hover {
    color: #1a2340 !important;
    text-decoration: none !important;
}

/* Strong and emphasis */
.chat-messages .mud-chat-bubble strong,
.chat-messages .ai-message strong {
    font-weight: 700 !important;
    color: #1a1a1a !important;
}

.chat-messages .mud-chat-bubble em,
.chat-messages .ai-message em {
    font-style: italic !important;
    color: #333 !important;
}

/* Definition lists */
.chat-messages .mud-chat-bubble dl,
.chat-messages .ai-message dl {
    margin: 1em 0 !important;
}

.chat-messages .mud-chat-bubble dt,
.chat-messages .ai-message dt {
    font-weight: 600 !important;
    margin-top: 0.5em !important;
    color: #1a1a1a !important;
}

.chat-messages .mud-chat-bubble dd,
.chat-messages .ai-message dd {
    margin-left: 2em !important;
    margin-bottom: 0.5em !important;
    color: #333 !important;
}

/* Images */
.chat-messages .mud-chat-bubble img,
.chat-messages .ai-message img {
    max-width: 100% !important;
    height: auto !important;
    margin: 1em 0 !important;
    border-radius: 4px !important;
}

/* Math rendering */
.chat-messages .mud-chat-bubble .MathJax,
.chat-messages .ai-message .MathJax {
    margin: 0.5em 0 !important;
}

.chat-messages .mud-chat-bubble .MathJax_Display,
.chat-messages .ai-message .MathJax_Display {
    margin: 1em 0 !important;
}

/* Scrollbar styling for chat messages */
.chat-messages::-webkit-scrollbar {
    width: 8px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

.chat-messages::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .chat-messages .mud-chat-bubble table,
    .chat-messages .ai-message table {
        font-size: 0.85em !important;
    }

    .chat-messages .mud-chat-bubble pre,
    .chat-messages .ai-message pre {
        font-size: 0.8em !important;
        padding: 0.75em !important;
    }
}