/* 族谱录入系统 - 响应式样式 */

:root {
    --primary: #8B4513;
    --primary-light: #A0522D;
    --bg: #fdf8f3;
    --card-bg: #fff;
    --text: #333;
    --text-light: #666;
    --border: #e0d5c7;
    --danger: #c0392b;
    --success: #27ae60;
    --radius: 8px;
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Microsoft YaHei", sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    min-height: 100vh;
}

/* 导航栏 */
nav {
    background: linear-gradient(135deg, var(--primary), var(--primary-light));
    color: white;
    padding: 0 1rem;
    box-shadow: 0 2px 8px rgba(139, 69, 19, 0.3);
    position: sticky;
    top: 0;
    z-index: 100;
}
.nav-inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    gap: 1rem;
    height: 56px;
}
nav a {
    color: white;
    text-decoration: none;
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    transition: background 0.2s;
    font-size: 0.95rem;
}
nav a:hover { background: rgba(255,255,255,0.2); }
nav .brand { font-size: 1.2rem; font-weight: bold; margin-right: auto; }

/* 搜索框 */
.search-form {
    display: flex;
    gap: 0.3rem;
}
.search-form input {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: var(--radius);
    font-size: 0.9rem;
    width: 180px;
    outline: none;
}
.search-form button {
    padding: 0.4rem 0.8rem;
    border: none;
    border-radius: var(--radius);
    background: rgba(255,255,255,0.3);
    color: white;
    cursor: pointer;
    font-size: 0.9rem;
}
.search-form button:hover { background: rgba(255,255,255,0.5); }

/* 主容器 */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* 卡片 */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    padding: 1.5rem;
    margin-bottom: 1rem;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    border: 1px solid var(--border);
}

/* 按钮 */
.btn {
    display: inline-block;
    padding: 0.5rem 1.2rem;
    border: none;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    text-decoration: none;
    transition: all 0.2s;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { opacity: 0.9; }
.btn-outline {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
}
.btn-outline:hover { background: var(--primary); color: white; }
.btn-sm { padding: 0.3rem 0.7rem; font-size: 0.8rem; }

/* 表格 */
table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
thead th {
    background: var(--primary);
    color: white;
    padding: 0.6rem 0.8rem;
    text-align: left;
    position: sticky;
    top: 0;
}
thead th:first-child { border-radius: var(--radius) 0 0 0; }
thead th:last-child { border-radius: 0 var(--radius) 0 0; }
tbody td {
    padding: 0.5rem 0.8rem;
    border-bottom: 1px solid var(--border);
}
tbody tr:hover { background: #fff8f0; }

/* 表格容器（移动端可滚动） */
.table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: var(--radius);
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
}

/* 分页 */
.pagination {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 0.5rem;
    margin: 1.5rem 0;
    flex-wrap: wrap;
}
.pagination a, .pagination span {
    padding: 0.4rem 0.8rem;
    border-radius: var(--radius);
    text-decoration: none;
    color: var(--primary);
    border: 1px solid var(--border);
    font-size: 0.9rem;
}
.pagination a:hover { background: var(--primary); color: white; }
.pagination .current {
    background: var(--primary);
    color: white;
    font-weight: bold;
}

/* 表单 */
.form-group {
    margin-bottom: 1rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.3rem;
    color: var(--primary);
    font-size: 0.9rem;
}
.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.6rem;
    border: 1px solid var(--border);
    border-radius: var(--radius);
    font-size: 0.95rem;
    font-family: inherit;
    background: #fefefe;
    transition: border 0.2s;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 2px rgba(139,69,19,0.15);
}
.form-group textarea { resize: vertical; min-height: 80px; }
.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}
.form-hint {
    font-size: 0.8rem;
    color: var(--text-light);
    margin-top: 0.2rem;
}

/* 详情页 */
.detail-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 0.5rem;
}
.detail-item {
    padding: 0.5rem 0;
    border-bottom: 1px dashed var(--border);
}
.detail-label {
    font-size: 0.8rem;
    color: var(--text-light);
}
.detail-value {
    font-size: 1rem;
    color: var(--text);
}
.detail-section {
    margin-top: 1.5rem;
    padding-top: 1rem;
    border-top: 2px solid var(--border);
}
.detail-section h3 {
    color: var(--primary);
    margin-bottom: 0.8rem;
    font-size: 1.1rem;
}

/* 树形结构 */
.tree-scroll {
    overflow-x: auto;
    overflow-y: visible;
    -webkit-overflow-scrolling: touch;
    padding-bottom: 1rem;
    /* subtle scroll hint */
    background:
        linear-gradient(to right, white 30%, rgba(255,255,255,0)),
        linear-gradient(to right, rgba(255,255,255,0), white 70%) 100% 0,
        linear-gradient(to right, rgba(0,0,0,.08), rgba(255,255,255,0)),
        linear-gradient(to left, rgba(0,0,0,.08), rgba(255,255,255,0)) 100% 0;
    background-repeat: no-repeat;
    background-size: 40px 100%, 40px 100%, 14px 100%, 14px 100%;
    background-attachment: local, local, scroll, scroll;
}
.tree-container {
    padding: 0.5rem 0;
    min-width: max-content;
    display: inline-block;
}
.tree-node {
    position: relative;
    margin-left: 18px;
    padding-left: 16px;
    border-left: 2px solid var(--border);
    min-height: 2.5rem;
    display: flex;
    flex-direction: column;
    justify-content: center;
}
.tree-node:last-child { border-left: 2px dashed transparent; }
.tree-node::before {
    content: "";
    position: absolute;
    top: 1.25rem;
    left: -2px;
    width: 14px;
    height: 2px;
    background: var(--border);
}
.tree-root > .tree-person-wrapper > div {
    margin-left: -2px;
    padding-left: 0;
}
.tree-person {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.35rem 0.7rem;
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
}
.tree-person:hover {
    border-color: var(--primary);
    box-shadow: 0 2px 6px rgba(139,69,19,0.15);
}
.tree-person.male { border-left: 3px solid #3498db; }
.tree-person.female { border-left: 3px solid #e74c3c; }
.tree-expand {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: 1px solid var(--border);
    background: white;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.65rem;
    color: var(--primary);
    margin-left: 0.2rem;
    flex-shrink: 0;
}
.tree-expand:hover { background: var(--primary); color: white; }
.tree-children { margin-left: 8px; }

/* 树节点操作按钮 */
.tree-actions {
    display: inline-flex;
    align-items: center;
    gap: 0.2rem;
    margin-left: 0.3rem;
    flex-shrink: 0;
}
.tree-actions a {
    color: var(--primary);
    text-decoration: none;
    font-size: 0.75rem;
    padding: 0.15rem 0.4rem;
    border-radius: 4px;
    background: rgba(139,69,19,0.06);
    white-space: nowrap;
    transition: background 0.15s;
}
.tree-actions a:hover {
    background: rgba(139,69,19,0.15);
}

/* 树行——横向排列节点和操作按钮 */
.tree-row {
    display: flex;
    align-items: center;
    gap: 0.2rem;
    flex-wrap: nowrap;
}

/* 收缩深度过大的树（超过第8代进一步压窄间距） */
.tree-root .tree-children .tree-children .tree-children .tree-children .tree-children .tree-children .tree-children .tree-node {
    margin-left: 10px;
    padding-left: 10px;
}
.tree-root .tree-children .tree-children .tree-children .tree-children .tree-children .tree-children .tree-children .tree-children {
    margin-left: 0px;
}

/* 错误/提示 */
.alert {
    padding: 0.8rem 1rem;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    font-size: 0.9rem;
}
.alert-error { background: #fde8e8; color: var(--danger); border: 1px solid #f5c6cb; }
.alert-success { background: #e8f5e9; color: var(--success); border: 1px solid #c8e6c9; }

/* 响应式 - 手机 */
@media (max-width: 768px) {
    .container { padding: 0.8rem 0.5rem; }
    .form-row { grid-template-columns: 1fr; }
    .detail-grid { grid-template-columns: 1fr; }
    .search-form input { width: 120px; }
    nav .brand { font-size: 1rem; }
    .card { padding: 1rem; }
    .tree-node { margin-left: 12px; padding-left: 10px; }
    .tree-children { margin-left: 4px; }
    .tree-person { font-size: 0.8rem; padding: 0.3rem 0.5rem; }
    .tree-actions a { font-size: 0.7rem; padding: 0.1rem 0.3rem; }
}

/* 响应式 - 大屏 */
@media (min-width: 1200px) {
    .detail-grid { grid-template-columns: repeat(4, 1fr); }
}

/* 打印样式 */
@media print {
    nav { display: none; }
    .btn { display: none; }
    .card { box-shadow: none; border: 1px solid #ccc; }
}
