/* === 全局 === */
* { box-sizing: border-box; }
body {
    margin: 0;
    font-family: -apple-system, "PingFang SC", "Microsoft YaHei", "Segoe UI", Roboto, sans-serif;
    background: #f5f7fa;
    color: #2c3e50;
    line-height: 1.6;
    font-size: 15px;
}
a { color: #3b82f6; text-decoration: none; cursor: pointer; }
a:hover { color: #1d4ed8; text-decoration: underline; }
code {
    background: #eef2f7;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: "SF Mono", Consolas, Monaco, monospace;
    font-size: 13px;
    color: #c7254e;
}
h1, h2, h3, h4 { margin-top: 0; color: #1a2a3a; }
.muted { color: #8796a6; }
.small { font-size: 13px; }
.center { text-align: center; }
.right { text-align: right; }

/* === 前台容器 === */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 20px;
}
.site-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 0 30px;
    border-bottom: 1px solid #e5e9ef;
    margin-bottom: 30px;
    flex-wrap: wrap;
    gap: 15px;
}
.brand {
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    cursor: pointer;
}
.site-header nav { display: flex; gap: 20px; flex-wrap: wrap; }
.site-header nav a { font-size: 15px; }
.site-footer {
    text-align: center;
    margin-top: 60px;
    padding: 20px;
    color: #8796a6;
    font-size: 13px;
    border-top: 1px solid #e5e9ef;
}

/* === 列表页 === */
.page-title { font-size: 22px; margin-bottom: 20px; }
.search {
    display: flex;
    gap: 10px;
    margin-bottom: 20px;
}
.search input {
    flex: 1;
    padding: 10px 14px;
    border: 1px solid #d1d8e0;
    border-radius: 6px;
    font-size: 14px;
}
.search button, button {
    padding: 10px 20px;
    background: #3b82f6;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
}
.search button:hover, button:hover { background: #2563eb; }

.doc-table, .admin-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.doc-table th, .doc-table td,
.admin-table th, .admin-table td {
    padding: 12px 14px;
    text-align: left;
    border-bottom: 1px solid #eef1f5;
}
.doc-table th, .admin-table th {
    background: #f0f4f8;
    font-weight: 600;
    font-size: 14px;
}
.doc-table tr:last-child td,
.admin-table tr:last-child td { border-bottom: none; }
.doc-table tr:hover,
.admin-table tr:hover { background: #fafbfc; }

.tag {
    display: inline-block;
    padding: 2px 8px;
    background: #eef2f7;
    border-radius: 4px;
    font-size: 12px;
    color: #5a6978;
    margin-left: 6px;
}
.tag.lock { background: #fef3c7; color: #92400e; }

.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin-top: 25px;
}
.pagination a {
    padding: 6px 12px;
    background: white;
    border: 1px solid #d1d8e0;
    border-radius: 4px;
    cursor: pointer;
}
.pagination a:hover { background: #3b82f6; color: white; text-decoration: none; border-color: #3b82f6; }

/* === 文档详情页 === */
.doc-article {
    background: white;
    padding: 40px 50px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}
.doc-article header {
    border-bottom: 2px solid #eef1f5;
    padding-bottom: 20px;
    margin-bottom: 30px;
}
.doc-article header h1 {
    font-size: 32px;
    margin-bottom: 12px;
}
.doc-article .meta {
    display: flex;
    gap: 16px;
    align-items: center;
    color: #8796a6;
    font-size: 14px;
    flex-wrap: wrap;
}
.doc-footer {
    display: flex;
    justify-content: space-between;
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid #eef1f5;
    font-size: 14px;
}
.share-link { cursor: pointer; color: #3b82f6; }
.share-link:hover { text-decoration: underline; }

/* === Markdown 渲染样式 === */
.md-content h1 { font-size: 28px; margin: 30px 0 16px; padding-bottom: 10px; border-bottom: 2px solid #eef1f5; }
.md-content h2 { font-size: 24px; margin: 26px 0 14px; padding-bottom: 8px; border-bottom: 1px solid #eef1f5; }
.md-content h3 { font-size: 20px; margin: 22px 0 12px; }
.md-content h4 { font-size: 17px; margin: 18px 0 10px; }
.md-content p { margin: 14px 0; line-height: 1.8; }
.md-content ul, .md-content ol { margin: 12px 0; padding-left: 26px; }
.md-content li { margin: 6px 0; }
.md-content blockquote {
    margin: 16px 0;
    padding: 12px 20px;
    border-left: 4px solid #3b82f6;
    background: #f0f7ff;
    color: #475569;
}
.md-content hr { border: none; border-top: 1px solid #e5e9ef; margin: 30px 0; }
.md-content pre {
    background: #1e293b;
    color: #e2e8f0;
    padding: 16px 20px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 16px 0;
    font-family: "SF Mono", Consolas, Monaco, monospace;
    font-size: 13px;
    line-height: 1.6;
}
.md-content pre code {
    background: transparent;
    color: inherit;
    padding: 0;
    font-size: 13px;
}
.md-content img {
    max-width: 100%;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    margin: 10px 0;
}
.md-content a { color: #3b82f6; text-decoration: underline; }
.md-content table {
    width: 100%;
    border-collapse: collapse;
    margin: 16px 0;
    font-size: 14px;
}
.md-content table th, .md-content table td {
    padding: 10px 14px;
    border: 1px solid #e5e9ef;
}
.md-content table th { background: #f0f4f8; font-weight: 600; }

/* === 密码页 / 空页 === */
.pwd-page, .empty-page {
    display: flex;
    justify-content: center;
    padding: 60px 20px;
}
.pwd-card, .empty-card {
    background: white;
    padding: 40px 50px;
    border-radius: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    text-align: center;
    max-width: 420px;
    width: 100%;
}
.pwd-card input {
    width: 100%;
    padding: 12px 14px;
    border: 1px solid #d1d8e0;
    border-radius: 6px;
    margin: 15px 0;
    font-size: 15px;
}

/* === 登录 / 认证页 === */
.auth-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    padding: 20px;
}
.auth-card {
    background: white;
    padding: 40px 50px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.2);
    max-width: 420px;
    width: 100%;
}
.auth-card h1 {
    text-align: center;
    font-size: 24px;
    margin-bottom: 10px;
}
.auth-card h2 {
    text-align: center;
    font-size: 16px;
    font-weight: normal;
    color: #64748b;
    margin-bottom: 30px;
}
.form { display: flex; flex-direction: column; gap: 8px; }
.form label { font-size: 14px; color: #475569; margin-top: 8px; }
.form input[type=password],
.form input[type=text] {
    padding: 12px 14px;
    border: 1px solid #d1d8e0;
    border-radius: 6px;
    font-size: 15px;
}
.form input:focus { outline: none; border-color: #3b82f6; box-shadow: 0 0 0 3px rgba(59,130,246,0.15); }
.form .tip { margin-top: 16px; }
.form h3 { margin: 30px 0 10px; font-size: 16px; }
.form ul { padding-left: 20px; }
.form li { margin: 6px 0; }
button.primary {
    background: #3b82f6;
    margin-top: 16px;
    font-weight: 600;
}
button.primary:hover { background: #2563eb; }

/* === 后台布局 === */
.admin-layout {
    display: flex;
    min-height: 100vh;
}
.sidebar {
    width: 220px;
    background: #1e293b;
    color: #cbd5e1;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
}
.brand-sidebar {
    padding: 22px 20px;
    font-size: 17px;
    font-weight: 700;
    color: white;
    border-bottom: 1px solid #334155;
}
.sidebar nav {
    padding: 10px 0;
    flex: 1;
    display: flex;
    flex-direction: column;
}
.nav-item {
    display: block;
    padding: 12px 20px;
    color: #cbd5e1;
    cursor: pointer;
    font-size: 14px;
    border-left: 3px solid transparent;
    transition: all 0.15s;
}
.nav-item:hover { background: #334155; color: white; text-decoration: none; }
.nav-item.active {
    background: #334155;
    color: white;
    border-left-color: #3b82f6;
}
.sidebar-foot { padding: 10px 0 20px; border-top: 1px solid #334155; }
.nav-item.logout { color: #fca5a5; }
.nav-item.logout:hover { background: #7f1d1d; color: #fecaca; }

.main-area {
    flex: 1;
    padding: 30px 40px;
    overflow-x: auto;
}

/* === 面板 === */
.panel {
    background: white;
    border-radius: 10px;
    padding: 24px 30px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    margin-bottom: 20px;
}
.panel-head {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 12px;
}
.panel-head h2 { font-size: 20px; margin: 0; }
.panel-head .count { font-size: 13px; color: #8796a6; font-weight: normal; }
.panel-actions { display: flex; gap: 10px; align-items: center; }
.search-input {
    padding: 8px 12px;
    border: 1px solid #d1d8e0;
    border-radius: 6px;
    font-size: 14px;
    width: 220px;
}
.btn {
    display: inline-block;
    padding: 8px 16px;
    background: #e2e8f0;
    color: #334155;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    border: none;
}
.btn:hover { background: #cbd5e1; text-decoration: none; color: #1e293b; }
.btn.primary { background: #3b82f6; color: white; }
.btn.primary:hover { background: #2563eb; }
.btn.back { background: #f1f5f9; }

/* === 表格按钮 === */
.status-tag {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 10px;
    font-size: 12px;
}
.status-tag.pub { background: #dcfce7; color: #15803d; }
.status-tag.dft { background: #fef3c7; color: #92400e; }

.doc-title-link { font-weight: 500; cursor: pointer; }
.act-link { margin: 0 6px; cursor: pointer; }
.act-link.danger { color: #dc2626; }
.act-link.danger:hover { color: #991b1b; }

.pin-btn {
    display: inline-block;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 16px;
    transition: all 0.15s;
}
.pin-btn:hover { background: #fef3c7; }
.pin-btn.on { background: #fef3c7; }

/* === 编辑面板 === */
.edit-panel .edit-form { gap: 12px; }
.big-input {
    padding: 12px 16px !important;
    font-size: 18px !important;
    font-weight: 500;
}
.row { display: flex; gap: 20px; margin: 6px 0; flex-wrap: wrap; }
.col { flex: 1; min-width: 200px; }
.chk {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}
.chk input { cursor: pointer; }

/* === Toast === */
.toast {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    padding: 12px 28px;
    background: #1e293b;
    color: white;
    border-radius: 6px;
    font-size: 14px;
    z-index: 9999;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: toastIn 0.3s;
}
.toast.ok { background: #16a34a; }
.toast.err { background: #dc2626; }
.toast.info { background: #1e293b; }
@keyframes toastIn {
    from { opacity: 0; transform: translate(-50%, -20px); }
    to { opacity: 1; transform: translate(-50%, 0); }
}

/* === 响应式 === */
@media (max-width: 768px) {
    .container { padding: 12px; }
    .doc-article { padding: 25px 20px; }
    .doc-article header h1 { font-size: 24px; }
    .sidebar { width: 70px; }
    .brand-sidebar, .nav-item { padding-left: 10px; padding-right: 10px; }
    .brand-sidebar { font-size: 14px; text-align: center; }
    .nav-item { font-size: 12px; text-align: center; }
    .main-area { padding: 20px 15px; }
    .panel { padding: 18px 15px; }
    .admin-table th:nth-child(5),
    .admin-table td:nth-child(5),
    .admin-table th:nth-child(1),
    .admin-table td:nth-child(1) { display: none; }
    .search-input { width: 140px; }
}
