/**
 * 公共 CSS 文件 - 所有页面共用
 * 版本: 2.0
 */

/* ========== CSS 变量定义 ========== */
:root {
    /* 亮色模式 */
    --bg-color: #f5f7fa;
    --text-color: #333;
    --card-bg: #fff;
    --border-color: #e5e5e5;
    --secondary-text: #8c8c8c;
    --muted-text: #999;
    --shadow-color: rgba(0, 0, 0, 0.06);
    
    /* 默认主题色 */
    --accent-color: #667eea;
    --accent-gradient: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

/* 暗色模式 - 跟随系统 */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg-color: #1a1a2e;
        --text-color: #e0e0e0;
        --card-bg: #16213e;
        --border-color: #2a2a4a;
        --secondary-text: #a0aec0;
        --muted-text: #718096;
        --shadow-color: rgba(0, 0, 0, 0.3);
    }
}

/* 暗色模式 - 手动切换 */
[data-theme="dark"] {
    --bg-color: #1a1a2e;
    --text-color: #e0e0e0;
    --card-bg: #16213e;
    --border-color: #2a2a4a;
    --secondary-text: #a0aec0;
    --muted-text: #718096;
    --shadow-color: rgba(0, 0, 0, 0.3);
}

/* ========== 基础重置 ========== */
*,
*::before,
*::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

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: background-color 0.3s ease, color 0.3s ease;
}

a {
    color: inherit;
    text-decoration: none;
}

/* ========== 布局容器 ========== */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: flex;
    gap: 30px;
}

.main-content {
    flex: 1;
    min-width: 0;
}

/* ========== 移动端顶部栏 ========== */
.top-bar {
    position: sticky;
    top: 0;
    background: var(--bg-color);
    padding: 12px 20px;
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color);
    z-index: 100;
    display: none;
    justify-content: space-between;
    align-items: center;
}

.page-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-color);
}

.menu-toggle,
.theme-toggle-mobile {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--secondary-text);
    padding: 8px;
    border-radius: 8px;
    transition: all 0.2s;
}

.menu-toggle:hover,
.theme-toggle-mobile:hover {
    background-color: var(--card-bg);
}

/* ========== 左侧导航栏 ========== */
.nav-sidebar {
    width: 200px;
    flex-shrink: 0;
}

.nav-bar {
    display: flex;
    flex-direction: column;
    gap: 12px;
    position: sticky;
    top: 20px;
}

.nav-btn {
    padding: 12px 16px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--card-bg);
    color: var(--accent-color);
    border: 1px solid var(--accent-color);
}

.nav-btn.active {
    background: var(--accent-color);
    color: white;
    border: none;
}

.nav-btn:hover {
    transform: translateX(4px);
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.2);
}

/* ========== 主题切换按钮 ========== */
.theme-toggle {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--secondary-text);
    padding: 12px;
    border-radius: 8px;
    transition: all 0.2s;
    text-align: left;
    width: 100%;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 15px;
}

.theme-toggle:hover {
    background-color: var(--card-bg);
}

.theme-toggle svg,
.theme-toggle-mobile svg {
    width: 20px;
    height: 20px;
}

/* ========== 页面标题头部 ========== */
.page-header {
    padding: 40px 20px;
    border-radius: 12px;
    margin-bottom: 30px;
    color: white;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
}

.page-header h1 {
    font-size: 32px;
    font-weight: 600;
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.page-header .update-time {
    opacity: 0.9;
    font-size: 14px;
}

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

.article-link {
    text-decoration: none;
    color: inherit;
}

.article-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 2px 12px var(--shadow-color);
    transition: all 0.3s ease;
    border-left: 4px solid transparent;
    cursor: pointer;
}

.article-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 24px var(--shadow-color);
    border-left-color: var(--accent-color);
}

.article-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
    gap: 12px;
}

.article-title {
    font-size: 20px;
    font-weight: 600;
    color: var(--text-color);
    line-height: 1.4;
    flex: 1;
}

.article-source {
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    flex-shrink: 0;
}

.article-meta {
    display: flex;
    gap: 16px;
    font-size: 13px;
    color: var(--muted-text);
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.article-summary {
    color: var(--secondary-text);
    font-size: 14px;
    line-height: 1.6;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 8px;
}

.article-stats {
    display: flex;
    gap: 20px;
    margin-top: 12px;
    font-size: 12px;
    color: var(--muted-text);
}

/* ========== 来源标签样式 ========== */
.source-sspai,
.source-少数派 {
    background-color: #7c3aed;
    color: #ffffff;
}

.source-36kr,
.source-36氪 {
    background-color: #2b6cb0;
    color: #ebf8ff;
}

.source-人民网 {
    background-color: #c8102e;
    color: #ffffff;
}

.source-original {
    background-color: #fff7e6;
    color: #fa8c16;
}

[data-theme="dark"] .source-original {
    background-color: #553c2a;
    color: #ffbd69;
}

/* ========== 空状态 ========== */
.empty-state {
    text-align: center;
    padding: 80px 20px;
    color: #8c8c8c;
}

/* ========== 响应式设计 ========== */
@media (max-width: 1024px) {
    .nav-sidebar {
        display: none;
    }
    
    .top-bar {
        display: flex;
    }
    
    .nav-sidebar.open {
        display: block;
        position: fixed;
        top: 60px;
        left: 0;
        right: 0;
        bottom: 0;
        background: var(--bg-color);
        padding: 20px;
        z-index: 99;
        width: 100%;
        overflow-y: auto;
    }
}

@media (max-width: 768px) {
    .container {
        padding: 15px;
        gap: 0;
    }
    
    .page-header h1 {
        font-size: 24px;
    }
    
    .article-header {
        flex-direction: column;
        gap: 8px;
    }
    
    .article-title {
        font-size: 18px;
    }
    
    .article-meta {
        gap: 8px;
    }
}
