/* PubMed AI Assistant - Optimized CSS */
:root {
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --secondary: #ec4899;
    --bg-base: #050508;
    --bg-glass: rgba(20, 20, 30, 0.5);
    --bg-input: rgba(10, 10, 15, 0.6);
    --text-main: #f8fafc;
    --text-sub: #cbd5e1;
    --text-muted: #94a3b8;
    --border: rgba(255, 255, 255, 0.08);
    --success: #10b981;
    --error: #ef4444;
    --accent: #c084fc;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-base);
    color: var(--text-main);
    min-height: 100vh;
    font-size: 15px;
}

/* Background Animation */
.bg-animation {
    position: fixed;
    inset: 0;
    z-index: 0;
    pointer-events: none;
    overflow: hidden;
}

.bg-blob {
    position: absolute;
    width: 50vw;
    height: 50vw;
    border-radius: 50%;
    opacity: 0.35;
    filter: blur(80px);
    animation: float 25s infinite ease-in-out;
}

.bg-blob-1 {
    top: -20%;
    left: -10%;
    background: radial-gradient(circle, #8b5cf6 0%, transparent 60%);
}

.bg-blob-2 {
    bottom: -20%;
    right: -10%;
    width: 60vw;
    height: 60vw;
    animation-delay: -8s;
    background: radial-gradient(circle, #ec4899 0%, transparent 60%);
}

.bg-blob-3 {
    top: 40%;
    left: 30%;
    width: 40vw;
    height: 40vw;
    animation-delay: -16s;
    background: radial-gradient(circle, #3b82f6 0%, transparent 60%);
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(40px, -40px) scale(1.05);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.95);
    }
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
    position: relative;
    z-index: 1;
}

.sidebar {
    width: 260px;
    background: rgba(10, 10, 15, 0.7);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border);
    padding: 28px 20px;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    flex-shrink: 0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 40px;
    padding-left: 8px;
}

.logo-icon {
    font-size: 28px;
}

.logo-text {
    font-size: 20px;
    font-weight: 700;
    background: linear-gradient(135deg, #fff 0%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.nav-section {
    margin-bottom: 28px;
}

.nav-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.2px;
    color: var(--text-muted);
    margin: 0 0 12px 12px;
    opacity: 0.7;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s;
    color: var(--text-sub);
    font-weight: 500;
    margin-bottom: 4px;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #fff;
}

.nav-item.active {
    background: linear-gradient(90deg, rgba(139, 92, 246, 0.2) 0%, rgba(139, 92, 246, 0.05) 100%);
    color: #a78bfa;
    border-left: 3px solid #a78bfa;
}

/* Main Content */
/* Main Content */
.main-content {
    flex: 1;
    padding: 36px 48px;
    overflow-y: auto;
    width: 100%;
}

.page-header {
    margin-bottom: 32px;
}

.page-title {
    font-size: 30px;
    font-weight: 700;
    margin-bottom: 8px;
}

.page-subtitle {
    color: var(--text-muted);
    font-size: 15px;
}

/* Cards */
.card {
    background: var(--bg-glass);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 28px;
    margin-bottom: 24px;
}

.card-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
}

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

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

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

input,
textarea,
select {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-main);
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
textarea:focus,
select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

input::placeholder,
textarea::placeholder {
    color: rgba(148, 163, 184, 0.4);
}

textarea {
    resize: vertical;
    min-height: 100px;
}

.form-hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(139, 92, 246, 0.35);
}

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

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

.btn-block {
    width: 100%;
}

/* Results */
.results-section {
    display: none;
    margin-top: 32px;
    width: 100%;
}

.results-section.show {
    display: block;
    animation: fadeIn 0.4s ease;
    width: 100%;
}

.results-section .card {
    max-width: none;
    width: 100%;
    margin-right: 0;
}

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

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

.file-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 12px;
    list-style: none;
}

.file-item {
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: rgba(10, 10, 15, 0.5);
    border: 1px solid var(--border);
    border-radius: 12px;
    transition: all 0.2s;
}

.file-item:hover {
    background: rgba(20, 20, 30, 0.8);
    border-color: var(--primary);
}

.file-info {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 12px;
}

.file-icon {
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    font-size: 20px;
}

.file-name {
    font-weight: 600;
    margin-bottom: 2px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 180px;
}

.file-type {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* Pages */
.page-view {
    display: none;
    width: 100%;
}

.page-view.active {
    display: block;
    width: 100%;
}

/* Loading */
#loadingOverlay {
    position: fixed;
    inset: 0;
    background: rgba(5, 5, 8, 0.85);
    backdrop-filter: blur(8px);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}

#loadingOverlay.show {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 44px;
    height: 44px;
    border: 3px solid rgba(139, 92, 246, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.8s linear infinite;
    margin-bottom: 16px;
}

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

/* Alerts */
.alert {
    padding: 12px 16px;
    border-radius: 10px;
    margin-top: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: var(--error);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

/* Misc */
.setting-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.setting-item:last-child {
    border-bottom: none;
}

.model-badge {
    display: inline-block;
    padding: 5px 10px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 16px;
    font-size: 12px;
    font-weight: 500;
}

.status-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 6px;
}

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

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

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.2);
}

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

    .main-content {
        padding: 20px;
    }

    .form-row {
        grid-template-columns: 1fr;
    }
}

/* === 简化检索样式 === */

/* 模式切换按钮 */
.search-mode-toggle {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    padding: 4px;
    background: var(--bg-input);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.mode-btn {
    flex: 1;
    padding: 12px 20px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

.mode-btn.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-hover));
    color: #fff;
    box-shadow: 0 2px 8px rgba(139, 92, 246, 0.3);
}

/* 输入区域 */
.input-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

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

.section-header h4 {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    margin: 0;
}

.btn-add {
    padding: 6px 14px;
    background: rgba(139, 92, 246, 0.15);
    border: 1px solid rgba(139, 92, 246, 0.3);
    border-radius: 6px;
    color: var(--primary);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-add:hover {
    background: rgba(139, 92, 246, 0.25);
    border-color: var(--primary);
}

/* 作者和单位输入行 */
.author-field-row,
.affiliation-field-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
}

.author-field-row:last-child,
.affiliation-field-row:last-child {
    margin-bottom: 0;
}

.author-input,
.affiliation-input {
    flex: 1;
}

.first-author-check {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.first-author-check:hover {
    background: rgba(139, 92, 246, 0.1);
    border-color: rgba(139, 92, 246, 0.3);
}

.first-author-check input {
    width: auto;
    margin: 0;
}

.first-author-check span {
    font-size: 13px;
    color: var(--text-sub);
}

.first-author-checkbox:checked+span {
    color: var(--primary);
    font-weight: 500;
}

.btn-remove {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(239, 68, 68, 0.1);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 6px;
    color: var(--error);
    font-size: 18px;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-remove:hover {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--error);
}

/* 连接符选择 */
.connector-section {
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 20px;
}

.connector-section>label {
    display: block;
    font-size: 15px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 12px;
}

.connector-options {
    display: flex;
    gap: 12px;
}

.connector-option {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: var(--bg-input);
    border: 2px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.2s;
}

.connector-option:hover {
    border-color: rgba(139, 92, 246, 0.3);
    background: rgba(139, 92, 246, 0.05);
}

.connector-option input {
    display: none;
}

.connector-option input:checked+.connector-label {
    color: var(--primary);
}

.connector-option:has(input:checked) {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
}

.connector-label {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 4px;
}

.connector-desc {
    font-size: 12px;
    color: var(--text-muted);
    text-align: center;
}

/* 生成的查询预览 */
.query-preview {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 10px;
    padding: 12px 16px;
    margin-bottom: 20px;
}

.query-preview-label {
    font-size: 12px;
    color: var(--success);
    font-weight: 500;
    margin-bottom: 6px;
}

.query-preview-text {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
    color: var(--text-main);
    word-break: break-all;
}

/* === 文件操作按钮 === */
.file-actions {
    display: flex;
    gap: 8px;
    margin-top: auto;
}

.file-item .btn {
    padding: 8px 12px;
    font-size: 12px;
}

/* === 预览模态框 === */
.preview-modal {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(10px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.preview-modal.show {
    opacity: 1;
    pointer-events: auto;
}

.preview-modal-content {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 16px;
    width: 90%;
    max-width: 1000px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-20px) scale(0.95);
    }

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

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

.preview-modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
}

.preview-modal-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-muted);
    font-size: 24px;
    cursor: pointer;
    transition: all 0.2s;
}

.preview-modal-close:hover {
    background: rgba(239, 68, 68, 0.15);
    border-color: var(--error);
    color: var(--error);
}

.preview-modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
    line-height: 1.7;
    color: var(--text-sub);
}

.preview-modal-body h2 {
    font-size: 20px;
    color: var(--text-main);
    margin: 24px 0 12px 0;
}

.preview-modal-body h3 {
    font-size: 17px;
    color: var(--text-main);
    margin: 20px 0 10px 0;
}

.preview-modal-body h4 {
    font-size: 15px;
    color: var(--text-main);
    margin: 16px 0 8px 0;
}

.preview-modal-body hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.preview-modal-body pre {
    background: var(--bg-input);
    padding: 16px;
    border-radius: 10px;
    overflow-x: auto;
    font-size: 13px;
    white-space: pre-wrap;
    word-break: break-word;
}

/* 预览表格 */
.preview-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.preview-table th,
.preview-table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.preview-table th {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary);
    font-weight: 600;
    position: sticky;
    top: 0;
}

.preview-table tr:hover {
    background: rgba(255, 255, 255, 0.03);
}

.preview-table td {
    color: var(--text-sub);
    max-width: 300px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* === 文件浏览器标签页 === */
.file-browser {
    background: var(--bg-glass);
    border: 1px solid var(--border);
    border-radius: 16px;
    overflow: hidden;
    width: 100%;
}

.file-browser-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 2px;
    padding: 8px 8px 0 8px;
    background: rgba(0, 0, 0, 0.3);
    border-bottom: 1px solid var(--border);
}

.file-browser-tab {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid transparent;
    border-bottom: none;
    border-radius: 10px 10px 0 0;
    color: var(--text-muted);
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    top: 1px;
}

.file-browser-tab:hover {
    background: rgba(255, 255, 255, 0.08);
    color: var(--text-sub);
}

.file-browser-tab.active {
    background: var(--bg-glass);
    border-color: var(--border);
    color: var(--text-main);
    font-weight: 500;
}

.file-browser-tab.excel-tab {
    background: rgba(16, 185, 129, 0.1);
    color: var(--success);
    border-color: rgba(16, 185, 129, 0.2);
}

.file-browser-tab.excel-tab:hover {
    background: rgba(16, 185, 129, 0.2);
}

.tab-icon {
    font-size: 14px;
}

.tab-name {
    max-width: 100px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-browser-toolbar {
    display: flex;
    justify-content: flex-end;
    padding: 12px 16px;
    border-bottom: 1px solid var(--border);
    background: rgba(0, 0, 0, 0.2);
}

.file-browser-content {
    min-height: 500px;
    max-height: 70vh;
    overflow-y: auto;
    padding: 20px;
    transition: opacity 0.15s ease;
}

.file-browser-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--text-muted);
    font-size: 15px;
}

.file-browser-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    height: 300px;
    color: var(--text-muted);
    font-size: 15px;
}

.mini-spinner {
    width: 20px;
    height: 20px;
    border: 2px solid rgba(139, 92, 246, 0.2);
    border-radius: 50%;
    border-top-color: var(--primary);
    animation: spin 0.6s linear infinite;
}

.file-browser-error {
    display: flex;
    align-items: center;
    justify-content: center;
    height: 300px;
    color: var(--error);
    font-size: 15px;
}

.markdown-content {
    line-height: 1.8;
    color: var(--text-sub);
}

.markdown-content h2 {
    font-size: 20px;
    color: var(--text-main);
    margin: 24px 0 12px 0;
    padding-bottom: 8px;
    border-bottom: 1px solid var(--border);
}

.markdown-content h3 {
    font-size: 17px;
    color: var(--text-main);
    margin: 20px 0 10px 0;
}

.markdown-content h4 {
    font-size: 15px;
    color: var(--text-main);
    margin: 16px 0 8px 0;
}

.markdown-content hr {
    border: none;
    border-top: 1px solid var(--border);
    margin: 20px 0;
}

.text-content {
    background: var(--bg-input);
    padding: 16px;
    border-radius: 10px;
    font-size: 13px;
    line-height: 1.6;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-sub);
}