/* ============================================================
   Forum Spider Web Dashboard - 公共样式表
   所有页面共享的基础样式，避免重复定义
   ============================================================ */

/* === Reset & Base === */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: #f3f4f6;
    color: #1f2937;
    line-height: 1.6;
    padding: 20px;
    min-height: 100vh;
}

a { color: #6366f1; text-decoration: none; }
a:hover { text-decoration: underline; }

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

/* === Header === */
.header {
    background: white;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.header h1 { color: #1f2937; font-size: 22px; font-weight: 700; }
.header p { color: #888; font-size: 13px; }

.header-actions {
    display: flex; gap: 8px; flex-wrap: wrap; align-items: center;
}

.header-actions a, .header-actions button {
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid #e5e7eb;
    background: white;
    color: #374151;
    text-decoration: none;
    transition: all 0.2s;
}

.header-actions a:hover, .header-actions button:hover {
    background: #f3f4f6;
    border-color: #d1d5db;
}

/* === Navigation === */
.nav-links {
    display: flex; gap: 8px; flex-wrap: wrap; margin-top: 16px;
}

.nav-links a {
    display: inline-block;
    padding: 8px 16px;
    background: #6366f1;
    color: white;
    border-radius: 8px;
    font-size: 13px;
    transition: background 0.2s;
    text-decoration: none;
}

.nav-links a:hover { background: #4f46e5; }

.nav-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 16px;
}

.nav-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 16px;
    background: white;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
    transition: all 0.2s;
    text-decoration: none;
    color: #374151;
}

.nav-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.1);
}

.nav-card .nav-icon { font-size: 32px; margin-bottom: 8px; }
.nav-card .nav-title { font-size: 14px; font-weight: 600; text-align: center; }

/* === Buttons === */
.btn {
    padding: 8px 16px;
    border: none;
    border-radius: 6px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.btn-primary { background: #6366f1; color: white; }
.btn-primary:hover:not(:disabled) { background: #4f46e5; }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-default {
    background: white;
    color: #374151;
    border: 1px solid #d1d5db;
}
.btn-default:hover:not(:disabled) { background: #f9fafb; border-color: #9ca3af; }
.btn-default:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-danger {
    background: white;
    color: #dc2626;
    border: 1px solid #fecaca;
}
.btn-danger:hover { background: #fef2f2; }

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

.back-btn {
    background: #f3f4f6;
    color: #374151;
    border: 1px solid #e5e7eb;
    padding: 8px 14px;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}
.back-btn:hover { background: #e5e7eb; }

/* === Table === */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 500px;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

th, td {
    padding: 8px 10px;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
    font-size: 13px;
}

th {
    background: #f9fafb;
    color: #374151;
    font-weight: 600;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

td { color: #1f2937; }

tbody tr:hover { background: #fafafa; }
tbody tr:last-child td { border-bottom: none; }

/* === Cards & Sections === */
.card, .section {
    background: white;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 16px;
}

.section { padding: 16px 12px; }

.section h2, .section-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 16px;
}

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

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

/* === Stats === */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

.stat-card {
    background: white;
    border-radius: 12px;
    padding: 16px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stat-card .stat-icon { font-size: 28px; margin-bottom: 6px; }
.stat-card .stat-value { font-size: 24px; font-weight: bold; color: #333; }
.stat-card h3 { font-size: 32px; margin-bottom: 8px; }
.stat-card p { font-size: 14px; opacity: 0.9; }

.stats-bar {
    display: flex;
    gap: 12px;
    padding: 12px;
    background: white;
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.stats-bar .stat {
    display: flex;
    align-items: baseline;
    gap: 6px;
}

.stats-bar .stat .value { font-size: 20px; font-weight: 700; color: #1f2937; }
.stats-bar .stat .label { font-size: 12px; color: #6b7280; }

/* === Forms === */
.form-group { margin-bottom: 16px; }
.form-group label {
    display: block;
    font-weight: 600;
    color: #374151;
    margin-bottom: 4px;
    font-size: 13px;
}

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    background: white;
    transition: border-color 0.2s;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #6366f1;
    background: white;
}

/* === Filters & Toolbar === */
.filters {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.filter-group label {
    font-size: 12px;
    font-weight: 500;
    color: #6b7280;
}

.filter-group select, .filter-group input {
    padding: 8px 12px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
    background: white;
}

.filter-group select:focus, .filter-group input:focus {
    outline: none;
    border-color: #6366f1;
    background: white;
}

.toolbar {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
    flex-wrap: wrap;
    align-items: center;
}

.toolbar input[type="text"] {
    flex: 1;
    min-width: 180px;
    padding: 8px 14px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
}

.toolbar select {
    padding: 8px 12px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 13px;
    background: white;
}

.toolbar .btn {
    padding: 8px 16px;
    border: none;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
}

/* === Pagination === */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    margin-top: 16px;
    flex-wrap: wrap;
}

.pagination button {
    padding: 6px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
}

.pagination button:disabled { opacity: 0.4; cursor: not-allowed; }
.pagination button:hover:not(:disabled) { background: #f3f4f6; border-color: #d1d5db; }
.pagination .page-info { font-size: 13px; color: #6b7280; }

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

.modal.active { display: flex; }

.modal-overlay.show { display: flex; }

.modal-content, .modal-box, .score-modal-card {
    background: white;
    border-radius: 12px;
    padding: 28px;
    max-width: 600px;
    width: 90%;
    max-height: 80vh;
    overflow-y: auto;
}

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

.modal-header h3 { color: #1f2937; font-size: 18px; font-weight: 600; }

.modal-box h3 {
    font-size: 18px;
    font-weight: 600;
    color: #1f2937;
    margin-bottom: 16px;
}

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

.modal-footer {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
}

.modal-actions {
    display: flex; gap: 10px; justify-content: flex-end; margin-top: 20px;
}

.modal-actions .btn { flex: 1; text-align: center; }

.modal-box .form-group { margin-bottom: 14px; }

.close-btn {
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: #9ca3af;
}

.close-btn:hover { color: #374151; }

/* === Toast === */
.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    z-index: 9999;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.2);
}

.toast.success { background: #10b981; }
.toast.error { background: #ef4444; }

/* === Loading === */
.loading { text-align: center; padding: 40px; color: #9ca3af; }

/* === Tabs === */
.tabs {
    display: flex;
    border-bottom: 2px solid #e5e7eb;
    overflow-x: auto;
    gap: 4px;
}

.tab {
    padding: 12px 24px;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
    white-space: nowrap;
}

.tab:hover { color: #1f2937; }
.tab.active { color: #6366f1; border-bottom-color: #6366f1; }

.tab-btn {
    padding: 12px 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 14px;
    color: #6b7280;
    border-bottom: 2px solid transparent;
    transition: all 0.2s;
}

.tab-content { padding: 16px; }
.tab-content.active { display: block; }
.tab-content h2 { font-size: 16px; color: #1f2937; margin-bottom: 20px; font-weight: 600; }

/* === Info Box === */
.info-box {
    background: #f0f9ff;
    padding: 12px 16px;
    border-radius: 8px;
    border: 1px solid #bae6fd;
    margin-bottom: 16px;
}

.info-box p { color: #0369a1; font-size: 13px; line-height: 1.6; }

/* === Progress === */
.progress-bar {
    width: 100%;
    height: 8px;
    background: #e5e7eb;
    border-radius: 4px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: #6366f1;
    width: 0%;
    transition: width 0.3s;
}

/* === Source Badges === */
.source-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 11px;
    font-weight: 600;
}

.source-linuxdo { background: #eff6ff; color: #2563eb; }
.source-nodeseek { background: #fff7ed; color: #ea580c; }
.source-v2ex { background: #faf5ff; color: #9333ea; }
.source-hackernews { background: #fefce8; color: #ca8a04; }

/* === Topic Source Cards === */
.source-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(350px, 1fr));
    gap: 12px;
}

.source-card {
    background: white;
    border-radius: 10px;
    padding: 12px;
    border: 1px solid #e5e7eb;
}

.source-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
}

/* === Config Grid === */
.config-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
}

.config-item {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.config-item label { font-size: 13px; font-weight: 600; color: #374151; }

/* === Action Buttons === */
.action-btn {
    padding: 6px 10px;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
}

.action-btn:hover { background: #f3f4f6; }
.action-btn.active.like { background: #eff6ff; color: #2563eb; border-color: #bfdbfe; }
.action-btn.active.dislike { background: #fef2f2; color: #dc2626; border-color: #fecaca; }
.action-btn.active.favorite { background: #fef3c7; color: #d97706; border-color: #fde68a; }

.action-btns {
    display: flex; gap: 4px;
}

/* === Score Bars === */
.score-bar-item { margin-bottom: 16px; }
.score-bar-item:last-child { margin-bottom: 0; }

.score-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 6px;
}

.score-bar-label {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}

.score-bar-value { font-size: 14px; font-weight: bold; }

.score-bar-track {
    height: 12px;
    background: #f0f0f0;
    border-radius: 6px;
    overflow: hidden;
}

.score-bar-fill {
    height: 100%;
    border-radius: 6px;
    transition: width 0.5s;
}

.score-bar-fill.interaction { background: linear-gradient(90deg, #e91e63, #f06292); }
.score-bar-fill.views { background: linear-gradient(90deg, #2196f3, #64b5f6); }
.score-bar-fill.time { background: linear-gradient(90deg, #ff9800, #ffb74d); }
.score-bar-fill.growth { background: linear-gradient(90deg, #4caf50, #81c784); }

.score-modal-total {
    text-align: center;
    padding: 16px;
    background: #f9fafb;
    border-radius: 12px;
    margin-bottom: 20px;
}

.score-modal-total .label { font-size: 14px; color: #6b7280; display: block; }
.score-modal-total .value { font-size: 28px; font-weight: 700; color: #1f2937; }

.score-formula {
    background: #f9fafb;
    padding: 12px;
    border-radius: 8px;
    font-size: 13px;
    color: #6b7280;
    margin-top: 16px;
}

/* === Topic Selector === */
.topic-selector {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}

.topic-selector select {
    flex: 2;
    min-width: 200px;
    padding: 10px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    font-size: 13px;
}

/* === Model Config === */
.model-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.model-info {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 8px;
}

.model-actions {
    display: flex; gap: 6px; margin-top: 12px; flex-wrap: wrap;
}

/* === Toggle Switch === */
.toggle-switch {
    position: relative;
    width: 44px;
    height: 24px;
    background: #d1d5db;
    border-radius: 12px;
    cursor: pointer;
    transition: background 0.3s;
}

.toggle-switch.active { background: #6366f1; }

.toggle-switch::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
}

.toggle-switch.active::after { transform: translateX(20px); }

/* === Overview Cards === */
.ov-card {
    background: #f9fafb;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 16px;
    text-align: center;
}

.ov-card .value { font-size: 22px; font-weight: 700; color: #1f2937; }

/* === Charts === */
.chart-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

/* === Mobile Responsive === */
@media (max-width: 768px) {
    body { padding: 12px; }
    
    .header { padding: 12px 16px; }
    .header h1 { font-size: 18px; }
    
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    
    .filters { flex-direction: column; }
    .filters .filter-group { width: 100%; }
    .filters .filter-group select, .filters .filter-group input { width: 100%; }
    .filters .filter-group .btn { width: 100%; text-align: center; }
    
    .toolbar { flex-direction: column; }
    .toolbar input[type="text"] { width: 100%; }
    .toolbar select { width: 100%; }
    .toolbar .btn { width: 100%; text-align: center; }
    
    .header-actions { flex-direction: column; }
    .header-actions a, .header-actions button { width: 100%; text-align: center; }
    
    .nav-grid { grid-template-columns: repeat(2, 1fr); }
    
    .source-list { grid-template-columns: 1fr; }
    
    .modal-content, .modal-box, .score-modal-card { padding: 20px; width: 95%; }
}

@media (max-width: 480px) {
    .header h1 { font-size: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .pagination { flex-direction: column; }
    .nav-grid { grid-template-columns: 1fr; }
}


/* ============================================================
   实用工具类 - 替代常见内联样式
   ============================================================ */

/* 文本颜色 */
.text-dark { color: #1f2937 !important; }
.text-muted { color: #6b7280 !important; }
.text-light { color: #9ca3af !important; }
.text-primary { color: #6366f1 !important; }
.text-danger { color: #dc2626 !important; }
.text-success { color: #10b981 !important; }
.text-warning { color: #f59e0b !important; }

/* 背景色 */
.bg-light { background: #f9fafb !important; }
.bg-white { background: white !important; }
.bg-muted { background: #f3f4f6 !important; }

/* 文本对齐 */
.text-center { text-align: center !important; }
.text-left { text-align: left !important; }
.text-right { text-align: right !important; }

/* 间距 - Padding */
.p-1 { padding: 4px !important; }
.p-2 { padding: 8px !important; }
.p-3 { padding: 12px !important; }
.p-4 { padding: 16px !important; }
.p-5 { padding: 20px !important; }
.px-2 { padding-left: 8px !important; padding-right: 8px !important; }
.px-3 { padding-left: 12px !important; padding-right: 12px !important; }
.py-2 { padding-top: 8px !important; padding-bottom: 8px !important; }
.py-3 { padding-top: 12px !important; padding-bottom: 12px !important; }

/* 间距 - Margin */
.m-0 { margin: 0 !important; }
.m-1 { margin: 4px !important; }
.m-2 { margin: 8px !important; }
.m-3 { margin: 12px !important; }
.mt-1 { margin-top: 4px !important; }
.mt-2 { margin-top: 8px !important; }
.mt-3 { margin-top: 12px !important; }
.mt-4 { margin-top: 16px !important; }
.mt-5 { margin-top: 20px !important; }
.mb-1 { margin-bottom: 4px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-4 { margin-bottom: 16px !important; }
.mb-5 { margin-bottom: 20px !important; }

/* Flex 布局 */
.flex { display: flex !important; align-items: center !important; }
.flex-1 { flex: 1 !important; }
.flex-col { flex-direction: column !important; }
.items-center { align-items: center !important; }
.justify-center { justify-content: center !important; }
.justify-between { justify-content: space-between !important; }
.gap-1 { gap: 4px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }

/* 字体大小 */
.text-xs { font-size: 11px !important; }
.text-sm { font-size: 12px !important; }
.text-base { font-size: 13px !important; }
.text-lg { font-size: 16px !important; }
.text-xl { font-size: 20px !important; }
.text-2xl { font-size: 24px !important; }
.font-bold { font-weight: 700 !important; }
.font-semibold { font-weight: 600 !important; }

/* 边框 */
.border { border: 1px solid #e5e7eb !important; }
.border-0 { border: none !important; }
.rounded { border-radius: 8px !important; }
.rounded-lg { border-radius: 12px !important; }

/* 宽度 */
.w-full { width: 100% !important; }
.w-auto { width: auto !important; }

/* 显示 */
.d-none { display: none !important; }
.d-block { display: block !important; }
.d-inline { display: inline !important; }
.d-inline-block { display: inline-block !important; }

/* 光标 */
.cursor-pointer { cursor: pointer !important; }
.cursor-default { cursor: default !important; }

/* 表格单元格 */
.table-cell-center { text-align: center !important; vertical-align: middle !important; }
.table-cell-num { text-align: right !important; font-variant-numeric: tabular-nums !important; }

/* 补充缺失的类 */
.text-success { color: #10b981 !important; }
.text-warning { color: #f59e0b !important; }
.rounded-lg { border-radius: 12px !important; }
.mb-2 { margin-bottom: 8px !important; }
.mb-3 { margin-bottom: 12px !important; }
.mb-5 { margin-bottom: 20px !important; }
.mt-3 { margin-top: 12px !important; }
.gap-2 { gap: 8px !important; }
.gap-3 { gap: 12px !important; }
.text-lg { font-size: 16px !important; }
.text-xl { font-size: 20px !important; }
.text-2xl { font-size: 24px !important; }
