:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --bg-color: #f8fafc;
    --chat-bg: #ffffff;
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    --user-bubble: linear-gradient(135deg, #6366f1, #8b5cf6);
    --bot-bubble: #f1f5f9;
}

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

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

/* Modal API Key */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}
.modal-overlay.hidden {
    display: none;
}
.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    text-align: center;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
    animation: slideUp 0.3s ease-out;
}
.modal-header h2 { margin-bottom: 0.5rem; color: var(--text-main); }
.modal-header p { font-size: 0.9rem; color: var(--text-muted); margin-bottom: 1.5rem; }
.modal-content input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    margin-bottom: 1rem;
    outline: none;
}
.modal-content input:focus { border-color: var(--primary-color); }
.modal-help { margin-top: 1rem; font-size: 0.8rem; color: var(--text-muted); }
.modal-help code { background: #f1f5f9; padding: 2px 6px; border-radius: 4px; }

/* Main App Container */
.app-container {
    width: 100%;
    max-width: 900px;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--chat-bg);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.05);
}

@media (min-width: 768px) {
    .app-container {
        height: 95vh;
        border-radius: 20px;
        overflow: hidden;
    }
}

/* Header */
.app-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
    z-index: 10;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}
.header-avatar {
    width: 40px;
    height: 40px;
    font-size: 1.2rem;
}
.app-header h1 {
    font-size: 1.2rem;
    font-weight: 600;
}
.status {
    font-size: 0.8rem;
    color: #10b981;
    display: flex;
    align-items: center;
    gap: 6px;
}
.dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    display: inline-block;
}

/* Buttons */
.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 500;
    transition: 0.2s;
    width: 100%;
}
.btn-primary:hover { background: var(--primary-hover); }

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border-color);
    padding: 8px 16px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    transition: 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
}
.btn-secondary:hover {
    background: #f8fafc;
    border-color: var(--text-muted);
}

/* Chat Area */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    scroll-behavior: smooth;
    position: relative;
}

/* Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    margin: auto 0;
    padding: 2rem;
    animation: fadeIn 0.5s ease-out;
}
.welcome-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    background: #e0e7ff;
    width: 80px; height: 80px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 24px;
}
.welcome-screen h2 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}
.welcome-screen p {
    color: var(--text-muted);
    max-width: 400px;
    margin-bottom: 2rem;
    line-height: 1.5;
}

.quick-questions {
    display: grid;
    grid-template-columns: 1fr;
    gap: 10px;
    width: 100%;
    max-width: 500px;
}
@media (min-width: 600px) {
    .quick-questions { grid-template-columns: 1fr 1fr; }
}

.quick-btn {
    background: white;
    border: 1px solid var(--border-color);
    padding: 12px 16px;
    border-radius: 12px;
    cursor: pointer;
    text-align: left;
    font-size: 0.9rem;
    color: var(--text-main);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 10px;
}
.quick-btn i { color: var(--primary-color); font-size: 1.1rem; }
.quick-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.1);
}

/* Chat Messages */
.chat-messages {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    padding-bottom: 1rem;
}

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

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

.message-wrapper.bot {
    align-self: flex-start;
}

.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    color: white;
}
.user-avatar { background: var(--text-main); }
.bot-avatar { background: var(--user-bubble); }

.message-content {
    padding: 12px 16px;
    border-radius: 16px;
    line-height: 1.5;
    font-size: 0.95rem;
}

.user .message-content {
    background: var(--user-bubble);
    color: white;
    border-top-right-radius: 4px;
}

.bot .message-content {
    background: var(--bot-bubble);
    color: var(--text-main);
    border-top-left-radius: 4px;
}

/* Markdown Styles in Bot Bubble */
.bot .message-content p { margin-bottom: 0.75rem; }
.bot .message-content p:last-child { margin-bottom: 0; }
.bot .message-content pre {
    background: #1e293b;
    color: #f8fafc;
    padding: 1rem;
    border-radius: 8px;
    overflow-x: auto;
    margin: 0.5rem 0;
    font-size: 0.85rem;
}
.bot .message-content code {
    background: #e2e8f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}
.bot .message-content pre code { background: transparent; padding: 0; }
.bot .message-content ul, .bot .message-content ol { margin-left: 1.5rem; margin-bottom: 0.75rem; }
.bot .message-content h1, .bot .message-content h2, .bot .message-content h3 { margin: 1rem 0 0.5rem 0; }

/* Loading Indicator */
.loading-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    align-self: flex-start;
    margin-top: 1rem;
}
.loading-indicator.hidden {
    display: none;
}
.small-avatar { width: 30px; height: 30px; font-size: 0.8rem; }
.typing-dots {
    display: flex;
    gap: 4px;
    background: var(--bot-bubble);
    padding: 10px 14px;
    border-radius: 16px;
    border-top-left-radius: 4px;
}
.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}
.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }
.loading-text { font-size: 0.8rem; color: var(--text-muted); }

/* Input Area */
.input-container {
    padding: 1rem 1.5rem;
    background: white;
    border-top: 1px solid var(--border-color);
}
.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 10px;
    background: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 8px 12px;
    transition: 0.2s;
}
.input-wrapper:focus-within {
    border-color: var(--primary-color);
    background: white;
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

textarea {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    padding: 8px 4px;
    font-size: 0.95rem;
    color: var(--text-main);
    max-height: 150px;
    outline: none;
    line-height: 1.5;
}
textarea::placeholder { color: #94a3b8; }

.send-btn {
    background: var(--primary-color);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: 0.2s;
    flex-shrink: 0;
}
.send-btn:hover { background: var(--primary-hover); transform: scale(1.05); }
.send-btn:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; }

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}
@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
