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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f8f9fa;
    height: 100vh;
    color: #1f2937;
    overflow: hidden;
}

.chat-container {
    height: 100vh;
    display: flex;
    flex-direction: column;
    max-width: 768px;
    margin: 0 auto;
    background: white;
    border-left: 1px solid #e5e7eb;
    border-right: 1px solid #e5e7eb;
}

/* Compact header */
.compact-header {
    background: white;
    border-bottom: 1px solid #e5e7eb;
    padding: 1rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.app-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: #1f2937;
    margin: 0;
}

.app-subtitle {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 400;
}

.clear-button {
    background: none;
    border: 1px solid #d1d5db;
    border-radius: 0.5rem;
    padding: 0.5rem;
    color: #6b7280;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clear-button:hover {
    background: #f9fafb;
    border-color: #9ca3af;
    color: #374151;
}

.clear-button:active {
    transform: scale(0.95);
}

/* Messages area */
.messages-container {
    flex: 1;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    scroll-behavior: smooth;
}

.message {
    margin-bottom: 1.5rem;
    max-width: 85%;
    word-wrap: break-word;
}

.message.user {
    margin-left: auto;
}

.message.assistant {
    margin-right: auto;
}

.message-content {
    background: #f3f4f6;
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    font-size: 0.95rem;
    line-height: 1.6;
    position: relative;
}

.message.user .message-content {
    background: #3b82f6;
    color: white;
    border-bottom-right-radius: 0.25rem;
}

.message.assistant .message-content {
    background: #f3f4f6;
    color: #1f2937;
    border-bottom-left-radius: 0.25rem;
}

/* Welcome message styling */
.welcome-message {
    max-width: none;
}

.welcome-message strong {
    color: #1f2937;
    font-size: 1.1rem;
    display: block;
    margin-bottom: 0.75rem;
}

.welcome-message p {
    margin-bottom: 1rem;
    color: #4b5563;
}

.example-queries {
    margin-top: 1rem;
}

.example-queries em {
    color: #6b7280;
    font-size: 0.875rem;
    display: block;
    margin-bottom: 0.5rem;
}

.example-queries ul {
    margin: 0;
    padding-left: 1.25rem;
}

.example-queries li {
    margin-bottom: 0.375rem;
    color: #4b5563;
    font-size: 0.875rem;
}

/* Markdown content styling */
.message-content h1,
.message-content h2,
.message-content h3,
.message-content h4,
.message-content h5,
.message-content h6 {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.message-content h1 { font-size: 1.25rem; }
.message-content h2 { font-size: 1.125rem; }
.message-content h3 { font-size: 1rem; }

.message-content ul,
.message-content ol {
    margin: 0.75rem 0;
    padding-left: 1.5rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

.message-content p {
    margin-bottom: 0.75rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content a {
    color: #3b82f6;
    text-decoration: underline;
}

.message.user .message-content a {
    color: #bfdbfe;
}

.message-content strong {
    font-weight: 600;
}

.message-content code {
    background: rgba(0, 0, 0, 0.1);
    padding: 0.125rem 0.25rem;
    border-radius: 0.25rem;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.875rem;
}

.message.user .message-content code {
    background: rgba(255, 255, 255, 0.2);
}

/* Sources styling */
.sources {
    margin-top: 1rem;
    padding: 0.75rem;
    background: #eff6ff;
    border-left: 3px solid #3b82f6;
    border-radius: 0.375rem;
    font-size: 0.875rem;
}

.sources-title {
    font-weight: 600;
    color: #1e40af;
    margin-bottom: 0.5rem;
}

.sources-list {
    color: #4b5563;
    line-height: 1.5;
}

/* Input area */
.input-area {
    background: white;
    border-top: 1px solid #e5e7eb;
    padding: 1rem;
    flex-shrink: 0;
}

.status-message {
    text-align: center;
    font-size: 0.875rem;
    color: #6b7280;
    margin-bottom: 0.75rem;
    min-height: 1.25rem;
}

.status-message.error {
    color: #dc2626;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 0.375rem;
    padding: 0.5rem;
}

.status-message.loading {
    color: #3b82f6;
}

.chat-form {
    display: flex;
    flex-direction: column;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: flex-end;
}

.message-input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid #d1d5db;
    border-radius: 1.5rem;
    font-size: 1rem;
    background: white;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
}

.message-input:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.message-input:disabled {
    background: #f9fafb;
    color: #9ca3af;
    cursor: not-allowed;
}

.send-button {
    padding: 0.75rem;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: background-color 0.2s, transform 0.1s;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 42px;
    height: 42px;
}

.send-button:hover:not(:disabled) {
    background: #2563eb;
}

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

.send-button:disabled {
    background: #9ca3af;
    cursor: not-allowed;
    transform: none;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: #f3f4f6;
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    border-bottom-left-radius: 0.25rem;
    max-width: 85%;
    margin-bottom: 1.5rem;
    margin-right: auto;
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typing 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 typing {
    0%, 80%, 100% { 
        transform: scale(0.8); 
        opacity: 0.5; 
    }
    40% { 
        transform: scale(1); 
        opacity: 1; 
    }
}

.typing-indicator span {
    color: #6b7280;
    font-size: 0.875rem;
}

/* Responsive design */
@media (max-width: 768px) {
    .chat-container {
        border-left: none;
        border-right: none;
    }
    
    .compact-header {
        padding: 0.875rem 1rem;
    }
    
    .header-left {
        gap: 0.5rem;
    }
    
    .messages {
        padding: 0.75rem;
    }
    
    .message {
        max-width: 90%;
    }
    
    .input-area {
        padding: 0.75rem;
    }
    
    .app-title {
        font-size: 1.125rem;
    }
    
    .app-subtitle {
        font-size: 0.8rem;
    }
    
    .clear-button {
        padding: 0.375rem;
    }
    
    .clear-button svg {
        width: 14px;
        height: 14px;
    }
}