/* Enable scrolling for this page */
body.rag-page {
    overflow-y: auto !important;
    overflow-x: hidden;
    height: auto;
    min-height: 100vh;
}

body.rag-page #app {
    height: auto;
    min-height: 100vh;
}

/* RAG Admin Page Styles */

.rag-main {
    max-width: 1000px;
    margin: 0 auto;
    padding: 2rem;
    padding-top: 80px;
}

/* Header */
.rag-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
    padding: 1.5rem;
    background: linear-gradient(135deg, #6366f1 0%, #8b5cf6 100%);
    border-radius: 16px;
    color: var(--text-primary);
}

.header-content h1 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0 0 0.25rem 0;
}

.header-subtitle {
    font-size: 0.9rem;
    opacity: 0.9;
    margin: 0;
}

.header-actions {
    display: flex;
    gap: 0.75rem;
}

/* Status Card */
.status-card {
    background: var(--surface-elevated);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-subtle);
}

.status-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
}

.status-item {
    text-align: center;
}

.status-label {
    display: block;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.status-value {
    display: block;
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text-primary);
}

.status-value.online {
    color: var(--success);
}

.status-value.offline {
    color: var(--error);
}

/* Upload Section */
.upload-section {
    margin-bottom: 1.5rem;
}

.upload-area {
    border: 2px dashed var(--border-subtle);
    border-radius: 16px;
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s;
    background: var(--surface-elevated);
}

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

.upload-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
}

.upload-text {
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.upload-text strong {
    color: var(--accent-primary);
}

/* Documents Section */
.documents-section,
.sources-section {
    background: var(--surface-elevated);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-subtle);
}

.section-subtitle {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin: -0.5rem 0 1rem 0;
}

/* Sources Section */
.sources-list {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    max-height: 300px;
    overflow-y: auto;
}

.source-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.75rem 1rem;
    background: var(--surface-subtle);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    border: 2px solid transparent;
}

.source-item:hover {
    background: rgba(99, 102, 241, 0.05);
}

.source-item.selected {
    border-color: var(--accent-primary);
    background: rgba(99, 102, 241, 0.1);
}

.source-item.already-added {
    opacity: 0.5;
    cursor: not-allowed;
}

.source-checkbox {
    width: 20px;
    height: 20px;
    accent-color: var(--accent-primary);
}

.source-icon {
    font-size: 1.25rem;
}

.source-info {
    flex: 1;
}

.source-name {
    font-weight: 500;
    color: var(--text-primary);
    font-size: 0.9rem;
}

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

.source-status {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
}

.source-status.added {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.sources-actions {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid var(--border-subtle);
}

#selectedCount {
    font-size: 0.9rem;
    color: var(--text-secondary);
}

.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.section-header h2 {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-primary);
    margin: 0;
}

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

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

.document-item:hover {
    transform: translateX(4px);
}

.document-icon {
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 10px;
}

.document-info {
    flex: 1;
}

.document-name {
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 0.25rem;
    font-size: 0.95rem;
}

.document-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    gap: 1rem;
}

.document-status {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.status-badge {
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
}

.status-badge.indexed {
    background: rgba(16, 185, 129, 0.15);
    color: var(--success);
}

.status-badge.pending {
    background: rgba(245, 158, 11, 0.15);
    color: var(--warning);
}

.status-badge.needs-update {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

.document-actions {
    display: flex;
    gap: 0.5rem;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    transition: all 0.2s;
}

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

.btn-icon.danger:hover {
    background: rgba(239, 68, 68, 0.15);
    color: var(--error);
}

/* Search Section */
.search-section {
    background: var(--surface-elevated);
    border-radius: 16px;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    border: 1px solid var(--border-subtle);
}

.search-form {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.search-form input {
    flex: 1;
    padding: 0.75rem 1rem;
    border: 1px solid var(--border-subtle);
    border-radius: 10px;
    background: var(--surface-subtle);
    color: var(--text-primary);
    font-size: 0.95rem;
}

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

.search-results {
    max-height: 400px;
    overflow-y: auto;
}

.result-item {
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: var(--surface-subtle);
    border-radius: 10px;
    border-left: 4px solid var(--accent-primary);
}

.result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.result-type {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    background: rgba(99, 102, 241, 0.15);
    color: var(--accent-primary);
    text-transform: uppercase;
}

.result-relevance {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.result-content {
    font-size: 0.9rem;
    color: var(--text-primary);
    line-height: 1.5;
    max-height: 100px;
    overflow: hidden;
}

.result-source {
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 0.5rem;
}

/* Logs Section */
.logs-section {
    background: var(--surface-elevated);
    border-radius: 16px;
    padding: 1.5rem;
    border: 1px solid var(--border-subtle);
}

.logs-container {
    max-height: 200px;
    overflow-y: auto;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 0.8rem;
}

.log-entry {
    padding: 0.5rem;
    border-radius: 4px;
    margin-bottom: 0.25rem;
}

.log-entry.info {
    color: var(--text-secondary);
}

.log-entry.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
}

.log-entry.error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
}

.log-entry.warning {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

/* Buttons */
.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 8px;
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    border: none;
}

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

.btn-primary:hover {
    background: #5558e3;
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
    border: 1px solid rgba(255, 255, 255, 0.2);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.2);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    background: var(--surface-subtle);
    color: var(--text-secondary);
}

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

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

/* Empty State */
.empty-state {
    text-align: center;
    padding: 2rem;
    color: var(--text-secondary);
}

/* Loading */
.loading {
    opacity: 0.6;
    pointer-events: none;
}

/* Responsive */
@media (max-width: 768px) {
    .rag-main {
        padding: 1rem;
        padding-top: 70px;
    }
    
    .rag-header {
        flex-direction: column;
        gap: 1rem;
        text-align: center;
    }
    
    .status-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .search-form {
        flex-direction: column;
    }
    
    .document-item {
        flex-direction: column;
        text-align: center;
    }
    
    .document-meta {
        flex-direction: column;
        gap: 0.25rem;
    }
}
