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

:root {
    --primary-color: #6366f1;
    --primary-hover: #4f46e5;
    --secondary-color: #8b5cf6;
    --danger-color: #ef4444;
    --success-color: #10b981;
    --warning-color: #f59e0b;
    --bg-dark: #1f2937;
    --bg-light: #f9fafb;
    --bg-gray: #374151;
    --text-dark: #111827;
    --text-light: #f9fafb;
    --text-gray: #6b7280;
    --border-color: #e5e7eb;
    --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1);
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.modal-content {
    background: white;
    padding: 2.5rem;
    border-radius: 16px;
    width: 90%;
    max-width: 450px;
    box-shadow: 0 20px 25px -5px rgb(0 0 0 / 0.1);
    animation: slideIn 0.3s ease-out;
}

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

.modal-content h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    color: var(--text-dark);
    font-size: 1.8rem;
}

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1.5rem;
    border-bottom: 2px solid var(--border-color);
}

.tab-btn {
    flex: 1;
    padding: 0.75rem;
    border: none;
    background: transparent;
    color: var(--text-gray);
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    position: relative;
}

.tab-btn.active {
    color: var(--primary-color);
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -2px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Form Styles */
.form-group {
    margin-bottom: 1.25rem;
}

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

.form-group input {
    width: 100%;
    padding: 0.75rem;
    border: 2px solid var(--border-color);
    border-radius: 8px;
    font-size: 1rem;
    transition: all 0.3s;
}

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

/* Button Styles */
.btn {
    padding: 0.75rem 1.5rem;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    width: 100%;
}

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

.btn-secondary {
    background: var(--bg-gray);
    color: white;
}

.btn-secondary:hover {
    background: var(--bg-dark);
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background: #dc2626;
}

.btn-block {
    width: 100%;
    margin-top: 0.5rem;
}

/* Chat Interface */
#chatInterface {
    display: flex;
    width: 100%;
    height: 100vh;
    background: white;
}

.hidden {
    display: none !important;
}

/* Sidebar */
.sidebar {
    width: 350px;
    background: var(--bg-light);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    overflow-y: auto;
    transition: transform 0.3s;
}

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

.sidebar-header h3 {
    color: var(--text-dark);
    font-size: 1.25rem;
}

.toggle-btn {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-gray);
}

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

.upload-section h4 {
    margin-bottom: 1rem;
    color: var(--text-dark);
    font-size: 1.1rem;
}

/* Accordion */
.accordion {
    margin-bottom: 1rem;
}

.accordion-btn {
    width: 100%;
    padding: 0.75rem;
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    text-align: left;
    cursor: pointer;
    font-weight: 500;
    color: var(--text-dark);
    display: flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s;
}

.accordion-btn:hover {
    background: var(--bg-light);
}

.accordion-content {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out;
    background: white;
    border: 1px solid var(--border-color);
    border-top: none;
    border-radius: 0 0 8px 8px;
    margin-top: -8px;
}

.accordion-content.active {
    max-height: 500px;
    padding: 1rem;
    overflow-y: auto;
}

.accordion-content p {
    margin-bottom: 0.75rem;
    font-size: 0.9rem;
    color: var(--text-gray);
    line-height: 1.6;
}

.accordion-content a {
    color: var(--primary-color);
    text-decoration: none;
}

.accordion-content a:hover {
    text-decoration: underline;
}

/* Upload Area */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: 12px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: white;
}

.upload-area:hover,
.upload-area.drag-over {
    border-color: var(--primary-color);
    background: rgba(99, 102, 241, 0.05);
}

.upload-area i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
}

.upload-area p {
    color: var(--text-gray);
    margin-bottom: 0.5rem;
}

.or-text {
    font-size: 0.9rem;
    color: var(--text-gray);
    margin: 1rem 0;
}

/* Upload Queue */
.upload-queue {
    margin-top: 1rem;
}

.upload-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
    transition: all 0.3s;
}

.upload-item-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

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

.upload-item-name {
    font-size: 0.9rem;
    color: var(--text-dark);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    margin-bottom: 0.25rem;
}

.upload-item-name i {
    color: var(--primary-color);
    flex-shrink: 0;
}

.upload-item-size {
    font-size: 0.75rem;
    color: var(--text-gray);
}

.upload-item-status {
    font-size: 0.8rem;
    margin-left: 0.5rem;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.upload-item-status.uploading {
    color: var(--warning-color);
}

.upload-item-status.processing {
    color: #3b82f6;  /* Blue for processing */
    animation: pulse 2s infinite;
}

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

.upload-item-status.success {
    color: var(--success-color);
}

.upload-item-status.error {
    color: var(--danger-color);
}

.upload-item-status.warning {
    color: var(--warning-color);
}

.upload-progress {
    height: 24px;
    background: var(--bg-light);
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    margin-bottom: 0.5rem;
}

.upload-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--primary-color), #8b5cf6);
    transition: width 0.3s;
    display: flex;
    align-items: center;
    justify-content: flex-end;
    padding-right: 0.5rem;
}

.upload-progress-text {
    font-size: 0.75rem;
    font-weight: 600;
    color: white;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Upload Message */
.upload-message {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(99, 102, 241, 0.05);
    border-left: 3px solid var(--primary-color);
    border-radius: 4px;
    font-size: 0.8rem;
    color: var(--text-gray);
    line-height: 1.4;
}

.upload-message i {
    color: var(--primary-color);
    margin-top: 0.1rem;
    flex-shrink: 0;
}

/* Files Section */
.files-section {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

.files-section h4 {
    margin-bottom: 1rem;
    color: var(--text-dark);
    font-size: 1.1rem;
}

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

.file-item {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 0.75rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    transition: all 0.3s;
}

.file-item:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow);
}

.file-name {
    font-size: 0.9rem;
    color: var(--text-dark);
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.delete-btn {
    background: transparent;
    border: none;
    color: var(--danger-color);
    cursor: pointer;
    font-size: 1rem;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: all 0.3s;
}

.delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
}

.loading {
    text-align: center;
    color: var(--text-gray);
    font-size: 0.9rem;
}

/* Sidebar Footer */
.sidebar-footer {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid var(--border-color);
}

/* Chat Container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.chat-header {
    padding: 1.5rem;
    background: white;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 1rem;
}

.menu-toggle {
    display: none;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-gray);
}

.chat-header h2 {
    color: var(--text-dark);
    font-size: 1.5rem;
}

/* Messages Container */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 2rem;
    background: var(--bg-light);
}

.message {
    margin-bottom: 1.5rem;
    animation: messageSlide 0.3s ease-out;
}

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

.message-content {
    max-width: 80%;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    line-height: 1.6;
}

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

.message.assistant .message-content {
    background: white;
    color: var(--text-dark);
    border: 1px solid var(--border-color);
    border-bottom-left-radius: 4px;
}

.message-sources {
    margin-top: 0.75rem;
    max-width: 80%;
}

/* Sources Toggle Button */
.sources-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    border-radius: 6px;
    color: var(--primary-color);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    width: 100%;
}

.sources-toggle:hover {
    background: rgba(99, 102, 241, 0.15);
    border-color: var(--primary-color);
}

.sources-toggle .toggle-icon {
    margin-left: auto;
    transition: transform 0.3s;
    font-size: 0.75rem;
}

/* Sources Content */
.sources-content {
    overflow: hidden;
    transition: all 0.3s ease-in-out;
    background: rgba(99, 102, 241, 0.05);
    border-radius: 0 0 8px 8px;
}

.sources-content.collapsed {
    max-height: 0;
    opacity: 0;
    padding: 0;
}

.sources-content.expanded {
    max-height: 1000px;
    opacity: 1;
    padding: 0.75rem;
    margin-top: 0.25rem;
}

.sources-list {
    font-size: 0.85rem;
    color: var(--text-gray);
}

.sources-list li {
    margin-bottom: 0.25rem;
    margin-left: 1.25rem;
}

.message-feedback {
    margin-top: 0.5rem;
    display: flex;
    gap: 0.5rem;
}

.feedback-btn {
    background: transparent;
    border: 1px solid var(--border-color);
    padding: 0.4rem 0.75rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.feedback-btn:hover {
    background: var(--bg-light);
}

/* Typing Indicator */
.typing-indicator .message-content {
    padding: 0.75rem 1rem;
}

.typing-dots {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

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

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

.feedback-btn.active {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
}

/* Input Container */
.input-container {
    padding: 1.5rem;
    background: white;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 1rem;
    align-items: flex-end;
}

#messageInput {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: 12px;
    font-size: 1rem;
    font-family: inherit;
    resize: none;
    max-height: 150px;
    transition: all 0.3s;
}

#messageInput:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.send-btn {
    width: 50px;
    height: 50px;
    background: var(--primary-color);
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    font-size: 1.25rem;
    transition: all 0.3s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover {
    background: var(--primary-hover);
    transform: translateY(-2px);
}

.send-btn:disabled {
    background: var(--text-gray);
    cursor: not-allowed;
    transform: none;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    top: 1rem;
    right: 1rem;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    padding: 1rem 1.5rem;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    box-shadow: var(--shadow);
    animation: toastSlide 0.3s ease-out;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    min-width: 300px;
}

@keyframes toastSlide {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

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

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

.toast.warning {
    background: var(--warning-color);
}

.toast.info {
    background: var(--primary-color);
}

/* Responsive Design */
@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        height: 100vh;
        z-index: 100;
        transform: translateX(-100%);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .toggle-btn,
    .menu-toggle {
        display: block;
    }

    .message-content,
    .message-sources {
        max-width: 90%;
    }

    .modal-content {
        padding: 1.5rem;
    }

    .toast {
        min-width: auto;
        max-width: calc(100vw - 2rem);
    }
}

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

::-webkit-scrollbar-track {
    background: var(--bg-light);
}

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

::-webkit-scrollbar-thumb:hover {
    background: var(--bg-gray);
}

