:root {
    --primary-color: #BFDBFE; /* Light Blue */
    --secondary-color: #93C5FD;
    --accent-color: #3B82F6; /* Darker blue */
    --bg-color: #EFF6FF;
    --text-color: #334155;
    --white: #FFFFFF;
    --bot-msg-bg: #FFFFFF;
    --user-msg-bg: #BFDBFE;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Nunito', sans-serif;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
}

.chat-container {
    width: 100%;
    max-width: 600px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--white);
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
}

@media (min-width: 640px) {
    .chat-container {
        height: 90vh;
        border-radius: 24px;
        overflow: hidden;
    }
}

.chat-header {
    background: var(--primary-color);
    padding: 16px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 2px solid var(--secondary-color);
}

.header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.avatar {
    width: 44px;
    height: 44px;
    background: var(--white);
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 20px;
    color: var(--accent-color);
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.chat-header h1 {
    font-size: 1.2rem;
    font-weight: 800;
    color: var(--accent-color);
}

.chat-header p {
    font-size: 0.85rem;
    color: var(--text-color);
    opacity: 0.9;
}

#reset-btn {
    background: rgba(255,255,255,0.6);
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    cursor: pointer;
    color: var(--accent-color);
    transition: all 0.2s ease;
}

#reset-btn:hover {
    background: var(--white);
    transform: scale(1.1);
}

.chat-box {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    background: #F8FAFC;
    scroll-behavior: smooth;
}

.message-row {
    display: flex;
    width: 100%;
}

.message-row.user {
    justify-content: flex-end;
}

.message-row.bot {
    justify-content: flex-start;
}

.message {
    max-width: 85%;
    padding: 12px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-wrap: break-word;
}

.message.user {
    background: var(--user-msg-bg);
    color: var(--text-color);
    border-bottom-right-radius: 4px;
}

.message.bot {
    background: var(--bot-msg-bg);
    color: var(--text-color);
    border-bottom-left-radius: 4px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid #E2E8F0;
}

/* Markdown Styles inside bot message */
.message.bot p { margin-bottom: 12px; }
.message.bot p:last-child { margin-bottom: 0; }
.message.bot ul, .message.bot ol { margin-left: 20px; margin-bottom: 12px; }
.message.bot li { margin-bottom: 6px; }
.message.bot h1, .message.bot h2, .message.bot h3, .message.bot h4 { 
    color: var(--accent-color); 
    margin-top: 16px; 
    margin-bottom: 8px; 
}
.message.bot h1:first-child, .message.bot h2:first-child, .message.bot h3:first-child { 
    margin-top: 0; 
}
.message.bot strong { color: var(--accent-color); font-weight: 700; }
.message.bot em { font-style: italic; color: #475569; }
.message.bot hr {
    border: 0;
    border-top: 1px solid #E2E8F0;
    margin: 16px 0;
}
.message.bot blockquote {
    border-left: 4px solid var(--secondary-color);
    padding-left: 12px;
    margin: 12px 0;
    color: #475569;
    font-style: italic;
    background: #F8FAFC;
    border-radius: 0 8px 8px 0;
}
.message.bot code { 
    background: #F1F5F9; 
    padding: 3px 6px; 
    border-radius: 4px; 
    font-family: monospace; 
    font-size: 0.9em;
    color: #EF4444; 
}
.message.bot pre {
    background: #1E293B;
    color: #F8FAFC;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 12px;
}
.message.bot pre code {
    background: none;
    color: inherit;
    padding: 0;
}
.message.bot table {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 12px;
    font-size: 0.9em;
}
.message.bot th, .message.bot td {
    border: 1px solid #E2E8F0;
    padding: 8px;
    text-align: left;
}
.message.bot th {
    background-color: #F8FAFC;
    font-weight: 700;
}
/* KaTeX overrides for responsiveness */
.message.bot .katex-display {
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 4px;
    margin: 1em 0;
}

.suggestions {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    overflow-x: auto;
    background: var(--white);
    border-top: 1px solid #F1F5F9;
}

/* Custom Scrollbar for suggestions */
.suggestions::-webkit-scrollbar {
    height: 4px;
}
.suggestions::-webkit-scrollbar-thumb {
    background: #CBD5E1;
    border-radius: 10px;
}

.suggestion-btn {
    white-space: nowrap;
    background: var(--bg-color);
    border: 1px solid var(--secondary-color);
    padding: 8px 14px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--accent-color);
    cursor: pointer;
    transition: all 0.2s ease;
}

.suggestion-btn:hover {
    background: var(--primary-color);
    transform: translateY(-1px);
}

.chat-input-area {
    padding: 16px;
    background: var(--white);
    display: flex;
    gap: 12px;
    border-top: 1px solid #E2E8F0;
}

#user-input {
    flex: 1;
    border: 2px solid #E2E8F0;
    border-radius: 24px;
    padding: 12px 20px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.2s;
}

#user-input:focus {
    border-color: var(--accent-color);
}

#user-input:disabled {
    background: #F8FAFC;
    cursor: not-allowed;
}

#send-btn {
    width: 48px;
    height: 48px;
    flex-shrink: 0;
    background: var(--accent-color);
    color: var(--white);
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    transition: transform 0.2s, background 0.2s;
    box-shadow: 0 4px 6px rgba(59, 130, 246, 0.3);
}

#send-btn:hover {
    background: #2563EB;
    transform: scale(1.05);
}

#send-btn:active {
    transform: scale(0.95);
}

#send-btn:disabled {
    background: #94A3B8;
    cursor: not-allowed;
    box-shadow: none;
    transform: none;
}

/* Typing Indicator Animation */
.typing-indicator {
    display: flex;
    gap: 6px;
    padding: 8px 6px;
    align-items: center;
    height: 24px;
}

.dot {
    width: 8px;
    height: 8px;
    background: var(--accent-color);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out both;
    opacity: 0.7;
}

.dot:nth-child(1) { animation-delay: -0.32s; }
.dot:nth-child(2) { animation-delay: -0.16s; }

@keyframes bounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
