/* ============ 全局样式 ============ */
* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: -apple-system, "Microsoft YaHei", "Segoe UI", sans-serif;
    background: #f5f5f5;
    color: #333;
    line-height: 1.6;
}

a { color: #2563eb; text-decoration: none; }
a:hover { text-decoration: underline; }

/* ============ 布局 ============ */
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }

.navbar {
    background: #1e293b;
    color: #fff;
    padding: 12px 0;
}
.navbar .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.navbar a { color: #cbd5e1; }
.navbar a:hover { color: #fff; }
.navbar .nav-brand { font-size: 18px; font-weight: bold; color: #fff; }
.navbar .nav-links a { margin-left: 16px; }

/* ============ 卡片 ============ */
.card {
    background: #fff;
    border-radius: 8px;
    padding: 20px;
    margin-bottom: 16px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* ============ 板块列表 ============ */
.board-item {
    background: #fff;
    border-radius: 8px;
    padding: 18px 20px;
    margin-bottom: 12px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    transition: box-shadow 0.2s;
}
.board-item:hover { box-shadow: 0 2px 8px rgba(0,0,0,0.12); }
.board-item h3 { margin-bottom: 6px; }
.board-item h3 a { color: #1e293b; font-size: 18px; }
.board-item .meta { color: #94a3b8; font-size: 14px; }
.board-item .desc { color: #64748b; margin-top: 4px; font-size: 14px; }

/* ============ 文章列表 ============ */
.article-item {
    padding: 14px 0;
    border-bottom: 1px solid #e2e8f0;
}
.article-item:last-child { border-bottom: none; }
.article-item h3 { font-size: 16px; }
.article-item .meta { color: #94a3b8; font-size: 13px; margin-top: 4px; }

/* ============ 文章详情 ============ */
.article-detail { position: relative; overflow: hidden; }
.article-detail h1 { font-size: 24px; margin-bottom: 8px; position: relative; z-index: 2; }
.article-detail .meta { color: #94a3b8; font-size: 14px; margin-bottom: 20px; position: relative; z-index: 2; }
.article-detail .content {
    font-size: 16px;
    line-height: 1.8;
    word-wrap: break-word;
    position: relative;
    z-index: 2;
}
.article-detail .content img { max-width: 100%; height: auto; border-radius: 6px; margin: 12px 0; }

/* ============ 附件文件 ============ */
.article-file {
    margin-top: 24px;
    padding: 16px 20px;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 16px;
    position: relative;
    z-index: 2;
}
.file-icon { font-size: 28px; flex-shrink: 0; }
.file-info { flex: 1; }
.file-name { font-weight: 500; color: #1e293b; font-size: 15px; margin-bottom: 8px; }
.file-actions { display: flex; gap: 8px; }

/* ============ 内容保护 ============ */
.content-protected {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
}
.content-protected .content img {
    pointer-events: none;
}

/* ============ 表单 ============ */
.form-group { margin-bottom: 16px; }
.form-group label { display: block; margin-bottom: 4px; font-weight: 500; }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 14px;
}
.form-group textarea { min-height: 200px; resize: vertical; font-family: inherit; }

.btn {
    display: inline-block;
    padding: 8px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    text-decoration: none;
}
.btn-primary { background: #2563eb; color: #fff; }
.btn-primary:hover { background: #1d4ed8; }
.btn-danger { background: #dc2626; color: #fff; }
.btn-danger:hover { background: #b91c1c; }
.btn-secondary { background: #e2e8f0; color: #475569; }
.btn-secondary:hover { background: #cbd5e1; }
.btn-sm { padding: 4px 12px; font-size: 13px; }

/* ============ 消息提示 ============ */
.flash {
    padding: 10px 16px;
    border-radius: 6px;
    margin-bottom: 16px;
}
.flash-success { background: #d1fae5; color: #065f46; }
.flash-error { background: #fee2e2; color: #991b1b; }

/* ============ 登录页 ============ */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
}
.login-box {
    background: #fff;
    border-radius: 12px;
    padding: 32px;
    width: 360px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
}
.login-box h1 { text-align: center; margin-bottom: 24px; font-size: 22px; }

/* ============ 管理后台 ============ */
.admin-header {
    background: #fff;
    border-bottom: 2px solid #e2e8f0;
    padding: 12px 0;
    margin-bottom: 20px;
}
.admin-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.admin-nav a {
    margin-right: 16px;
    color: #475569;
    font-size: 14px;
}
.admin-nav a.active { color: #2563eb; font-weight: 500; }

.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
    margin-bottom: 20px;
}
.stat-card {
    background: #fff;
    border-radius: 8px;
    padding: 24px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}
.stat-card .num { font-size: 32px; font-weight: bold; color: #2563eb; }
.stat-card .label { color: #94a3b8; font-size: 14px; margin-top: 4px; }

/* ============ 表格 ============ */
table { width: 100%; border-collapse: collapse; }
table th, table td {
    padding: 10px 12px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    font-size: 14px;
}
table th { color: #64748b; font-weight: 500; background: #f8fafc; }

/* ============ 权限复选框 ============ */
.permission-list { list-style: none; }
.permission-list li {
    padding: 10px 0;
    border-bottom: 1px solid #e2e8f0;
}
.permission-list label { cursor: pointer; }

/* ============ 工具 ============ */
.text-center { text-align: center; }
.mt-20 { margin-top: 20px; }
.mb-20 { margin-bottom: 20px; }
.text-muted { color: #94a3b8; }
.badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 12px;
}
.badge-success { background: #d1fae5; color: #065f46; }
.badge-danger { background: #fee2e2; color: #991b1b; }

/* ============ 手机端适配 ============ */
@media (max-width: 640px) {
    .container { padding: 12px; }

    /* 导航栏 - 文章页深色导航 */
    .navbar { padding: 10px 0; }
    .navbar .container { flex-wrap: wrap; gap: 6px; }
    .navbar .nav-brand { font-size: 16px; }
    .navbar .nav-links {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    .navbar .nav-links a, .navbar .nav-links span {
        font-size: 12px;
        margin-left: 0;
        padding: 2px 8px;
        background: rgba(255,255,255,0.1);
        border-radius: 4px;
    }

    /* 管理后台导航 */
    .admin-header { padding: 10px 0; }
    .admin-header .container { flex-direction: column; gap: 8px; }
    .admin-header .container > span { font-size: 16px !important; }
    .admin-nav {
        display: flex;
        flex-wrap: wrap;
        gap: 4px;
    }
    .admin-nav a {
        font-size: 12px;
        padding: 4px 10px;
        margin-right: 0;
        border-radius: 4px;
        background: #f1f5f9;
    }
    .admin-nav a.active { background: #2563eb; color: #fff; }

    /* 统计卡片网格 */
    .stats-grid { grid-template-columns: repeat(3, 1fr); gap: 8px; }
    .stat-card { padding: 16px 8px; }
    .stat-card .num { font-size: 24px; }

    /* 表格 → 卡片模式 */
    table, thead, tbody, th, td, tr { display: block; }
    table thead { display: none; }
    table tr {
        padding: 10px 0;
        border-bottom: 1px solid #e2e8f0;
    }
    table td {
        padding: 4px 0;
        border-bottom: none;
        font-size: 14px;
        display: flex;
        justify-content: space-between;
        align-items: center;
    }
    table td::before {
        content: attr(data-label);
        font-weight: 500;
        color: #64748b;
        font-size: 13px;
        flex-shrink: 0;
        margin-right: 8px;
    }
    /* 操作列特殊处理 */
    table td:last-child {
        flex-wrap: wrap;
        gap: 4px;
        justify-content: flex-start;
    }
    table td:last-child::before { display: none; }

    /* 板块列表 */
    .board-item { padding: 14px 16px; }
    .board-item h3 a { font-size: 16px; }

    /* 文章详情 */
    .article-detail h1 { font-size: 20px; }
    .article-detail .content { font-size: 15px; line-height: 1.7; }
    .article-detail .meta { font-size: 12px; }
    .article-file { flex-direction: column; align-items: flex-start; gap: 8px; padding: 12px 14px; }
    .file-icon { font-size: 22px; }
    .file-name { font-size: 14px; }
    .file-actions { width: 100%; }
    .file-actions .btn { flex: 1; text-align: center; font-size: 13px; }

    /* 登录页 */
    .login-box { width: 90%; padding: 24px 20px; }

    /* 按钮 */
    .btn { font-size: 14px; padding: 10px 16px; }
    .btn-sm { font-size: 13px; padding: 6px 12px; }

    /* 卡片 */
    .card { padding: 14px; }
    .card h3 { font-size: 16px; }

    /* 表单 */
    .form-group input, .form-group select, .form-group textarea { font-size: 16px; } /* 防止iOS缩放 */
}

/* 超小屏适配 */
@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr 1fr; gap: 6px; }
    .admin-nav a { font-size: 12px; padding: 3px 8px; }
}
