/* ── 全局重置与基础 ──────────────────────────────────────────── */
:root {
    --color-bg: #f8f9fa;
    --color-white: #ffffff;
    --color-text: #2d3436;
    --color-text-light: #636e72;
    --color-primary: #0984e3;
    --color-primary-hover: #0770c2;
    --color-border: #dfe6e9;
    --color-success: #00b894;
    --color-danger: #d63031;
    --color-warning: #fdcb6e;
    --color-info: #74b9ff;
    --radius: 8px;
    --shadow: 0 2px 8px rgba(0,0,0,0.06);
    --shadow-hover: 0 4px 16px rgba(0,0,0,0.1);
    --max-width: 1100px;
    --transition: 0.2s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
                 "Noto Sans SC", "PingFang SC", "Microsoft YaHei",
                 sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    line-height: 1.7;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.container { max-width: var(--max-width); margin: 0 auto; padding: 0 20px; }

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

/* ── 导航栏 ─────────────────────────────────────────────────── */
.navbar {
    background: var(--color-white);
    border-bottom: 1px solid var(--color-border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.navbar .container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}

.nav-brand {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--color-text) !important;
    text-decoration: none !important;
}

.nav-menu {
    display: flex;
    list-style: none;
    gap: 4px;
}

.nav-menu a {
    display: block;
    padding: 8px 16px;
    border-radius: var(--radius);
    color: var(--color-text-light);
    font-size: 0.95rem;
    text-decoration: none;
}

.nav-menu a:hover {
    background: var(--color-bg);
    color: var(--color-primary);
}

.nav-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--color-text);
    padding: 4px 8px;
}

/* ── Flash 消息 ─────────────────────────────────────────────── */
.flash-container { margin-top: 16px; }

.flash-message {
    padding: 12px 16px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.95rem;
    animation: slideDown 0.3s ease;
}

.flash-success { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.flash-danger  { background: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.flash-info    { background: #d1ecf1; color: #0c5460; border: 1px solid #bee5eb; }
.flash-warning { background: #fff3cd; color: #856404; border: 1px solid #ffeeba; }

.flash-close {
    background: none;
    border: none;
    font-size: 1.3rem;
    cursor: pointer;
    color: inherit;
    opacity: 0.7;
    padding: 0 4px;
}

.flash-close:hover { opacity: 1; }

@keyframes slideDown {
    from { transform: translateY(-10px); opacity: 0; }
    to   { transform: translateY(0); opacity: 1; }
}

/* ── 布局 ───────────────────────────────────────────────────── */
.main-content {
    flex: 1;
    padding-top: 24px;
    padding-bottom: 40px;
}

.layout {
    display: grid;
    grid-template-columns: 1fr 300px;
    gap: 32px;
}

/* ── 文章卡片 ───────────────────────────────────────────────── */
.post-card {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
    transition: box-shadow var(--transition), transform var(--transition);
}

.post-card:hover { box-shadow: var(--shadow-hover); transform: translateY(-1px); }

.post-card .post-title {
    font-size: 1.4rem;
    margin-bottom: 10px;
    line-height: 1.4;
}

.post-card .post-title a {
    color: var(--color-text);
    text-decoration: none;
}

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

.post-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    font-size: 0.85rem;
    color: var(--color-text-light);
    margin-bottom: 14px;
    align-items: center;
}

.post-summary {
    color: var(--color-text-light);
    font-size: 0.95rem;
    line-height: 1.7;
    margin-bottom: 14px;
}

.read-more {
    font-size: 0.9rem;
    font-weight: 600;
}

/* ── 标签 ───────────────────────────────────────────────────── */
.tag {
    display: inline-block;
    padding: 2px 10px;
    background: #e8f4fd;
    color: var(--color-primary) !important;
    border-radius: 12px;
    font-size: 0.8rem;
    text-decoration: none !important;
    transition: var(--transition);
}

.tag:hover {
    background: var(--color-primary);
    color: white !important;
}

.tag-sm { font-size: 0.75rem; padding: 1px 8px; }

.tag-cloud-item { margin: 3px; }

.tag-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 16px 20px;
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.tag-clear { font-size: 0.9rem; }

/* ── 文章详情页 ─────────────────────────────────────────────── */
.post-full {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 36px;
    box-shadow: var(--shadow);
}

.post-full .post-header { margin-bottom: 32px; }

.post-full .post-title {
    font-size: 2rem;
    margin-bottom: 14px;
    line-height: 1.3;
}

.post-content { font-size: 1.05rem; line-height: 1.8; }

.post-content h2 { font-size: 1.6rem; margin: 28px 0 14px; padding-bottom: 8px; border-bottom: 1px solid var(--color-border); }
.post-content h3 { font-size: 1.3rem; margin: 24px 0 12px; }
.post-content h4 { font-size: 1.1rem; margin: 20px 0 10px; }

.post-content p { margin-bottom: 16px; }

.post-content ul, .post-content ol { margin: 0 0 16px 24px; }
.post-content li { margin-bottom: 6px; }

.post-content blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid var(--color-primary);
    background: #f0f8ff;
    color: var(--color-text-light);
    border-radius: 0 var(--radius) var(--radius) 0;
}

.post-content code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 0.9em;
    font-family: "Fira Code", "Consolas", monospace;
}

.post-content pre {
    background: #2d3436;
    color: #f8f9fa;
    padding: 16px 20px;
    border-radius: var(--radius);
    overflow-x: auto;
    margin: 16px 0;
    font-size: 0.9rem;
    line-height: 1.5;
}

.post-content pre code { background: none; padding: 0; color: inherit; }

.post-content img {
    max-width: 100%;
    border-radius: var(--radius);
    margin: 16px 0;
}

.post-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
}

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

.post-content th { background: var(--color-bg); font-weight: 600; }

.post-content a { text-decoration: underline; }

.post-author {
    margin-top: 40px;
    padding: 20px;
    background: var(--color-bg);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
}

.author-info strong { display: block; margin-bottom: 4px; }
.author-info p { color: var(--color-text-light); font-size: 0.9rem; }

/* ── 上下篇导航 ─────────────────────────────────────────────── */
.post-nav {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-top: 32px;
    padding-top: 24px;
    border-top: 1px solid var(--color-border);
}

.post-nav-label {
    display: block;
    font-size: 0.8rem;
    color: var(--color-text-light);
    margin-bottom: 4px;
}

.post-nav a { font-weight: 600; }
.post-nav-next { text-align: right; }

/* ── 评论 ───────────────────────────────────────────────────── */
.comments {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 28px;
    margin-top: 24px;
    box-shadow: var(--shadow);
}

.comments h2 { font-size: 1.3rem; margin-bottom: 20px; }

.comment-form { margin-bottom: 24px; }

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 12px;
}

.comment-form input, .comment-form textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border var(--transition);
}

.comment-form input:focus, .comment-form textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.comment-form textarea { resize: vertical; margin-bottom: 12px; }

.comment-item {
    padding: 16px;
    border-bottom: 1px solid var(--color-border);
}

.comment-item:last-child { border-bottom: none; }

.comment-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
}

.comment-author { color: var(--color-text); }
.comment-date { font-size: 0.8rem; color: var(--color-text-light); }
.comment-content { color: var(--color-text); font-size: 0.95rem; line-height: 1.6; }

.no-comments { color: var(--color-text-light); text-align: center; padding: 20px; }

/* ── 侧边栏 ─────────────────────────────────────────────────── */
.sidebar-widget {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: var(--shadow);
}

.sidebar-widget h3 {
    font-size: 0.95rem;
    margin-bottom: 14px;
    padding-bottom: 10px;
    border-bottom: 2px solid var(--color-primary);
    color: var(--color-text);
}

.search-form { display: flex; gap: 0; }

.search-form input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--color-border);
    border-right: none;
    border-radius: var(--radius) 0 0 var(--radius);
    font-size: 0.9rem;
    font-family: inherit;
}

.search-form input:focus { outline: none; border-color: var(--color-primary); }

.search-form button {
    padding: 8px 14px;
    background: var(--color-primary);
    color: white;
    border: 1px solid var(--color-primary);
    border-radius: 0 var(--radius) var(--radius) 0;
    cursor: pointer;
    font-size: 0.9rem;
    transition: var(--transition);
}

.search-form button:hover { background: var(--color-primary-hover); }

.recent-posts { list-style: none; }

.recent-posts li {
    padding: 8px 0;
    border-bottom: 1px solid var(--color-border);
}

.recent-posts li:last-child { border-bottom: none; }

.recent-posts a {
    font-size: 0.9rem;
    color: var(--color-text-light);
    text-decoration: none;
}

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

.tag-cloud { display: flex; flex-wrap: wrap; gap: 4px; }

/* ── 分页 ───────────────────────────────────────────────────── */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 16px;
    padding: 24px 0;
}

.page-link {
    padding: 8px 20px;
    background: var(--color-white);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    color: var(--color-text) !important;
    text-decoration: none !important;
    font-size: 0.9rem;
    transition: var(--transition);
}

.page-link:hover {
    border-color: var(--color-primary);
    color: var(--color-primary) !important;
}

.page-info { color: var(--color-text-light); font-size: 0.9rem; }

/* ── 空状态 ─────────────────────────────────────────────────── */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--color-text-light);
}

.empty-state p { font-size: 1.1rem; margin-bottom: 20px; }

/* ── 按钮 ───────────────────────────────────────────────────── */
.btn {
    display: inline-block;
    padding: 10px 20px;
    background: var(--color-white);
    color: var(--color-text) !important;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    font-family: inherit;
    text-decoration: none !important;
    transition: all var(--transition);
}

.btn:hover {
    border-color: var(--color-primary);
    color: var(--color-primary) !important;
}

.btn-primary {
    background: var(--color-primary);
    color: white !important;
    border-color: var(--color-primary);
}

.btn-primary:hover {
    background: var(--color-primary-hover);
    border-color: var(--color-primary-hover);
}

.btn-danger {
    color: var(--color-danger) !important;
    border-color: var(--color-danger);
}

.btn-danger:hover {
    background: var(--color-danger);
    color: white !important;
}

.btn-block { display: block; width: 100%; text-align: center; }
.btn-sm { padding: 4px 12px; font-size: 0.8rem; }

/* ── 表单 ───────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }

.form-group label {
    display: block;
    margin-bottom: 6px;
    font-weight: 600;
    font-size: 0.95rem;
}

.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="email"],
.form-group textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    transition: border var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--color-primary);
}

.form-checkbox {
    display: flex;
    align-items: center;
}

.form-checkbox label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: normal;
    cursor: pointer;
}

.form-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.form-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

/* ── 编辑器 ─────────────────────────────────────────────────── */
.editor-wrapper {
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    overflow: hidden;
}

.editor-textarea {
    width: 100%;
    padding: 16px;
    border: none !important;
    border-radius: 0 !important;
    font-family: "Fira Code", "Consolas", "Monaco", monospace;
    font-size: 0.92rem;
    line-height: 1.6;
    resize: vertical;
    min-height: 400px;
    background: #fafafa;
}

.editor-textarea:focus { outline: none; }

.editor-toolbar {
    display: flex;
    gap: 2px;
    padding: 8px 12px;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
    flex-wrap: wrap;
}

.editor-toolbar button {
    padding: 6px 10px;
    background: none;
    border: 1px solid transparent;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
    font-family: inherit;
    color: var(--color-text-light);
    transition: var(--transition);
}

.editor-toolbar button:hover {
    background: var(--color-white);
    border-color: var(--color-border);
    color: var(--color-text);
}

hr { border: none; border-top: 1px solid var(--color-border); margin: 20px 0; }

/* ── 登录页 ─────────────────────────────────────────────────── */
.auth-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 60vh;
}

.auth-card {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 40px;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow);
}

.auth-card h1 { font-size: 1.4rem; margin-bottom: 24px; text-align: center; }

.auth-form .form-group { margin-bottom: 20px; }

.auth-footer { text-align: center; margin-top: 16px; }
.auth-footer a { font-size: 0.9rem; }

/* ── 管理页 ─────────────────────────────────────────────────── */
.admin-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
}

.admin-header h1 { font-size: 1.5rem; }

.admin-actions { display: flex; gap: 8px; flex-wrap: wrap; }

.admin-stats {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 20px;
    text-align: center;
    box-shadow: var(--shadow);
}

.stat-number {
    display: block;
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label { font-size: 0.85rem; color: var(--color-text-light); }

.admin-table-wrapper {
    background: var(--color-white);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    overflow-x: auto;
}

.admin-table { width: 100%; border-collapse: collapse; }

.admin-table th {
    background: var(--color-bg);
    padding: 12px 16px;
    text-align: left;
    font-size: 0.85rem;
    color: var(--color-text-light);
    white-space: nowrap;
}

.admin-table td {
    padding: 12px 16px;
    border-top: 1px solid var(--color-border);
    font-size: 0.92rem;
}

.admin-table tr:hover { background: #f8f9fa; }

.post-link { font-weight: 600; }

.action-cell {
    white-space: nowrap;
    display: flex;
    gap: 6px;
}

.inline-form { display: inline; }

.status {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.78rem;
    font-weight: 600;
}

.status-published { background: #d4edda; color: #155724; }
.status-draft { background: #fff3cd; color: #856404; }

/* ── 关于页 ─────────────────────────────────────────────────── */
.about-card {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 40px;
    text-align: center;
    box-shadow: var(--shadow);
}

.about-avatar { margin-bottom: 16px; }

.avatar-placeholder {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--color-primary);
    color: white;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    font-weight: 700;
}

.about-card h2 { font-size: 1.4rem; margin-bottom: 12px; }

.about-bio {
    color: var(--color-text-light);
    font-size: 1rem;
    line-height: 1.8;
    max-width: 500px;
    margin: 0 auto;
}

/* ── 搜索页 ─────────────────────────────────────────────────── */
.search-header { margin-bottom: 20px; }
.search-header h1 { font-size: 1.4rem; margin-bottom: 4px; }
.search-header p { color: var(--color-text-light); font-size: 0.9rem; }

/* ── 评论管理 ───────────────────────────────────────────────── */
.admin-comment-list .comment-item {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 16px 20px;
    margin-bottom: 12px;
    box-shadow: var(--shadow);
    border: none;
}

.comment-pending { border-left: 3px solid var(--color-warning) !important; }

.comment-article { font-size: 0.85rem; margin: 4px 0 8px; }
.comment-email { font-size: 0.8rem; color: var(--color-text-light); margin-top: 4px; }

/* ── 编辑页 ─────────────────────────────────────────────────── */
.edit-page {
    background: var(--color-white);
    border-radius: var(--radius);
    padding: 32px;
    box-shadow: var(--shadow);
    max-width: 800px;
    margin: 0 auto;
}

.edit-page h1 { font-size: 1.4rem; margin-bottom: 24px; }

/* ── 页脚 ───────────────────────────────────────────────────── */
.footer {
    background: var(--color-white);
    border-top: 1px solid var(--color-border);
    padding: 24px 0;
    margin-top: auto;
}

.footer-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 0.85rem;
    color: var(--color-text-light);
}

.footer-icp { margin-top: 4px; }
.footer-icp a { color: var(--color-text-light); font-size: 0.8rem; text-decoration: none; }
.footer-icp a:hover { color: var(--color-primary); }

.footer-links { display: flex; gap: 16px; }
.footer-links a { color: var(--color-text-light) !important; font-size: 0.85rem; text-decoration: none; }
.footer-links a:hover { color: var(--color-primary) !important; }

/* ── 响应式設計 ─────────────────────────────────────────────── */
@media (max-width: 900px) {
    .layout { grid-template-columns: 1fr; }
    .admin-stats { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .nav-menu {
        display: none;
        position: absolute;
        top: 60px;
        left: 0;
        right: 0;
        background: var(--color-white);
        flex-direction: column;
        padding: 8px 20px;
        border-bottom: 1px solid var(--color-border);
        box-shadow: var(--shadow);
    }

    .nav-menu.active { display: flex; }
    .nav-toggle { display: block; }

    .post-full { padding: 20px; }
    .post-full .post-title { font-size: 1.5rem; }

    .auth-card { padding: 24px; }
    .admin-header { flex-direction: column; align-items: flex-start; }
    .form-row { grid-template-columns: 1fr; }

    .footer-content {
        flex-direction: column;
        gap: 8px;
        text-align: center;
    }
}

@media (max-width: 480px) {
    .admin-stats { grid-template-columns: 1fr; }
    .post-nav { grid-template-columns: 1fr; }
    .post-nav-next { text-align: left; }
}
