/* ============================================================
   清言博客 - 主样式文件
   森林系精简治愈风：低饱和绿色调、大量留白、圆角柔和
   ============================================================ */

/* ----- CSS 变量（浅色模式） ----- */
:root {
    --primary:        #5a9e6f;   /* 主色：森林绿 */
    --primary-hover:  #4a8a5d;   /* 悬停色 */
    --primary-light:  #e8f5ed;   /* 浅绿背景 */
    --bg:             #f8faf8;   /* 页面背景 */
    --surface:        #ffffff;   /* 卡片/面板背景 */
    --surface-alt:    #f2f7f3;   /* 次级面板背景 */
    --border:         #dce8dd;   /* 边框色 */
    --text-primary:   #2c3e2d;   /* 主文字 */
    --text-secondary: #6b7e6c;   /* 次级文字 */
    --text-muted:     #9ab09b;   /* 禁用/辅助文字 */
    --shadow-sm:      0 1px 4px rgba(50,80,50,.08);
    --shadow-md:      0 4px 16px rgba(50,80,50,.12);
    --radius:         10px;
    --radius-sm:      6px;
    --radius-lg:      16px;
    --font:           'Noto Sans SC', 'PingFang SC', 'Microsoft YaHei', sans-serif;
    --font-mono:      'JetBrains Mono', 'Fira Code', 'Consolas', monospace;
    --transition:     0.3s ease;
}

/* ----- 夜间模式 ----- */
:root.dark {
    --primary:        #6ab87f;
    --primary-hover:  #7ac98f;
    --primary-light:  #1a3322;
    --bg:             #141a14;
    --surface:        #1e271e;
    --surface-alt:    #243024;
    --border:         #2d3d2d;
    --text-primary:   #d4e8d5;
    --text-secondary: #8aa88b;
    --text-muted:     #566857;
    --shadow-sm:      0 1px 4px rgba(0,0,0,.3);
    --shadow-md:      0 4px 16px rgba(0,0,0,.4);
}

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

html {
    font-size: 16px;
    scroll-behavior: smooth;
    /* 防止夜间模式闪烁 */
    background: var(--bg);
}

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text-primary);
    line-height: 1.7;
    min-height: 100vh;
    transition: background var(--transition), color var(--transition);
}

a { color: var(--primary); text-decoration: none; }
a:hover { color: var(--primary-hover); }
img { max-width: 100%; height: auto; }

/* ----- 导航栏 ----- */
.navbar {
    height: 64px;
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    transition: box-shadow var(--transition);
}
.navbar.scrolled { box-shadow: var(--shadow-sm); }
.nav-inner {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
    height: 100%;
    display: flex;
    align-items: center;
    gap: 32px;
}
.nav-logo {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}
.nav-logo svg { color: var(--primary); }
.nav-links {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
.nav-links a {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-secondary);
    transition: background var(--transition), color var(--transition);
    display: flex;
    align-items: center;
    gap: 6px;
}
.nav-links a:hover, .nav-links a.active {
    background: var(--primary-light);
    color: var(--primary);
}
.theme-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-secondary);
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    transition: color var(--transition), background var(--transition);
}
.theme-btn:hover { color: var(--primary); background: var(--primary-light); }

/* ----- 布局容器 ----- */
.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 32px 24px;
}
.layout-main {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 28px;
    align-items: start;
}
@media (max-width: 768px) {
    .layout-main { grid-template-columns: 1fr; }
    .sidebar { display: none; }
}

/* ----- 卡片 ----- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }
.card-title {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 16px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 8px;
}
.card-title::before {
    content: '';
    width: 3px;
    height: 16px;
    background: var(--primary);
    border-radius: 2px;
    display: inline-block;
}

/* ----- 文章列表卡片 ----- */
.article-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 24px;
    margin-bottom: 16px;
    transition: box-shadow var(--transition), transform var(--transition);
}
.article-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.article-card .top-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--primary);
    color: #fff;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    margin-bottom: 8px;
}
.article-card h2 { font-size: 18px; font-weight: 600; margin-bottom: 10px; }
.article-card h2 a { color: var(--text-primary); }
.article-card h2 a:hover { color: var(--primary); }
.article-card .summary {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.6;
    margin-bottom: 14px;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.article-meta {
    display: flex;
    align-items: center;
    gap: 16px;
    font-size: 13px;
    color: var(--text-muted);
    flex-wrap: wrap;
}
.article-meta span { display: flex; align-items: center; gap: 4px; }
.article-tags { display: flex; gap: 6px; flex-wrap: wrap; }
.tag {
    background: var(--primary-light);
    color: var(--primary);
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 10px;
    cursor: pointer;
    transition: background var(--transition);
}
.tag:hover { background: var(--primary); color: #fff; }
.category-badge {
    display: inline-block;
    background: var(--surface-alt);
    color: var(--text-secondary);
    font-size: 12px;
    padding: 2px 10px;
    border-radius: 10px;
}

/* ----- 按钮 ----- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0 20px;
    height: 38px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    cursor: pointer;
    border: none;
    transition: background var(--transition), color var(--transition), box-shadow var(--transition);
    text-decoration: none;
    white-space: nowrap;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-hover); color: #fff; box-shadow: 0 2px 8px rgba(90,158,111,.3); }
.btn-outline { background: transparent; color: var(--primary); border: 1px solid var(--primary); }
.btn-outline:hover { background: var(--primary-light); }
.btn-ghost { background: transparent; color: var(--text-secondary); }
.btn-ghost:hover { background: var(--surface-alt); }
.btn-danger { background: #e74c3c; color: #fff; }
.btn-danger:hover { background: #c0392b; }
.btn-sm { height: 30px; padding: 0 12px; font-size: 13px; }

/* ----- 表单 ----- */
.form-group { margin-bottom: 20px; }
.form-label {
    display: block;
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    font-weight: 500;
}
.form-input {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    background: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition), box-shadow var(--transition);
    font-family: var(--font);
}
.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(90,158,111,.15);
}
.form-input::placeholder { color: var(--text-muted); }
textarea.form-input { resize: vertical; min-height: 100px; }
select.form-input { appearance: none; cursor: pointer; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }
.form-error { font-size: 12px; color: #e74c3c; margin-top: 4px; }

/* ----- 搜索框 ----- */
.search-box {
    display: flex;
    gap: 8px;
    align-items: center;
}
.search-input {
    flex: 1;
    padding: 9px 16px;
    border: 1px solid var(--border);
    border-radius: 20px;
    background: var(--surface);
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    transition: border-color var(--transition);
}
.search-input:focus { border-color: var(--primary); }

/* ----- 分页 ----- */
.pagination {
    display: flex;
    justify-content: center;
    gap: 6px;
    margin-top: 32px;
    flex-wrap: wrap;
}
.page-btn {
    min-width: 36px;
    height: 36px;
    padding: 0 10px;
    border: 1px solid var(--border);
    background: var(--surface);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 14px;
    transition: all var(--transition);
}
.page-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); color: #fff; border-color: var(--primary); }
.page-btn:disabled { opacity: 0.4; cursor: not-allowed; }
.page-ellipsis { display: flex; align-items: center; font-size: 14px; color: var(--text-muted); padding: 0 4px; }

/* ----- 分类导航 ----- */
.category-nav {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}
.category-nav a {
    padding: 5px 14px;
    border-radius: 20px;
    font-size: 13px;
    color: var(--text-secondary);
    border: 1px solid var(--border);
    transition: all var(--transition);
}
.category-nav a:hover, .category-nav a.active {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

/* ----- 侧边栏 ----- */
.sidebar { display: flex; flex-direction: column; gap: 20px; }
.sidebar-section { }
.hot-article-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.hot-article-item:last-child { border-bottom: none; }
.hot-num {
    flex-shrink: 0;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: var(--surface-alt);
    color: var(--text-muted);
    font-size: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}
.hot-num.top3 { background: var(--primary); color: #fff; }
.recent-comment-item {
    padding: 10px 0;
    border-bottom: 1px solid var(--border);
    font-size: 13px;
}
.recent-comment-item:last-child { border-bottom: none; }

/* ----- 文章详情 ----- */
.article-content {
    font-size: 16px;
    line-height: 1.9;
    color: var(--text-primary);
    max-width: 72ch;
}
.article-content h1,.article-content h2,.article-content h3,
.article-content h4,.article-content h5,.article-content h6 {
    margin: 1.6em 0 .6em;
    font-weight: 600;
    color: var(--text-primary);
    line-height: 1.4;
}
.article-content h1 { font-size: 1.8em; }
.article-content h2 { font-size: 1.4em; padding-bottom: .3em; border-bottom: 1px solid var(--border); }
.article-content h3 { font-size: 1.2em; }
.article-content p { margin: .8em 0; }
.article-content blockquote {
    border-left: 3px solid var(--primary);
    padding: .5em 1em;
    margin: 1em 0;
    background: var(--primary-light);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
    color: var(--text-secondary);
}
.article-content code {
    font-family: var(--font-mono);
    background: var(--surface-alt);
    padding: .15em .4em;
    border-radius: 4px;
    font-size: .88em;
    color: var(--primary);
}
.article-content pre {
    background: #1a2020;
    border-radius: var(--radius-sm);
    padding: 1em 1.2em;
    overflow-x: auto;
    margin: 1em 0;
}
.article-content pre code {
    background: none;
    color: #d4e8d4;
    padding: 0;
    font-size: .9em;
}
.article-content img { border-radius: var(--radius-sm); }
.article-content ul, .article-content ol { margin: .8em 0; padding-left: 1.8em; }
.article-content li { margin: .3em 0; }
.article-content a { color: var(--primary); text-decoration: underline; }
.article-content table { width: 100%; border-collapse: collapse; margin: 1em 0; font-size: 14px; }
.article-content th, .article-content td { border: 1px solid var(--border); padding: 8px 12px; text-align: left; }
.article-content th { background: var(--surface-alt); font-weight: 600; }
.article-content hr { border: none; border-top: 1px solid var(--border); margin: 2em 0; }
mark.highlight { background: #fff3cd; color: #856404; padding: 0 2px; border-radius: 2px; }

/* ----- 评论区 ----- */
.comment-item {
    padding: 16px 0;
    border-bottom: 1px solid var(--border);
}
.comment-author {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 8px;
}
.avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 600;
    color: var(--primary);
    flex-shrink: 0;
    overflow: hidden;
}
.avatar img { width: 100%; height: 100%; object-fit: cover; }
.comment-content { font-size: 14px; color: var(--text-primary); }
.comment-time { font-size: 12px; color: var(--text-muted); }

/* ----- 登录/注册页 ----- */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px;
    background: var(--bg);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 40px;
    box-shadow: var(--shadow-md);
}
.auth-title {
    text-align: center;
    margin-bottom: 32px;
}
.auth-title h1 { font-size: 26px; color: var(--text-primary); margin-bottom: 4px; }
.auth-title p { font-size: 14px; color: var(--text-muted); }
.auth-logo { color: var(--primary); font-size: 32px; margin-bottom: 8px; }

/* ----- 编辑器 ----- */
.editor-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0;
    height: calc(100vh - 200px);
    min-height: 400px;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
}
.editor-pane, .preview-pane {
    height: 100%;
    overflow-y: auto;
    padding: 20px;
}
.editor-pane {
    border-right: 1px solid var(--border);
}
.editor-textarea {
    width: 100%;
    height: 100%;
    border: none;
    background: var(--surface);
    color: var(--text-primary);
    font-family: var(--font-mono);
    font-size: 14px;
    line-height: 1.7;
    resize: none;
    outline: none;
}
.editor-toolbar {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    border-bottom: 1px solid var(--border);
    background: var(--surface-alt);
    flex-wrap: wrap;
}

/* ----- 管理后台 ----- */
.admin-layout {
    display: grid;
    grid-template-columns: 220px 1fr;
    min-height: 100vh;
}
.admin-sidebar {
    background: var(--surface);
    border-right: 1px solid var(--border);
    padding: 24px 0;
}
.admin-logo {
    padding: 0 20px 20px;
    font-size: 18px;
    font-weight: 700;
    color: var(--primary);
    border-bottom: 1px solid var(--border);
    margin-bottom: 12px;
}
.admin-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 20px;
    font-size: 14px;
    color: var(--text-secondary);
    cursor: pointer;
    border-left: 3px solid transparent;
    transition: all var(--transition);
}
.admin-nav-item:hover, .admin-nav-item.active {
    color: var(--primary);
    background: var(--primary-light);
    border-left-color: var(--primary);
}
.admin-content { padding: 28px; background: var(--bg); overflow-y: auto; }
.admin-page-title { font-size: 20px; font-weight: 600; margin-bottom: 20px; }
.stats-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin-bottom: 28px; }
@media (max-width: 900px) { .stats-grid { grid-template-columns: repeat(2,1fr); } }
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
}
.stat-num { font-size: 32px; font-weight: 700; color: var(--primary); }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th, .data-table td { padding: 12px 16px; text-align: left; border-bottom: 1px solid var(--border); }
.data-table th { background: var(--surface-alt); font-weight: 600; color: var(--text-secondary); font-size: 13px; }
.data-table tr:hover td { background: var(--primary-light); }
.table-card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); overflow: hidden; }
.table-header { padding: 16px 20px; display: flex; align-items: center; justify-content: space-between; border-bottom: 1px solid var(--border); }
.badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 500;
}
.badge-success { background: #e8f5e9; color: #388e3c; }
.badge-danger  { background: #ffebee; color: #d32f2f; }
.badge-warning { background: #fff8e1; color: #f57f17; }
.badge-info    { background: #e3f2fd; color: #1976d2; }

/* ----- 标签云 ----- */
.tag-cloud { display: flex; flex-wrap: wrap; gap: 8px; }

/* ----- Footer ----- */
.footer {
    text-align: center;
    padding: 24px;
    font-size: 13px;
    color: var(--text-muted);
    border-top: 1px solid var(--border);
    margin-top: 48px;
}

/* ----- 加载指示器 ----- */
.loading {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
    font-size: 14px;
}
.spinner {
    width: 32px;
    height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin .8s linear infinite;
    margin: 0 auto 12px;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ----- 空状态 ----- */
.empty {
    text-align: center;
    padding: 48px;
    color: var(--text-muted);
}
.empty svg { margin-bottom: 12px; opacity: .4; }
