:root {
    --primary: #6366f1;
    --primary-hover: #4f46e5;
    --secondary: #64748b;
    --bg-dark: #0f172a;
    --bg-dark-light: #1e293b;
    --text-main: #f8fafc;
    --text-dim: #94a3b8;
    --glass: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --accent: #10b981;
    --danger: #ef4444;
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-lg: 16px;
    --radius-md: 12px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow: hidden;
    height: 100vh;
}

h1,
h2,
h3 {
    font-family: 'Outfit', sans-serif;
}

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

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-dark-light);
    border-right: 1px solid var(--glass-border);
    display: flex;
    flex-direction: column;
    padding: 24px 16px;
    z-index: 100;
}

.logo-section {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding: 0 8px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary), #a855f7);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.logo-section h1 {
    font-size: 22px;
    font-weight: 800;
    letter-spacing: -0.5px;
}

.logo-section span {
    color: var(--primary);
}

.nav-menu {
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    text-align: left;
}

.nav-item i {
    font-size: 18px;
    width: 24px;
}

.nav-item:hover {
    color: var(--text-main);
    background-color: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--text-main);
    background-color: var(--primary);
}

.sidebar-footer {
    margin-top: auto;
    padding: 16px 8px 0;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.dot.online {
    background-color: var(--accent);
    box-shadow: 0 0 8px var(--accent);
}

.version {
    font-size: 12px;
    color: var(--text-dim);
    opacity: 0.6;
}

/* Main Content */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    position: relative;
    background: radial-gradient(circle at top right, rgba(99, 102, 241, 0.05), transparent);
}

.top-header {
    height: var(--header-height);
    padding: 0 32px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--glass-border);
    backdrop-filter: blur(10px);
    z-index: 10;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 16px;
}

#page-title {
    font-size: 20px;
    font-weight: 700;
    font-family: 'Outfit', sans-serif;
}

.workspace-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(99, 102, 241, 0.1);
    border: 1px solid rgba(99, 102, 241, 0.2);
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
}

.workspace-badge i {
    font-size: 10px;
}

.user-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.user-actions button {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
    transition: color 0.2s;
}

.user-actions button:hover {
    color: var(--text-main);
}

.content-scroll {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    scrollbar-width: thin;
    scrollbar-color: var(--primary) transparent;
}

.tab-content {
    display: none;
    max-width: 1000px;
    margin: 0 auto;
    animation: fadeIn 0.3s ease-out;
}

.tab-content.active {
    display: block;
}

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

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Chat Tab */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - var(--header-height) - 64px);
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.message.user {
    align-self: flex-end;
}

.message.assistant {
    align-self: flex-start;
}

.message-content {
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 15px;
    line-height: 1.5;
    position: relative;
}

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

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

.chat-input-area {
    padding: 24px;
    border-top: 1px solid var(--glass-border);
    background-color: rgba(15, 23, 42, 0.5);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    background-color: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 12px 12px;
    gap: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

#chat-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 15px;
    resize: none;
    max-height: 150px;
    outline: none;
    padding: 4px 0;
}

#send-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background-color: var(--primary);
    color: white;
    border: none;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#send-btn:hover {
    background-color: var(--primary-hover);
}

/* Document Grid */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.docs-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 20px;
}

.doc-card {
    background: var(--bg-dark-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 20px;
    transition: transform 0.2s, border-color 0.2s;
    cursor: default;
    position: relative;
}

.doc-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary);
}

.doc-icon {
    font-size: 24px;
    color: var(--primary);
    margin-bottom: 16px;
}

.doc-title {
    font-weight: 600;
    font-size: 16px;
    margin-bottom: 8px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.doc-info {
    font-size: 13px;
    color: var(--text-dim);
    display: flex;
    justify-content: space-between;
}

.doc-delete-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: transparent;
    border: none;
    color: var(--text-dim);
    opacity: 0.3;
    cursor: pointer;
    transition: all 0.2s;
}

.doc-card:hover .doc-delete-btn {
    opacity: 1;
}

.doc-status-badge {
    position: absolute;
    bottom: 45px;
    right: 12px;
    font-size: 10px;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 600;
    letter-spacing: 0.5px;
}

.status-processing {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.3);
    animation: pulse 2s infinite;
}

.status-failed {
    background: rgba(239, 68, 68, 0.2);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

@keyframes pulse {
    0% {
        opacity: 0.6;
    }

    50% {
        opacity: 1;
    }

    100% {
        opacity: 0.6;
    }
}

.doc-delete-btn:hover {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    transform: scale(1.1);
}

/* Upload Area */
.upload-container {
    max-width: 600px;
    margin: 40px auto;
}

.upload-box {
    border: 2px dashed var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 60px 40px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background-color: rgba(30, 41, 59, 0.3);
}

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

.upload-icon {
    font-size: 48px;
    color: var(--text-dim);
    margin-bottom: 24px;
}

.upload-box h3 {
    font-size: 20px;
    margin-bottom: 12px;
}

.upload-box p {
    color: var(--text-dim);
    margin-bottom: 16px;
}

.file-limit {
    font-size: 12px;
    color: var(--text-dim);
    opacity: 0.6;
}

.upload-progress-container {
    margin-top: 32px;
    background: var(--bg-dark-light);
    border-radius: var(--radius-md);
    padding: 24px;
}

.progress-info {
    display: flex;
    justify-content: space-between;
    margin-bottom: 12px;
    font-size: 14px;
}

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

.progress-fill {
    height: 100%;
    background: var(--primary);
    width: 0%;
    transition: width 0.3s;
}

.processing-steps {
    margin-top: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.step {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 13px;
    color: var(--text-dim);
    opacity: 0.7;
}

.step.active {
    color: var(--primary);
    opacity: 1;
}

.step.done {
    color: var(--accent);
    opacity: 1;
}

.step i {
    width: 16px;
    text-align: center;
}

/* Search Area */
.search-bar-wrapper {
    display: flex;
    align-items: center;
    background: var(--bg-dark-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 12px 24px;
    gap: 16px;
    margin-bottom: 16px;
}

.search-main-icon {
    color: var(--text-dim);
    font-size: 18px;
}

#raw-search-input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-main);
    font-size: 16px;
    outline: none;
}

.search-options {
    display: flex;
    gap: 24px;
    padding-left: 8px;
    font-size: 14px;
    color: var(--text-dim);
}

.search-options label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
}

.search-results-area {
    margin-top: 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
}

.search-result-item {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-md);
    padding: 24px;
}

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

.result-title {
    font-weight: 700;
    color: var(--primary);
}

.result-score {
    font-size: 12px;
    background: rgba(16, 185, 129, 0.1);
    color: var(--accent);
    padding: 2px 8px;
    border-radius: 20px;
}

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

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    padding: 10px 24px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}

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

.btn-secondary {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    color: var(--text-main);
    padding: 10px 20px;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* Notifications */
.notification-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.notification {
    padding: 16px 24px;
    border-radius: 12px;
    background: var(--bg-dark-light);
    color: white;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.3);
    border-left: 4px solid var(--primary);
    animation: slideIn 0.3s ease-out;
    min-width: 300px;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
    }

    to {
        transform: translateX(0);
    }
}

@media (max-width: 768px) {
    .sidebar {
        width: 80px;
    }

    .sidebar h1,
    .sidebar span,
    .sidebar .nav-item span {
        display: none;
    }

    .main-content {
        margin-left: 0;
    }
}

/* Hierarchical Tree Styles */
.hierarchy-section {
    margin-top: 24px;
    padding: 16px 8px;
    border-top: 1px solid var(--glass-border);
    flex: 1;
    overflow-y: auto;
}

.section-label {
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-dim);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 700;
    margin-bottom: 12px;
}

.hierarchy-tree {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tree-item {
    user-select: none;
}

.tree-item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 10px;
    border-radius: 8px;
    font-size: 14px;
    color: var(--text-dim);
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
}

.tree-item-header:hover {
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-main);
}

.tree-item.active>.tree-item-header {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
    font-weight: 600;
}

.tree-toggle {
    font-size: 10px;
    width: 12px;
    color: var(--text-dim);
    transition: transform 0.2s;
}

.tree-icon {
    font-size: 13px;
    opacity: 0.8;
}

.tree-label {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tree-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.tree-item-header:hover .tree-actions {
    opacity: 1;
}

.tree-action-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 11px;
    padding: 4px 6px;
    border-radius: 4px;
    transition: all 0.2s;
}

.tree-action-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--primary);
}

.tree-action-btn.delete-btn:hover {
    color: var(--danger);
}

.tree-children {
    margin-left: 20px;
    margin-top: 2px;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.tree-empty {
    padding: 8px 12px;
    font-size: 12px;
    color: var(--text-dim);
    opacity: 0.6;
    font-style: italic;
}

/* Organization items */
.org-item>.tree-item-header {
    font-weight: 600;
}

/* Workspace items */
.ws-item>.tree-item-header {
    padding-left: 12px;
}

/* Folder items */
.folder-item>.tree-item-header {
    padding-left: 16px;
    font-size: 13px;
}

#add-organization-btn {
    background: transparent;
    border: none;
    color: var(--text-dim);
    cursor: pointer;
    font-size: 14px;
    transition: color 0.2s;
}

#add-organization-btn:hover {
    color: var(--primary);
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-dark-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 450px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    animation: modalSlide 0.3s ease-out;
}

@keyframes modalSlide {
    from {
        transform: translateY(30px);
        opacity: 0;
    }

    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* Auth Styles */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: var(--bg-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.auth-box {
    background: var(--bg-dark-light);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: 0 20px 50px rgba(0, 0, 0, 0.5);
    text-align: center;
}

.auth-box h2 {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-main);
}

.auth-box p {
    color: var(--text-dim);
    margin-bottom: 24px;
    font-size: 14px;
}

.form-group {
    margin-bottom: 16px;
    text-align: left;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    width: 100%;
    background: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    font-family: inherit;
    font-size: 14px;
    outline: none;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
}

.auth-footer {
    margin-top: 24px;
    font-size: 14px;
    color: var(--text-dim);
}

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

.auth-footer a:hover {
    text-decoration: underline;
}

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

.close-modal {
    background: transparent;
    border: none;
    color: var(--text-dim);
    font-size: 18px;
    cursor: pointer;
}

.modal-body {
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.form-group label {
    font-size: 13px;
    color: var(--text-dim);
    font-weight: 500;
}

.form-group input,
.form-group textarea {
    background: var(--bg-dark);
    border: 1px solid var(--glass-border);
    border-radius: 8px;
    padding: 10px 12px;
    color: var(--text-main);
    font-family: inherit;
    outline: none;
}

.form-group textarea {
    min-height: 80px;
    resize: vertical;
}

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

.modal-footer {
    padding: 20px 24px;
    border-top: 1px solid var(--glass-border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}
/* Admin Tab Styles */
.admin-card {
    background: var(--glass);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    padding: 24px;
    margin-top: 10px;
}

.section-desc {
    color: var(--text-dim);
    margin-bottom: 24px;
    font-size: 14px;
}

.table-container {
    width: 100%;
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th {
    text-align: left;
    padding: 12px;
    border-bottom: 2px solid var(--glass-border);
    color: var(--text-dim);
}

.admin-table td {
    padding: 16px 12px;
    border-bottom: 1px solid var(--glass-border);
}

.admin-table tr:last-child td {
    border-bottom: none;
}

.revoke-btn {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
    border: 1px solid rgba(239, 68, 68, 0.2);
    padding: 6px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.2s;
}

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

/* API Key Modal */
.api-key-display {
    background: var(--bg-dark);
    padding: 16px;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 20px;
    border: 1px solid var(--primary);
}

.api-key-display code {
    font-family: monospace;
    color: var(--accent);
    word-break: break-all;
}

#copy-api-key-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 8px;
    border-radius: 4px;
    cursor: pointer;
    margin-left: 12px;
}

.warning-box {
    display: flex;
    align-items: center;
    gap: 12px;
    background: rgba(251, 191, 36, 0.1);
    border: 1px solid rgba(251, 191, 36, 0.3);
    padding: 12px;
    border-radius: 8px;
    color: #fbbf24;
    font-size: 13px;
}
