/* ============================================================
   冯氏族谱 - 全站样式
   ============================================================ */

:root {
    --gold: #b8860b;
    --gold-dark: #8a6404;
    --ink: #2b2b2b;
    --paper: #faf6ee;
    --line: #e2d8c2;
    --red: #a33327;
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: "Microsoft YaHei", "PingFang SC", "Songti SC", serif;
    color: var(--ink);
    background: var(--paper);
    line-height: 1.7;
}

.container { max-width: 1080px; margin: 0 auto; padding: 0 20px; }

/* ---------- 页头 ---------- */
.site-header {
    background: #3a2b18;
    color: #f7ecd7;
    position: sticky;
    top: 0;
    z-index: 50;
    box-shadow: 0 2px 10px rgba(0,0,0,.25);
}
.header-inner {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 60px;
}
.brand {
    font-size: 24px;
    font-weight: bold;
    color: #e7c873;
    text-decoration: none;
    letter-spacing: 4px;
}
.nav a {
    color: #e7d8b8;
    text-decoration: none;
    padding: 8px 14px;
    margin-left: 6px;
    border-radius: 6px;
    transition: background .2s;
}
.nav a:hover { background: rgba(255,255,255,.12); color: #fff; }
.nav a.active { background: var(--gold); color: #fff; }

/* ---------- 页脚 ---------- */
.site-footer {
    background: #3a2b18;
    color: #cbbf9e;
    text-align: center;
    padding: 18px 0;
    margin-top: 50px;
    font-size: 14px;
}

/* ---------- 首页 Hero ---------- */
.hero {
    background: linear-gradient(rgba(30,22,10,.68), rgba(30,22,10,.68)),
                url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="120" height="120" viewBox="0 0 120 120"><circle cx="60" cy="40" r="14" fill="none" stroke="%23e7c873" stroke-width="2"/><path d="M60 54 L60 90 M40 90 h40 M60 70 L40 60 M60 70 L80 60 M60 70 L60 54" stroke="%23e7c873" stroke-width="2" fill="none"/></svg>')
                center/220px;
    color: #f7ecd7;
    text-align: center;
    padding: 90px 20px 80px;
}
.hero h1 {
    font-size: 52px;
    letter-spacing: 16px;
    margin: 0 0 10px;
    color: #f3dd9d;
}
.hero p { font-size: 22px; margin: 6px 0; letter-spacing: 6px; }
.hero .hero-sub { font-size: 15px; letter-spacing: 2px; color: #d9c9a3; }
.hero-actions { margin-top: 30px; }
.btn {
    display: inline-block;
    padding: 10px 26px;
    border-radius: 6px;
    text-decoration: none;
    font-size: 15px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: all .2s;
}
.btn-gold { background: var(--gold); color: #fff; }
.btn-gold:hover { background: var(--gold-dark); }
.btn-gold-outline { border-color: #e7c873; color: #f3dd9d; }
.btn-gold-outline:hover { background: rgba(231,200,115,.15); }
.btn-dark { background: #3a2b18; color: #fff; }
.btn-dark:hover { background: #2a1f10; }
.btn-light { background: #efe6d2; color: #4a3a20; }
.btn-light:hover { background: #e3d6ba; }
.btn-red { background: var(--red); color: #fff; }
.btn-ghost { border-color: #b7a888; color: #4a3a20; background: transparent; }
.btn-sm { padding: 5px 12px; font-size: 13px; }

/* ---------- 统计卡 ---------- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    margin: -40px auto 40px;
    position: relative;
}
.stat-card {
    background: #fff;
    border: 1px solid var(--line);
    border-top: 4px solid var(--gold);
    border-radius: 8px;
    text-align: center;
    padding: 24px 10px;
    box-shadow: 0 4px 14px rgba(0,0,0,.06);
}
.stat-num { font-size: 40px; color: var(--gold); font-weight: bold; }
.stat-label { color: #6d5f43; margin-top: 4px; }

/* ---------- 通用标题 ---------- */
.section-title {
    text-align: center;
    font-size: 30px;
    letter-spacing: 8px;
    color: #4a3a20;
    margin: 50px 0 24px;
    position: relative;
}
.section-title::after {
    content: "";
    display: block;
    width: 70px;
    height: 3px;
    background: var(--gold);
    margin: 12px auto 0;
}

/* ---------- 起源页 ---------- */
.page-banner {
    background: #4a3a20;
    color: #f3dd9d;
    text-align: center;
    padding: 60px 20px 44px;
}
.page-banner h1 { font-size: 40px; letter-spacing: 12px; margin: 0 0 6px; }
.page-banner p { color: #cabf9c; letter-spacing: 4px; margin: 0; }

.content-layout { padding-top: 40px; }
.origin-block {
    background: #fff;
    border: 1px solid var(--line);
    border-left: 5px solid var(--gold);
    border-radius: 8px;
    padding: 28px 32px;
    margin-bottom: 30px;
    box-shadow: 0 3px 10px rgba(0,0,0,.05);
}
.origin-block h2 { color: var(--gold-dark); margin-top: 0; letter-spacing: 4px; }
.content-html p { margin: 10px 0; }
.content-html strong { color: var(--red); }

/* 时间线 */
.timeline { position: relative; padding-left: 30px; }
.timeline::before {
    content: "";
    position: absolute;
    left: 8px;
    top: 6px;
    bottom: 6px;
    width: 3px;
    background: #d8c9a2;
}
.timeline-item { position: relative; margin-bottom: 18px; }
.timeline-dot {
    position: absolute;
    left: -26px;
    top: 8px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--gold);
    border: 3px solid #faf6ee;
}

/* ---------- 世系树 ---------- */
.tree-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 12px;
    align-items: center;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: 14px 18px;
    margin: 26px 0;
}
.inline-form label { margin-right: 6px; color: #6d5f43; }
.inline-form select, .inline-form input {
    padding: 6px 10px;
    border: 1px solid #ccc0a0;
    border-radius: 5px;
    background: #fffdf7;
}
.inline-form input { min-width: 50px; }

.tree-wrap {
    background:
        repeating-linear-gradient(0deg, transparent 0 29px, rgba(184,134,11,.06) 29px 30px);
    border: 1px solid var(--line);
    border-radius: 10px;
    padding: 26px 16px;
    overflow-x: auto;
}
.tree-node { text-align: center; }
.tree-node > .node-card {
    display: inline-block;
    position: relative;
    background: #fff;
    border: 1px solid var(--gold);
    border-radius: 8px;
    padding: 10px 22px;
    min-width: 120px;
    box-shadow: 0 2px 8px rgba(0,0,0,.08);
}
.node-name { font-size: 17px; font-weight: bold; color: #4a3a20; }
.node-meta { font-size: 12px; color: #8a7a5c; margin-top: 2px; }
.node-toggle {
    position: absolute;
    top: -12px;
    right: -12px;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    border: 1px solid var(--gold);
    background: var(--gold);
    color: #fff;
    font-weight: bold;
    cursor: pointer;
    line-height: 1;
    font-size: 14px;
    box-shadow: 0 1px 3px rgba(0,0,0,.25);
}
.node-toggle:hover { background: var(--gold-dark); }

.children-wrap {
    display: flex;
    justify-content: center;
    gap: 14px;
    flex-wrap: wrap;
    padding-top: 34px;
    margin-top: 12px;
    position: relative;
}
/* 竖向连接线 (从父节点向下) */
.children-wrap::before {
    content: "";
    position: absolute;
    top: 0;
    left: 50%;
    width: 0;
    height: 22px;
    border-left: 2px solid #c9b684;
}
/* 兄弟间横向连接线 */
.children-wrap::after {
    content: "";
    position: absolute;
    top: 22px;
    left: 8%;
    right: 8%;
    border-top: 2px solid #c9b684;
}
/* 每个子的向上竖线 */
.tree-node > .children-wrap .tree-node::before {
    content: "";
    position: absolute;
    top: -34px;
    left: 50%;
    width: 2px;
    height: 34px;
    background: #c9b684;
}
.tree-node { position: relative; }

.children-wrap.collapsed { display: none; }
.tree-node > .children-wrap.collapsed { display: none; }

.tree-legend { color: #6d5f43; font-size: 13px; margin-top: 18px; }
.legend-square { display: inline-block; width: 12px; height: 12px; border-radius: 3px; }
.legend-square.male { background: #7f9cc4; }
.legend-square.female { background: #d88aa0; }
.legend-item { margin-right: 18px; }

.empty-tip { text-align: center; color: #8a7a5c; padding: 50px 0; font-size: 16px; }

/* ---------- 后台通用 ---------- */
.admin-wrap { display: flex; min-height: calc(100vh - 60px); }
.admin-sidebar {
    width: 200px;
    background: #2f2416;
    color: #d9c9a3;
    padding: 20px 0;
    flex-shrink: 0;
}
.admin-sidebar .side-brand { padding: 6px 22px 16px; font-size: 20px; color: #f3dd9d; letter-spacing: 3px; border-bottom: 1px solid rgba(255,255,255,.1); }
.admin-sidebar a {
    display: block;
    color: #d9c9a3;
    text-decoration: none;
    padding: 11px 22px;
    font-size: 15px;
}
.admin-sidebar a:hover, .admin-sidebar a.active { background: rgba(231,200,115,.15); color: #fff; }
.admin-main { flex: 1; padding: 24px 30px; }
.admin-main h1 { margin-top: 0; color: #4a3a20; }

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(rgba(30,22,10,.62), rgba(30,22,10,.62)),
                repeating-linear-gradient(45deg, #6b5123 0 2px, #7a5d29 2px 4px);
}
.login-card {
    background: #fffdf6;
    border: 1px solid var(--line);
    border-top: 5px solid var(--gold);
    border-radius: 12px;
    padding: 40px 44px;
    width: 360px;
    box-shadow: 0 12px 40px rgba(0,0,0,.35);
}
.login-card h1 { text-align: center; letter-spacing: 6px; color: #4a3a20; margin-top: 0; }

.form-group { margin-bottom: 18px; }
.form-group label { display: block; margin-bottom: 6px; color: #5d4f33; font-size: 14px; }
.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid #ccc0a0;
    border-radius: 6px;
    background: #fff;
    font-size: 14px;
    font-family: inherit;
}
.form-group textarea { min-height: 140px; resize: vertical; }
.form-group textarea.short { min-height: 90px; }

.form-row { display: flex; gap: 12px; flex-wrap: wrap; }
.form-row .form-group { flex: 1; min-width: 160px; }

.form-actions { margin-top: 20px; display: flex; gap: 12px; }

/* 表格 */
.data-table { width: 100%; border-collapse: collapse; background: #fff; border: 1px solid var(--line); border-radius: 8px; overflow: hidden; }
.data-table th, .data-table td { padding: 10px 12px; border-bottom: 1px solid #eee5d0; text-align: left; font-size: 14px; }
.data-table th { background: #4a3a20; color: #f3dd9d; letter-spacing: 1px; }
.data-table tr:hover td { background: #fdf8ec; }
.data-table .actions a { margin-right: 8px; font-size: 13px; }

/* 提示 */
.alert { padding: 12px 16px; border-radius: 6px; margin-bottom: 18px; font-size: 14px; }
.alert-success { background: #eaf7ec; color: #1e7d32; border: 1px solid #b9e0c1; }
.alert-error { background: #fdecec; color: #b02a2a; border: 1px solid #f0b9b9; }
.alert-info { background: #eef3fb; color: #25558c; border: 1px solid #bfd3ef; }

/* 工具条 */
.table-toolbar { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.table-toolbar .search-box { display: flex; gap: 6px; }
.table-toolbar .search-box input { padding: 7px 10px; border: 1px solid #ccc0a0; border-radius: 5px; min-width: 220px; }

.generation-badge {
    display: inline-block;
    background: #f0e5c8;
    color: #7a5d17;
    border-radius: 10px;
    padding: 1px 9px;
    font-size: 12px;
}

/* 统计小卡（后台首页） */
.dash-grid { display: grid; grid-template-columns: repeat(4, 1fr); gap: 16px; margin: 20px 0 30px; }
.dash-card { background: #fff; border: 1px solid var(--line); border-top: 3px solid var(--gold); border-radius: 8px; padding: 18px; text-align: center; }
.dash-card .num { font-size: 32px; color: var(--gold); font-weight: bold; }
.dash-card .lbl { color: #6d5f43; font-size: 13px; margin-top: 2px; }

@media (max-width: 720px) {
    .stat-grid { grid-template-columns: 1fr; margin-top: 20px; }
    .dash-grid { grid-template-columns: repeat(2, 1fr); }
    .header-inner { flex-direction: column; height: auto; padding: 10px 0; gap: 6px; }
    .admin-wrap { flex-direction: column; }
    .admin-sidebar { width: 100%; display: flex; flex-wrap: wrap; }
    .admin-sidebar a { padding: 8px 14px; }
}
