:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #f1f5f9;
    --chat-bg: #ffffff;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --ai-msg-bg: #f8fafc;
    --user-msg-bg: #6366f1;
    --user-msg-text: #ffffff;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    --radius-lg: 16px;
    --radius-md: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    height: 100vh;
    overflow: hidden;
}

.app-container {
    width: 100%;
    max-width: 900px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background-color: var(--chat-bg);
    box-shadow: var(--shadow-lg);
    position: relative;
}

/* Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(8px);
    z-index: 10;
}

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

.header-info h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.header-info p {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
    flex-shrink: 0;
}

.ai-avatar {
    background-color: #e0e7ff;
    color: var(--primary-color);
}

.user-avatar {
    background-color: var(--primary-color);
    color: white;
}

.btn-secondary {
    background-color: transparent;
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 20px;
    font-family: inherit;
    font-weight: 500;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-secondary:hover {
    background-color: var(--bg-color);
    border-color: #cbd5e1;
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    scroll-behavior: smooth;
}

.message {
    display: flex;
    gap: 16px;
    max-width: 85%;
    animation: fadeIn 0.3s ease-out forwards;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message-content {
    padding: 16px 20px;
    border-radius: var(--radius-lg);
    font-size: 0.95rem;
    line-height: 1.6;
    word-wrap: break-word;
}

/* AI Message */
.ai-message {
    align-self: flex-start;
}

.ai-message .message-content {
    background-color: var(--ai-msg-bg);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

/* User Message */
.user-message {
    align-self: flex-end;
    flex-direction: row-reverse;
}

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

.user-message .avatar {
    display: none; /* Hidden for a cleaner UI, typical of modern chats */
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--text-muted);
    font-size: 0.9rem;
    padding: 8px 0;
    animation: fadeIn 0.3s ease-out;
}

.typing-dots {
    display: flex;
    gap: 4px;
    margin-left: 4px;
}

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

.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); }
}

/* Input Area */
.input-container {
    padding: 16px 24px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--chat-bg);
}

.quick-questions {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    overflow-x: auto;
    padding-bottom: 8px;
    scrollbar-width: none; /* Firefox */
}

.quick-questions::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
}

.quick-btn {
    background-color: var(--ai-msg-bg);
    border: 1px solid var(--border-color);
    padding: 10px 16px;
    border-radius: 20px;
    font-size: 0.85rem;
    color: var(--text-main);
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.2s;
    font-family: inherit;
}

.quick-btn:hover {
    background-color: #e2e8f0;
    border-color: #cbd5e1;
    transform: translateY(-1px);
}

.input-box {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 12px 16px;
    box-shadow: var(--shadow-sm);
    transition: border-color 0.2s, box-shadow 0.2s;
}

.input-box:focus-within {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.2);
}

textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    outline: none;
    font-family: inherit;
    font-size: 1rem;
    line-height: 1.5;
    padding: 4px 0;
    max-height: 150px;
    color: var(--text-main);
}

textarea::placeholder {
    color: var(--text-muted);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
    border: none;
    width: 44px;
    height: 44px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    flex-shrink: 0;
}

.btn-primary:hover:not(:disabled) {
    background-color: var(--primary-hover);
}

.btn-primary:active:not(:disabled) {
    transform: scale(0.95);
}

.btn-primary:disabled {
    background-color: #94a3b8;
    cursor: not-allowed;
    opacity: 0.7;
}

.footer-text {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 16px;
}

/* Markdown Styles for AI Responses */
.message-content h1, .message-content h2, .message-content h3 {
    margin-top: 16px;
    margin-bottom: 8px;
    font-size: 1.1em;
    font-weight: 600;
}
.message-content h1:first-child, .message-content h2:first-child, .message-content h3:first-child {
    margin-top: 0;
}
.message-content p { margin-bottom: 12px; }
.message-content p:last-child { margin-bottom: 0; }
.message-content ul, .message-content ol { margin-left: 24px; margin-bottom: 12px; }
.message-content li { margin-bottom: 6px; }
.message-content code {
    background-color: rgba(0,0,0,0.06);
    padding: 3px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}
.message-content pre {
    background-color: #1e293b;
    color: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin-bottom: 12px;
}
.message-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
}

/* System Messages */
.system-message {
    align-self: center !important;
    background-color: #fee2e2 !important;
    color: #991b1b !important;
    border: 1px solid #f87171 !important;
    padding: 10px 16px !important;
    border-radius: 8px !important;
    font-size: 0.9rem !important;
    max-width: 90% !important;
    text-align: center;
}

/* Responsive Styles */
@media (max-width: 640px) {
    .message { max-width: 95%; }
    .chat-header { padding: 12px 16px; }
    .chat-container { padding: 16px; }
    .input-container { padding: 12px 16px 16px; }
    .app-container { box-shadow: none; border-radius: 0; }
    
    .header-info h1 { font-size: 1.1rem; }
    .btn-secondary { padding: 6px 12px; font-size: 0.85rem; }
}
