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

:root {
    --bg-primary: #ffffff;
    --bg-secondary: #f7f7f8;
    --bg-sidebar: #202123;
    --text-primary: #353740;
    --text-secondary: #6e6e80;
    --border-color: #e5e5e6;
    --accent-color: #10a37f;
    --accent-hover: #0d8f6e;
    --user-msg-bg: #f7f7f8;
    --assistant-msg-bg: #ffffff;
    --error-color: #ef4444;
    --shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--bg-secondary);
    color: var(--text-primary);
    height: 100vh;
    overflow: hidden;
}

.app-container {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-sidebar);
    color: white;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header {
    padding: 16px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h1 {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
}

.new-chat-btn {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.new-chat-btn span {
    font-size: 20px;
    font-weight: 300;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.chat-history {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.chat-history-item {
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    transition: background 0.2s;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-item:hover {
    background: rgba(255, 255, 255, 0.1);
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

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

.user-details {
    flex: 1;
    min-width: 0;
}

.user-name {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 2px;
}

.user-id {
    font-size: 11px;
    color: rgba(255, 255, 255, 0.6);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: var(--bg-primary);
}

.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
}

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 40px;
}

.welcome-icon {
    font-size: 64px;
    margin-bottom: 24px;
}

.welcome-screen h2 {
    font-size: 28px;
    margin-bottom: 8px;
    color: var(--text-primary);
}

.welcome-screen p {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 32px;
}

.example-questions h3 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 16px;
    font-weight: 500;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    justify-content: center;
    max-width: 600px;
}

.example-chip {
    padding: 10px 16px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-primary);
}

.example-chip:hover {
    background: var(--accent-color);
    color: white;
    border-color: var(--accent-color);
}

.upload-section {
    margin-top: 32px;
    padding-top: 32px;
    border-top: 1px solid var(--border-color);
}

.upload-section h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.upload-btn {
    display: inline-flex;
    align-items: center;
    padding: 12px 20px;
    background: var(--accent-color);
    color: white;
    border: none;
    border-radius: 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: 0 2px 4px rgba(16, 163, 127, 0.2);
}

.upload-btn:hover {
    background: var(--accent-hover);
    box-shadow: 0 4px 8px rgba(16, 163, 127, 0.3);
    transform: translateY(-1px);
}

.upload-btn:active {
    transform: translateY(0);
}

.upload-status {
    margin-top: 12px;
    font-size: 13px;
    min-height: 20px;
    transition: all 0.3s;
}

.upload-status-uploading {
    color: var(--accent-color);
    font-weight: 500;
}

.upload-status-success {
    color: #10a37f;
    font-weight: 500;
}

.upload-status-error {
    color: var(--error-color);
    font-weight: 500;
}

.messages {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 768px;
    width: 100%;
    margin: 0 auto;
}

.message {
    display: flex;
    gap: 16px;
    animation: fadeIn 0.3s;
}

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

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

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

.message.assistant .message-avatar {
    background: var(--bg-secondary);
    color: var(--text-primary);
}

.message-content {
    flex: 1;
    padding: 16px;
    border-radius: 12px;
    line-height: 1.6;
    font-size: 15px;
}

.message.user .message-content {
    background: var(--user-msg-bg);
    color: var(--text-primary);
}

.message.assistant .message-content {
    background: var(--assistant-msg-bg);
    border: 1px solid var(--border-color);
    color: var(--text-primary);
}

.message.error .message-content {
    background: #fef2f2;
    border-color: var(--error-color);
    color: var(--error-color);
}

.message.loading .message-content {
    display: flex;
    align-items: center;
    gap: 8px;
}

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

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

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

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

@keyframes bounce {
    0%, 60%, 100% {
        transform: translateY(0);
    }
    30% {
        transform: translateY(-10px);
    }
}

.debug-info {
    margin-top: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: 8px;
    font-size: 12px;
    font-family: 'Monaco', 'Courier New', monospace;
    overflow-x: auto;
}

.debug-info summary {
    cursor: pointer;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.debug-info pre {
    margin-top: 8px;
    white-space: pre-wrap;
    word-break: break-all;
}

/* Input Area */
.input-container {
    padding: 24px;
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
}

.chat-form {
    max-width: 768px;
    margin: 0 auto;
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 12px 16px;
    transition: border-color 0.2s;
}

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

.message-input {
    flex: 1;
    border: none;
    background: transparent;
    resize: none;
    font-size: 15px;
    font-family: inherit;
    color: var(--text-primary);
    max-height: 200px;
    overflow-y: auto;
}

.message-input:focus {
    outline: none;
}

.send-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: var(--accent-color);
    color: white;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
    flex-shrink: 0;
}

.send-btn:hover:not(:disabled) {
    background: var(--accent-hover);
}

.send-btn:disabled {
    background: var(--border-color);
    cursor: not-allowed;
    opacity: 0.5;
}

.input-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 8px;
    padding: 0 4px;
}

.char-count {
    font-size: 12px;
    color: var(--text-secondary);
}

.debug-toggle {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--text-secondary);
    cursor: pointer;
}

.debug-toggle input[type="checkbox"] {
    cursor: pointer;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--text-secondary);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        display: none;
    }
    
    .messages {
        max-width: 100%;
    }
}

