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

:root {
    --primary-color: #4f46e5;
    --primary-dark: #4338ca;
    --secondary-color: #64748b;
    --success-color: #10b981;
    --error-color: #ef4444;
    --warning-color: #f59e0b;
    --bg-color: #f8fafc;
    --surface-color: #ffffff;
    --border-color: #e2e8f0;
    --text-color: #1e293b;
    --text-secondary: #64748b;
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

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

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
}

/* Header */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
    padding: 30px;
    border-radius: 12px;
    margin-bottom: 20px;
    box-shadow: var(--shadow-md);
}

.header h1 {
    font-size: 2.5rem;
    margin-bottom: 5px;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 15px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
}

.dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background-color: var(--secondary-color);
    animation: pulse 2s infinite;
}

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

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

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

/* Main Content */
.main-content {
    display: grid;
    grid-template-columns: 350px 1fr;
    gap: 20px;
    min-height: 600px;
}

/* Sidebar */
.sidebar {
    background: var(--surface-color);
    border-radius: 12px;
    padding: 20px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.sidebar-section {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 20px;
}

.sidebar-section:last-child {
    border-bottom: none;
    padding-bottom: 0;
}

.sidebar-section h3 {
    font-size: 1.2rem;
    margin-bottom: 15px;
    color: var(--text-color);
}

.sidebar-section h4 {
    font-size: 1rem;
    margin-bottom: 10px;
    color: var(--text-secondary);
}

/* Folder Input Section */
.folder-input-section {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.folder-input-section label {
    font-weight: 500;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.input-field {
    padding: 10px 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Documents List */
.documents-list {
    max-height: 200px;
    overflow-y: auto;
    margin-bottom: 10px;
    padding: 10px;
    background: var(--bg-color);
    border-radius: 8px;
}

.document-item {
    padding: 8px 10px;
    margin-bottom: 8px;
    background: var(--surface-color);
    border-radius: 6px;
    border-left: 3px solid var(--primary-color);
    font-size: 0.85rem;
}

.document-item .filename {
    font-weight: 500;
    display: block;
    margin-bottom: 3px;
}

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

.placeholder-text {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-align: center;
    padding: 20px;
}

/* System Info */
.system-info {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    font-size: 0.9rem;
}

.info-item .label {
    color: var(--text-secondary);
    font-weight: 500;
}

.info-item .value {
    color: var(--text-color);
    font-weight: 600;
}

/* Chat Container */
.chat-container {
    background: var(--surface-color);
    border-radius: 12px;
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
}

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

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

/* Chat Messages */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    min-height: 400px;
    max-height: 600px;
}

.welcome-message {
    padding: 30px;
    background: var(--bg-color);
    border-radius: 12px;
    border: 2px dashed var(--border-color);
}

.welcome-message h3 {
    color: var(--primary-color);
    margin-bottom: 15px;
}

.welcome-message ol {
    margin-left: 20px;
    margin-bottom: 15px;
}

.welcome-message ol li {
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.welcome-message .note {
    background: var(--primary-color);
    color: white;
    padding: 15px;
    border-radius: 8px;
    margin-top: 15px;
}

.message {
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease-in;
}

.message-user {
    display: flex;
    justify-content: flex-end;
}

.message-user .message-content {
    background: var(--primary-color);
    color: white;
    padding: 12px 16px;
    border-radius: 12px 12px 0 12px;
    max-width: 80%;
}

.message-assistant {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.message-assistant .message-content {
    background: var(--bg-color);
    color: var(--text-color);
    padding: 12px 16px;
    border-radius: 12px 12px 12px 0;
    max-width: 90%;
    border: 1px solid var(--border-color);
}

.message-sources {
    margin-top: 10px;
    padding: 12px;
    background: var(--surface-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

.message-sources h4 {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.source-item {
    padding: 6px 10px;
    background: var(--bg-color);
    border-radius: 6px;
    margin-bottom: 6px;
    font-size: 0.8rem;
}

.source-item strong {
    color: var(--primary-color);
}

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

/* Chat Input */
.chat-input-container {
    padding: 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    gap: 12px;
}

.chat-input {
    flex: 1;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    font-size: 0.95rem;
    font-family: inherit;
    resize: vertical;
    min-height: 60px;
    transition: border-color 0.2s;
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    justify-content: center;
}

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

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

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

.btn-secondary:hover:not(:disabled) {
    background: #475569;
}

.btn-send {
    background: var(--success-color);
    color: white;
    padding: 12px 24px;
}

.btn-send:hover:not(:disabled) {
    background: #059669;
}

.btn-text {
    background: transparent;
    color: var(--text-secondary);
    padding: 8px 12px;
}

.btn-text:hover {
    background: var(--bg-color);
    color: var(--text-color);
}

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

.btn-icon {
    font-size: 1.1rem;
}

/* Loading Overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-spinner {
    width: 60px;
    height: 60px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.loading-overlay p {
    color: white;
    margin-top: 20px;
    font-size: 1.1rem;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Toast Notifications */
.toast {
    position: fixed;
    bottom: 30px;
    right: 30px;
    background: var(--text-color);
    color: white;
    padding: 16px 20px;
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1001;
    max-width: 400px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

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

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

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

/* Demo Banner */
.demo-banner {
    background: linear-gradient(90deg, #fbbf24, #f59e0b);
    color: #78350f;
    text-align: center;
    padding: 10px 20px;
    font-size: 0.9rem;
    font-weight: 500;
    letter-spacing: 0.02em;
}

.demo-banner-icon {
    margin-right: 6px;
    font-size: 1rem;
}

/* Site Footer */
.site-footer {
    margin-top: 40px;
    padding: 30px 20px;
    background: var(--text-color);
    color: #cbd5e1;
    text-align: center;
}

.footer-content {
    max-width: 1400px;
    margin: 0 auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
    align-items: center;
}

.footer-credit {
    font-size: 1rem;
}

.footer-credit strong {
    color: #ffffff;
}

.footer-links {
    display: flex;
    gap: 20px;
    flex-wrap: wrap;
    justify-content: center;
}

.footer-links a {
    color: #93c5fd;
    text-decoration: none;
    font-size: 0.9rem;
    transition: color 0.2s;
}

.footer-links a:hover {
    color: #ffffff;
    text-decoration: underline;
}

.footer-tech {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    justify-content: center;
    margin-top: 4px;
}

.tech-badge {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 20px;
    font-size: 0.75rem;
    color: #e2e8f0;
    font-weight: 500;
    letter-spacing: 0.03em;
}

/* Responsive Design */
@media (max-width: 1024px) {
    .main-content {
        grid-template-columns: 1fr;
    }

    .sidebar {
        order: 2;
    }

    .chat-container {
        order: 1;
    }
}

@media (max-width: 768px) {
    .header h1 {
        font-size: 1.75rem;
    }

    .header {
        padding: 20px;
    }

    .chat-messages {
        min-height: 300px;
        max-height: 400px;
    }

    .message-user .message-content,
    .message-assistant .message-content {
        max-width: 95%;
    }

    .container {
        padding: 10px;
    }

    .demo-banner {
        font-size: 0.8rem;
        padding: 8px 12px;
    }

    .site-footer {
        padding: 24px 16px;
    }

    .footer-links {
        gap: 12px;
    }

    .chat-input-container {
        flex-direction: column;
    }

    .btn-send {
        width: 100%;
    }
}

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

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

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

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

/* Typing Indicator */
.typing-indicator .message-content {
    display: flex;
    align-items: center;
    gap: 10px;
}

.typing-dots {
    display: flex;
    gap: 4px;
    align-items: center;
}

.typing-dots span {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--primary-color);
    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;
}

.typing-text {
    color: var(--text-secondary);
    font-size: 0.9rem;
    font-style: italic;
}

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