/* Genealogy Tree CSS */
.genealogy-page {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Header & Controls Toolbar */
.tree-toolbar {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 14px;
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 16px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.02);
}

.tree-breadcrumbs {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
}

.crumb-item {
    color: var(--purple-primary);
    cursor: pointer;
    text-decoration: none;
    transition: opacity 0.2s;
}
.crumb-item:hover {
    text-decoration: underline;
}

.crumb-separator {
    color: var(--text-muted);
}

.crumb-current {
    color: var(--text-main);
    font-weight: 700;
}

.tree-actions {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tree-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #ffffff;
    border: 1.5px solid var(--border-color);
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    cursor: pointer;
    transition: all 0.2s;
}

.tree-btn:hover:not(:disabled) {
    border-color: var(--purple-primary);
    color: var(--purple-primary);
    background: var(--purple-light);
}

.tree-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.tree-btn.primary {
    background: linear-gradient(135deg, var(--purple-primary), var(--purple-dark));
    color: #ffffff;
    border: none;
    box-shadow: 0 4px 12px rgba(152,40,200,0.2);
}

.zoom-group {
    display: flex;
    align-items: center;
    background: #f8f7fb;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 2px;
}

.zoom-btn {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    font-size: 15px;
    font-weight: 700;
    color: var(--text-main);
    cursor: pointer;
    border-radius: 6px;
    transition: background 0.2s;
}

.zoom-btn:hover {
    background: #ffffff;
}

.zoom-label {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    padding: 0 8px;
}

/* Tree Container Canvas */
.tree-canvas-container {
    background: #ffffff;
    border: 1px solid var(--border-color);
    border-radius: 16px;
    padding: 40px 20px 60px 20px;
    overflow: auto;
    min-height: 540px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    position: relative;
    box-shadow: 0 2px 8px rgba(0,0,0,0.02);
}

.tree-canvas {
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s ease-out;
    transform-origin: top center;
    min-width: 800px;
    padding: 20px 0;
}

/* Tree Structure & Connector Lines */
.tree-root, .tree-children {
    display: flex;
    justify-content: center;
    padding: 0;
    margin: 0;
    list-style-type: none;
    position: relative;
}

.tree-children {
    padding-top: 24px;
}

.tree-root li {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0 16px;
}

.tree-children > li {
    padding: 24px 16px 0 16px;
}

/* Horizontal connector line spanning sibling nodes */
    .tree-children > li::before,
    .tree-children > li::after {
        content: '';
        position: absolute;
        top: 0;
        right: 50%;
        border-top: 2px solid #cbd5e1;
        width: 50%;
        height: 24px;
        z-index: -1;
    }

.tree-children > li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid #cbd5e1;
}

/* Remove horizontal overhangs from leftmost and rightmost children */
.tree-children > li:only-child::after,
.tree-children > li:only-child::before {
    display: none;
}

.tree-children > li:only-child {
    padding-top: 0;
}

.tree-children > li:first-child::before {
    border: 0 none;
}

.tree-children > li:last-child::after {
    border: 0 none;
}

.tree-children > li:last-child::before {
    border-right: 2px solid #cbd5e1;
    border-radius: 0 0 0 0;
}

.tree-children > li:first-child::after {
    border-radius: 0 0 0 0;
}

/* Downward vertical connector from parent node */
.tree-root li:has(> .tree-children) > .tree-node-wrapper::after,
.tree-children li:has(> .tree-children) > .tree-node-wrapper::after {
    content: '';
    position: absolute;
    bottom: -24px;
    left: 50%;
    border-left: 2px solid #cbd5e1;
    width: 0;
    height: 24px;
    transform: translateX(-50%);
}

.tree-node-wrapper {
    position: relative;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1;
}

.tree-root > li > .tree-node-wrapper {
    z-index: 50;
}

.tree-node-wrapper:hover {
    z-index: 100;
}

.tree-root > li > .tree-node-wrapper:hover {
    z-index: 150;
}

/* Node Card */
.node-card {
    width: 160px;
    background: #ffffff;
    border: 2px solid #e2e8f0;
    border-radius: 14px;
    padding: 12px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    cursor: pointer;
    position: relative;
    z-index: 1;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 4px 10px rgba(0,0,0,0.03);
}

.node-card:hover {
    transform: translateY(-4px) scale(1.02);
    box-shadow: 0 10px 24px rgba(152,40,200,0.15);
    border-color: var(--purple-primary);
    z-index: 100;
}

.root-node-card {
    z-index: 10;
}

.root-node-card:hover {
    z-index: 200;
}

.node-card.active-status {
    border-color: #10b981;
}

.node-card.pending-status {
    border-color: #f59e0b;
}

.node-avatar {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: linear-gradient(135deg, #9828c8, #6d28d9);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-weight: 800;
    margin-bottom: 8px;
    box-shadow: 0 4px 8px rgba(152,40,200,0.2);
}

.node-avatar.active-avatar {
    background: linear-gradient(135deg, #10b981, #059669);
}

.node-avatar.pending-avatar {
    background: linear-gradient(135deg, #f59e0b, #d97706);
}

.node-code {
    font-size: 13px;
    font-weight: 800;
    color: var(--text-main);
    letter-spacing: 0.3px;
}

.node-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    margin-top: 2px;
}

.node-side-badge {
    position: absolute;
    top: -10px;
    left: 50%;
    transform: translateX(-50%);
    background: #1e1731;
    color: #ffffff;
    font-size: 10px;
    font-weight: 800;
    padding: 2px 8px;
    border-radius: 10px;
}

.node-status-pill {
    margin-top: 6px;
    font-size: 10px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 6px;
    text-transform: uppercase;
}

.node-status-pill.active {
    background: #d1fae5;
    color: #065f46;
}

.node-status-pill.pending {
    background: #fef3c7;
    color: #92400e;
}

/* Empty Vacant Node */
.node-card.vacant {
    border: 2px dashed #cbd5e1;
    background: #fbfbfd;
    box-shadow: none;
    cursor: pointer;
    min-height: 146px;
}

.node-card.vacant:hover {
    border-color: var(--purple-primary);
    background: var(--purple-light);
    transform: translateY(-3px);
}

.vacant-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #f1f5f9;
    color: #94a3b8;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    font-weight: 700;
    margin-bottom: 6px;
}

.node-card.vacant:hover .vacant-avatar {
    background: var(--purple-primary);
    color: #ffffff;
}

.vacant-title {
    font-size: 12px;
    font-weight: 700;
    color: #94a3b8;
}

.node-card.vacant:hover .vacant-title {
    color: var(--purple-primary);
}

.vacant-action {
    font-size: 11px;
    font-weight: 600;
    color: var(--purple-primary);
    margin-top: 4px;
}

/* Hover Tooltip Popup */
.node-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: 105%;
    left: 50%;
    transform: translateX(-50%) translateY(8px);
    width: 220px;
    background: #1e1731;
    color: #ffffff;
    border-radius: 12px;
    padding: 12px;
    box-shadow: 0 12px 30px rgba(0,0,0,0.25);
    z-index: 200;
    pointer-events: none;
    transition: all 0.2s ease-out;
    text-align: left;
}

.node-card:hover .node-tooltip {
    visibility: visible;
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* Tooltip positioned below when on root node or top boundary */
.node-tooltip.tooltip-bottom {
    bottom: auto;
    top: 105%;
    transform: translateX(-50%) translateY(-8px);
}

.node-card:hover .node-tooltip.tooltip-bottom {
    transform: translateX(-50%) translateY(0);
}

.tooltip-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    padding-bottom: 6px;
    margin-bottom: 8px;
}

.tooltip-title {
    font-size: 13px;
    font-weight: 800;
    color: #ffffff;
}

.tooltip-row {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    margin-bottom: 4px;
}

.tooltip-label {
    color: #a5b4fc;
}

.tooltip-value {
    color: #ffffff;
    font-weight: 600;
}

/* Modal Overlay for Tree Add Member */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 20px;
}

.modal-card {
    background: #ffffff;
    border-radius: 18px;
    width: 100%;
    max-width: 680px;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    box-shadow: 0 25px 50px -12px rgba(0,0,0,0.25);
    position: relative;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.modal-title {
    font-size: 20px;
    font-weight: 800;
    color: var(--text-main);
}

.modal-close-btn {
    background: transparent;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
}
