/* 工厂智能问答系统 - 样式表 */

/* ========== 基础样式 ========== */
:root {
    --primary-color: #2563eb;
    --primary-dark: #1d4ed8;
    --primary-light: #3b82f6;
    --secondary-color: #64748b;
    --success-color: #22c55e;
    --warning-color: #f59e0b;
    --danger-color: #ef4444;
    --info-color: #06b6d4;
    
    --bg-primary: #ffffff;
    --bg-secondary: #f8fafc;
    --bg-tertiary: #f1f5f9;
    --text-primary: #1e293b;
    --text-secondary: #64748b;
    --text-muted: #94a3b8;
    --border-color: #e2e8f0;
    
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background-color: var(--bg-secondary);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* ========== 导航栏 ========== */
.navbar {
    background: var(--bg-primary);
    box-shadow: var(--shadow-md);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.nav-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.nav-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-brand i {
    font-size: 1.5rem;
}

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

.nav-link {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 10px 16px;
    text-decoration: none;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    transition: all 0.2s;
    font-weight: 500;
}

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

.nav-link.active {
    background: var(--primary-color);
    color: white;
}

/* ========== 主内容区 ========== */
.main-content {
    flex: 1;
    padding: 0;
}

/* ========== 首页样式 ========== */
.home-container {
    max-width: 1400px;
    margin: 0 auto;
}

.hero-section {
    background: linear-gradient(135deg, var(--primary-color) 0%, #4f46e5 100%);
    padding: 60px 24px;
    text-align: center;
    color: white;
}

.hero-content h1 {
    font-size: 2.5rem;
    margin-bottom: 12px;
}

.hero-subtitle {
    font-size: 1.1rem;
    opacity: 0.9;
    margin-bottom: 32px;
}

.search-box {
    max-width: 700px;
    margin: 0 auto;
}

.search-input-wrapper {
    position: relative;
    display: flex;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 1.25rem;
}

.search-input-wrapper input {
    flex: 1;
    padding: 16px 56px;
    border: none;
    font-size: 1rem;
    outline: none;
}

.search-btn {
    padding: 16px 24px;
    background: var(--primary-color);
    color: white;
    border: none;
    cursor: pointer;
    font-size: 1.25rem;
    transition: background 0.2s;
}

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

/* ========== 主网格布局 ========== */
.main-grid {
    display: grid;
    grid-template-columns: 280px 1fr 280px;
    gap: 24px;
    padding: 24px;
    max-width: 1400px;
    margin: 0 auto;
}

@media (max-width: 1200px) {
    .main-grid {
        grid-template-columns: 1fr;
    }
    .side-panel {
        order: 2;
    }
    .chat-section {
        order: 1;
    }
    .right-panel {
        order: 3;
    }
}

/* ========== 侧边面板 ========== */
.side-panel {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.panel-card {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.panel-header {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 16px;
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.panel-header i {
    color: var(--primary-color);
}

.clear-btn {
    margin-left: auto;
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
    border-radius: var(--radius-sm);
    transition: all 0.2s;
}

.clear-btn:hover {
    color: var(--danger-color);
    background: rgba(239, 68, 68, 0.1);
}

.panel-content {
    padding: 12px;
    max-height: 300px;
    overflow-y: auto;
}

/* ========== 问题列表 ========== */
.question-list {
    list-style: none;
}

.question-item {
    padding: 12px;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all 0.2s;
    border-bottom: 1px solid var(--border-color);
}

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

.question-item:hover {
    background: var(--bg-tertiary);
}

.question-title {
    font-size: 0.9rem;
    color: var(--text-primary);
    margin-bottom: 6px;
    line-height: 1.4;
}

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

.question-meta i {
    margin-right: 3px;
}

.question-meta .tag {
    background: var(--primary-light);
    color: white;
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 0.75rem;
}

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

.empty-item {
    text-align: center;
    color: var(--text-muted);
    padding: 24px;
    font-size: 0.9rem;
}

/* ========== 聊天区域 ========== */
.chat-section {
    min-height: 500px;
}

.chat-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    height: 100%;
    display: flex;
    flex-direction: column;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    min-height: 400px;
    max-height: 600px;
}

.welcome-message {
    text-align: center;
    padding: 60px 24px;
    color: var(--text-secondary);
}

.welcome-message i {
    font-size: 4rem;
    color: var(--primary-color);
    margin-bottom: 20px;
}

.welcome-message h2 {
    font-size: 1.5rem;
    margin-bottom: 12px;
    color: var(--text-primary);
}

.welcome-message p {
    margin-bottom: 8px;
}

.message {
    margin-bottom: 20px;
    display: flex;
    gap: 12px;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.message.assistant .message-avatar {
    background: var(--primary-color);
    color: white;
}

.message.user .message-avatar {
    background: var(--bg-tertiary);
    color: var(--text-primary);
}

.message-content {
    max-width: 70%;
    padding: 12px 16px;
    border-radius: var(--radius-lg);
    line-height: 1.6;
}

.message.assistant .message-content {
    background: var(--bg-tertiary);
    border-bottom-left-radius: var(--radius-sm);
}

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

.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
}

.quick-questions {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

.quick-label {
    color: var(--text-muted);
    font-size: 0.9rem;
}

.quick-btn {
    padding: 6px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    font-size: 0.85rem;
    cursor: pointer;
    transition: all 0.2s;
}

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

/* ========== 统计数据 ========== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
}

.stat-item {
    text-align: center;
    padding: 16px;
    background: var(--bg-tertiary);
    border-radius: var(--radius-md);
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--primary-color);
}

.stat-label {
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ========== 后台管理页面 ========== */
.admin-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 24px;
}

.admin-header {
    margin-bottom: 24px;
}

.admin-header h1 {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.75rem;
    color: var(--text-primary);
}

.admin-header h1 i {
    color: var(--primary-color);
}

.admin-subtitle {
    color: var(--text-secondary);
    margin-top: 6px;
}

/* ========== 标签页 ========== */
.tabs {
    display: flex;
    gap: 8px;
    margin-bottom: 24px;
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 8px;
}

.tab-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 0.95rem;
    color: var(--text-secondary);
    border-radius: var(--radius-md) var(--radius-md) 0 0;
    transition: all 0.2s;
    position: relative;
}

.tab-btn:hover {
    color: var(--primary-color);
    background: var(--bg-tertiary);
}

.tab-btn.active {
    color: var(--primary-color);
    font-weight: 600;
}

.tab-btn.active::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--primary-color);
}

.tab-content {
    display: none;
}

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

/* ========== 上传区域 ========== */
.upload-area {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 48px;
    text-align: center;
    transition: all 0.2s;
    background: var(--bg-primary);
}

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

.upload-area i {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 16px;
}

.upload-hint {
    color: var(--text-muted);
    font-size: 0.9rem;
    margin: 8px 0 16px;
}

/* ========== 表格 ========== */
.table-container {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th, .data-table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.data-table th {
    background: var(--bg-tertiary);
    font-weight: 600;
    color: var(--text-primary);
}

.data-table tr:hover {
    background: var(--bg-secondary);
}

.empty-row {
    text-align: center;
    color: var(--text-muted);
    padding: 32px;
}

/* ========== 按钮 ========== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
}

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

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

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

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

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

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

.btn-sm {
    padding: 6px 10px;
    font-size: 0.8rem;
}

/* ========== 徽章 ========== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8rem;
    font-weight: 500;
}

.badge-success {
    background: rgba(34, 197, 94, 0.1);
    color: var(--success-color);
}

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

.badge-danger {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger-color);
}

.badge-info {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info-color);
}

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

/* ========== 表单 ========== */
.form-card {
    background: var(--bg-primary);
    padding: 24px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
}

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

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

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

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

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 20px;
}

/* ========== 知识卡片 ========== */
.knowledge-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 16px;
    margin-top: 16px;
}

.knowledge-card {
    background: var(--bg-primary);
    border-radius: var(--radius-md);
    padding: 16px;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
    transition: all 0.2s;
}

.knowledge-card:hover {
    border-color: var(--primary-color);
    box-shadow: var(--shadow-md);
}

.knowledge-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 10px;
    font-size: 0.85rem;
}

.knowledge-source {
    color: var(--primary-color);
}

.knowledge-index {
    color: var(--text-muted);
}

.knowledge-content {
    font-size: 0.9rem;
    color: var(--text-secondary);
    line-height: 1.6;
}

.filter-bar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
}

.filter-bar input, .filter-bar select {
    padding: 10px 14px;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    font-size: 0.9rem;
}

.filter-bar input {
    flex: 1;
}

/* ========== 设置页面 ========== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

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

.settings-card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 20px;
    font-size: 1.1rem;
}

.settings-card h3 i {
    color: var(--primary-color);
}

.empty-state {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 16px;
    opacity: 0.5;
}

/* ========== 模态框 ========== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--bg-primary);
    border-radius: var(--radius-lg);
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow: hidden;
}

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

.modal-header h3 {
    font-size: 1.1rem;
}

.modal-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
}

.modal-body {
    padding: 24px;
    overflow-y: auto;
    max-height: calc(80vh - 80px);
}

/* ========== 页脚 ========== */
.footer {
    background: var(--bg-primary);
    border-top: 1px solid var(--border-color);
    padding: 20px;
    text-align: center;
    color: var(--text-muted);
    margin-top: auto;
}

.footer-container {
    max-width: 1400px;
    margin: 0 auto;
}

/* ========== 滚动条 ========== */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: var(--bg-tertiary);
}

::-webkit-scrollbar-thumb {
    background: var(--border-color);
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--text-muted);
}

/* ========== 加载动画 ========== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid var(--border-color);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s linear infinite;
}

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

/* ========== 响应式设计 ========== */
@media (max-width: 768px) {
    .hero-content h1 {
        font-size: 1.75rem;
    }
    
    .main-grid {
        padding: 16px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    .tabs {
        flex-wrap: wrap;
    }
    
    .tab-btn {
        padding: 10px 14px;
        font-size: 0.85rem;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
}
