/* ============================================
   家族树 V52 - SVG 重绘版
   - 树状图：纯SVG绘制，连接线纯色实线直角转折
   - 男蓝女粉，媳妇显示"配:xxx"
   - 吊线图：世代分组布局
   ============================================ */

.ftree-page {
    background: #FAF7F2;
    min-height: 100vh;
    padding: 20px;
}

/* ===== 工具栏 ===== */
.ftree-toolbar {
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(139, 69, 19, 0.08);
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
    border-left: 4px solid #C8102E;
}

.ftree-toolbar .ftree-title {
    font-size: 20px;
    font-weight: bold;
    color: #8B0000;
    margin-right: auto;
}

.ftree-view-tabs {
    display: flex;
    gap: 4px;
    background: #f5f5f5;
    padding: 4px;
    border-radius: 8px;
}

.ftree-view-tab {
    padding: 8px 16px;
    border: none;
    background: transparent;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #666;
    transition: all 0.2s;
    text-decoration: none;
}

.ftree-view-tab.active {
    background: #C8102E;
    color: #fff;
    box-shadow: 0 2px 8px rgba(200, 16, 46, 0.3);
}

.ftree-view-tab:hover:not(.active) {
    background: #e8e8e8;
}

.ftree-actions {
    display: flex;
    gap: 8px;
}

.ftree-btn {
    padding: 8px 16px;
    border: 1px solid #C8102E;
    background: #fff;
    color: #8B0000;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-block;
}

.ftree-btn:hover {
    background: #C8102E;
    color: #fff;
}

/* ===== 筛选栏 ===== */
.ftree-filters {
    background: #fff;
    border-radius: 12px;
    padding: 16px 20px;
    margin-bottom: 16px;
    box-shadow: 0 2px 12px rgba(139, 69, 19, 0.08);
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    align-items: center;
}

.ftree-filter-group {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ftree-filter-label {
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.ftree-select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    min-width: 140px;
}

.ftree-select:focus {
    outline: none;
    border-color: #C8102E;
}

.ftree-hint {
    color: #999;
    font-size: 13px;
}

/* ===== 筛选切换按钮 ===== */
.ftree-toggle-group {
    gap: 8px;
}

.ftree-toggle-btn {
    padding: 7px 14px;
    border: 1px solid #ddd;
    background: #fff;
    color: #666;
    border-radius: 6px;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.2s;
    min-height: 36px;
}

.ftree-toggle-btn:hover {
    border-color: #C8102E;
    color: #C8102E;
}

.ftree-toggle-btn.active {
    background: #C8102E;
    color: #fff;
    border-color: #C8102E;
}

/* ===== 树容器 ===== */
.ftree-container-wrapper {
    position: relative;
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(139, 69, 19, 0.12);
    overflow: hidden;
}

.ftree-container {
    width: 100%;
    height: 70vh;
    min-height: 500px;
    overflow: auto;
    position: relative;
    background: #FDFCF9;
}

/* SVG 树容器 */
.ftree-svg-container {
    width: 100%;
    height: 100%;
    min-height: 100%;
    position: relative;
    overflow: hidden;
}

/* 缩放比例显示标签 */
.ftree-scale-label {
    position: absolute;
    bottom: 12px;
    left: 12px;
    background: rgba(139, 0, 0, 0.85);
    color: #FFD700;
    padding: 4px 12px;
    border-radius: 12px;
    font-size: 12px;
    font-weight: bold;
    z-index: 100;
    pointer-events: none;
    font-family: sans-serif;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.ftree-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #999;
    font-size: 15px;
}

/* 吊线图/列表视图内容区 */
.ftree-content {
    width: 100%;
    height: 100%;
    overflow: auto;
}

/* ===== 缩放控制 ===== */
.ftree-zoom-controls {
    position: absolute;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
    z-index: 100;
}

.ftree-zoom-btn {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    border: 2px solid #C8102E;
    background: #fff;
    color: #8B0000;
    font-size: 20px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 12px rgba(0, 0, 0, 0.15);
    transition: all 0.2s;
    font-weight: bold;
}

.ftree-zoom-btn:hover {
    background: #C8102E;
    color: #fff;
    transform: scale(1.08);
}

.ftree-zoom-btn:active {
    transform: scale(0.95);
}

/* ===== 全屏 ===== */
.ftree-fullscreen {
    position: fixed !important;
    top: 0;
    left: 0;
    width: 100vw !important;
    height: 100vh !important;
    z-index: 9999;
    border-radius: 0;
}

.ftree-fullscreen .ftree-container {
    height: 100vh;
    min-height: 100vh;
}

/* ===== 统计栏 ===== */
.ftree-stats-bar {
    background: linear-gradient(135deg, #8B0000, #C8102E);
    color: #fff;
    padding: 12px 24px;
    border-radius: 0 0 12px 12px;
    display: flex;
    gap: 32px;
    font-size: 14px;
}

.ftree-stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
}

.ftree-stat-value {
    font-size: 18px;
    font-weight: bold;
    color: #FFD700;
}

/* ============================================
   吊线图样式
   ============================================ */
.hanging-v3 {
    padding: 30px 20px;
}

.hanging-v3-gen {
    display: flex;
    align-items: stretch;
    margin-bottom: 0;
    position: relative;
}

.hanging-v3-gen-label {
    width: 100px;
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 20px 10px;
    position: relative;
    z-index: 2;
}

.hanging-v3-gen-badge {
    background: linear-gradient(135deg, #8B0000, #C8102E);
    color: #FFD700;
    padding: 12px 16px;
    border-radius: 12px;
    font-weight: bold;
    font-size: 15px;
    text-align: center;
    box-shadow: 0 3px 10px rgba(139, 0, 0, 0.3);
    min-width: 70px;
    letter-spacing: 1px;
}

.hanging-v3-gen-count {
    margin-top: 8px;
    font-size: 12px;
    color: #8B6914;
    font-weight: 500;
}

.hanging-v3-gen-members {
    flex: 1;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    padding: 20px 24px;
    position: relative;
    border-left: 3px solid #C8102E;
    background: #FDF8F0;
    min-height: 80px;
    align-content: center;
}

.hanging-v3-gen:not(:last-child) {
    margin-bottom: 20px;
}

.hanging-v3-member {
    border-radius: 10px;
    padding: 10px 16px;
    min-width: 100px;
    text-align: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    transition: all 0.2s;
    cursor: pointer;
    position: relative;
    text-decoration: none;
    display: inline-block;
}

.hanging-v3-member:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.18);
}

.hanging-v3-member.male {
    background: #1976D2;
    color: #fff;
    border: 1px solid #0D47A1;
}

.hanging-v3-member.female {
    background: #C2185B;
    color: #fff;
    border: 1px solid #880E4F;
}

.hanging-v3-member-name {
    font-size: 15px;
    font-weight: bold;
    letter-spacing: 1px;
    margin-bottom: 2px;
}

.hanging-v3-member-info {
    font-size: 11px;
    opacity: 0.8;
}

.hanging-v3-spouse {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 2px 8px;
    border-radius: 10px;
    font-size: 10px;
    margin-top: 4px;
    color: #FFD54F;
}

/* ============================================
   响应式 - 平板端 (768px - 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .ftree-page { padding: 14px; }
    .ftree-toolbar { padding: 12px 16px; gap: 10px; }
    .ftree-toolbar .ftree-title { font-size: 18px; }
    .ftree-view-tab { padding: 7px 12px; font-size: 13px; }
    .ftree-btn { padding: 7px 12px; font-size: 13px; }
    .ftree-filters { padding: 12px 16px; gap: 12px; }
    .ftree-select { min-width: 120px; padding: 7px 10px; font-size: 13px; }
    .ftree-container { height: 65vh; min-height: 450px; }
    .ftree-stats-bar { padding: 10px 16px; gap: 20px; font-size: 13px; flex-wrap: wrap; }
    .ftree-stat-value { font-size: 16px; }
    .ftree-zoom-controls { bottom: 14px; right: 14px; gap: 6px; }
    .ftree-zoom-btn { width: 40px; height: 40px; font-size: 18px; }
    .ftree-toggle-btn { padding: 6px 12px; font-size: 12px; min-height: 34px; }
}

/* ============================================
   响应式 - 手机端 (<768px)
   ============================================ */
@media (max-width: 768px) {
    .ftree-page { padding: 8px; }

    .ftree-toolbar {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 10px;
    }

    .ftree-toolbar .ftree-title {
        font-size: 17px;
        text-align: center;
        margin-right: 0;
    }

    .ftree-view-tabs {
        justify-content: center;
        width: 100%;
    }

    .ftree-view-tab {
        padding: 8px 10px;
        font-size: 12px;
        flex: 1;
        text-align: center;
        min-height: 36px;
    }

    .ftree-actions {
        justify-content: center;
        flex-wrap: wrap;
        gap: 6px;
    }

    .ftree-btn {
        padding: 8px 12px;
        font-size: 12px;
        flex: 1;
        text-align: center;
        min-height: 38px;
    }

    .ftree-filters {
        flex-direction: column;
        align-items: stretch;
        padding: 12px;
        gap: 10px;
    }

    .ftree-filter-group {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .ftree-filter-label { font-size: 12px; }

    .ftree-select {
        width: 100%;
        min-width: auto;
        padding: 10px;
        font-size: 14px;
        min-height: 40px;
    }

    .ftree-toggle-group {
        flex-direction: row !important;
        justify-content: center;
    }

    .ftree-toggle-btn {
        flex: 1;
        min-height: 38px;
        font-size: 13px;
    }

    .ftree-hint {
        text-align: center;
        font-size: 11px;
    }

    .ftree-container-wrapper { border-radius: 12px; }

    .ftree-container {
        height: 55vh;
        min-height: 350px;
        -webkit-overflow-scrolling: touch;
    }

    /* 吊线图适配 */
    .hanging-v3 { padding: 16px 10px; }
    .hanging-v3-gen { flex-direction: column; }
    .hanging-v3-gen-label {
        width: 100%;
        flex-direction: row;
        justify-content: center;
        padding: 10px;
        gap: 12px;
    }
    .hanging-v3-gen-badge {
        padding: 8px 14px;
        font-size: 13px;
        min-width: 60px;
    }
    .hanging-v3-gen-count { margin-top: 0; font-size: 11px; }
    .hanging-v3-gen-members {
        border-left: none;
        border-top: 3px solid #C8102E;
        padding: 14px 10px;
        gap: 8px;
        justify-content: center;
    }
    .hanging-v3-member {
        padding: 8px 12px;
        min-width: 85px;
        font-size: 12px;
    }
    .hanging-v3-member-name { font-size: 13px; }
    .hanging-v3-member-info { font-size: 10px; }
    .hanging-v3-gen:not(:last-child) { margin-bottom: 16px; }

    /* 统计栏 */
    .ftree-stats-bar {
        padding: 10px 12px;
        gap: 12px;
        font-size: 12px;
        flex-wrap: wrap;
        justify-content: center;
    }
    .ftree-stat-value { font-size: 15px; }

    /* 缩放按钮 */
    .ftree-zoom-controls {
        bottom: 10px;
        right: 10px;
        gap: 6px;
    }
    .ftree-zoom-btn {
        width: 38px;
        height: 38px;
        font-size: 17px;
    }

    /* 触摸设备：禁用hover效果 */
    @media (hover: none) {
        .hanging-v3-member:hover { transform: none; }
        .ftree-btn:hover, .ftree-zoom-btn:hover { transform: none; }
    }
}

/* ============================================
   响应式 - 小屏手机 (<480px)
   ============================================ */
@media (max-width: 480px) {
    .ftree-container { height: 50vh; min-height: 300px; }
    .ftree-stats-bar { font-size: 11px; gap: 8px; padding: 8px 10px; }
    .ftree-stat-value { font-size: 14px; }
}
/* ============================================
   v73: 搜索定位族人
   ============================================ */
.ft-search-box {
    position: relative;
    display: inline-flex;
    align-items: center;
}
.ft-search-box input {
    padding: 8px 12px 8px 34px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 14px;
    background: #fff;
    min-width: 200px;
    transition: border-color 0.2s;
}
.ft-search-box input:focus {
    outline: none;
    border-color: #C8102E;
    box-shadow: 0 0 0 3px rgba(200,16,46,0.1);
}
.ft-search-box::before {
    content: '🔍';
    position: absolute;
    left: 10px;
    font-size: 13px;
    opacity: 0.5;
}
.ft-search-dropdown {
    position: absolute;
    z-index: 10000;
    background: #fff;
    border: 1px solid #E8DDD0;
    border-radius: 8px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.15);
    max-height: 360px;
    overflow-y: auto;
    display: none;
}
.ft-search-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    cursor: pointer;
    border-bottom: 1px solid #f5f0e8;
    transition: background 0.15s;
}
.ft-search-item:last-child {
    border-bottom: none;
}
.ft-search-item:hover {
    background: #FDF5E6;
}
.ft-search-name {
    font-weight: bold;
    color: #2C1810;
    font-size: 14px;
    min-width: 70px;
}
.ft-search-name em {
    color: #C8102E;
    font-style: normal;
    background: #FFF3CD;
    padding: 0 2px;
    border-radius: 2px;
}
.ft-search-meta {
    color: #8B6914;
    font-size: 12px;
    flex: 1;
}
.ft-search-status {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 10px;
    font-weight: 500;
}
.ft-search-status.alive {
    background: #E8F5E9;
    color: #2E7D32;
}
.ft-search-status.dead {
    background: #F5F5F5;
    color: #757575;
}
.ft-search-no-result {
    padding: 20px;
    text-align: center;
    color: #999;
    font-size: 13px;
}
/* v73: 节点高亮脉冲动画 */
.ft-node-highlight {
    animation: ftHighlightPulse 1s ease-in-out infinite;
}
@keyframes ftHighlightPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}
/* ============================================
   v73: 导出申请弹窗
   ============================================ */
.ft-export-modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.ft-export-modal-overlay.active {
    display: flex;
}
.ft-export-modal {
    background: #fff;
    border-radius: 16px;
    width: 90%;
    max-width: 460px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    overflow: hidden;
    animation: ftModalIn 0.3s ease;
}
@keyframes ftModalIn {
    from { transform: translateY(20px) scale(0.95); opacity: 0; }
    to { transform: translateY(0) scale(1); opacity: 1; }
}
.ft-export-modal-header {
    background: linear-gradient(135deg, #8B0000, #C8102E);
    color: #fff;
    padding: 18px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.ft-export-modal-header h3 {
    margin: 0;
    font-size: 18px;
}
.ft-export-modal-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 22px;
    cursor: pointer;
    opacity: 0.8;
    transition: opacity 0.2s;
    line-height: 1;
}
.ft-export-modal-close:hover {
    opacity: 1;
}
.ft-export-modal-body {
    padding: 24px;
}
.ft-form-group {
    margin-bottom: 18px;
}
.ft-form-group label {
    display: block;
    font-size: 14px;
    font-weight: 600;
    color: #2C1810;
    margin-bottom: 8px;
}
.ft-form-group select,
.ft-form-group textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ddd;
    border-radius: 8px;
    font-size: 14px;
    background: #FAF8F5;
    transition: border-color 0.2s;
    box-sizing: border-box;
}
.ft-form-group select:focus,
.ft-form-group textarea:focus {
    outline: none;
    border-color: #C8102E;
    background: #fff;
}
.ft-form-group textarea {
    resize: vertical;
    min-height: 70px;
    font-family: inherit;
}
.ft-format-options {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}
.ft-format-option {
    flex: 1;
    min-width: 80px;
    padding: 10px 8px;
    border: 2px solid #E8DDD0;
    border-radius: 8px;
    text-align: center;
    cursor: pointer;
    font-size: 13px;
    font-weight: 600;
    color: #666;
    transition: all 0.2s;
    background: #FAF8F5;
}
.ft-format-option:hover {
    border-color: #C8102E;
    color: #C8102E;
}
.ft-format-option.selected {
    border-color: #C8102E;
    background: #C8102E;
    color: #fff;
}
.ft-export-modal-footer {
    padding: 16px 24px;
    background: #FAF8F5;
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    border-top: 1px solid #E8DDD0;
}
.ft-export-btn {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    transition: all 0.2s;
}
.ft-export-btn-cancel {
    background: #fff;
    color: #666;
    border: 1px solid #ddd;
}
.ft-export-btn-cancel:hover {
    background: #f5f5f5;
}
.ft-export-btn-submit {
    background: linear-gradient(135deg, #C8102E, #8B0000);
    color: #fff;
}
.ft-export-btn-submit:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(200,16,46,0.3);
}
.ft-export-btn-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}
.ft-export-tip {
    font-size: 12px;
    color: #999;
    margin-top: 6px;
    line-height: 1.5;
}
/* 响应式：搜索框和弹窗 */
@media (max-width: 768px) {
    .ft-search-box input {
        min-width: 140px;
        font-size: 13px;
    }
    .ft-export-modal {
        width: 95%;
        max-width: 400px;
    }
    .ft-export-modal-body {
        padding: 18px;
    }
    .ft-format-option {
        min-width: 65px;
        font-size: 12px;
        padding: 8px 4px;
    }
}
