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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary: #64748b;
    --success: #22c55e;
    --error: #ef4444;
    --warning: #f59e0b;
    --bg: #f8fafc;
    --bg-chat: #ffffff;
    --text: #1e293b;
    --text-light: #64748b;
    --border: #e2e8f0;
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.container {
    max-width: 800px;
    margin: 0 auto;
    height: 100vh;
    display: flex;
    flex-direction: column;
    background: var(--bg-chat);
    box-shadow: var(--shadow-lg);
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 1rem 1.5rem;
    box-shadow: var(--shadow);
}

.header-content {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.avatar {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.avatar svg {
    width: 28px;
    height: 28px;
}

.header-info h1 {
    font-size: 1.25rem;
    font-weight: 600;
}

.status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.875rem;
    opacity: 0.9;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--warning);
    animation: pulse 2s infinite;
}

.status.online .status-dot {
    background: var(--success);
}

.status.offline .status-dot {
    background: var(--error);
    animation: none;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 2rem;
    color: var(--text-light);
}

.welcome-icon {
    width: 64px;
    height: 64px;
    background: var(--primary-light);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 1rem;
}

.welcome-icon svg {
    width: 32px;
    height: 32px;
    color: var(--primary);
}

.welcome-message h2 {
    color: var(--text);
    margin-bottom: 0.5rem;
}

.suggestion-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    justify-content: center;
    margin-top: 1rem;
}

.chip {
    background: var(--primary-light);
    color: var(--primary);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    font-size: 0.875rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: var(--primary);
    color: white;
}

/* Messages */
.message {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

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

.message.bot .message-avatar {
    background: var(--primary-light);
    color: var(--primary);
}

.message.user .message-avatar {
    background: var(--secondary);
    color: white;
}

.message-avatar svg {
    width: 20px;
    height: 20px;
}

.message-content {
    background: var(--bg);
    padding: 0.875rem 1rem;
    border-radius: 1rem;
    position: relative;
}

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

.message.bot .message-content {
    border-bottom-left-radius: 4px;
}

.message-text {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: var(--text-light);
}

.message.user .message-meta {
    color: rgba(255, 255, 255, 0.8);
}

.source-btn {
    background: none;
    border: 1px solid var(--border);
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    font-size: 0.75rem;
    color: var(--primary);
    cursor: pointer;
    transition: all 0.2s;
}

.source-btn:hover {
    background: var(--primary-light);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 0.5rem 0;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--secondary);
    border-radius: 50%;
    animation: bounce 1.4s infinite ease-in-out;
}

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

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

/* Input Area */
.input-area {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border);
    background: white;
}

.input-wrapper {
    display: flex;
    gap: 0.75rem;
    background: var(--bg);
    border-radius: 25px;
    padding: 0.5rem 0.5rem 0.5rem 1.25rem;
    border: 2px solid var(--border);
    transition: border-color 0.2s;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
}

#messageInput {
    flex: 1;
    border: none;
    background: none;
    font-size: 1rem;
    outline: none;
    color: var(--text);
}

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

#sendButton {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

#sendButton:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

#sendButton:disabled {
    background: var(--secondary);
    cursor: not-allowed;
    transform: none;
}

#sendButton svg {
    width: 20px;
    height: 20px;
}

.disclaimer {
    text-align: center;
    font-size: 0.75rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.modal.show {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    width: 100%;
    max-width: 500px;
    max-height: 80vh;
    overflow: hidden;
    box-shadow: var(--shadow-lg);
    animation: slideUp 0.3s ease;
}

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

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border);
}

.modal-header h3 {
    font-size: 1.125rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-light);
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover {
    color: var(--text);
}

.modal-body {
    padding: 1.5rem;
    overflow-y: auto;
    max-height: 60vh;
}

.source-item {
    background: var(--bg);
    padding: 1rem;
    border-radius: 8px;
    margin-bottom: 0.75rem;
    font-size: 0.875rem;
    border-left: 3px solid var(--primary);
}

.source-item:last-child {
    margin-bottom: 0;
}

.source-item p {
    white-space: pre-wrap;
    word-wrap: break-word;
}

/* Error State */
.error-message {
    background: #fef2f2;
    color: var(--error);
    padding: 0.75rem 1rem;
    border-radius: 8px;
    font-size: 0.875rem;
    text-align: center;
}

/* Responsive */
@media (max-width: 640px) {
    .container {
        max-width: 100%;
    }

    .header {
        padding: 1rem;
    }

    .chat-container {
        padding: 1rem;
    }

    .message {
        max-width: 90%;
    }

    .suggestion-chips {
        flex-direction: column;
    }

    .chip {
        width: 100%;
    }
}
