:root {
    /* Minimalist Aesthetic Palette */
    --primary: #4f46e5; /* Indigo 600 */
    --primary-hover: #4338ca; /* Indigo 700 */
    --primary-light: #e0e7ff; /* Indigo 100 */
    --bg-base: #f8fafc; /* Slate 50 */
    --surface-glass: rgba(255, 255, 255, 0.75);
    --surface-border: rgba(255, 255, 255, 0.4);
    --text-primary: #0f172a; /* Slate 900 */
    --text-secondary: #475569; /* Slate 600 */
    --text-tertiary: #94a3b8; /* Slate 400 */
    --divider: #e2e8f0; /* Slate 200 */
    
    --bubble-bot: #ffffff;
    --bubble-user: #4f46e5;
    --text-user: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-base);
    color: var(--text-primary);
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

/* Beautiful Animated Mesh Gradient Background */
.bg-shape {
    position: absolute;
    border-radius: 50%;
    filter: blur(80px);
    z-index: 0;
    opacity: 0.6;
    animation: drift 20s infinite alternate ease-in-out;
}

.shape-1 {
    width: 500px; height: 500px;
    background: #e0e7ff; /* Soft Indigo */
    top: -100px; left: -100px;
}

.shape-2 {
    width: 400px; height: 400px;
    background: #fce7f3; /* Soft Pink */
    bottom: -100px; right: 10%;
    animation-delay: -5s;
}

.shape-3 {
    width: 600px; height: 600px;
    background: #e0f2fe; /* Soft Sky Blue */
    bottom: 20%; left: 20%;
    animation-delay: -10s;
}

@keyframes drift {
    0% { transform: translate(0, 0) scale(1); }
    100% { transform: translate(50px, 30px) scale(1.05); }
}

/* Main App Container */
.app-container {
    width: 100%;
    max-width: 860px;
    height: 92vh;
    background: var(--surface-glass);
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border: 1px solid var(--surface-border);
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(15, 23, 42, 0.08), 
                0 0 0 1px rgba(255, 255, 255, 0.5) inset;
    display: flex;
    flex-direction: column;
    position: relative;
    z-index: 1;
}

/* Header */
.chat-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 32px;
    background: rgba(255, 255, 255, 0.6);
    border-bottom: 1px solid var(--divider);
    border-radius: 24px 24px 0 0;
}

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

.avatar {
    width: 44px;
    height: 44px;
    background: white;
    border-radius: 50%;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.06);
    border: 1px solid var(--divider);
}

.avatar img {
    width: 80%;
    height: 80%;
}

.header-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.header-text h1 {
    font-size: 1.15rem;
    font-weight: 600;
    color: var(--text-primary);
    letter-spacing: -0.01em;
}

.status-wrapper {
    display: flex;
    align-items: center;
    gap: 6px;
}

.status-dot {
    width: 6px;
    height: 6px;
    background-color: #10b981; /* Emerald 500 */
    border-radius: 50%;
    box-shadow: 0 0 0 2px rgba(16, 185, 129, 0.2);
}

.status {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 400;
}

.icon-btn {
    background: transparent;
    border: none;
    color: var(--text-tertiary);
    cursor: pointer;
    transition: all 0.2s ease;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    color: var(--text-primary);
    background: rgba(15, 23, 42, 0.05);
}

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

/* Aesthetic Welcome Screen */
.welcome-screen {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    animation: fadeScale 0.6s cubic-bezier(0.16, 1, 0.3, 1);
    max-width: 500px;
    margin: 0 auto;
}

.welcome-icon {
    color: var(--primary);
    margin-bottom: 24px;
    background: white;
    padding: 20px;
    border-radius: 20px;
    box-shadow: 0 8px 24px rgba(79, 70, 229, 0.1);
    border: 1px solid var(--primary-light);
}

.welcome-screen h2 {
    font-size: 1.75rem;
    margin-bottom: 12px;
    color: var(--text-primary);
    font-weight: 600;
    letter-spacing: -0.02em;
}

.welcome-screen p {
    color: var(--text-secondary);
    margin-bottom: 36px;
    font-size: 1rem;
    line-height: 1.6;
}

.suggestion-chips {
    display: flex;
    flex-direction: column;
    gap: 12px;
    width: 100%;
}

.chip {
    background: white;
    border: 1px solid var(--divider);
    padding: 14px 24px;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
    text-align: left;
    box-shadow: 0 2px 4px rgba(15, 23, 42, 0.02);
}

.chip:hover {
    border-color: var(--primary);
    color: var(--primary);
    background: #f8fafc;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.05);
}

/* Messages */
.message {
    display: flex;
    max-width: 82%;
    animation: fadeSlideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

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

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

.message-content {
    padding: 16px 20px;
    border-radius: 16px;
    font-size: 0.95rem;
    line-height: 1.6;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

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

.message.bot .message-content {
    background: var(--bubble-bot);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--divider);
    color: var(--text-primary);
}

/* Markdown styling inside bot message */
.message.bot .message-content p { margin-bottom: 12px; }
.message.bot .message-content p:last-child { margin-bottom: 0; }
.message.bot .message-content pre {
    background: #f8fafc;
    padding: 16px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 12px 0;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    border: 1px solid var(--divider);
}
.message.bot .message-content code {
    background: #f1f5f9;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: 'JetBrains Mono', 'Fira Code', monospace;
    font-size: 0.85em;
    color: #db2777; /* Pink 600 */
}
.message.bot .message-content pre code { background: none; padding: 0; color: var(--text-primary); }
.message.bot .message-content ul, .message.bot .message-content ol { margin-left: 20px; margin-bottom: 12px; }
.message.bot .message-content strong { color: var(--text-primary); font-weight: 600; }

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 16px 20px;
    background: var(--bubble-bot);
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    border: 1px solid var(--divider);
    width: fit-content;
    align-self: flex-start;
    box-shadow: 0 2px 8px rgba(15, 23, 42, 0.04);
}

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

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

/* Input Area */
.chat-input-container {
    padding: 20px 32px 16px 32px;
    background: rgba(255, 255, 255, 0.7);
    border-top: 1px solid var(--divider);
    border-radius: 0 0 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background: white;
    border-radius: 20px;
    padding: 8px 12px 8px 20px;
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.03);
    border: 1px solid var(--divider);
    transition: all 0.2s ease;
    width: 100%;
}

.input-wrapper:focus-within {
    box-shadow: 0 4px 20px rgba(79, 70, 229, 0.08);
    border-color: #a5b4fc;
}

#messageInput {
    flex-grow: 1;
    border: none;
    outline: none;
    resize: none;
    max-height: 120px;
    padding: 10px 0;
    font-family: inherit;
    font-size: 0.95rem;
    color: var(--text-primary);
    background: transparent;
    line-height: 1.5;
}

#messageInput::placeholder {
    color: var(--text-tertiary);
}

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

.send-btn:hover:not(:disabled) {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

.send-btn:disabled {
    background: var(--divider);
    color: var(--text-tertiary);
    cursor: not-allowed;
}

.footer-note {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-top: 12px;
    font-weight: 500;
}

/* Neat Settings Modal */
.modal {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 100;
    border-radius: 24px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 36px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 20px 40px -8px rgba(15, 23, 42, 0.15);
    animation: fadeScale 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.modal-icon {
    width: 48px; height: 48px;
    background: var(--primary-light);
    color: var(--primary);
    border-radius: 12px;
    display: flex;
    justify-content: center;
    align-items: center;
    margin-bottom: 20px;
}

.modal-content h2 { 
    margin-bottom: 8px; 
    color: var(--text-primary);
    font-weight: 600;
    font-size: 1.25rem;
}

.modal-content p { 
    color: var(--text-secondary); 
    margin-bottom: 24px; 
    font-size: 0.9rem; 
    line-height: 1.5;
}

#apiKeyInput {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid var(--divider);
    border-radius: 10px;
    margin-bottom: 24px;
    font-family: inherit;
    font-size: 0.95rem;
    outline: none;
    transition: all 0.2s ease;
    background: #f8fafc;
}

#apiKeyInput:focus {
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

.primary-btn {
    background: var(--text-primary);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    width: 100%;
    transition: all 0.2s ease;
}

.primary-btn:hover { 
    background: #000000;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.15);
}

/* Elegant Scrollbar */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { 
    background: var(--divider); 
    border-radius: 6px; 
}
::-webkit-scrollbar-thumb:hover { background: var(--text-tertiary); }

/* Keyframes */
@keyframes fadeScale { 
    from { opacity: 0; transform: scale(0.96); } 
    to { opacity: 1; transform: scale(1); } 
}
@keyframes fadeSlideUp { 
    0% { opacity: 0; transform: translateY(12px); } 
    100% { opacity: 1; transform: translateY(0); } 
}
@keyframes typingPulse { 
    0%, 80%, 100% { transform: scale(0.8); opacity: 0.4; } 
    40% { transform: scale(1.2); opacity: 1; } 
}
