/* DocuChat - Professional Chatbot Styles */

:root {
    /* Color Palette */
    --primary-color: #2563eb;
    --primary-hover: #1d4ed8;
    --primary-light: #dbeafe;
    --secondary-color: #64748b;
    --background: #f8fafc;
    --surface: #ffffff;
    --surface-secondary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    --success: #10b981;
    --error: #ef4444;
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);

    /* Spacing */
    --sidebar-width: 320px;
    --chat-max-width: 800px;

    /* Typography */
    --font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

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

body {
    font-family: var(--font-family);
    background-color: var(--background);
    color: var(--text-primary);
    line-height: 1.6;
}

/* App Container */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--primary-color);
    font-weight: 700;
    font-size: 1.25rem;
}

/* Upload Section */
.upload-section {
    padding: 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.upload-section h3,
.documents-section h3 {
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-secondary);
    margin-bottom: 1rem;
}

.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem 1.5rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: var(--surface-secondary);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.upload-area.drag-over {
    border-color: var(--primary-color);
    background: var(--primary-light);
}

.upload-area svg {
    color: var(--text-muted);
    margin-bottom: 0.75rem;
}

.upload-area p {
    font-weight: 500;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
}

.upload-area span {
    font-size: 0.875rem;
    color: var(--text-muted);
}

.upload-progress {
    margin-top: 1rem;
}

.progress-bar {
    height: 6px;
    background: var(--surface-secondary);
    border-radius: 3px;
    overflow: hidden;
    margin-bottom: 0.5rem;
}

.progress-fill {
    height: 100%;
    background: var(--primary-color);
    border-radius: 3px;
    transition: width 0.3s ease;
    width: 0%;
}

#uploadStatus {
    font-size: 0.875rem;
    color: var(--text-secondary);
}

/* Documents List */
.documents-section {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.documents-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.empty-state {
    text-align: center;
    padding: 2rem 1rem;
    color: var(--text-muted);
}

.document-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1rem;
    background: var(--surface-secondary);
    border-radius: 8px;
    transition: all 0.2s ease;
}

.document-item:hover {
    background: var(--primary-light);
}

.document-item.active {
    background: var(--primary-light);
    border: 1px solid var(--primary-color);
}

.document-icon {
    width: 40px;
    height: 40px;
    background: var(--primary-color);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.document-info {
    flex: 1;
    min-width: 0;
}

.document-name {
    font-weight: 500;
    font-size: 0.875rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.document-meta {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.document-delete {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: all 0.2s ease;
}

.document-delete:hover {
    color: var(--error);
    background: rgba(239, 68, 68, 0.1);
}

/* Main Chat Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.chat-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border-color);
    background: var(--surface);
}

.chat-header h1 {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.chat-header p {
    color: var(--text-secondary);
    font-size: 0.875rem;
}

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

.chat-messages {
    max-width: var(--chat-max-width);
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

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

.user-message {
    flex-direction: row-reverse;
    margin-left: auto;
}

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

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

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

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

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

.message-content {
    flex: 1;
    min-width: 0;
}

.message-content p {
    background: var(--surface);
    padding: 1rem 1.25rem;
    border-radius: 12px;
    box-shadow: var(--shadow-sm);
    line-height: 1.7;
}

.user-message .message-content p {
    background: var(--primary-color);
    color: white;
}

.bot-message .message-content p {
    border: 1px solid var(--border-color);
}

/* Markdown formatting in messages */
.message-content p strong {
    font-weight: 600;
    color: var(--text-primary);
}

.message-content p em {
    font-style: italic;
}

.message-content p code {
    background: var(--surface-secondary);
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    font-family: 'Consolas', 'Monaco', monospace;
    font-size: 0.875em;
}

.message-content p ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

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

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

/* Sources */
.message-sources {
    margin-top: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--surface-secondary);
    border-radius: 8px;
    font-size: 0.8125rem;
}

.sources-label {
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 0.5rem;
}

.source-item {
    color: var(--text-muted);
    padding: 0.25rem 0;
    border-top: 1px solid var(--border-color);
}

.source-item:first-of-type {
    border-top: none;
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 1rem 1.25rem;
    background: var(--surface);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    width: fit-content;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: var(--text-muted);
    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); }
}

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

.chat-input-form {
    max-width: var(--chat-max-width);
    margin: 0 auto;
    display: flex;
    gap: 0.75rem;
    background: var(--surface-secondary);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 0.5rem;
    transition: border-color 0.2s ease;
}

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

#messageInput {
    flex: 1;
    border: none;
    background: transparent;
    padding: 0.75rem 1rem;
    font-size: 0.9375rem;
    font-family: inherit;
    outline: none;
}

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

#sendButton {
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 8px;
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background-color 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

#sendButton:hover {
    background: var(--primary-hover);
}

#sendButton:disabled {
    background: var(--text-muted);
    cursor: not-allowed;
}

.disclaimer {
    max-width: var(--chat-max-width);
    margin: 0.75rem auto 0;
    font-size: 0.75rem;
    color: var(--text-muted);
    text-align: center;
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        max-height: 40vh;
        border-right: none;
        border-bottom: 1px solid var(--border-color);
    }

    .chat-main {
        min-height: 60vh;
    }

    .chat-header {
        padding: 1rem;
    }

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

/* Scrollbar Styling */
::-webkit-scrollbar {
    width: 6px;
}

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

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

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

/* Notification Toast */
.toast {
    position: fixed;
    bottom: 2rem;
    right: 2rem;
    background: var(--text-primary);
    color: white;
    padding: 1rem 1.5rem;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease;
    z-index: 1000;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--error);
}

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