:root {
    --bg-color: #0f172a;
    --chat-bg: #1e293b;
    --primary-color: #3b82f6;
    --text-color: #e2e8f0;
    --subtext-color: #94a3b8;
    --user-msg-bg: #2563eb;
    --ai-msg-bg: #334155;
    --border-color: #334155;
    --input-bg: #1e293b;
}

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

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

.app-container {
    width: 100%;
    max-width: 900px;
    height: 100%;
    display: flex;
    flex-direction: column;
    background: radial-gradient(circle at top left, #1e293b, transparent 40%),
                radial-gradient(circle at bottom right, #0f172a, transparent 40%);
}

/* Header */
.chat-header {
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    backdrop-filter: blur(10px);
    background: rgba(15, 23, 42, 0.8);
    position: sticky;
    top: 0;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 600;
    font-size: 1.1rem;
    color: var(--primary-color);
}

.status-indicator {
    font-size: 0.8rem;
    color: var(--subtext-color);
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.dot {
    width: 8px;
    height: 8px;
    background-color: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
}

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

.welcome-message {
    text-align: center;
    margin-top: 20vh;
    opacity: 0.8;
}

.welcome-message h1 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
    background: linear-gradient(135deg, #fff 0%, #94a3b8 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Messages */
.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
    animation: fadeIn 0.3s ease-out;
}

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

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

.message-bubble {
    padding: 0.8rem 1.2rem;
    border-radius: 12px;
    font-size: 1rem;
    line-height: 1.5;
    word-wrap: break-word;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
}

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

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

/* Sources */
.sources-container {
    margin-top: 0.5rem;
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.source-chip {
    font-size: 0.75rem;
    background: rgba(255, 255, 255, 0.05);
    padding: 0.3rem 0.6rem;
    border-radius: 4px;
    color: var(--subtext-color);
    text-decoration: none;
    border: 1px solid var(--border-color);
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 0.3rem;
}

.source-chip:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary-color);
    border-color: var(--primary-color);
}

/* Input Area */
.input-area {
    padding: 1.5rem;
    background: rgba(15, 23, 42, 0.9);
    border-top: 1px solid var(--border-color);
    backdrop-filter: blur(10px);
}

.input-wrapper {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem;
    box-shadow: 0 0 0 2px transparent;
    transition: box-shadow 0.2s;
    display: flex;
    align-items: flex-end;
}

.input-wrapper:focus-within {
    box-shadow: 0 0 0 2px var(--primary-color);
    border-color: transparent;
}

textarea {
    flex: 1;
    background: transparent;
    border: none;
    color: white;
    font-family: inherit;
    font-size: 1rem;
    padding: 0.8rem;
    resize: none;
    max-height: 150px;
    outline: none;
}

button#send-btn {
    background: var(--primary-color);
    border: none;
    color: white;
    padding: 0.6rem;
    border-radius: 8px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    margin-right: 4px;
}

button#send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    background: var(--subtext-color);
}

button#send-btn:not(:disabled):hover {
    opacity: 0.9;
}

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

.footer-note {
    text-align: center;
    font-size: 0.7rem;
    color: var(--subtext-color);
    margin-top: 0.8rem;
}

/* Loading Animation */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem;
}

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

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

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

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--subtext-color);
}
