/* 通用知识库系统 - 主样式 */

:root {
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --secondary: #6B7280;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    
    --bg-primary: #F9FAFB;
    --bg-secondary: #FFFFFF;
    --bg-sidebar: #1F2937;
    
    --text-primary: #111827;
    --text-secondary: #6B7280;
    --text-light: #9CA3AF;
    --text-white: #FFFFFF;
    
    --border: #E5E7EB;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    
    --sidebar-width: 260px;
    --header-height: 60px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.6;
}

/* 按钮样式 */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow);
}

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

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

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-primary);
}

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

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

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

.btn-block {
    width: 100%;
}

/* 表单样式 */
.form-group {
    margin-bottom: 16px;
}

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

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    transition: border-color 0.2s;
}

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

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

.auth-card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    width: 100%;
    max-width: 420px;
    box-shadow: var(--shadow-lg);
}

.auth-header {
    text-align: center;
    margin-bottom: 30px;
}

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

.auth-header p {
    color: var(--text-secondary);
}

.auth-form h2 {
    font-size: 20px;
    margin-bottom: 20px;
    color: var(--text-primary);
}

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

.auth-links a {
    color: var(--primary);
    text-decoration: none;
}

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

/* 主布局 */
#main-page {
    display: flex;
    min-height: 100vh;
}

/* 侧边栏 */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-sidebar);
    color: var(--text-white);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 103;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
    font-size: 18px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.sidebar-close {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 18px;
    display: none;
}

.sidebar-nav {
    flex: 1;
    padding: 20px 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    color: rgba(255, 255, 255, 0.7);
    text-decoration: none;
    transition: all 0.2s;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: white;
}

.nav-item.active {
    background: rgba(255, 255, 255, 0.15);
    color: white;
    border-left: 3px solid var(--primary);
}

.nav-item i {
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
}

/* 主内容区 */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    padding: 30px;
}

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

.page-header h1 {
    font-size: 24px;
    color: var(--text-primary);
}

/* 统计卡片 */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow);
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(79, 70, 229, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: var(--primary);
}

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

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

/* 快速操作 */
.quick-actions {
    margin-top: 30px;
}

.quick-actions h2 {
    font-size: 18px;
    margin-bottom: 16px;
}

.action-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
}

.action-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    cursor: pointer;
    transition: all 0.2s;
    box-shadow: var(--shadow);
}

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

.action-card i {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 12px;
}

.action-card h3 {
    font-size: 16px;
    margin-bottom: 8px;
}

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

/* 内容列表 */
.contents-list {
    background: white;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.content-item {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 16px;
    transition: background 0.2s;
}

.content-item:hover {
    background: var(--bg-primary);
}

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

.content-status {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    flex-shrink: 0;
}

.content-status.pending { background: var(--warning); }
.content-status.processing { background: var(--info); animation: pulse 2s infinite; }
.content-status.completed { background: var(--success); }
.content-status.failed { background: var(--danger); }

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

.content-info {
    flex: 1;
    min-width: 0;
}

.content-title {
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.content-meta {
    font-size: 12px;
    color: var(--text-secondary);
    display: flex;
    gap: 12px;
}

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

/* 筛选器 */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filters select,
.filters input {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
}

.filters input {
    flex: 1;
    min-width: 200px;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 20px;
}

.pagination button {
    padding: 8px 12px;
    border: 1px solid var(--border);
    background: white;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover:not(:disabled) {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.pagination button.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

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

.pagination-info {
    font-size: 13px;
    color: var(--text-secondary);
    margin-left: 8px;
}

/* Webhook页面 */
.webhook-section {
    display: grid;
    gap: 24px;
}

.webhook-info,
.webhook-submit,
.webhook-example {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.webhook-info h2,
.webhook-submit h2,
.webhook-example h2 {
    font-size: 16px;
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.webhook-url-container {
    display: flex;
    gap: 8px;
}

.webhook-url-container input {
    flex: 1;
    padding: 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: monospace;
    font-size: 14px;
}

.webhook-hint {
    margin-top: 12px;
    font-size: 13px;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 6px;
}

.code-block {
    position: relative;
    background: #1e1e1e;
    border-radius: 8px;
    padding: 16px;
    overflow-x: auto;
}

.code-block pre {
    margin: 0;
}

.code-block code {
    color: #d4d4d4;
    font-family: 'Monaco', 'Menlo', 'Consolas', monospace;
    font-size: 13px;
    line-height: 1.5;
}

.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    cursor: pointer;
}

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

/* 设置页面 */
.settings-grid {
    display: grid;
    gap: 24px;
}

.settings-card {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: var(--shadow);
}

.settings-card h2 {
    font-size: 16px;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.path-input-group,
.token-input-group {
    display: flex;
    gap: 8px;
}

.path-input-group input,
.token-input-group input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: monospace;
    font-size: 13px;
}

.vault-info {
    margin: 16px 0;
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 8px;
    font-size: 13px;
}

.vault-info .info-row {
    display: flex;
    justify-content: space-between;
    padding: 4px 0;
}

.vault-info .info-label {
    color: var(--text-secondary);
}

.vault-info .info-value {
    font-weight: 500;
}

.suggested-paths {
    margin: 16px 0;
}

.suggested-paths h4 {
    font-size: 13px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.suggested-path {
    display: flex;
    align-items: center;
    justify-content: space-between;
    width: 100%;
    padding: 8px 12px;
    background: var(--bg-primary);
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 6px;
    cursor: pointer;
    text-align: left;
    transition: background 0.2s;
}

.suggested-path:hover {
    background: var(--border);
}

.suggested-path:focus-visible {
    outline: 2px solid var(--primary);
    outline-offset: 2px;
}

.suggested-path .path-label {
    font-size: 13px;
    font-weight: 500;
}

.suggested-path .path-value {
    font-size: 12px;
    color: var(--text-secondary);
    font-family: monospace;
}

/* 文件夹配置 */
.folder-config {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 16px;
}

.folder-item {
    padding: 12px;
    background: var(--bg-primary);
    border-radius: 8px;
}

.folder-item label {
    display: block;
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.folder-item input {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid var(--border);
    border-radius: 4px;
    font-size: 13px;
}

/* 依赖列表 */
.dependencies-list {
    margin-bottom: 16px;
}

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

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

.dependency-name {
    font-weight: 500;
}

.dependency-status {
    display: flex;
    align-items: center;
    gap: 8px;
}

.dependency-status .installed {
    color: var(--success);
}

.dependency-status .not-installed {
    color: var(--danger);
}

/* 系统信息 */
.system-info {
    display: grid;
    gap: 8px;
}

.system-info .info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

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

.system-info .info-label {
    color: var(--text-secondary);
}

/* Toast消息 */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.toast {
    background: white;
    border-radius: 8px;
    padding: 12px 20px;
    margin-bottom: 8px;
    box-shadow: var(--shadow-lg);
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--success); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.info { border-left: 4px solid var(--info); }

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

/* 移动端顶部栏 */
.mobile-header {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--header-height);
    background: var(--bg-sidebar);
    color: white;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    z-index: 101;
}

.mobile-header h2 {
    font-size: 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.mobile-toggle {
    background: none;
    border: none;
    color: white;
    cursor: pointer;
    font-size: 20px;
    padding: 8px;
}

/* 侧边栏遮罩层 */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 102;
}

.sidebar-overlay.active {
    display: block;
}

/* 弹窗样式 */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 200;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
}

.modal-content {
    position: relative;
    background: white;
    border-radius: 16px;
    max-width: 700px;
    width: 90%;
    max-height: 80vh;
    margin: 10vh auto;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-lg);
}

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

.modal-header h2 {
    font-size: 18px;
    margin: 0;
}

.modal-close {
    background: none;
    border: none;
    font-size: 18px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 4px 8px;
    border-radius: 4px;
}

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

.modal-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.modal-body .detail-row {
    display: flex;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
}

.modal-body .detail-row:last-child {
    border-bottom: none;
}

.modal-body .detail-label {
    width: 120px;
    flex-shrink: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-body .detail-value {
    flex: 1;
    font-size: 14px;
    word-break: break-all;
}

.modal-body .detail-value a {
    color: var(--primary);
    text-decoration: none;
}

.modal-body .detail-value a:hover {
    text-decoration: underline;
}

.modal-body .detail-tags {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.modal-body .detail-tag {
    background: var(--bg-primary);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* 全局Loading */
.global-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    z-index: 300;
    display: flex;
    align-items: center;
    justify-content: center;
}

.loading-spinner {
    text-align: center;
}

.loading-spinner p {
    margin-top: 12px;
    color: var(--text-secondary);
    font-size: 14px;
}

/* 响应式设计 */
@media (max-width: 768px) {
    .mobile-header {
        display: flex;
    }
    
    .sidebar {
        transform: translateX(-100%);
        top: 0;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-close {
        display: block;
    }
    
    .main-content {
        margin-left: 0;
        padding-top: calc(var(--header-height) + 20px);
    }
    
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .filters {
        flex-direction: column;
    }
    
    .webhook-url-container {
        flex-direction: column;
    }
    
    .modal-content {
        width: 95%;
        margin: 5vh auto;
        max-height: 90vh;
    }
}

/* 加载状态 */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

/* 空状态 */
.empty-state {
    text-align: center;
    padding: 40px;
    color: var(--text-secondary);
}

.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    margin-bottom: 8px;
}
