:root {
    --primary: #2563eb;
    --primary-hover: #1d4ed8;
    --secondary: #64748b;
    --background: #ffffff;
    --surface: #f8fafc;
    --border: #e2e8f0;
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-tertiary: #94a3b8;
    --success: #10b981;
    --error: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue', sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    background-color: var(--surface);
    color: var(--text-primary);
    line-height: 1.6;
}

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

/* Header */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--background);
}

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

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

.logo h1 {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--text-primary);
}

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

.settings-btn:hover {
    background-color: var(--surface);
    color: var(--text-primary);
}

.settings-btn svg {
    width: 20px;
    height: 20px;
}

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

.chat-container::-webkit-scrollbar {
    width: 8px;
}

.chat-container::-webkit-scrollbar-track {
    background: transparent;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 4px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--secondary);
}

/* Welcome Message */
.welcome-message {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 3rem 1rem;
    margin-top: auto;
    margin-bottom: auto;
}

.welcome-icon {
    width: 80px;
    height: 80px;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 1.5rem;
    box-shadow: var(--shadow-lg);
}

.welcome-icon svg {
    width: 40px;
    height: 40px;
    color: white;
}

.welcome-message h2 {
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-primary);
}

.welcome-message p {
    font-size: 1rem;
    color: var(--text-secondary);
    max-width: 400px;
}

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

@keyframes slideIn {
    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;
    font-weight: 600;
    font-size: 0.875rem;
}

.message.user .message-avatar {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: white;
}

.message.bot .message-avatar {
    background: var(--surface);
    color: var(--text-secondary);
    border: 2px solid var(--border);
}

.message-content {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.message-bubble {
    padding: 0.875rem 1.125rem;
    border-radius: 16px;
    word-wrap: break-word;
    line-height: 1.5;
}

.message.user .message-bubble {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: white;
    border-bottom-right-radius: 4px;
}

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

.message-time {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    padding: 0 0.5rem;
}

/* Context Chunks */
.context-chunks {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background: var(--background);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.875rem;
}

.context-chunks-title {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.context-chunk {
    padding: 0.5rem;
    margin-bottom: 0.5rem;
    background: var(--surface);
    border-radius: 6px;
    border-left: 3px solid var(--primary);
}

.context-chunk:last-child {
    margin-bottom: 0;
}

.chunk-header {
    font-size: 0.75rem;
    color: var(--text-tertiary);
    margin-bottom: 0.25rem;
}

.chunk-text {
    font-size: 0.8125rem;
    color: var(--text-secondary);
    line-height: 1.4;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 0.75rem;
    max-width: 85%;
}

.typing-indicator .message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--surface);
    color: var(--text-secondary);
    border: 2px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.typing-dots {
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 1rem 1.5rem;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    display: flex;
    gap: 0.375rem;
}

.typing-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: typing 1.4s infinite;
}

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

.typing-dot:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

/* Input Container */
.input-container {
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
    background-color: var(--background);
}

.chat-form {
    display: flex;
    gap: 0.75rem;
}

.message-input {
    flex: 1;
    padding: 0.875rem 1.125rem;
    border: 1px solid var(--border);
    border-radius: 12px;
    font-size: 0.9375rem;
    font-family: inherit;
    background-color: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.message-input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--background);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.message-input::placeholder {
    color: var(--text-tertiary);
}

.send-btn {
    width: 48px;
    height: 48px;
    border: none;
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: white;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.send-btn:hover:not(:disabled) {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.send-btn:active:not(:disabled) {
    transform: translateY(0);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.send-btn svg {
    width: 20px;
    height: 20px;
}

/* Modal */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--background);
    border-radius: 16px;
    width: 90%;
    max-width: 500px;
    box-shadow: var(--shadow-xl);
    animation: modalSlideIn 0.3s ease;
}

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

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

.modal-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
}

.close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.close-btn:hover {
    background: var(--surface);
    color: var(--text-primary);
}

.close-btn svg {
    width: 18px;
    height: 18px;
}

.modal-body {
    padding: 2rem;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group:last-child {
    margin-bottom: 0;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9375rem;
}

.form-input {
    width: 100%;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 0.9375rem;
    font-family: inherit;
    background-color: var(--surface);
    color: var(--text-primary);
    transition: all 0.2s ease;
}

.form-input:focus {
    outline: none;
    border-color: var(--primary);
    background-color: var(--background);
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

.form-help {
    display: block;
    margin-top: 0.375rem;
    font-size: 0.8125rem;
    color: var(--text-tertiary);
}

.checkbox {
    width: 18px;
    height: 18px;
    margin-right: 0.5rem;
    cursor: pointer;
    accent-color: var(--primary);
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    padding: 1.5rem 2rem;
    border-top: 1px solid var(--border);
}

.btn {
    padding: 0.625rem 1.25rem;
    border: none;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, #3b82f6 100%);
    color: white;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: var(--border);
    color: var(--text-primary);
}

/* Error Message */
.error-message {
    padding: 1rem;
    background: #fee;
    border: 1px solid var(--error);
    border-radius: 8px;
    color: var(--error);
    font-size: 0.875rem;
    margin-top: 0.5rem;
}

/* Responsive */
@media (max-width: 768px) {
    .container {
        box-shadow: none;
    }

    .header {
        padding: 1rem 1.5rem;
    }

    .logo h1 {
        font-size: 1.25rem;
    }

    .chat-container {
        padding: 1.5rem 1rem;
    }

    .message {
        max-width: 90%;
    }

    .input-container {
        padding: 1rem 1.5rem;
    }

    .modal-content {
        width: 95%;
        margin: 1rem;
    }

    .modal-header,
    .modal-body,
    .modal-footer {
        padding: 1.25rem 1.5rem;
    }
}

