/* ============================================
   股市百科 - 主样式表
   技术文档风格 UI
   ============================================ */

/* --- CSS 变量 --- */
:root {
    --sidebar-width: 280px;
    --topbar-height: 56px;
    --primary: #1a73e8;
    --primary-light: #e8f0fe;
    --primary-dark: #1557b0;
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f1f3f4;
    --text: #202124;
    --text-secondary: #5f6368;
    --text-tertiary: #80868b;
    --border: #dadce0;
    --border-light: #e8eaed;
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.06), 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --radius: 8px;
    --radius-sm: 4px;
    --transition: 0.2s ease;
    --font-mono: 'SF Mono', 'Cascadia Code', 'Consolas', monospace;
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "PingFang SC", "Microsoft YaHei", "Helvetica Neue", sans-serif;
    color: var(--text);
    background: var(--bg);
    line-height: 1.7;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--primary);
    text-decoration: none;
}
a:hover {
    text-decoration: underline;
}

/* --- 顶部导航栏 --- */
.topbar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    height: var(--topbar-height);
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 20px;
    gap: 16px;
    z-index: 100;
    box-shadow: var(--shadow-sm);
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 22px;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px 8px;
    border-radius: var(--radius-sm);
    line-height: 1;
}
.menu-toggle:hover {
    background: var(--bg-tertiary);
}

.logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    flex-shrink: 0;
}
.logo:hover {
    text-decoration: none;
    color: var(--primary);
}

.topbar-search {
    position: relative;
    max-width: 400px;
    width: 100%;
    margin-left: auto;
}

.topbar-search input {
    width: 100%;
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    font-size: 14px;
    background: var(--bg-secondary);
    outline: none;
    transition: var(--transition);
}
.topbar-search input:focus {
    background: var(--bg);
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(26,115,232,0.12);
}

.search-results {
    display: none;
    position: absolute;
    top: calc(100% + 6px);
    left: 0;
    right: 0;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    max-height: 360px;
    overflow-y: auto;
    z-index: 200;
}
.search-results.active {
    display: block;
}
.search-result-item {
    padding: 10px 16px;
    cursor: pointer;
    border-bottom: 1px solid var(--border-light);
    font-size: 14px;
}
.search-result-item:last-child {
    border-bottom: none;
}
.search-result-item:hover,
.search-result-item.highlighted {
    background: var(--primary-light);
}
.search-result-item .result-title {
    font-weight: 500;
    color: var(--text);
}
.search-result-item .result-category {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-top: 2px;
}
.search-result-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 14px;
}

/* --- 主体布局 --- */
.app-container {
    display: flex;
    margin-top: var(--topbar-height);
    min-height: calc(100vh - var(--topbar-height));
}

/* --- 侧边栏 --- */
.sidebar {
    width: var(--sidebar-width);
    min-width: var(--sidebar-width);
    background: var(--bg-secondary);
    border-right: 1px solid var(--border);
    height: calc(100vh - var(--topbar-height));
    position: sticky;
    top: var(--topbar-height);
    overflow-y: auto;
    padding: 12px 0;
    transition: transform var(--transition);
}

.sidebar-overlay {
    display: none;
}

/* --- 导航树 --- */
.nav-tree {
    padding: 0 12px;
}

.nav-group {
    margin-bottom: 4px;
}

.nav-group-title {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text);
    cursor: pointer;
    border-radius: var(--radius-sm);
    user-select: none;
    transition: var(--transition);
}
.nav-group-title:hover {
    background: var(--bg-tertiary);
}

.nav-arrow {
    font-size: 10px;
    color: var(--text-tertiary);
    transition: transform var(--transition);
    display: inline-block;
    width: 14px;
    text-align: center;
}
.nav-group.expanded .nav-arrow {
    transform: rotate(90deg);
}

.nav-list {
    list-style: none;
    overflow: hidden;
    max-height: 0;
    transition: max-height 0.3s ease;
}
.nav-group.expanded .nav-list {
    max-height: 600px;
}

.nav-link {
    display: block;
    padding: 7px 12px 7px 34px;
    font-size: 13.5px;
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    transition: var(--transition);
    border-left: 2px solid transparent;
}
.nav-link:hover {
    background: var(--bg-tertiary);
    color: var(--text);
    text-decoration: none;
}
.nav-link.active {
    color: var(--primary);
    background: var(--primary-light);
    border-left-color: var(--primary);
    font-weight: 500;
}

/* --- 主内容区 --- */
.content {
    flex: 1;
    padding: 40px 48px;
    max-width: 900px;
    min-width: 0;
}

.content-welcome {
    text-align: center;
    padding-top: 80px;
}

.content-welcome h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 12px;
    color: var(--text);
}

.welcome-desc {
    font-size: 16px;
    color: var(--text-secondary);
    max-width: 500px;
    margin: 0 auto 48px;
}

.feature-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    text-align: left;
}

.feature-card {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 24px;
    transition: var(--transition);
}
.feature-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.feature-icon {
    font-size: 32px;
    margin-bottom: 12px;
}

.feature-card h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 8px;
    color: var(--text);
}

.feature-card p {
    font-size: 13px;
    color: var(--text-secondary);
    line-height: 1.6;
}

/* --- 知识文章排版 --- */
.article {
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.article h1 {
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 8px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border-light);
}

.article-meta {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-bottom: 28px;
}

.article h2 {
    font-size: 20px;
    font-weight: 600;
    margin: 36px 0 14px;
    color: var(--text);
}

.article h3 {
    font-size: 17px;
    font-weight: 600;
    margin: 28px 0 10px;
    color: var(--text);
}

.article p {
    margin-bottom: 14px;
    font-size: 15px;
}

.article ul, .article ol {
    margin: 10px 0 16px 20px;
}

.article li {
    margin-bottom: 6px;
    font-size: 15px;
}

.article strong {
    color: var(--primary-dark);
}

/* --- 提示框 --- */
.tip-box {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin: 20px 0;
    font-size: 14px;
    line-height: 1.6;
}

.tip-info {
    background: #e8f0fe;
    border-left: 4px solid var(--primary);
    color: #1a3a5c;
}

.tip-warning {
    background: #fef7e0;
    border-left: 4px solid #f9ab00;
    color: #5c4a00;
}

.tip-success {
    background: #e6f4ea;
    border-left: 4px solid #34a853;
    color: #1a4a2a;
}

.tip-danger {
    background: #fce8e6;
    border-left: 4px solid #ea4335;
    color: #5c1a1a;
}

/* --- 表格 --- */
.article table {
    width: 100%;
    border-collapse: collapse;
    margin: 20px 0;
    font-size: 14px;
}

.article th, .article td {
    padding: 10px 14px;
    border: 1px solid var(--border-light);
    text-align: left;
}

.article th {
    background: var(--bg-secondary);
    font-weight: 600;
}

.article tr:nth-child(even) td {
    background: var(--bg-secondary);
}

/* --- 公式 --- */
.formula {
    background: var(--bg-tertiary);
    padding: 12px 20px;
    border-radius: var(--radius);
    font-family: var(--font-mono);
    font-size: 14px;
    margin: 16px 0;
    overflow-x: auto;
    color: var(--text);
}

/* --- 代码/术语 --- */
.inline-code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 3px;
    font-family: var(--font-mono);
    font-size: 0.9em;
    color: var(--primary-dark);
}

/* --- 响应式 --- */
@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }

    .sidebar {
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        z-index: 150;
        transform: translateX(-100%);
    }
    .sidebar.open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        position: fixed;
        top: var(--topbar-height);
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.5);
        z-index: 140;
        opacity: 0;
        pointer-events: none;
        transition: opacity var(--transition);
    }
    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    .content {
        padding: 24px 16px;
    }

    .content-welcome {
        padding-top: 40px;
    }
    .content-welcome h1 {
        font-size: 26px;
    }

    .feature-cards {
        grid-template-columns: 1fr;
    }

    .topbar-search {
        max-width: none;
    }
}

@media (max-width: 480px) {
    .logo {
        font-size: 17px;
    }
    .article h1 {
        font-size: 22px;
    }
    .article h2 {
        font-size: 18px;
    }
}

/* ============================================
   独立文章页（SEO 直接访问）
   ============================================ */
.standalone-article {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px 48px 60px;
}

.standalone-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 0;
    border-bottom: 1px solid var(--border-light);
    margin-bottom: 32px;
}

.standalone-logo {
    font-size: 18px;
    font-weight: 700;
    color: var(--text);
    text-decoration: none;
}
.standalone-logo:hover {
    color: var(--primary);
    text-decoration: none;
}

.back-link {
    font-size: 14px;
    color: var(--primary);
    text-decoration: none;
}
.back-link:hover {
    text-decoration: underline;
}

.standalone-footer {
    margin-top: 48px;
    padding-top: 20px;
    border-top: 1px solid var(--border-light);
    font-size: 13px;
    color: var(--text-tertiary);
    text-align: center;
    line-height: 1.8;
}
.standalone-footer a {
    color: var(--primary);
}

@media (max-width: 768px) {
    .standalone-article {
        padding: 16px 16px 40px;
    }
}

/* ============================================
   首页增强样式
   ============================================ */
.hero-section {
    text-align: center;
    padding: 40px 0 20px;
}

.hero-section .hero-img {
    max-width: 400px;
    width: 100%;
    height: auto;
    margin-bottom: 24px;
}

.hero-section h1 {
    font-size: 36px;
    font-weight: 700;
    margin-bottom: 10px;
}

.hero-section .hero-subtitle {
    font-size: 16px;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

.stats-bar {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin: 32px 0;
    flex-wrap: wrap;
}

.stat-item {
    text-align: center;
}

.stat-item .stat-num {
    font-size: 28px;
    font-weight: 700;
    color: var(--primary);
}

.stat-item .stat-label {
    font-size: 13px;
    color: var(--text-tertiary);
    margin-top: 4px;
}

.section-title {
    font-size: 20px;
    font-weight: 700;
    text-align: center;
    margin: 48px 0 24px;
    color: var(--text);
}

.learning-path {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 24px;
    margin: 24px 0;
    flex-wrap: wrap;
}

.learning-path .step {
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px 24px;
    text-align: center;
    width: 180px;
}

.learning-path .step .step-num {
    display: inline-block;
    width: 32px;
    height: 32px;
    line-height: 32px;
    border-radius: 50%;
    background: var(--primary);
    color: #fff;
    font-weight: 700;
    font-size: 14px;
    margin-bottom: 10px;
}

.learning-path .step h4 {
    font-size: 15px;
    margin-bottom: 6px;
    color: var(--text);
}

.learning-path .step p {
    font-size: 12px;
    color: var(--text-secondary);
}

.learning-path .path-arrow {
    font-size: 20px;
    color: var(--text-tertiary);
}

.quick-links-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 14px;
    margin: 20px 0;
}

.quick-link-card {
    display: block;
    padding: 14px 18px;
    background: var(--bg);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    text-decoration: none;
    transition: var(--transition);
}
.quick-link-card:hover {
    border-color: var(--primary);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    transform: translateY(-1px);
}
.quick-link-card .ql-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    margin-bottom: 4px;
}
.quick-link-card .ql-desc {
    font-size: 12px;
    color: var(--text-tertiary);
}
.quick-link-card .ql-cat {
    display: inline-block;
    font-size: 11px;
    color: var(--primary);
    background: var(--primary-light);
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 6px;
}

/* --- 文章配图 --- */
.article-img {
    margin: 28px 0;
    text-align: center;
}

.article-img img {
    max-width: 100%;
    height: auto;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-light);
}

.article-img figcaption {
    margin-top: 10px;
    font-size: 13px;
    color: var(--text-tertiary);
    line-height: 1.5;
}

.home-footer-note {
    text-align: center;
    margin-top: 48px;
    padding: 20px;
    color: var(--text-tertiary);
    font-size: 13px;
    border-top: 1px solid var(--border-light);
}
