/* ===== 基础变量 ===== */
:root {
    --primary-color: #1890ff;
    --bg-color: #ffffff;
    --bg-secondary: #f5f5f5;
    --text-color: #333333;
    --text-secondary: #666666;
    --border-color: #e8e8e8;
    --card-bg: #ffffff;
    --header-bg: #ffffff;
    --footer-bg: #333333;
    --footer-text: #ffffff;
    --link-color: #1890ff;
    --link-hover: #40a9ff;
    --shadow: 0 2px 8px rgba(0,0,0,0.1);
    --radius: 8px;
}

/* ===== 蓝白色科技版 ===== */
[data-theme="blue-white"] {
    --primary-color: #1890ff;
    --bg-color: #ffffff;
    --bg-secondary: #f0f5ff;
    --text-color: #333333;
    --text-secondary: #666666;
    --border-color: #e8e8e8;
    --card-bg: #ffffff;
    --header-bg: #ffffff;
    --footer-bg: #001529;
    --footer-text: #ffffff;
    --link-color: #1890ff;
    --link-hover: #40a9ff;
}

/* ===== 暗黑专业版 ===== */
[data-theme="dark-pro"] {
    --primary-color: #00d4ff;
    --bg-color: #1a1a2e;
    --bg-secondary: #16213e;
    --text-color: #e0e0e0;
    --text-secondary: #a0a0a0;
    --border-color: #2a2a4a;
    --card-bg: #16213e;
    --header-bg: #0f0f23;
    --footer-bg: #0a0a1a;
    --footer-text: #e0e0e0;
    --link-color: #00d4ff;
    --link-hover: #33e0ff;
}

/* ===== 温色休闲版 ===== */
[data-theme="warm-casual"] {
    --primary-color: #ff9f43;
    --bg-color: #fef9f3;
    --bg-secondary: #fff5eb;
    --text-color: #5a4a42;
    --text-secondary: #8a7a72;
    --border-color: #f0e0d0;
    --card-bg: #ffffff;
    --header-bg: #fff9f3;
    --footer-bg: #5a4a42;
    --footer-text: #fef9f3;
    --link-color: #ff9f43;
    --link-hover: #ffb063;
}

/* ===== 清风古雅版 ===== */
[data-theme="classic-elegant"] {
    --primary-color: #8b6914;
    --bg-color: #f5f0e8;
    --bg-secondary: #ebe5d8;
    --text-color: #4a3f35;
    --text-secondary: #7a6f65;
    --border-color: #d5cfc0;
    --card-bg: #ffffff;
    --header-bg: #f5f0e8;
    --footer-bg: #4a3f35;
    --footer-text: #f5f0e8;
    --link-color: #8b6914;
    --link-hover: #a6831a;
}

/* ===== 绿色果蔬版 ===== */
[data-theme="green-veggie"] {
    --primary-color: #52c41a;
    --bg-color: #f6ffed;
    --bg-secondary: #f0f9e8;
    --text-color: #2b4f2b;
    --text-secondary: #5a7f5a;
    --border-color: #d9f7be;
    --card-bg: #ffffff;
    --header-bg: #f6ffed;
    --footer-bg: #2b4f2b;
    --footer-text: #f6ffed;
    --link-color: #52c41a;
    --link-hover: #73d13d;
}

/* ===== 重置样式 ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'PingFang SC', 'Hiragino Sans GB', 'Microsoft YaHei', sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: all 0.3s ease;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--link-hover);
}

img {
    max-width: 100%;
    height: auto;
}

/* ===== 容器 ===== */
.container {
    max-width: 1440px;
    margin: 0 auto;
    padding: 0 24px;
}

/* ===== 头部 ===== */
.header {
    background: var(--header-bg);
    box-shadow: var(--shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-top {
    background: var(--primary-color);
    color: #fff;
    padding: 8px 0;
    font-size: 14px;
}

.header-top .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-main {
    padding: 15px 0;
}

.header-main .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 15px;
}

.logo h1 {
    font-size: 28px;
    color: var(--primary-color);
    font-weight: bold;
}

.logo span {
    font-size: 14px;
    color: var(--text-secondary);
}

/* 导航 */
.nav {
    display: flex;
    gap: 22px;
    flex: 1;
    justify-content: center;
    flex-wrap: nowrap;
}

.nav a {
    color: var(--text-color);
    font-size: 15px;
    font-weight: 500;
    padding: 8px 0;
    position: relative;
    white-space: nowrap;
}

.nav a:hover,
.nav a.active {
    color: var(--primary-color);
}

.nav a::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    width: 0;
    height: 2px;
    background: var(--primary-color);
    transition: width 0.3s;
}

.nav a:hover::after,
.nav a.active::after {
    width: 100%;
}

/* 导航项（链接或下拉容器） */
.nav-item {
    position: relative;
}

.nav-link {
    display: inline-block;
}

/* 一级栏目下拉容器 */
.nav-dropdown {
    position: relative;
}

.nav-dropdown > .nav-link::after {
    display: none;
}

/* 下拉网格面板：默认隐藏，鼠标悬停一级栏目时显示 */
.dropdown-grid-panel {
    display: none;
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    min-width: 980px;
    max-width: 1200px;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: var(--radius);
    box-shadow: 0 8px 24px rgba(0,0,0,0.15);
    padding: 20px 24px 12px;
    z-index: 1000;
    animation: dropdownFadeIn 0.18s ease-out;
}

.nav-dropdown:hover .dropdown-grid-panel,
.nav-dropdown:focus-within .dropdown-grid-panel {
    display: block;
}

@keyframes dropdownFadeIn {
    from { opacity: 0; transform: translateX(-50%) translateY(-6px); }
    to   { opacity: 1; transform: translateX(-50%) translateY(0); }
}

/* 二级栏目网格：7 列平铺 */
.dropdown-grid {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: 16px 12px;
}

.dropdown-grid-col {
    min-width: 0;
}

.dropdown-grid-title {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary-color);
    padding: 4px 0 6px;
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 6px;
    white-space: nowrap;
}

.dropdown-grid-title:hover {
    color: var(--link-hover);
}

.dropdown-grid-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.dropdown-grid-list li a {
    display: block;
    color: var(--text-secondary);
    font-size: 12px;
    font-weight: 400;
    padding: 3px 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.dropdown-grid-list li a:hover {
    color: var(--primary-color);
    background: transparent;
}

.dropdown-grid-list li a::after {
    display: none;
}

/* 下拉底部「查看全部」链接 */
.dropdown-grid-footer {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px dashed var(--border-color);
    text-align: center;
}

.dropdown-view-all {
    display: inline-block;
    color: var(--primary-color);
    font-size: 13px;
    font-weight: 500;
    padding: 4px 12px;
}

.dropdown-view-all:hover {
    color: var(--link-hover);
}

.dropdown-view-all::after {
    display: none;
}

/* 页脚栏目导航样式见页脚区域统一设置 */

/* 主题切换器 */
.theme-switcher {
    display: flex;
    gap: 8px;
    align-items: center;
}

.theme-btn {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 2px solid var(--border-color);
    cursor: pointer;
    transition: transform 0.2s, border-color 0.2s;
}

.theme-btn:hover {
    transform: scale(1.2);
    border-color: var(--primary-color);
}

.theme-btn.active {
    border-color: var(--primary-color);
    box-shadow: 0 0 5px var(--primary-color);
}

/* ===== 搜索框 ===== */
.search-box {
    display: flex;
    align-items: center;
    background: var(--bg-secondary);
    border-radius: 20px;
    padding: 5px 10px;
    gap: 6px;
    flex-shrink: 0;
}

.search-box input {
    border: none;
    background: transparent;
    outline: none;
    color: var(--text-color);
    width: 130px;
    font-size: 13px;
}

.search-box button {
    background: var(--primary-color);
    color: #fff;
    border: none;
    border-radius: 16px;
    padding: 5px 12px;
    cursor: pointer;
    font-size: 13px;
}

/* ===== 面包屑 ===== */
.breadcrumb {
    padding: 15px 0;
    font-size: 14px;
    color: var(--text-secondary);
}

.breadcrumb a {
    color: var(--text-secondary);
}

.breadcrumb a:hover {
    color: var(--primary-color);
}

/* ===== 主内容区 ===== */
.main-content {
    padding: 30px 0;
}

.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 30px;
}

/* ===== 文章列表 ===== */
.article-list {
    display: grid;
    gap: 25px;
}

.article-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
}

.article-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
}

.article-card-horizontal {
    display: grid;
    grid-template-columns: 280px 1fr;
}

.article-card .cover {
    height: 100%;
    min-height: 180px;
    background: var(--bg-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.article-card .cover img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.article-card .content {
    padding: 20px;
}

.article-card .title {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--text-color);
}

.article-card .title a {
    color: inherit;
}

.article-card .title a:hover {
    color: var(--primary-color);
}

.article-card .summary {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 15px;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.article-card .meta {
    display: flex;
    gap: 20px;
    font-size: 13px;
    color: var(--text-secondary);
}

.article-card .tags {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-top: 10px;
}

.article-card .tag {
    background: var(--bg-secondary);
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 15px;
    font-size: 12px;
}

.article-card .tag:hover {
    background: var(--primary-color);
    color: #fff;
}

/* ===== 侧边栏 ===== */
.sidebar {
    display: grid;
    gap: 25px;
}

.sidebar-widget {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.sidebar-widget .widget-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 15px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--primary-color);
    color: var(--text-color);
}

.sidebar-widget .widget-list {
    list-style: none;
}

.sidebar-widget .widget-list li {
    padding: 10px 0;
    border-bottom: 1px solid var(--border-color);
}

.sidebar-widget .widget-list li:last-child {
    border-bottom: none;
}

.sidebar-widget .widget-list li a {
    color: var(--text-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-widget .widget-list li a:hover {
    color: var(--primary-color);
}

.sidebar-widget .widget-list .count {
    background: var(--bg-secondary);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 12px;
    color: var(--text-secondary);
}

/* ===== 广告位 ===== */
.ad-placeholder {
    background: var(--bg-secondary);
    border: 2px dashed var(--border-color);
    border-radius: var(--radius);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--text-secondary);
    font-size: 14px;
    position: relative;
    overflow: hidden;
}

.ad-placeholder .ad-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.ad-placeholder .ad-size {
    font-size: 11px;
    color: var(--text-secondary);
    opacity: 0.7;
}

.ad-home-top { width: 100%; height: 120px; margin-bottom: 25px; }
.ad-article-top { width: 100%; height: 90px; margin-bottom: 20px; }
.ad-article-middle { width: 100%; height: 200px; margin: 30px 0; }
.ad-article-bottom { width: 100%; height: 100px; margin-top: 30px; }
.ad-sidebar-large { width: 100%; height: 250px; }
.ad-sidebar-small { width: 100%; height: 250px; }
.ad-list-top { width: 100%; height: 80px; margin-bottom: 25px; }
.ad-footer-banner { width: 100%; height: 60px; margin-top: 20px; }
.ad-mobile-top { width: 100%; height: 100px; display: none; }
.ad-mobile-bottom { width: 100%; height: 80px; display: none; }

/* ===== 文章详情 ===== */
.article-detail {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 40px;
}

.article-detail .article-header {
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
}

.article-detail .article-title {
    font-size: 32px;
    font-weight: bold;
    margin-bottom: 15px;
    color: var(--text-color);
}

.article-detail .article-meta {
    display: flex;
    gap: 20px;
    color: var(--text-secondary);
    font-size: 14px;
    flex-wrap: wrap;
}

.article-detail .article-content {
    font-size: 16px;
    line-height: 1.8;
    color: var(--text-color);
}

.article-detail .article-content h2 {
    font-size: 24px;
    margin: 30px 0 15px;
    color: var(--primary-color);
}

.article-detail .article-content h3 {
    font-size: 20px;
    margin: 25px 0 12px;
}

.article-detail .article-content p {
    margin-bottom: 15px;
}

.article-detail .article-content ul,
.article-detail .article-content ol {
    margin: 15px 0;
    padding-left: 25px;
}

.article-detail .article-content li {
    margin-bottom: 8px;
}

/* Markdown 表格美化：带边框、斑马纹、表头强调、hover 高亮 */
.article-detail .article-content table {
    width: 100%;
    margin: 20px 0;
    border-collapse: collapse;
    border: 1px solid var(--border-color, #e0e0e0);
    border-radius: 6px;
    overflow: hidden;
    font-size: 14px;
    line-height: 1.6;
    background: #fff;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.04);
}

.article-detail .article-content table thead {
    background: linear-gradient(to bottom, #f5f9f5, #eaf3ea);
}

.article-detail .article-content table th {
    padding: 10px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--primary-color, #2e7d32);
    border-bottom: 2px solid var(--primary-color, #2e7d32);
    white-space: nowrap;
}

.article-detail .article-content table td {
    padding: 9px 14px;
    border-bottom: 1px solid var(--border-color, #e8e8e8);
    color: var(--text-color, #333);
}

.article-detail .article-content table tbody tr:nth-child(even) {
    background: #fafdf9;
}

.article-detail .article-content table tbody tr:hover {
    background: #eef7ee;
}

.article-detail .article-content table tbody tr:last-child td {
    border-bottom: none;
}

/* 上一篇/下一篇 */
.article-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 20px;
    margin-top: 40px;
    padding-top: 30px;
    border-top: 1px solid var(--border-color);
}

.article-nav a {
    padding: 15px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    color: var(--text-color);
    transition: background 0.2s;
}

.article-nav a:hover {
    background: var(--primary-color);
    color: #fff;
}

.article-nav .nav-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 5px;
}

.article-nav a:hover .nav-label {
    color: rgba(255,255,255,0.8);
}

.article-nav .nav-title {
    font-size: 14px;
    font-weight: 500;
}

/* ===== 分类列表 ===== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 25px;
}

.category-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 25px;
    transition: transform 0.3s;
}

.category-card:hover {
    transform: translateY(-5px);
}

.category-card .category-name {
    font-size: 20px;
    font-weight: bold;
    margin-bottom: 10px;
    color: var(--primary-color);
}

.category-card .category-desc {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 15px;
}

.category-card .sub-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
}

.category-card .sub-cat {
    background: var(--bg-secondary);
    padding: 5px 12px;
    border-radius: 15px;
    font-size: 13px;
    color: var(--text-secondary);
}

.category-card .sub-cat:hover {
    background: var(--primary-color);
    color: #fff;
}

/* ===== 知识概念 ===== */
.concept-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
}

.concept-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 25px;
    border-left: 4px solid var(--primary-color);
}

.concept-card .concept-title {
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 10px;
}

.concept-card .concept-summary {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 15px;
}

/* ===== 页脚 ===== */
.footer {
    background: var(--footer-bg);
    color: var(--footer-text);
    padding: 50px 0 30px;
    margin-top: 50px;
}

.footer-grid {
    display: grid;
    grid-template-columns: repeat(5, 1fr);
    gap: 30px;
    margin-bottom: 40px;
    align-items: start;
}

.footer-col {
    min-width: 0;
}

.footer-col h4 {
    font-size: 16px;
    font-weight: 600;
    margin: 0 0 16px;
    padding-bottom: 10px;
    color: #fff;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
}

.footer-desc {
    opacity: 0.75;
    line-height: 1.7;
    font-size: 13px;
    margin: 0;
}

.footer-links-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.footer-links-list li {
    margin-bottom: 10px;
}

.footer-links-list li:last-child {
    margin-bottom: 0;
}

.footer-links-list li a {
    color: var(--footer-text);
    opacity: 0.75;
    font-size: 13px;
    line-height: 1.6;
}

.footer-links-list li a:hover {
    opacity: 1;
    color: #fff;
}

.footer-bottom {
    text-align: center;
    padding-top: 30px;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 14px;
    opacity: 0.8;
}

/* ===== 栏目导航（竖向） ===== */
.footer-nav-cols {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.footer-nav-col .footer-nav-l1 {
    display: block;
    color: var(--footer-text);
    opacity: 0.75;
    font-weight: 400;
    font-size: 13px;
    line-height: 1.6;
    padding: 0;
}

.footer-nav-col .footer-nav-l1:hover {
    opacity: 1;
    color: #fff;
}

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

.pagination a,
.pagination span {
    padding: 8px 15px;
    background: var(--card-bg);
    border-radius: var(--radius);
    color: var(--text-color);
    box-shadow: var(--shadow);
}

.pagination a:hover,
.pagination .active {
    background: var(--primary-color);
    color: #fff;
}

/* ===== 移动端菜单按钮 ===== */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    color: var(--text-color);
    cursor: pointer;
}

/* ===== 响应式设计 ===== */
@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .footer-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .mobile-menu-btn {
        display: block;
    }
    
    .nav {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        background: var(--header-bg);
        flex-direction: column;
        padding: 20px;
        box-shadow: var(--shadow);
        gap: 15px;
    }
    
    .nav.active {
        display: flex;
    }
    
    .header-top .container {
        flex-direction: column;
        gap: 5px;
        text-align: center;
    }
    
    .header-main .container {
        flex-wrap: wrap;
    }
    
    .logo h1 {
        font-size: 22px;
    }
    
    .search-box {
        order: 3;
        width: 100%;
        margin-top: 10px;
    }
    
    .search-box input {
        width: 100%;
    }
    
    .article-card-horizontal {
        grid-template-columns: 1fr;
    }
    
    .article-card .cover {
        min-height: 150px;
    }
    
    .article-detail {
        padding: 20px;
    }
    
    .article-detail .article-title {
        font-size: 24px;
    }
    
    .article-nav {
        grid-template-columns: 1fr;
    }
    
    .sidebar {
        grid-template-columns: 1fr;
    }

    .footer-grid {
        grid-template-columns: 1fr;
        gap: 24px;
    }

    .category-grid {
        grid-template-columns: 1fr;
    }
    
    .concept-grid {
        grid-template-columns: 1fr;
    }
    
    .ad-home-top,
    .ad-article-top,
    .ad-article-middle,
    .ad-article-bottom,
    .ad-sidebar-large,
    .ad-sidebar-small,
    .ad-list-top,
    .ad-footer-banner {
        display: none;
    }
    
    .ad-mobile-top,
    .ad-mobile-bottom {
        display: flex;
    }
}

@media (max-width: 480px) {
    .container {
        padding: 0 15px;
    }
    
    .article-detail .article-meta {
        flex-direction: column;
        gap: 8px;
    }
    
    .article-card .meta {
        flex-direction: column;
        gap: 5px;
    }
}

/* ===== 工具类 ===== */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.flex { display: flex; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.gap-10 { gap: 10px; }
.hidden { display: none; }
