:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --primary-light: #e0e7ff;
    --bg-color: #f8fafc;
    --chat-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --user-bubble: #6366f1;
    --user-text: #ffffff;
    --ai-bubble: #f1f5f9;
    --ai-text: #1e293b;
    --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-xl: 24px;
}

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

body {
    font-family: 'Outfit', sans-serif;
    background: linear-gradient(135deg, #e0e7ff 0%, #ede9fe 100%);
    color: var(--text-main);
    height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 900px;
    height: 95vh;
    background: var(--chat-bg);
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    margin: 0 20px;
    border: 1px solid rgba(255,255,255,0.5);
}

/* Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 24px;
    background: var(--chat-bg);
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}

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

.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    flex-shrink: 0;
}

.ai-avatar {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary), #8b5cf6);
    color: white;
    box-shadow: 0 4px 10px rgba(99, 102, 241, 0.3);
}

.user-avatar {
    width: 36px;
    height: 36px;
    background: #e2e8f0;
    color: #475569;
}

.ai-avatar.small {
    width: 36px;
    height: 36px;
    box-shadow: none;
}

.header-title h1 {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.2;
}

.header-title .status {
    font-size: 0.85rem;
    color: #10b981;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 4px;
}
.header-title .status::before {
    content: "";
    display: block;
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
}

.icon-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    padding: 8px 16px;
    border-radius: var(--radius-lg);
    cursor: pointer;
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    background: var(--bg-color);
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: auto;
    max-width: 500px;
    animation: fadeIn 0.5s ease;
}

.welcome-icon {
    font-size: 3rem;
    color: #fbbf24;
    margin-bottom: 16px;
    background: white;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-md);
}

.welcome-icon .material-icons-round {
    font-size: 3rem;
}

.welcome-screen h2 {
    font-size: 1.5rem;
    margin-bottom: 8px;
    color: var(--text-main);
}

.welcome-screen p {
    color: var(--text-muted);
    margin-bottom: 32px;
}

.quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
}

.quick-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    color: var(--text-main);
    font-family: inherit;
    font-size: 0.9rem;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow-sm);
}

.quick-btn:hover {
    border-color: var(--primary);
    color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Messages */
.messages-wrapper {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message-row {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: slideUp 0.3s ease;
}

.message-row.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-row.ai {
    align-self: flex-start;
}

.message-bubble {
    padding: 14px 18px;
    border-radius: 20px;
    font-size: 0.95rem;
    line-height: 1.5;
    position: relative;
    word-break: break-word;
}

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

.ai .message-bubble {
    background: var(--ai-bubble);
    color: var(--ai-text);
    border-bottom-left-radius: 4px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

/* Markdown Styles inside AI bubble */
.message-bubble p { margin-bottom: 8px; }
.message-bubble p:last-child { margin-bottom: 0; }
.message-bubble strong { font-weight: 600; color: #111827; }
.user .message-bubble strong { color: white; }
.message-bubble code {
    background: rgba(0,0,0,0.05);
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}
.user .message-bubble code {
    background: rgba(255,255,255,0.2);
}
.message-bubble pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
}
.message-bubble pre code { background: none; color: inherit; padding: 0; }
.message-bubble ul, .message-bubble ol { margin-left: 20px; margin-bottom: 8px; }
.message-bubble h1, .message-bubble h2, .message-bubble h3 { margin: 12px 0 8px; font-size: 1.1em; font-weight: 600; }

/* Error Message */
.message-bubble.error {
    background: #fef2f2;
    color: #ef4444;
    border: 1px solid #fca5a5;
}

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-top: 20px;
    align-self: flex-start;
    animation: fadeIn 0.3s ease;
}

.typing-bubble {
    background: var(--ai-bubble);
    padding: 12px 16px;
    border-radius: 20px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 6px;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
}

.dot {
    width: 6px;
    height: 6px;
    background: var(--primary);
    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; }

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

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

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

.input-container:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

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

textarea::placeholder {
    color: #94a3b8;
}

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

.send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: scale(1.05);
}

.send-btn:disabled {
    background: #cbd5e1;
    cursor: not-allowed;
    transform: none;
}

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

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

/* Responsive */
@media (max-width: 600px) {
    .app-container {
        height: 100vh;
        margin: 0;
        border-radius: 0;
        border: none;
    }
    
    .chat-header {
        padding: 16px;
    }
    
    .btn-text {
        display: none;
    }
    
    .icon-btn {
        padding: 8px;
    }
    
    .message-row {
        max-width: 95%;
    }
    
    .welcome-screen h2 {
        font-size: 1.25rem;
    }
    
    .chat-input-area {
        padding: 16px;
    }
}
