/* ===== CSS Custom Properties (Theme System) ===== */
:root {
    --kb-primary: #667eea;
    --kb-secondary: #764ba2;
    --kb-accent: #8e44ad;
    --kb-text: #333;
    --kb-text-light: #666;
    --kb-bg-card: rgba(255,255,255,0.95);
    --kb-bg-nav: rgba(255,255,255,0.98);
    --kb-bg-hover: rgba(102,126,234,0.1);
    --kb-border-light: #ddd;
    --kb-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    --kb-gradient-light: linear-gradient(135deg, rgba(102,126,234,0.1) 0%, rgba(118,75,162,0.1) 100%);
    --kb-gradient-lighter: linear-gradient(135deg, rgba(102,126,234,0.05) 0%, rgba(118,75,162,0.05) 100%);
    --kb-shadow-card: 0 5px 20px rgba(0,0,0,0.1);
    --kb-shadow-nav: 0 10px 40px rgba(0,0,0,0.3);
    --kb-radius-card: 15px;
    --kb-radius-btn: 25px;
    --kb-radius-sm: 10px;
    --kb-radius-xs: 5px;
    --kb-transition: all 0.3s ease;
}

/* ===== Dark Mode Variables ===== */
body.dark-mode {
    --kb-text: #e8e8e8;
    --kb-text-light: #a0a0a0;
    --kb-bg-card: rgba(25,25,45,0.95);
    --kb-bg-nav: rgba(25,25,45,0.98);
    --kb-bg-hover: rgba(255,107,107,0.1);
    --kb-border-light: #3a3a5a;
    --kb-gradient: linear-gradient(135deg, #ff6b6b 0%, #ee5a5a 100%);
    --kb-gradient-light: linear-gradient(135deg, rgba(255,107,107,0.15) 0%, rgba(238,90,90,0.15) 100%);
    --kb-gradient-lighter: linear-gradient(135deg, rgba(255,107,107,0.08) 0%, rgba(238,90,90,0.08) 100%);
    --kb-shadow-card: 0 5px 20px rgba(0,0,0,0.3);
    --kb-shadow-nav: 0 10px 40px rgba(0,0,0,0.5);
}

/* ===== Theme Color Classes ===== */
.bg-economy { --kb-primary: #667eea; --kb-secondary: #764ba2; --kb-accent: #8e44ad; }
.bg-psychology { --kb-primary: #f093fb; --kb-secondary: #f5576c; --kb-accent: #e74c3c; }
.bg-technology { --kb-primary: #11998e; --kb-secondary: #38ef7d; --kb-accent: #27ae60; }
.bg-education { --kb-primary: #4facfe; --kb-secondary: #00f2fe; --kb-accent: #3498db; }
.bg-history { --kb-primary: #2c3e50; --kb-secondary: #4a5568; --kb-accent: #7f8c8d; }
.bg-health { --kb-primary: #a8edea; --kb-secondary: #fed6e3; --kb-accent: #e91e63; }
.bg-philosophy { --kb-primary: #ff9a9e; --kb-secondary: #fecfef; --kb-accent: #c0392b; }
.bg-business { --kb-primary: #f6d365; --kb-secondary: #fda085; --kb-accent: #e67e22; }
.bg-law { --kb-primary: #6a11cb; --kb-secondary: #2575fc; --kb-accent: #2980b9; }
.bg-art { --kb-primary: #a18cd1; --kb-secondary: #fbc2eb; --kb-accent: #9b59b6; }

/* ===== Base Styles ===== */
* { margin: 0; padding: 0; box-sizing: border-box; }
body {
    font-family: 'Microsoft YaHei', '微软雅黑', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    min-height: 100vh;
    color: var(--kb-text);
    line-height: 1.8;
}
.container { max-width: 1200px; margin: 0 auto; padding: 40px 20px; }

/* ===== Navigation Menu ===== */
.nav-menu-btn { position: fixed; top: 20px; left: 20px; z-index: 1000; display: flex; gap: 10px; align-items: center; }
.nav-menu-btn button {
    background: var(--kb-gradient);
    color: white; border: none; padding: 12px 24px; border-radius: var(--kb-radius-btn);
    cursor: pointer; font-size: 16px; font-weight: bold;
    box-shadow: 0 4px 15px rgba(0,0,0,0.3); transition: var(--kb-transition);
}
.nav-menu-btn button:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.4); }
.nav-menu-tooltip {
    display: none; position: fixed; top: 70px; left: 20px; width: 320px;
    max-height: 80vh; overflow-y: auto; background: var(--kb-bg-nav);
    border-radius: var(--kb-radius-card); padding: 20px; box-shadow: var(--kb-shadow-nav); z-index: 999;
}
.nav-menu-tooltip.show { display: block; }
.nav-menu-tooltip h3 { color: var(--kb-primary); margin-bottom: 15px; padding-bottom: 10px; border-bottom: 2px solid var(--kb-primary); }
.nav-section { margin-bottom: 20px; }
.nav-section-title { font-weight: bold; color: var(--kb-text); margin-bottom: 10px; padding: 5px 10px; background: var(--kb-bg-hover); border-radius: var(--kb-radius-xs); }
.nav-item { display: block; padding: 10px 15px; margin: 5px 0; color: var(--kb-text); text-decoration: none; border-radius: 8px; transition: var(--kb-transition); }
.nav-item:hover { background: var(--kb-bg-hover); transform: translateX(5px); }
.nav-item-title { font-weight: bold; color: var(--kb-text); }
.nav-item-desc { font-size: 12px; color: var(--kb-text-light); margin-top: 3px; }

/* ===== Sidebar Navigation ===== */
.sidebar-nav {
    position: fixed; right: 20px; top: 50%; transform: translateY(-50%);
    background: var(--kb-bg-card); border-radius: var(--kb-radius-sm); padding: 15px;
    box-shadow: 0 2px 15px rgba(0,0,0,0.2); z-index: 100; max-width: 200px;
}
.sidebar-nav h4 { color: var(--kb-primary); margin-bottom: 10px; padding-bottom: 5px; border-bottom: 2px solid var(--kb-primary); }
.sidebar-nav a { display: block; padding: 8px 10px; color: var(--kb-text); text-decoration: none; border-radius: var(--kb-radius-xs); margin: 5px 0; transition: var(--kb-transition); }
.sidebar-nav a:hover { background: var(--kb-bg-hover); color: var(--kb-primary); }
.sidebar-nav a.active { background: var(--kb-bg-hover); color: var(--kb-primary); font-weight: bold; }

/* ===== Header ===== */
header { text-align: center; padding: 60px 20px; background: var(--kb-bg-card); border-radius: 20px; margin-bottom: 30px; box-shadow: 0 10px 40px rgba(0,0,0,0.2); }
header .back-link { display: inline-block; margin-bottom: 20px; padding: 10px 20px; background: var(--kb-bg-hover); color: var(--kb-primary); text-decoration: none; border-radius: var(--kb-radius-btn); transition: var(--kb-transition); }
header .back-link:hover { background: rgba(102,126,234,0.2); transform: translateX(-5px); }
header h1 { font-size: 48px; color: var(--kb-primary); margin-bottom: 20px; text-shadow: 2px 2px 4px rgba(0,0,0,0.1); }
header p { font-size: 18px; color: var(--kb-text-light); max-width: 800px; margin: 0 auto; }
header .subtitle { font-size: 18px; color: var(--kb-text-light); }

/* ===== Content Card ===== */
.content-card { background: var(--kb-bg-card); border-radius: var(--kb-radius-card); padding: 30px; margin-bottom: 25px; box-shadow: var(--kb-shadow-card); }
.content-card h2 { color: var(--kb-primary); margin-bottom: 20px; padding-bottom: 10px; border-bottom: 3px solid var(--kb-primary); }
.content-card h3 { color: #2c3e50; margin: 20px 0 15px; }
body.dark-mode .content-card h3 { color: #4ecdc4; }
.content-card h4 { color: #34495e; margin: 15px 0 10px; }
body.dark-mode .content-card h4 { color: #95e1d3; }
.content-card p { margin-bottom: 15px; text-align: justify; }
.content-card ul, .content-card ol { margin: 15px 0 15px 30px; }
.content-card li { margin-bottom: 10px; }

/* ===== Highlight Box ===== */
.highlight-box { background: var(--kb-gradient-light); border-left: 5px solid var(--kb-primary); padding: 20px; margin: 20px 0; border-radius: 0 var(--kb-radius-sm) var(--kb-radius-sm) 0; }
.highlight-box h4 { color: var(--kb-primary); margin-bottom: 10px; }

/* ===== Quote Box ===== */
.quote-box { background: #f8f9fa; border-left: 5px solid var(--kb-accent); padding: 20px; margin: 20px 0; border-radius: 0 var(--kb-radius-sm) var(--kb-radius-sm) 0; font-style: italic; }
body.dark-mode .quote-box { background: rgba(35,35,55,0.8); }
.quote-box .author { text-align: right; color: var(--kb-text-light); margin-top: 10px; font-style: normal; }

/* ===== Comparison Table ===== */
.comparison-table { width: 100%; border-collapse: collapse; margin: 20px 0; }
.comparison-table th { background: var(--kb-gradient); color: white; padding: 15px; text-align: left; }
.comparison-table td { padding: 15px; border-bottom: 1px solid var(--kb-border-light); }
.comparison-table tr:hover { background: var(--kb-bg-hover); }

/* ===== Key Concepts Grid ===== */
.key-concepts { display: grid; grid-template-columns: repeat(auto-fit, minmax(280px, 1fr)); gap: 20px; margin: 20px 0; }
.concept-card { background: var(--kb-gradient-lighter); border-left: 4px solid var(--kb-primary); padding: 20px; border-radius: var(--kb-radius-sm); }
.concept-card h4 { color: var(--kb-primary); margin-bottom: 10px; }

/* ===== Timeline ===== */
.timeline { position: relative; padding-left: 30px; margin: 20px 0; }
.timeline::before { content: ''; position: absolute; left: 0; top: 0; bottom: 0; width: 3px; background: var(--kb-gradient); }
.timeline-item { position: relative; margin-bottom: 25px; padding-left: 20px; }
.timeline-item::before { content: ''; position: absolute; left: -36px; top: 5px; width: 12px; height: 12px; background: var(--kb-primary); border-radius: 50%; border: 3px solid white; box-shadow: 0 0 0 3px var(--kb-primary); }
body.dark-mode .timeline-item::before { border-color: #1a1a2e; }
.timeline-year { font-weight: bold; color: var(--kb-primary); margin-bottom: 5px; }

/* ===== Tip Box ===== */
.tip-box { background: rgba(39,174,96,0.1); border: 2px dashed #27ae60; border-radius: var(--kb-radius-sm); padding: 20px; margin: 20px 0; }
.tip-box h5 { color: #27ae60; margin-bottom: 10px; }
body.dark-mode .tip-box { background: rgba(78,205,196,0.1); border-color: #4ecdc4; }
body.dark-mode .tip-box h5 { color: #4ecdc4; }

/* ===== Warning Box ===== */
.warning-box { background: rgba(243,156,18,0.1); border: 2px solid #f39c12; border-radius: var(--kb-radius-sm); padding: 20px; margin: 20px 0; }
.warning-box h5 { color: #f39c12; margin-bottom: 10px; }

/* ===== School Card ===== */
.school-card { background: var(--kb-gradient-lighter); border: 2px solid var(--kb-primary); border-radius: var(--kb-radius-card); padding: 25px; margin: 20px 0; transition: var(--kb-transition); }
.school-card:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(102,126,234,0.2); }
.school-card h3 { color: var(--kb-primary); margin-bottom: 15px; }
.school-card a { display: inline-block; margin-top: 15px; padding: 10px 20px; background: var(--kb-gradient); color: white; text-decoration: none; border-radius: var(--kb-radius-btn); transition: var(--kb-transition); }
.school-card a:hover { transform: translateX(5px); box-shadow: 0 5px 15px rgba(102,126,234,0.3); }

/* ===== Application Card ===== */
.application-card { background: var(--kb-bg-card); border: 2px solid var(--kb-accent); border-radius: var(--kb-radius-card); padding: 25px; margin: 20px 0; transition: var(--kb-transition); }
.application-card:hover { transform: translateY(-5px); box-shadow: 0 10px 30px rgba(142,68,173,0.2); }
.application-card h3 { color: var(--kb-accent); margin-bottom: 15px; }
.application-card a { display: inline-block; margin-top: 15px; padding: 10px 20px; background: linear-gradient(135deg, var(--kb-accent) 0%, var(--kb-primary) 100%); color: white; text-decoration: none; border-radius: var(--kb-radius-btn); transition: var(--kb-transition); }
.application-card a:hover { transform: translateX(5px); box-shadow: 0 5px 15px rgba(142,68,173,0.3); }

/* ===== Table Container ===== */
.table-container { overflow-x: auto; }
.table-container table { width: 100%; border-collapse: collapse; margin: 20px 0; }
.table-container th { background: var(--kb-gradient); color: white; padding: 15px; text-align: left; }
.table-container td { padding: 15px; border-bottom: 1px solid var(--kb-border-light); }
.table-container tr:hover { background: var(--kb-bg-hover); }
.table-container a { color: var(--kb-primary); text-decoration: none; font-weight: bold; }
.table-container a:hover { text-decoration: underline; }

/* ===== Accordion (New) ===== */
.accordion { margin: 20px 0; }
.accordion-item { border: 1px solid var(--kb-border-light); border-radius: var(--kb-radius-sm); margin-bottom: 10px; overflow: hidden; }
.accordion-header { display: flex; justify-content: space-between; align-items: center; padding: 15px 20px; background: var(--kb-gradient-lighter); cursor: pointer; font-weight: bold; color: var(--kb-primary); transition: var(--kb-transition); }
.accordion-header:hover { background: var(--kb-gradient-light); }
.accordion-header::after { content: '+'; font-size: 20px; font-weight: bold; transition: transform 0.3s ease; }
.accordion-item.active .accordion-header::after { content: '−'; }
.accordion-body { max-height: 0; overflow: hidden; transition: max-height 0.3s ease; padding: 0 20px; }
.accordion-item.active .accordion-body { max-height: 2000px; padding: 15px 20px; }

/* ===== Tabs (New) ===== */
.tabs { margin: 20px 0; }
.tab-nav { display: flex; gap: 5px; border-bottom: 2px solid var(--kb-border-light); margin-bottom: 20px; flex-wrap: wrap; }
.tab-btn { padding: 10px 20px; background: transparent; border: none; border-bottom: 3px solid transparent; cursor: pointer; font-size: 16px; font-weight: bold; color: var(--kb-text-light); transition: var(--kb-transition); }
.tab-btn:hover { color: var(--kb-primary); }
.tab-btn.active { color: var(--kb-primary); border-bottom-color: var(--kb-primary); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ===== Stats Grid (New) ===== */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin: 20px 0; }
.stat-card { background: var(--kb-bg-card); border-radius: var(--kb-radius-card); padding: 25px; text-align: center; box-shadow: var(--kb-shadow-card); transition: var(--kb-transition); }
.stat-card:hover { transform: translateY(-5px); }
.stat-value { font-size: 36px; font-weight: bold; color: var(--kb-primary); margin-bottom: 5px; }
.stat-label { font-size: 14px; color: var(--kb-text-light); }
.stat-desc { font-size: 12px; color: var(--kb-text-light); margin-top: 5px; }

/* ===== Steps Flow (New) ===== */
.steps-flow { display: flex; flex-wrap: wrap; gap: 0; margin: 20px 0; align-items: flex-start; }
.step-item { flex: 1; min-width: 150px; text-align: center; position: relative; padding: 20px 10px; }
.step-item::after { content: '→'; position: absolute; right: -10px; top: 35px; font-size: 24px; color: var(--kb-primary); }
.step-item:last-child::after { display: none; }
.step-number { width: 50px; height: 50px; border-radius: 50%; background: var(--kb-gradient); color: white; display: flex; align-items: center; justify-content: center; font-size: 20px; font-weight: bold; margin: 0 auto 10px; }
.step-title { font-weight: bold; color: var(--kb-primary); margin-bottom: 5px; }
.step-desc { font-size: 14px; color: var(--kb-text-light); }

/* ===== Rating Compare (New) ===== */
.rating-compare { margin: 20px 0; }
.rating-item { margin-bottom: 15px; }
.rating-label { display: flex; justify-content: space-between; margin-bottom: 5px; font-weight: bold; }
.rating-bar-track { height: 24px; background: rgba(0,0,0,0.05); border-radius: 12px; overflow: hidden; position: relative; }
body.dark-mode .rating-bar-track { background: rgba(255,255,255,0.05); }
.rating-bar { height: 100%; border-radius: 12px; background: var(--kb-gradient); transition: width 0.5s ease; display: flex; align-items: center; padding-left: 10px; color: white; font-size: 12px; font-weight: bold; min-width: 40px; }
.rating-bar.compare-a { background: var(--kb-gradient); }
.rating-bar.compare-b { background: linear-gradient(135deg, var(--kb-accent) 0%, var(--kb-secondary) 100%); }

/* ===== Footer ===== */
footer { text-align: center; padding: 40px 20px; color: var(--kb-text-light); margin-top: 40px; }

/* ===== Dark Mode Button ===== */
.dark-mode-btn { margin-left: 10px; padding: 10px 20px; background: linear-gradient(135deg, rgba(100,100,120,0.3) 0%, rgba(80,80,100,0.3) 100%); border: 2px solid rgba(100,100,120,0.5); border-radius: var(--kb-radius-btn); cursor: pointer; font-size: 14px; font-weight: bold; color: white; transition: var(--kb-transition); }
.dark-mode-btn:hover { background: linear-gradient(135deg, rgba(100,100,120,0.5) 0%, rgba(80,80,100,0.5) 100%); transform: translateY(-2px); }
body.dark-mode .dark-mode-btn { background: linear-gradient(135deg, rgba(255,107,107,0.3) 0%, rgba(238,90,90,0.3) 100%); border-color: rgba(255,107,107,0.5); }
body.dark-mode .dark-mode-btn:hover { background: linear-gradient(135deg, rgba(255,107,107,0.5) 0%, rgba(238,90,90,0.5) 100%); }
body.dark-mode .nav-menu-btn button { background: var(--kb-gradient) !important; }

/* ===== Dark Mode Body ===== */
body.dark-mode { background: linear-gradient(135deg, #1a1a2e 0%, #16213e 100%) !important; }
body.dark-mode a { color: #4ecdc4; }
body.dark-mode a:hover { color: #95e1d3; }
body.dark-mode .content-card h2 { border-bottom-color: var(--kb-primary); }
body.dark-mode .sidebar-nav { box-shadow: 0 2px 15px rgba(0,0,0,0.4); }

/* ===== Search Box ===== */
.search-box { position: fixed; top: 20px; right: 20px; z-index: 1000; display: flex; gap: 5px; background: var(--kb-bg-card); padding: 10px; border-radius: var(--kb-radius-sm); box-shadow: 0 2px 10px rgba(0,0,0,0.2); }
.search-box input { padding: 8px 12px; border-radius: var(--kb-radius-xs); border: 1px solid var(--kb-border-light); width: 200px; background: transparent; color: var(--kb-text); }
.search-box button { padding: 8px 12px; border: none; background: var(--kb-primary); color: white; border-radius: var(--kb-radius-xs); cursor: pointer; }
.search-highlight { background: yellow; padding: 2px; border-radius: 2px; }
body.dark-mode .search-highlight { background: rgba(255,200,0,0.4); }

/* ===== Progress Bar ===== */
.progress-bar { position: fixed; top: 0; left: 0; width: 100%; height: 4px; background: rgba(0,0,0,0.1); z-index: 1001; }
.progress-fill { height: 100%; background: var(--kb-gradient); width: 0%; transition: width 0.1s ease; }

/* ===== Back to Top ===== */
.back-to-top { position: fixed; bottom: 20px; left: 20px; width: 50px; height: 50px; background: var(--kb-gradient); color: white; border: none; border-radius: 50%; cursor: pointer; font-size: 20px; box-shadow: 0 2px 10px rgba(0,0,0,0.2); z-index: 100; transition: var(--kb-transition); display: none; }
.back-to-top:hover { transform: translateY(-5px); }

/* ===== Font Control ===== */
.font-control { position: fixed; bottom: 80px; right: 20px; display: flex; gap: 5px; z-index: 100; }
.font-control button { padding: 8px 12px; background: var(--kb-bg-card); border: 1px solid var(--kb-border-light); border-radius: var(--kb-radius-xs); cursor: pointer; color: var(--kb-text); }
.font-control button:hover { background: var(--kb-primary); color: white; }

/* ===== Bookmark ===== */
.bookmark-btn { position: absolute; right: 0; top: 0; padding: 5px 10px; background: var(--kb-bg-hover); border: none; border-radius: var(--kb-radius-xs); cursor: pointer; font-size: 14px; }
.bookmark-btn:hover { background: rgba(102,126,234,0.2); }
.bookmark-btn.active { background: rgba(102,126,234,0.3); }
.bookmark-list { position: fixed; bottom: 20px; right: 20px; background: var(--kb-bg-card); padding: 15px; border-radius: var(--kb-radius-sm); box-shadow: 0 2px 15px rgba(0,0,0,0.2); z-index: 100; max-width: 250px; }
.bookmark-list h4 { margin-bottom: 10px; color: var(--kb-primary); }
.bookmark-list a { display: block; padding: 5px; color: var(--kb-text); text-decoration: none; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .nav-menu-tooltip { width: calc(100vw - 40px); left: 10px; }
    .sidebar-nav { display: none; }
    header h1 { font-size: 32px; }
    .key-concepts { grid-template-columns: 1fr; }
    .container { padding: 20px 10px; }
    .search-box { top: auto; bottom: 20px; right: 10px; left: 10px; width: auto; }
    .search-box input { width: 100%; }
    .steps-flow { flex-direction: column; }
    .step-item::after { content: '↓'; right: auto; top: auto; bottom: -25px; left: 50%; transform: translateX(-50%); }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    .tab-nav { gap: 0; }
    .tab-btn { padding: 8px 12px; font-size: 14px; }
}

/* ===== Decision Tree ===== */
.decision-tree { margin: 20px 0; }
.decision-node { background: var(--kb-gradient-lighter); border: 2px solid var(--kb-primary); border-radius: var(--kb-radius-sm); padding: 20px; margin-bottom: 15px; }
.decision-question { font-weight: bold; color: var(--kb-primary); font-size: 18px; margin-bottom: 15px; }
.decision-branches { display: flex; gap: 20px; flex-wrap: wrap; }
.decision-branch { flex: 1; min-width: 200px; background: var(--kb-bg-card); border-radius: var(--kb-radius-xs); padding: 15px; }
.decision-answer { font-weight: bold; color: var(--kb-accent); margin-bottom: 8px; }
.decision-result { color: var(--kb-text); }
body.dark-mode .decision-node { border-color: var(--kb-primary); }

/* ===== Print ===== */
@media print {
    .nav-menu-btn, .sidebar-nav, .print-btn, .dark-mode-btn, .search-box, .font-control, .back-to-top, .bookmark-list, .progress-bar { display: none !important; }
    body { background: white !important; }
    .content-card { box-shadow: none !important; border: 1px solid #ddd; page-break-inside: avoid; }
    header { box-shadow: none !important; border: 1px solid #ddd; }
}
