/* 运维知识库 - 样式 v3.1 */

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

:root {
    --primary: #2563eb;
    --primary-dark: #1d4ed8;
    --bg: #f8fafc;
    --card: #ffffff;
    --text: #1e293b;
    --text2: #64748b;
    --muted: #94a3b8;
    --border: #e2e8f0;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --radius: 8px;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    line-height: 1.5;
}

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

/* 头部 */
.header {
    margin-bottom: 20px;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.header h1 {
    font-size: 1.5rem;
    font-weight: 600;
}

.header-stats {
    font-size: 0.875rem;
    color: var(--text2);
}

/* 工具栏 */
.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    flex-wrap: wrap;
}

.search-box {
    flex: 1;
    min-width: 280px;
    position: relative;
    display: flex;
    gap: 8px;
}

.search-box input {
    flex: 1;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.9375rem;
}

.search-box input:focus {
    outline: none;
    border-color: var(--primary);
}

.search-box button {
    padding: 10px 16px;
    border: none;
    border-radius: var(--radius);
    font-size: 0.875rem;
    cursor: pointer;
}

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

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

.btn-clear {
    background: var(--border);
    color: var(--text2);
}

.btn-clear:hover {
    background: #cbd5e1;
}

/* 筛选和切换 */
.filter-box {
    display: flex;
    align-items: center;
    gap: 8px;
}

.filter-box select {
    padding: 10px 32px 10px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.875rem;
    background: var(--card);
}

.view-toggle, .display-toggle {
    display: flex;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.view-toggle button, .display-toggle button {
    padding: 10px 16px;
    border: none;
    background: transparent;
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text2);
}

.view-toggle button:hover, .display-toggle button:hover {
    background: #f1f5f9;
}

.view-toggle button.active, .display-toggle button.active {
    background: var(--primary);
    color: white;
}

/* 结果统计 */
.result-info {
    font-size: 0.875rem;
    color: var(--text2);
    margin-bottom: 16px;
    padding: 8px 12px;
    background: var(--card);
    border-radius: var(--radius);
    border: 1px solid var(--border);
}

/* 表格视图 */
.qa-list.table-view {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}

.table-header, .table-row {
    display: grid;
    grid-template-columns: 60px 1fr 1fr 80px;
}

.table-header {
    background: #f8fafc;
    border-bottom: 1px solid var(--border);
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--text2);
}

.table-header span {
    padding: 12px;
}

.table-row {
    border-bottom: 1px solid var(--border);
    cursor: pointer;
    transition: background 0.15s;
}

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

.table-row:hover {
    background: #f8fafc;
}

.table-row span {
    padding: 12px;
    display: flex;
    align-items: center;
}

.table-row .num {
    color: var(--muted);
    font-size: 0.8125rem;
}

.table-row .content {
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.table-row .action {
    color: var(--primary);
    font-size: 0.8125rem;
    justify-content: center;
}

/* 卡片视图 */
.qa-list.cards {
    display: grid;
    gap: 12px;
}

.qa-item.card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 16px;
    cursor: pointer;
    transition: all 0.2s;
}

.qa-item.card:hover {
    border-color: var(--primary);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

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

.qa-item.card .qa-number {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--primary);
}

.qa-item.card .source-tag {
    font-size: 0.75rem;
    padding: 2px 8px;
    background: #f1f5f9;
    color: var(--text2);
    border-radius: 4px;
}

.qa-item.card .qa-preview {
    font-size: 0.875rem;
    color: var(--text);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* 详情弹窗 */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 40px 20px;
    z-index: 1000;
    overflow-y: auto;
}

.modal-content {
    background: var(--card);
    border-radius: 12px;
    width: 100%;
    max-width: 800px;
    max-height: calc(100vh - 80px);
    overflow-y: auto;
    box-shadow: 0 20px 40px rgba(0,0,0,0.2);
}

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

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

.close-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: #f1f5f9;
    border-radius: 50%;
    cursor: pointer;
    font-size: 1.25rem;
    color: var(--text2);
}

.close-btn:hover {
    background: #e2e8f0;
}

.modal-body {
    padding: 24px;
}

.detail-section {
    margin-bottom: 24px;
    padding: 16px;
    border-radius: var(--radius);
}

.detail-section:last-child {
    margin-bottom: 0;
}

.detail-section.problem {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
}

.detail-section.solution {
    background: #d1fae5;
    border-left: 4px solid #10b981;
}

.section-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.section-content {
    font-size: 0.9375rem;
    line-height: 1.7;
    white-space: pre-wrap;
    word-break: break-word;
}

.no-content {
    color: var(--muted);
}

/* 图片 */
.qa-image {
    max-width: 100%;
    max-height: 200px;
    margin: 8px 0;
    border-radius: var(--radius);
    cursor: pointer;
    transition: transform 0.2s;
}

.qa-image:hover {
    transform: scale(1.02);
}

.img-error {
    color: var(--muted);
    font-size: 0.875rem;
}

/* 图片弹窗 */
.image-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 2000;
    cursor: pointer;
}

.image-modal-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.image-modal-content img {
    max-width: 100%;
    max-height: 90vh;
    border-radius: var(--radius);
}

.image-modal-close {
    position: absolute;
    top: -40px;
    right: 0;
    color: white;
    font-size: 32px;
    cursor: pointer;
}

/* 高亮 */
.highlight {
    background: #fef08a;
    padding: 0 2px;
    border-radius: 2px;
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    margin-top: 24px;
}

.pagination button {
    min-width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--card);
    border-radius: var(--radius);
    font-size: 0.875rem;
    cursor: pointer;
    color: var(--text);
}

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

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

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

/* 加载状态 */
.loading {
    text-align: center;
    padding: 40px;
}

.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
    margin: 0 auto 12px;
}

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

/* 错误 */
.error {
    text-align: center;
    padding: 40px;
}

.error p {
    color: #dc2626;
    margin-bottom: 16px;
}

.error button {
    padding: 10px 24px;
    background: var(--primary);
    color: white;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
}

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

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

/* 响应式 */
@media (max-width: 768px) {
    .container {
        padding: 12px;
    }
    
    .header h1 {
        font-size: 1.25rem;
    }
    
    .toolbar {
        flex-direction: column;
    }
    
    .search-box {
        min-width: auto;
        flex-direction: column;
    }
    
    .filter-box {
        width: 100%;
    }
    
    .filter-box select {
        flex: 1;
    }
    
    .view-toggle, .display-toggle {
        display: none;
    }
    
    .modal-overlay {
        padding: 20px 12px;
    }
    
    .modal-content {
        max-height: calc(100vh - 40px);
    }
    
    .modal-header, .modal-body {
        padding: 16px;
    }
}
