/* RAG CMS Styles */
:root {
    --primary: #6366f1;
    --primary-dark: #4f46e5;
    --secondary: #8b5cf6;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --bg-primary: #ffffff;
    --bg-secondary: #f9fafb;
    --bg-tertiary: #f3f4f6;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-tertiary: #9ca3af;
    --border: #e5e7eb;
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    color: var(--text-primary);
    background: var(--bg-secondary);
    line-height: 1.6;
}

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

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--bg-primary);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
}

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

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 18px;
    color: var(--text-primary);
    margin-bottom: 12px;
}

.embedding-badge {
    display: inline-block;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.nav-menu {
    flex: 1;
    padding: 12px 8px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    margin-bottom: 4px;
    border-radius: var(--radius);
    color: var(--text-secondary);
    text-decoration: none;
    transition: all 0.2s;
    font-weight: 500;
    font-size: 14px;
}

.nav-item:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.nav-item.active {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid var(--border);
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: var(--text-secondary);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--text-tertiary);
    animation: pulse 2s infinite;
}

.status-dot.online {
    background: var(--success);
}

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

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    overflow-y: auto;
    padding: 32px;
}

.view {
    display: none;
}

.view.active {
    display: block;
}

.view-header {
    margin-bottom: 32px;
    display: flex;
    justify-content: space-between;
    align-items: start;
}

.view-header h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.view-header p {
    color: var(--text-secondary);
    font-size: 15px;
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.stat-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-icon.documents { background: linear-gradient(135deg, #dbeafe, #bfdbfe); }
.stat-icon.chunks { background: linear-gradient(135deg, #ddd6fe, #c4b5fd); }
.stat-icon.queries { background: linear-gradient(135deg, #fce7f3, #fbcfe8); }
.stat-icon.storage { background: linear-gradient(135deg, #d1fae5, #a7f3d0); }

.stat-value {
    font-size: 32px;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-label {
    font-size: 13px;
    color: var(--text-secondary);
    font-weight: 500;
}

/* Info Grid */
.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr));
    gap: 20px;
}

.info-card {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

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

.info-row, .health-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid var(--bg-tertiary);
}

.info-row:last-child, .health-row:last-child {
    border-bottom: none;
}

.info-row span:first-child, .health-row span:first-child {
    color: var(--text-secondary);
    font-size: 14px;
}

.info-row span:last-child, .health-row span:last-child {
    font-weight: 600;
    font-size: 14px;
}

.highlight {
    color: var(--primary) !important;
}

.health-status {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px !important;
    font-weight: 600 !important;
}

.health-status.online {
    background: #d1fae5;
    color: #065f46;
}

.health-status.offline {
    background: #fee2e2;
    color: #991b1b;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: var(--radius);
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.btn-secondary {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

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

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

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

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
}

/* Search Bar */
.search-bar {
    position: relative;
    margin-bottom: 24px;
}

.search-bar svg {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
}

.search-bar input {
    width: 100%;
    padding: 12px 16px 12px 48px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    background: var(--bg-primary);
}

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

/* Documents List */
.documents-list {
    display: grid;
    gap: 16px;
}

.document-card {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
    transition: all 0.2s;
    cursor: pointer;
}

.document-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.document-header {
    display: flex;
    justify-content: space-between;
    align-items: start;
    margin-bottom: 12px;
}

.document-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.document-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--text-secondary);
}

.document-actions {
    display: flex;
    gap: 8px;
}

.document-content {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
    margin-bottom: 12px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.document-footer {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.badge {
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}

.badge-primary {
    background: #dbeafe;
    color: #1e40af;
}

.badge-success {
    background: #d1fae5;
    color: #065f46;
}

/* Search View */
.search-container {
    max-width: 800px;
}

.search-input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.search-input-group input {
    flex: 1;
    padding: 14px 20px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 15px;
}

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

.search-options {
    margin-bottom: 24px;
}

.search-options label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--text-secondary);
}

.search-options select {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
}

.search-results {
    display: grid;
    gap: 16px;
}

.search-result {
    background: var(--bg-primary);
    padding: 20px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.search-result-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.search-result-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.similarity-score {
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 600;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
}

.search-result-content {
    color: var(--text-secondary);
    font-size: 14px;
    line-height: 1.6;
}

/* Upload View */
.upload-container {
    max-width: 600px;
}

.upload-zone {
    border: 2px dashed var(--border);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    background: var(--bg-primary);
    transition: all 0.2s;
    cursor: pointer;
}

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

.upload-zone h3 {
    margin: 16px 0 8px;
    font-size: 18px;
}

.upload-zone p {
    color: var(--text-secondary);
    margin-bottom: 20px;
}

.upload-progress {
    margin-top: 24px;
}

.upload-progress.hidden {
    display: none;
}

.upload-file {
    background: var(--bg-primary);
    padding: 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    border: 1px solid var(--border);
}

.upload-file-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 8px;
}

.upload-file-name {
    font-weight: 500;
    font-size: 14px;
}

.upload-file-status {
    font-size: 13px;
    color: var(--text-secondary);
}

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

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

.progress-bar {
    height: 4px;
    background: var(--bg-tertiary);
    border-radius: 2px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, var(--primary), var(--secondary));
    transition: width 0.3s;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
}

.modal-large {
    max-width: 900px;
}

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    font-size: 28px;
    color: var(--text-tertiary);
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius);
}

.modal-close:hover {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

/* Form */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    font-size: 14px;
    color: var(--text-primary);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: inherit;
    background: var(--bg-primary);
}

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

.form-group textarea {
    resize: vertical;
}

.form-actions {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
    margin-top: 24px;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.toast {
    background: var(--bg-primary);
    padding: 16px 20px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-lg);
    min-width: 300px;
    display: flex;
    align-items: center;
    gap: 12px;
    animation: slideIn 0.3s;
    border-left: 4px solid var(--primary);
}

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

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

.toast-icon {
    font-size: 20px;
}

.toast-message {
    flex: 1;
    font-size: 14px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Loading */
.loading {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-secondary);
    font-size: 15px;
}

.loading::after {
    content: '';
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin-left: 12px;
    vertical-align: middle;
}

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

/* Embedding View */
.embedding-list {
    display: grid;
    gap: 12px;
}

.embedding-item {
    background: var(--bg-secondary);
    padding: 12px;
    border-radius: var(--radius);
    font-family: 'Monaco', 'Courier New', monospace;
    font-size: 12px;
}

.embedding-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-weight: 600;
    color: var(--text-primary);
}

.embedding-values {
    color: var(--text-secondary);
    word-break: break-all;
}

/* Authentication */
.auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}

.auth-box {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 440px;
    overflow: hidden;
}

.auth-form {
    display: none !important;
    animation: fadeIn 0.3s;
}

.auth-form.active {
    display: block !important;
}

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

.auth-header {
    text-align: center;
    padding: 40px 40px 32px;
    background: linear-gradient(135deg, rgba(102, 126, 234, 0.05) 0%, rgba(118, 75, 162, 0.05) 100%);
}

.auth-logo {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 20px;
}

.auth-header h1 {
    font-size: 24px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 8px;
}

.auth-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.auth-form-fields {
    padding: 32px 40px;
}

.auth-footer {
    padding: 20px 40px 32px;
    text-align: center;
    border-top: 1px solid var(--border);
    background: var(--bg-secondary);
}

.auth-footer p {
    font-size: 14px;
    color: var(--text-secondary);
}

.auth-footer a,
.auth-links a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
}

.auth-footer a:hover,
.auth-links a:hover {
    color: var(--primary-dark);
    text-decoration: underline;
}

.auth-links {
    text-align: center;
    margin-top: 16px;
}

.auth-links a {
    font-size: 14px;
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.form-group input::placeholder {
    color: var(--text-tertiary);
}

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
    }

    .sidebar-header .logo span,
    .embedding-badge,
    .nav-item span,
    .status-text {
        display: none;
    }

    .main-content {
        margin-left: 70px;
        padding: 20px;
    }

    .stats-grid {
        grid-template-columns: 1fr;
    }

    .view-header {
        flex-direction: column;
        gap: 16px;
    }

    .auth-header {
        padding: 32px 24px 24px;
    }

    .auth-form-fields {
        padding: 24px;
    }

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

    .auth-box {
        max-width: 100%;
    }
}
