/* ============================================================
   FJ 个人博客 样式表
   ============================================================ */
:root {
    --primary: #4f46e5;
    --primary-dark: #4338ca;
    --primary-light: #eef2ff;
    --text: #1f2937;
    --text-light: #6b7280;
    --text-muted: #9ca3af;
    --bg: #f9fafb;
    --bg-white: #ffffff;
    --border: #e5e7eb;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --info: #3b82f6;
    --radius: 10px;
    --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --max-width: 1100px;
}

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

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

a { color: var(--primary); text-decoration: none; transition: color .2s; }
a:hover { color: var(--primary-dark); }

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

/* ---------- Header ---------- */
.site-header {
    background: var(--bg-white);
    border-bottom: 1px solid var(--border);
    position: sticky; top: 0; z-index: 100;
    box-shadow: var(--shadow);
}
.header-inner {
    display: flex; align-items: center; justify-content: space-between;
    height: 64px; flex-wrap: wrap; gap: 12px;
}
.logo { display: flex; align-items: center; gap: 10px; color: var(--text); font-weight: 700; }
.logo:hover { color: var(--text); }
.logo-mark {
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff; width: 36px; height: 36px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    font-size: 14px; font-weight: 800; letter-spacing: 0.5px;
}
.logo-text { font-size: 18px; }
.main-nav { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.main-nav a {
    padding: 8px 14px; border-radius: 8px; color: var(--text-light);
    font-size: 14px; font-weight: 500;
}
.main-nav a:hover { background: var(--primary-light); color: var(--primary); }
.main-nav a.active { background: var(--primary); color: #fff; }
.main-nav a.nav-admin { color: var(--primary); font-weight: 600; }

/* ---------- Main ---------- */
.main-content { flex: 1; padding: 36px 20px; width: 100%; max-width: var(--max-width); margin: 0 auto; }

/* Hero */
.hero { text-align: center; padding: 40px 20px 50px; }
.hero h1 { font-size: 34px; font-weight: 800; margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    -webkit-background-clip: text; -webkit-text-fill-color: transparent; background-clip: text; }
.hero-sub { color: var(--text-light); font-size: 16px; }

/* Post grid */
.post-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(320px, 1fr)); gap: 20px; }
.post-card {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 22px; box-shadow: var(--shadow);
    transition: transform .2s, box-shadow .2s; display: flex; flex-direction: column;
}
.post-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-md); }
.post-card-meta { display: flex; align-items: center; gap: 10px; margin-bottom: 10px; font-size: 12px; }
.post-card-cat {
    background: var(--primary-light); color: var(--primary);
    padding: 3px 10px; border-radius: 20px; font-weight: 600;
}
.post-card-date { color: var(--text-muted); }
.post-card-title { font-size: 19px; font-weight: 700; margin-bottom: 8px; line-height: 1.4; }
.post-card-title a { color: var(--text); }
.post-card-title a:hover { color: var(--primary); }
.post-card-summary { color: var(--text-light); font-size: 14px; flex: 1; margin-bottom: 14px;
    display: -webkit-box; -webkit-line-clamp: 3; -webkit-box-orient: vertical; overflow: hidden; }
.post-card-footer { display: flex; justify-content: space-between; align-items: center;
    font-size: 12px; color: var(--text-muted); border-top: 1px solid var(--border); padding-top: 12px; }
.read-more { font-weight: 600; font-size: 13px; }

/* Post list (archive) */
.archive-header { padding: 20px 0 30px; }
.archive-header h1 { font-size: 28px; margin-bottom: 6px; }
.archive-header p { color: var(--text-light); }
.post-list { display: flex; flex-direction: column; gap: 16px; }
.post-list-item {
    background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 20px 24px; box-shadow: var(--shadow);
    transition: box-shadow .2s;
}
.post-list-item:hover { box-shadow: var(--shadow-md); }
.post-list-meta { display: flex; gap: 14px; font-size: 12px; color: var(--text-muted); margin-bottom: 8px; }
.post-list-title { font-size: 20px; margin-bottom: 6px; }
.post-list-title a { color: var(--text); }
.post-list-title a:hover { color: var(--primary); }
.post-list-summary { color: var(--text-light); font-size: 14px; }

/* Post detail */
.post-detail { background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 40px; box-shadow: var(--shadow); }
.post-detail-header { border-bottom: 1px solid var(--border); padding-bottom: 20px; margin-bottom: 28px; }
.post-meta { display: flex; gap: 12px; font-size: 13px; color: var(--text-muted); margin-bottom: 12px; flex-wrap: wrap; }
.meta-cat { background: var(--primary-light); color: var(--primary); padding: 2px 10px; border-radius: 20px; font-weight: 600; }
.post-detail-title { font-size: 30px; font-weight: 800; line-height: 1.3; }
.post-detail-content { font-size: 16px; line-height: 1.85; color: #374151; }
.post-detail-content h1, .post-detail-content h2, .post-detail-content h3 {
    margin: 24px 0 12px; color: var(--text); }
.post-detail-content h2 { font-size: 24px; border-left: 4px solid var(--primary); padding-left: 12px; }
.post-detail-content h3 { font-size: 20px; }
.post-detail-content p { margin-bottom: 16px; }
.post-detail-content ul, .post-detail-content ol { margin: 12px 0 16px 24px; }
.post-detail-content li { margin-bottom: 6px; }
.post-detail-content strong { color: var(--text); }
.post-detail-footer { border-top: 1px solid var(--border); padding-top: 20px; margin-top: 32px; }
.back-link { font-weight: 600; }

/* About */
.about-page { background: var(--bg-white); border: 1px solid var(--border);
    border-radius: var(--radius); padding: 40px; box-shadow: var(--shadow); max-width: 760px; margin: 0 auto; }
.about-page h1 { font-size: 30px; margin-bottom: 20px; }
.about-avatar {
    width: 80px; height: 80px; border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff; display: flex; align-items: center; justify-content: center;
    font-size: 32px; font-weight: 800; margin-bottom: 20px;
}
.about-page h2 { margin: 20px 0 10px; }
.about-page h3 { margin: 18px 0 8px; color: var(--primary); }
.about-page ul { margin: 8px 0 16px 24px; }
.about-page p { margin-bottom: 14px; color: #374151; }

/* 404 */
.error-page { text-align: center; padding: 80px 20px; }
.error-code { font-size: 96px; font-weight: 900; color: var(--primary); line-height: 1; }
.error-desc { font-size: 18px; color: var(--text-light); margin: 14px 0 28px; }

/* Pagination */
.pagination { display: flex; justify-content: center; gap: 8px; margin-top: 40px; flex-wrap: wrap; }
.page-btn {
    padding: 8px 14px; background: var(--bg-white); border: 1px solid var(--border);
    border-radius: 8px; color: var(--text-light); font-size: 14px; font-weight: 500;
}
.page-btn:hover { border-color: var(--primary); color: var(--primary); }
.page-btn.active { background: var(--primary); border-color: var(--primary); color: #fff; }

/* Empty */
.empty-state { text-align: center; padding: 60px 20px; color: var(--text-muted); grid-column: 1 / -1; }

/* ---------- Footer ---------- */
.site-footer { background: var(--bg-white); border-top: 1px solid var(--border); margin-top: 40px; }
.footer-inner { display: flex; justify-content: space-between; align-items: center;
    padding: 22px 20px; font-size: 13px; color: var(--text-muted); flex-wrap: wrap; gap: 10px; }

/* ---------- Flash messages ---------- */
.flash-messages { margin-bottom: 20px; display: flex; flex-direction: column; gap: 10px; }
.flash {
    padding: 12px 18px; border-radius: 8px; font-size: 14px; font-weight: 500;
    border: 1px solid transparent;
}
.flash-success { background: #ecfdf5; color: #047857; border-color: #a7f3d0; }
.flash-danger { background: #fef2f2; color: #b91c1c; border-color: #fecaca; }
.flash-warning { background: #fffbeb; color: #b45309; border-color: #fde68a; }
.flash-info { background: #eff6ff; color: #1d4ed8; border-color: #bfdbfe; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-block; padding: 9px 18px; border-radius: 8px;
    font-size: 14px; font-weight: 600; cursor: pointer; border: none;
    transition: all .2s; text-align: center;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); color: #fff; }
.btn-ghost { background: transparent; color: var(--text-light); border: 1px solid var(--border); }
.btn-ghost:hover { background: var(--bg); color: var(--text); }
.btn-block { width: 100%; }
.btn-sm { padding: 6px 12px; font-size: 13px; }

/* ============================================================
   登录页
   ============================================================ */
.login-body {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px;
}
.login-wrapper { width: 100%; max-width: 400px; }
.login-card {
    background: #fff; border-radius: 16px; padding: 40px 36px;
    box-shadow: 0 20px 50px rgba(0,0,0,0.25);
}
.login-brand { text-align: center; margin-bottom: 28px; }
.login-brand .logo-mark { margin: 0 auto 14px; width: 54px; height: 54px; font-size: 20px; border-radius: 14px; }
.login-brand h1 { font-size: 22px; margin-bottom: 4px; }
.login-sub { color: var(--text-muted); font-size: 14px; }
.login-form .form-group { margin-bottom: 16px; }
.login-tip { text-align: center; font-size: 12px; color: var(--text-muted); margin-top: 16px;
    background: var(--primary-light); padding: 8px; border-radius: 6px; }
.login-back { text-align: center; margin-top: 14px; font-size: 13px; }

/* ============================================================
   后台布局
   ============================================================ */
.admin-body { background: var(--bg); }
.admin-layout { display: flex; min-height: 100vh; }
.admin-sidebar {
    width: 230px; background: #1f2937; color: #d1d5db; flex-shrink: 0;
    display: flex; flex-direction: column; position: fixed; top: 0; bottom: 0; left: 0;
}
.admin-brand { display: flex; align-items: center; gap: 12px; padding: 22px 20px; border-bottom: 1px solid #374151; }
.admin-brand .logo-mark { width: 38px; height: 38px; font-size: 15px; }
.admin-brand strong { display: block; color: #fff; font-size: 15px; }
.admin-brand small { color: #9ca3af; font-size: 11px; }
.admin-nav { flex: 1; padding: 16px 12px; display: flex; flex-direction: column; gap: 4px; }
.admin-nav a {
    display: block; padding: 11px 16px; border-radius: 8px; color: #d1d5db;
    font-size: 14px; font-weight: 500;
}
.admin-nav a:hover { background: #374151; color: #fff; }
.admin-nav a.active { background: var(--primary); color: #fff; }
.admin-user { padding: 16px 20px; border-top: 1px solid #374151; display: flex;
    justify-content: space-between; align-items: center; font-size: 13px; }
.logout-link { color: #fca5a5; }
.logout-link:hover { color: #f87171; }

.admin-main { flex: 1; margin-left: 230px; display: flex; flex-direction: column; min-width: 0; }
.admin-topbar { background: #fff; border-bottom: 1px solid var(--border); padding: 0 32px; height: 64px;
    display: flex; align-items: center; position: sticky; top: 0; z-index: 50; }
.admin-page-title { font-size: 20px; font-weight: 700; }
.admin-content { padding: 28px 32px; flex: 1; }

/* Stats */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 16px; margin-bottom: 28px; }
.stat-card { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    padding: 20px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); }
.stat-icon { font-size: 30px; }
.stat-value { font-size: 28px; font-weight: 800; line-height: 1; }
.stat-label { font-size: 13px; color: var(--text-muted); margin-top: 4px; }
.stat-green { border-left: 4px solid var(--success); }
.stat-orange { border-left: 4px solid var(--warning); }
.stat-purple { border-left: 4px solid #7c3aed; }
.stat-blue { border-left: 4px solid var(--info); }

/* Panel */
.panel { background: #fff; border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: var(--shadow); margin-bottom: 24px; }
.panel-header { display: flex; justify-content: space-between; align-items: center;
    padding: 16px 22px; border-bottom: 1px solid var(--border); }
.panel-header h2 { font-size: 17px; }
.panel-body { padding: 22px; }

/* Table */
.data-table { width: 100%; border-collapse: collapse; font-size: 14px; }
.data-table th { text-align: left; padding: 12px 14px; background: #f9fafb;
    color: var(--text-light); font-weight: 600; font-size: 13px;
    border-bottom: 1px solid var(--border); white-space: nowrap; }
.data-table td { padding: 13px 14px; border-bottom: 1px solid var(--border); }
.data-table tbody tr:hover { background: #f9fafb; }
.data-table tbody tr:last-child td { border-bottom: none; }
.td-title { font-weight: 600; max-width: 320px; }
.td-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.empty-td { text-align: center; color: var(--text-muted); padding: 40px !important; }

/* Badges */
.badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 12px; font-weight: 600; }
.badge-green { background: #ecfdf5; color: #047857; }
.badge-orange { background: #fffbeb; color: #b45309; }

/* Links in table */
.btn-link { background: none; border: none; color: var(--primary); cursor: pointer;
    font-size: 13px; font-weight: 500; padding: 0 4px; }
.btn-link:hover { text-decoration: underline; }
.btn-link-danger { color: var(--danger); }
.inline-form { display: inline; }

/* ---------- Forms ---------- */
.form-group { margin-bottom: 18px; }
.form-group label { display: block; font-size: 14px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-group .hint { font-weight: 400; color: var(--text-muted); font-size: 12px; margin-left: 8px; }
.form-group .req { color: var(--danger); }
.form-group input[type="text"],
.form-group input[type="password"],
.form-group select,
.form-group textarea {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border); border-radius: 8px;
    font-size: 14px; font-family: inherit; color: var(--text); background: #fff;
    transition: border-color .2s, box-shadow .2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none; border-color: var(--primary); box-shadow: 0 0 0 3px var(--primary-light);
}
.form-group textarea { resize: vertical; min-height: 120px; line-height: 1.7; }
.form-row { display: flex; gap: 16px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 200px; }
.form-row .flex-2 { flex: 2; }
.flex-1 { flex: 1; }
.form-check { display: flex; align-items: center; }
.check-label { display: flex; align-items: center; gap: 8px; font-weight: 500; cursor: pointer; }
.check-label input { width: 18px; height: 18px; accent-color: var(--primary); }
.form-actions { display: flex; gap: 12px; margin-top: 24px; }
.inline-flex { display: flex; gap: 12px; align-items: center; flex-wrap: wrap; }
.inline-flex input[type="text"] { min-width: 240px; }

/* ============================================================
   响应式
   ============================================================ */
@media (max-width: 900px) {
    .admin-sidebar { position: static; width: 100%; flex-direction: row; flex-wrap: wrap; align-items: center; }
    .admin-nav { flex-direction: row; flex-wrap: wrap; flex: 1; padding: 8px; }
    .admin-nav a { display: inline-block; }
    .admin-user { border: none; }
    .admin-main { margin-left: 0; }
    .admin-layout { flex-direction: column; }
}
@media (max-width: 640px) {
    .header-inner { height: auto; padding: 12px 0; }
    .main-nav { width: 100%; justify-content: center; }
    .hero h1 { font-size: 26px; }
    .post-detail, .about-page { padding: 24px; }
    .post-detail-title { font-size: 24px; }
    .admin-content, .admin-topbar { padding-left: 18px; padding-right: 18px; }
    .form-row { flex-direction: column; gap: 0; }
    .data-table { font-size: 13px; }
    .td-title { max-width: 140px; }
}
