/* ============================================
   科研导航管理后台 - 基础样式 + 主题系统
   默认: spring 青春活力
   可选: neon 霓虹紫 / cream 米白绿 / teal 青绿
   切换: <body data-theme="...">
   ============================================ */

/* ---- 默认主题：spring ---- */
:root {
    --page-bg: #f5f6fa;
    --text: #1f2937;
    --text-soft: #374151;
    --text-muted: #6b7280;
    --sidebar-bg: #1f2937;
    --sidebar-text: #d1d5db;
    --sidebar-hover: #374151;
    --sidebar-border: #374151;
    --sidebar-active-text: #fff;
    --primary: #ff6b6b;
    --primary-hover: #e85a5a;
    --primary-focus: rgba(255, 107, 107, 0.12);
    --login-grad: linear-gradient(135deg, #ff9f43 0%, #ff6b6b 50%, #c780fa 100%);
    --card-bg: #fff;
    --border: #e5e7eb;
    --border-light: #f3f4f6;
    --table-head: #f9fafb;
    --table-hover: #f9fafb;
    --input-border: #d1d5db;
    --input-bg: #fff;
    --btn-secondary-bg: #e5e7eb;
    --btn-secondary-text: #374151;
    --btn-secondary-hover: #d1d5db;
    --badge-draft-bg: #fef3c7;
    --badge-draft-text: #92400e;
    --badge-pub-bg: #d1fae5;
    --badge-pub-text: #065f46;
    --modal-overlay: rgba(0, 0, 0, 0.5);
    --toast-bg: #1f2937;
    --tab-color: #6b7280;
    --tab-hover: #1f2937;
    --tab-active: #ff6b6b;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ---- neon 霓虹紫（深色） ---- */
[data-theme="neon"] {
    --page-bg: #12121a;
    --text: #e9e4ff;
    --text-soft: #d6cff0;
    --text-muted: #8f8aa8;
    --sidebar-bg: #17142a;
    --sidebar-text: #c4b5fd;
    --sidebar-hover: #251d45;
    --sidebar-border: #342e55;
    --sidebar-active-text: #fff;
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-focus: rgba(139, 92, 246, 0.18);
    --login-grad: linear-gradient(135deg, #0b0b12 0%, #3b1e6e 60%, #7c3aed 130%);
    --card-bg: #1c1930;
    --border: #342e55;
    --border-light: #2a2545;
    --table-head: #221e3a;
    --table-hover: #221e3a;
    --input-border: #4a4270;
    --input-bg: #17142a;
    --btn-secondary-bg: #2a2545;
    --btn-secondary-text: #d6cff0;
    --btn-secondary-hover: #3a3360;
    --badge-draft-bg: rgba(251, 191, 36, 0.15);
    --badge-draft-text: #fbbf24;
    --badge-pub-bg: rgba(16, 185, 129, 0.15);
    --badge-pub-text: #34d399;
    --modal-overlay: rgba(0, 0, 0, 0.7);
    --toast-bg: #2a2545;
    --tab-color: #8f8aa8;
    --tab-hover: #e9e4ff;
    --tab-active: #a78bfa;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

/* ---- cream 米白简约绿 ---- */
[data-theme="cream"] {
    --page-bg: #f6f4e8;
    --text: #24312c;
    --text-soft: #3a4a42;
    --text-muted: #6b7a72;
    --sidebar-bg: #24362e;
    --sidebar-text: #cfe0d6;
    --sidebar-hover: #33493e;
    --sidebar-border: #33493e;
    --sidebar-active-text: #fff;
    --primary: #2f5d50;
    --primary-hover: #23493e;
    --primary-focus: rgba(47, 93, 80, 0.12);
    --login-grad: linear-gradient(135deg, #2f5d50 0%, #4f7d6a 60%, #7d9b76 130%);
    --card-bg: #fff;
    --border: #e2e4d8;
    --border-light: #f0f1e8;
    --table-head: #f7f6ec;
    --table-hover: #f7f6ec;
    --input-border: #cdd1c0;
    --input-bg: #fff;
    --btn-secondary-bg: #e8e7d8;
    --btn-secondary-text: #37413a;
    --btn-secondary-hover: #dcdbc8;
    --badge-draft-bg: #f6edc9;
    --badge-draft-text: #7a6514;
    --badge-pub-bg: #d9ead9;
    --badge-pub-text: #2f5d50;
    --modal-overlay: rgba(0, 0, 0, 0.45);
    --toast-bg: #24362e;
    --tab-color: #6b7a72;
    --tab-hover: #24312c;
    --tab-active: #2f5d50;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

/* ---- teal 青绿清透 ---- */
[data-theme="teal"] {
    --page-bg: #eaf6f3;
    --text: #1e3d35;
    --text-soft: #2c5047;
    --text-muted: #5c7a72;
    --sidebar-bg: #1f4037;
    --sidebar-text: #c6e6de;
    --sidebar-hover: #2b5a4e;
    --sidebar-border: #2b5a4e;
    --sidebar-active-text: #fff;
    --primary: #2c8e7c;
    --primary-hover: #1f6e5e;
    --primary-focus: rgba(44, 142, 124, 0.14);
    --login-grad: linear-gradient(135deg, #1f6e5e 0%, #2c8e7c 60%, #61bfad 130%);
    --card-bg: #fff;
    --border: #d5e8e3;
    --border-light: #e8f3ef;
    --table-head: #f4faf7;
    --table-hover: #f4faf7;
    --input-border: #c3dcd5;
    --input-bg: #fff;
    --btn-secondary-bg: #e0efe9;
    --btn-secondary-text: #1e3d35;
    --btn-secondary-hover: #cfe5dd;
    --badge-draft-bg: #f6edc9;
    --badge-draft-text: #7a6514;
    --badge-pub-bg: #d2ece4;
    --badge-pub-text: #1f6e5e;
    --modal-overlay: rgba(0, 0, 0, 0.45);
    --toast-bg: #1f4037;
    --tab-color: #5c7a72;
    --tab-hover: #1e3d35;
    --tab-active: #2c8e7c;
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", sans-serif;
    background: var(--page-bg);
    color: var(--text);
    font-size: 14px;
    transition: background 0.35s ease, color 0.35s ease;
}

/* ===== 登录页 ===== */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--login-grad);
}

.login-box {
    background: var(--card-bg);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
    width: 380px;
    text-align: center;
}

.login-title { font-size: 28px; margin-bottom: 4px; color: var(--text); }
.login-subtitle { color: var(--text-muted); margin-bottom: 30px; }

.form-group { margin-bottom: 16px; text-align: left; }
.form-group label { display: block; margin-bottom: 6px; font-weight: 500; color: var(--text-soft); }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text);
    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 var(--primary-focus);
}
.form-group textarea { resize: vertical; font-family: inherit; }

.form-row { display: flex; gap: 12px; }
.form-row .form-group { flex: 1; }

.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    font-weight: 500;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); }
.btn-secondary { background: var(--btn-secondary-bg); color: var(--btn-secondary-text); }
.btn-secondary:hover { background: var(--btn-secondary-hover); }
.btn-danger { background: #ef4444; color: #fff; }
.btn-danger:hover { background: #dc2626; }
.btn-block { width: 100%; margin-top: 8px; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

.error-msg { color: #ef4444; margin-top: 12px; font-size: 13px; min-height: 18px; }

/* ===== 主布局 ===== */
.admin-main { display: flex; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: var(--sidebar-bg);
    color: var(--sidebar-text);
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    transition: background 0.35s ease;
}

.sidebar-logo {
    padding: 20px;
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    border-bottom: 1px solid var(--sidebar-border);
}

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

.nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    transition: all 0.2s;
    cursor: pointer;
}
.nav-item:hover { background: var(--sidebar-hover); color: #fff; }
.nav-item.active { background: var(--primary); color: var(--sidebar-active-text); }
.nav-icon { font-size: 16px; }

.sidebar-footer { border-top: 1px solid var(--sidebar-border); padding: 12px 0; }

.admin-content {
    flex: 1;
    margin-left: 220px;
    padding: 24px;
}

.page { display: none; }
.page.active { display: block; }

.page-title { font-size: 22px; margin-bottom: 20px; }
.page-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 12px;
}
.page-header-row .page-title { margin-bottom: 0; }

/* ===== 仪表盘 ===== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}

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

.stat-icon { font-size: 32px; }
.stat-value { font-size: 28px; font-weight: 700; color: var(--text); }
.stat-label { color: var(--text-muted); font-size: 13px; }

.welcome-card {
    background: var(--card-bg);
    padding: 24px;
    border-radius: 12px;
    box-shadow: var(--shadow);
}
.welcome-card h3 { margin-bottom: 8px; }
.welcome-card p { color: var(--text-muted); line-height: 1.6; }

/* ===== 表格 ===== */
.data-table {
    width: 100%;
    background: var(--card-bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--shadow);
    border-collapse: collapse;
}

.data-table th {
    background: var(--table-head);
    padding: 12px 16px;
    text-align: left;
    font-weight: 600;
    color: var(--text-soft);
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}

.data-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-soft);
}

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

.status-badge {
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: 500;
}
.status-draft { background: var(--badge-draft-bg); color: var(--badge-draft-text); }
.status-published { background: var(--badge-pub-bg); color: var(--badge-pub-text); }

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

/* ===== Tabs ===== */
.tabs {
    display: flex;
    gap: 4px;
    margin-bottom: 16px;
    border-bottom: 2px solid var(--border);
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 14px;
    color: var(--tab-color);
    border-bottom: 2px solid transparent;
    margin-bottom: -2px;
    transition: all 0.2s;
}
.tab-btn:hover { color: var(--tab-hover); }
.tab-btn.active { color: var(--tab-active); border-bottom-color: var(--tab-active); font-weight: 600; }

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

.filter-bar { margin-bottom: 16px; }
.filter-bar select {
    padding: 8px 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text);
}

.pagination-admin {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 20px;
}

/* ===== 模态框 ===== */
.modal {
    display: none;
    position: fixed;
    top: 0; left: 0;
    width: 100%; height: 100%;
    background: var(--modal-overlay);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}
.modal.show { display: flex; }

.modal-content {
    background: var(--card-bg);
    border-radius: 16px;
    width: 90%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    animation: modalIn 0.2s ease;
}
.modal-large .modal-content { max-width: 720px; }

@keyframes modalIn {
    from { transform: scale(0.95); opacity: 0; }
    to { transform: scale(1); opacity: 1; }
}

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

.modal-close {
    font-size: 24px;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
}
.modal-close:hover { color: var(--text); }

.modal-body { padding: 24px; }
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

/* ===== Toast ===== */
.toast {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 24px;
    background: var(--toast-bg);
    color: #fff;
    border-radius: 8px;
    z-index: 2000;
    opacity: 0;
    transform: translateY(-20px);
    transition: all 0.3s;
    pointer-events: none;
}
.toast.show { opacity: 1; transform: translateY(0); }
.toast.success { background: #059669; }
.toast.error { background: #dc2626; }

/* ===== 主题设置 ===== */
.theme-hint { color: var(--text-muted); font-size: 13px; }

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

.theme-card {
    background: var(--card-bg);
    border: 2px solid var(--border);
    border-radius: 14px;
    overflow: hidden;
    cursor: pointer;
    position: relative;
    transition: transform 0.25s, box-shadow 0.25s, border-color 0.25s;
}
.theme-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
}
.theme-card.active {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-focus);
}

.theme-preview {
    position: relative;
    height: 130px;
    display: flex;
    align-items: flex-end;
    padding: 14px;
    gap: 8px;
}
.tp-bg { position: absolute; inset: 0; }
.tp-card { position: relative; display: flex; gap: 6px; }
.tp-card span {
    width: 26px;
    height: 26px;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.18);
}

.theme-check {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    display: none;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.25);
}
.theme-card.active .theme-check { display: flex; }

.theme-info {
    padding: 14px 16px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    border-top: 1px solid var(--border-light);
}
.theme-name { font-weight: 700; font-size: 15px; color: var(--text); }
.theme-desc { font-size: 12px; color: var(--text-muted); }

/* 主题预览配色 */
.theme-preview-spring .tp-bg { background: linear-gradient(135deg, #fff5f0, #f0f7ff); }
.theme-preview-spring .tp-card span:nth-child(1) { background: #ff6b6b; }
.theme-preview-spring .tp-card span:nth-child(2) { background: #4d96ff; }
.theme-preview-spring .tp-card span:nth-child(3) { background: #6bcb77; }

.theme-preview-neon .tp-bg { background: radial-gradient(120% 80% at 50% 0%, #3b1e6e, #0b0b12); }
.theme-preview-neon .tp-card span:nth-child(1) { background: #8b5cf6; }
.theme-preview-neon .tp-card span:nth-child(2) { background: #a78bfa; }
.theme-preview-neon .tp-card span:nth-child(3) { background: #6d28d9; }

.theme-preview-cream .tp-bg { background: linear-gradient(135deg, #f9f7e8, #efeadd); }
.theme-preview-cream .tp-card span:nth-child(1) { background: #2f5d50; }
.theme-preview-cream .tp-card span:nth-child(2) { background: #4f7d6a; }
.theme-preview-cream .tp-card span:nth-child(3) { background: #7d9b76; }

.theme-preview-teal .tp-bg { background: linear-gradient(135deg, #eaf6f3, #d3efe8); }
.theme-preview-teal .tp-card span:nth-child(1) { background: #61bfad; }
.theme-preview-teal .tp-card span:nth-child(2) { background: #2c8e7c; }
.theme-preview-teal .tp-card span:nth-child(3) { background: #1f6e5e; }

.theme-preview-baipiao .tp-bg { background: linear-gradient(135deg, #ffffff, #f2f4f7); }
.theme-preview-baipiao .tp-card span:nth-child(1) { background: #e74c3c; }
.theme-preview-baipiao .tp-card span:nth-child(2) { background: #2c3e50; }
.theme-preview-baipiao .tp-card span:nth-child(3) { background: #f39c12; }

/* ===== 网站设置 ===== */
.site-settings-card {
    background: var(--card-bg);
    border-radius: 14px;
    padding: 28px;
    max-width: 720px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
}

.site-settings-card .form-group { margin-bottom: 20px; }
.site-settings-card input, .site-settings-card textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text);
    transition: border-color 0.2s;
}
.site-settings-card input:focus, .site-settings-card textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-focus);
}
.site-settings-card textarea { resize: vertical; font-family: inherit; }

.site-settings-actions {
    margin-top: 8px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    display: flex;
    justify-content: flex-end;
}

/* ===== 性能设置 ===== */
.perf-section {
    padding: 20px 0;
    border-bottom: 1px solid var(--border-light);
}
.perf-section:first-of-type { padding-top: 0; }
.perf-section:last-of-type { border-bottom: none; }

.perf-section-title {
    font-weight: 700;
    font-size: 15px;
    margin-bottom: 16px;
    color: var(--text);
}

.perf-row {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 12px 0;
}
.perf-row + .perf-row { border-top: 1px dashed var(--border-light); }

.perf-row-text { flex: 1; min-width: 0; }
.perf-row-label { font-weight: 600; color: var(--text-soft); margin-bottom: 2px; }
.perf-row-desc { font-size: 12px; color: var(--text-muted); }

.perf-input {
    width: 110px;
    padding: 8px 10px;
    border: 1px solid var(--input-border);
    border-radius: 8px;
    font-size: 14px;
    background: var(--input-bg);
    color: var(--text);
    text-align: right;
}
.perf-input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-focus);
}
.perf-unit { color: var(--text-muted); font-size: 13px; }

/* 开关 */
.switch {
    position: relative;
    display: inline-block;
    width: 46px;
    height: 26px;
    flex-shrink: 0;
}
.switch input { opacity: 0; width: 0; height: 0; }
.switch-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: var(--btn-secondary-bg);
    border-radius: 26px;
    transition: 0.3s;
}
.switch-slider::before {
    content: '';
    position: absolute;
    height: 20px;
    width: 20px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: 0.3s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}
.switch input:checked + .switch-slider { background: var(--primary); }
.switch input:checked + .switch-slider::before { transform: translateX(20px); }

/* ===== 响应式 ===== */
@media (max-width: 768px) {
    .sidebar { width: 60px; }
    .sidebar-logo, .nav-item span:not(.nav-icon) { display: none; }
    .admin-content { margin-left: 60px; padding: 16px; }
}
