/* ============================================
   v56 五服九族页面样式
   中国红 + 米金主题，与家族树风格一致
   ============================================ */

.kinship-page {
    background: #FAF7F2;
    min-height: 100vh;
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
}

/* ===== 页面标题 ===== */
.kinship-header {
    margin-bottom: 20px;
}
.kinship-title {
    display: flex;
    align-items: center;
    gap: 16px;
}
.kinship-title-icon {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #8B0000, #C8102E);
    color: #FFD700;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 28px;
    font-weight: bold;
    font-family: KaiTi, STKaiti, serif;
    box-shadow: 0 4px 16px rgba(139, 0, 0, 0.3);
}
.kinship-title h2 {
    margin: 0;
    font-size: 24px;
    color: #8B0000;
    font-family: KaiTi, STKaiti, serif;
    letter-spacing: 2px;
}
.kinship-title p {
    margin: 4px 0 0;
    font-size: 13px;
    color: #999;
}

/* ===== 搜索卡片 ===== */
.kinship-search-card {
    background: #fff;
    border-radius: 14px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 2px 16px rgba(139, 69, 19, 0.08);
    border-left: 4px solid #C8102E;
}

.kinship-search-box {
    position: relative;
    display: flex;
    align-items: center;
}
.search-icon {
    position: absolute;
    left: 16px;
    font-size: 16px;
    color: #999;
    z-index: 2;
}
.kinship-search-input {
    width: 100%;
    padding: 14px 44px 14px 44px;
    border: 2px solid #E0D8CC;
    border-radius: 10px;
    font-size: 15px;
    background: #FDFCF9;
    transition: all 0.25s;
    outline: none;
    box-sizing: border-box;
}
.kinship-search-input:focus {
    border-color: #C8102E;
    background: #fff;
    box-shadow: 0 0 0 3px rgba(200, 16, 46, 0.1);
}
.kinship-search-input::placeholder {
    color: #BBB;
}
.search-clear {
    position: absolute;
    right: 14px;
    cursor: pointer;
    color: #999;
    font-size: 14px;
    padding: 4px;
    z-index: 2;
}
.search-clear:hover {
    color: #C8102E;
}

/* 搜索下拉 */
.kinship-search-dropdown {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    margin-top: 6px;
    background: #fff;
    border-radius: 10px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15);
    border: 1px solid #E8E0D4;
    z-index: 1000;
    max-height: 360px;
    overflow-y: auto;
}
.search-loading, .search-empty {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 14px;
}
.search-result-list {
    list-style: none;
    margin: 0;
    padding: 6px;
}
.search-result-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.15s;
}
.search-result-item:hover, .search-result-item.active {
    background: #FFF5F5;
}
.sr-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    font-weight: bold;
    color: #fff;
    flex-shrink: 0;
}
.sr-avatar.male { background: #1976D2; }
.sr-avatar.female { background: #C2185B; }
.sr-info { flex: 1; min-width: 0; }
.sr-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}
.sr-meta {
    font-size: 12px;
    color: #999;
    margin-top: 2px;
}
.sr-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}
.sr-status.alive { background: #E8F5E9; color: #2E7D32; }
.sr-status.dead { background: #F5F5F5; color: #999; }

/* 已选族人信息 */
.kinship-selected-info {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-top: 16px;
    padding: 14px 18px;
    background: linear-gradient(135deg, #FFF8E7, #FDF5E6);
    border-radius: 10px;
    border: 1px solid #E8D5A8;
}
.selected-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: bold;
    color: #fff;
    flex-shrink: 0;
}
.selected-avatar.male { background: linear-gradient(135deg, #1976D2, #0D47A1); }
.selected-avatar.female { background: linear-gradient(135deg, #C2185B, #880E4F); }
.selected-detail { flex: 1; }
.selected-name {
    font-size: 18px;
    font-weight: bold;
    color: #8B0000;
    font-family: KaiTi, STKaiti, serif;
}
.selected-meta {
    font-size: 13px;
    color: #8B6914;
    margin-top: 2px;
}
.btn-change {
    padding: 8px 18px;
    background: #fff;
    border: 1px solid #C8102E;
    color: #8B0000;
    border-radius: 8px;
    font-size: 13px;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s;
    flex-shrink: 0;
}
.btn-change:hover {
    background: #C8102E;
    color: #fff;
}

/* ===== 空状态 ===== */
.kinship-empty-state {
    background: #fff;
    border-radius: 14px;
    padding: 60px 30px;
    text-align: center;
    box-shadow: 0 2px 16px rgba(139, 69, 19, 0.08);
}
.empty-icon {
    font-size: 64px;
    margin-bottom: 16px;
}
.kinship-empty-state h3 {
    color: #8B0000;
    font-size: 20px;
    margin: 0 0 10px;
}
.kinship-empty-state p {
    color: #888;
    font-size: 14px;
    margin: 0 0 28px;
}
.empty-tips {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 12px 24px;
    max-width: 600px;
    margin: 0 auto;
}
.tip-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    color: #666;
}
.tip-dot {
    width: 12px;
    height: 12px;
    border-radius: 3px;
}

/* ===== Tab 切换 ===== */
.kinship-tabs {
    display: flex;
    gap: 4px;
    background: #fff;
    padding: 6px;
    border-radius: 12px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(139, 69, 19, 0.06);
}
.kinship-tab {
    flex: 1;
    padding: 12px 16px;
    border: none;
    background: transparent;
    border-radius: 8px;
    cursor: pointer;
    font-size: 15px;
    color: #666;
    transition: all 0.25s;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 500;
}
.kinship-tab:hover:not(.active) {
    background: #F5F0E8;
    color: #8B0000;
}
.kinship-tab.active {
    background: linear-gradient(135deg, #8B0000, #C8102E);
    color: #fff;
    box-shadow: 0 3px 12px rgba(200, 16, 46, 0.3);
}
.tab-icon { font-size: 16px; }
.tab-badge {
    background: rgba(255, 255, 255, 0.25);
    padding: 1px 8px;
    border-radius: 10px;
    font-size: 12px;
    font-weight: 600;
}

/* ===== Tab 内容区 ===== */
.kinship-tab-content {
    position: relative;
}
.kinship-panel {
    display: none;
}
.kinship-panel.active {
    display: block;
}

/* ===== 关系图 ===== */
.graph-container-wrapper {
    background: #fff;
    border-radius: 14px;
    overflow: hidden;
    box-shadow: 0 2px 16px rgba(139, 69, 19, 0.08);
}
.graph-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 20px;
    background: linear-gradient(135deg, #8B0000, #C8102E);
    color: #fff;
}
.graph-title {
    font-size: 16px;
    font-weight: 600;
    font-family: KaiTi, STKaiti, serif;
    letter-spacing: 1px;
}
.graph-actions {
    display: flex;
    gap: 8px;
}
.graph-btn {
    width: 34px;
    height: 34px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.4);
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    font-size: 18px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    line-height: 1;
}
.graph-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.1);
}
.graph-container {
    position: relative;
    width: 100%;
    height: 65vh;
    min-height: 480px;
    overflow: hidden;
    background: #FDFCF9;
    cursor: grab;
    touch-action: none;
}
.graph-container:active {
    cursor: grabbing;
}
#kinshipSvg {
    width: 100%;
    height: 100%;
    display: block;
    user-select: none;
}
.kin-node {
    cursor: pointer;
    transition: transform 0.15s;
}
.kin-node:hover rect {
    filter: brightness(0.97);
}
.kin-node.ego-node:hover rect {
    filter: brightness(1.02);
}
.graph-hint {
    position: absolute;
    bottom: 12px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 12px;
    color: #BBB;
    background: rgba(255, 255, 255, 0.85);
    padding: 4px 14px;
    border-radius: 12px;
    pointer-events: none;
}

/* ===== 五服列表 ===== */
.wufu-group {
    background: #fff;
    border-radius: 12px;
    margin-bottom: 16px;
    overflow: hidden;
    box-shadow: 0 2px 12px rgba(139, 69, 19, 0.06);
    border-left: 5px solid #ccc;
}
.wufu-group-header {
    padding: 14px 20px;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.wufu-grade-name {
    font-size: 17px;
    font-weight: bold;
    font-family: KaiTi, STKaiti, serif;
    letter-spacing: 2px;
}
.wufu-grade-meta {
    font-size: 13px;
    opacity: 0.9;
}
.wufu-empty {
    padding: 18px;
    text-align: center;
    color: #BBB;
    font-size: 13px;
}
.wufu-member-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 12px;
    padding: 16px 20px;
}
.wufu-member-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #FDFCF9;
    border: 1px solid #E8E0D4;
    border-left: 3px solid #ccc;
    border-radius: 10px;
    text-decoration: none;
    transition: all 0.2s;
}
.wufu-member-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 14px rgba(0, 0, 0, 0.1);
    background: #fff;
}
.wm-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: bold;
    color: #fff;
    flex-shrink: 0;
}
.wm-avatar.male { background: #1976D2; }
.wm-avatar.female { background: #C2185B; }
.wm-info { flex: 1; min-width: 0; }
.wm-name {
    font-size: 15px;
    font-weight: 600;
    color: #333;
}
.wm-relation {
    font-size: 12px;
    font-weight: 500;
    margin: 2px 0;
}
.wm-meta {
    font-size: 11px;
    color: #999;
}

/* ===== 九族列表 ===== */
.jiuzu-group {
    background: #fff;
    border-radius: 12px;
    margin-bottom: 12px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(139, 69, 19, 0.05);
}
.jiuzu-group.ego-gen {
    border: 2px solid #D4AF37;
    box-shadow: 0 4px 18px rgba(212, 175, 55, 0.2);
}
.jiuzu-gen-header {
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #F8F4ED;
}
.jiuzu-gen-label {
    font-size: 15px;
    font-weight: 600;
    color: #8B0000;
    font-family: KaiTi, STKaiti, serif;
    letter-spacing: 1px;
}
.ego-gen .jiuzu-gen-label {
    color: #FFD700;
    font-size: 16px;
}
.jiuzu-gen-count {
    font-size: 12px;
    color: #999;
    background: rgba(0, 0, 0, 0.05);
    padding: 2px 10px;
    border-radius: 10px;
}
.ego-gen .jiuzu-gen-count {
    background: rgba(255, 255, 255, 0.2);
    color: #FFD700;
}
.jiuzu-empty {
    padding: 14px;
    text-align: center;
    color: #CCC;
    font-size: 13px;
}
.jiuzu-member-list {
    padding: 8px 12px;
}
.jiuzu-member-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: 8px;
    border-left: 3px solid #ccc;
    text-decoration: none;
    transition: background 0.15s;
    margin-bottom: 4px;
}
.jiuzu-member-item:hover {
    background: #FFF8F0;
}
.jm-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}
.jm-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
    min-width: 70px;
}
.jm-relation {
    font-size: 12px;
    color: #8B6914;
    flex: 1;
}
.jm-gender {
    font-size: 12px;
    color: #888;
    padding: 1px 8px;
    background: #F0F0F0;
    border-radius: 8px;
}
.jm-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 8px;
}
.jm-status.alive { background: #E8F5E9; color: #2E7D32; }
.jm-status.dead { background: #F5F5F5; color: #999; }

/* ===== 底部图例 ===== */
.kinship-legend {
    background: #fff;
    border-radius: 14px;
    padding: 20px 24px;
    margin-top: 20px;
    box-shadow: 0 2px 12px rgba(139, 69, 19, 0.06);
}
.legend-title {
    font-size: 16px;
    font-weight: bold;
    color: #8B0000;
    margin-bottom: 14px;
    font-family: KaiTi, STKaiti, serif;
    letter-spacing: 1px;
}
.legend-items {
    display: flex;
    flex-wrap: wrap;
    gap: 16px 28px;
    margin-bottom: 14px;
}
.legend-item {
    display: flex;
    align-items: center;
    gap: 8px;
}
.legend-color {
    width: 20px;
    height: 14px;
    border-radius: 3px;
}
.legend-name {
    font-size: 14px;
    font-weight: 600;
    color: #333;
}
.legend-period {
    font-size: 12px;
    color: #999;
}
.legend-desc {
    font-size: 12px;
    color: #888;
    line-height: 1.7;
    padding-top: 12px;
    border-top: 1px solid #F0EBE0;
}

/* ============================================
   响应式 - 平板端 (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .kinship-page { padding: 14px; }
    .kinship-title h2 { font-size: 20px; }
    .kinship-title-icon { width: 48px; height: 48px; font-size: 24px; }
    .graph-container { height: 55vh; min-height: 400px; }
    .wufu-member-grid { grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); }
}

/* ============================================
   响应式 - 移动端 (<=768px)
   ============================================ */
@media (max-width: 768px) {
    .kinship-page {
        padding: 10px;
        padding-bottom: 80px; /* 底部导航不遮挡 */
    }
    .kinship-header { margin-bottom: 14px; }
    .kinship-title { gap: 10px; }
    .kinship-title-icon { width: 42px; height: 42px; font-size: 20px; border-radius: 10px; }
    .kinship-title h2 { font-size: 18px; letter-spacing: 1px; }
    .kinship-title p { font-size: 12px; }

    .kinship-search-card { padding: 14px; border-radius: 12px; }
    .kinship-search-input { padding: 12px 40px 12px 40px; font-size: 14px; width: 100%; }
    .kinship-selected-info { padding: 12px; gap: 10px; flex-wrap: wrap; }
    .selected-avatar { width: 40px; height: 40px; font-size: 17px; }
    .selected-name { font-size: 16px; }
    .selected-meta { font-size: 12px; }
    .btn-change { padding: 7px 14px; font-size: 12px; }

    .kinship-tabs { padding: 4px; gap: 2px; }
    .kinship-tab { padding: 10px 8px; font-size: 13px; gap: 4px; }
    .tab-icon { font-size: 14px; }
    .tab-badge { font-size: 11px; padding: 0 6px; }

    .graph-toolbar { padding: 10px 14px; }
    .graph-title { font-size: 14px; }
    .graph-btn { width: 30px; height: 30px; font-size: 16px; }
    .graph-container { height: 60vh; min-height: 360px; }
    .graph-hint { font-size: 10px; padding: 3px 10px; }

    .wufu-group { margin-bottom: 12px; }
    .wufu-group-header { padding: 10px 14px; }
    .wufu-grade-name { font-size: 15px; }
    .wufu-grade-meta { font-size: 12px; }
    .wufu-member-grid {
        grid-template-columns: 1fr;
        gap: 8px;
        padding: 12px;
    }
    .wufu-member-card { padding: 10px 12px; }

    .jiuzu-group { margin-bottom: 10px; }
    .jiuzu-gen-header { padding: 10px 14px; }
    .jiuzu-gen-label { font-size: 14px; }
    .jiuzu-member-list { padding: 6px 8px; }
    .jiuzu-member-item { padding: 8px 10px; gap: 8px; flex-wrap: wrap; }
    .jm-name { font-size: 13px; min-width: 60px; }
    .jm-relation { font-size: 11px; flex-basis: 100%; order: 5; padding-left: 18px; }
    .jm-gender, .jm-status { font-size: 11px; }

    .kinship-legend { padding: 14px 16px; margin-top: 14px; }
    .legend-title { font-size: 14px; margin-bottom: 10px; }
    .legend-items { gap: 10px 18px; }
    .legend-color { width: 16px; height: 12px; }
    .legend-name { font-size: 13px; }
    .legend-period { font-size: 11px; }
    .legend-desc { font-size: 11px; line-height: 1.6; }

    .kinship-empty-state { padding: 40px 20px; }
    .empty-icon { font-size: 48px; }
    .kinship-empty-state h3 { font-size: 17px; }
    .kinship-empty-state p { font-size: 13px; }
    .empty-tips { gap: 8px 16px; }
    .tip-item { font-size: 12px; }

    .kinship-search-dropdown { max-height: 300px; }
    .search-result-item { padding: 8px 10px; gap: 10px; }
    .sr-avatar { width: 32px; height: 32px; font-size: 13px; }
    .sr-name { font-size: 14px; }
    .sr-meta { font-size: 11px; }
}

/* 超小屏 */
@media (max-width: 380px) {
    .kinship-tab { font-size: 12px; padding: 9px 4px; }
    .tab-icon { display: none; }
}
