html {
    overflow-y: scroll;
    /* Force scrollbar to prevent layout jumping */
}

body {
    background-color: #121212;
    color: #ffffff;
    font-family: 'Inter', sans-serif;
    /* overflow-x: auto; - Managed by container or specific element if needed */
}

.tree-container {
    padding: 50px;
    display: flex;
    /* Use flex-start + auto margins for safe centering that allows scroll */
    justify-content: flex-start;
    /* min-width: max-content; Removed to prevent forcing body width issues if not needed, or keep if horizontal scroll is desired */
    min-width: 100%;
    /* Ensure it takes full width but allows scroll */
    overflow-x: auto;

    /* Hide scrollbar for Chrome, Safari and Opera */
    -ms-overflow-style: none;
    /* IE and Edge */
    scrollbar-width: none;
    /* Firefox */
}

.tree-container::-webkit-scrollbar {
    display: none;
}

/* Tree Structure using Flexbox/CSS */
.tf-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 auto;
    /* Center the tree if it fits, else start at left */
}

.node-card:hover {
    background-color: #2a2a2a;
    /* transform: translateY(-5px); Removed to prevent hover loop jitter */
    transform: scale(1.05);
    /* Stable scaling */
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    border-color: #6366f1;
    z-index: 10;
    /* Ensure it pops over connectors */
}

/* Node Styling mimicking PrimeNG OrgChart */
.node-card {
    background-color: #1e1e1e;
    border: 1px solid #3f3f46;
    /* Lighter border for better definition */
    border-radius: 12px;
    padding: 1rem;
    width: 200px;
    text-align: center;
    position: relative;
    transition: all 0.3s ease;
    cursor: pointer;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5);
    z-index: 2;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

/* Navigation Controls (Floating & Draggable) */
.navigation-controls {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    background: rgba(30, 30, 30, 0.8);
    padding: 10px;
    border-radius: 16px;
    border: 1px solid #3f3f46;
    backdrop-filter: blur(8px);
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.5);
    cursor: grab;
    user-select: none; /* Prevent text selection while dragging */
    touch-action: none; /* Prevent scrolling while dragging on touch */
}

.navigation-controls:active {
    cursor: grabbing;
}

.nav-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 2px;
    background-color: #27272a;
    border-color: #3f3f46;
    color: #e4e4e7;
    transition: all 0.2s;
}

.nav-btn:hover {
    background-color: #3f3f46;
    color: white;
    transform: scale(1.1);
}

/* Toggler Button */
.node-toggler {
    width: 24px;
    height: 24px;
    background-color: #6366f1;
    color: white;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 14px;
    position: absolute;
    bottom: -12px;
    /* Halfway overlapping the bottom connector area */
    left: 50%;
    transform: translateX(-50%);
    z-index: 20;
    transition: background-color 0.2s;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.3);
}

.node-toggler:hover {
    background-color: #4f46e5;
}

.node-card img.avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 0.5rem;
    border: 2px solid #6366f1;
}

.node-card .name {
    font-weight: 600;
    font-size: 0.9rem;
    color: #e2e8f0;
}

/* Connectors */
.children-container {
    display: flex;
    padding-top: 20px;
    position: relative;
}

.node-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin: 0 10px;
    position: relative;
}

/* Vertical line from parent to children-container */
.node-wrapper::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid #555;
    width: 0;
    height: 20px;
    transform: translateY(-100%);
    z-index: 1;
}

/* Remove connector for root */
.root-wrapper>.node-wrapper::before {
    display: none;
}

/* Horizontal connectors between siblings */
.node-wrapper::after {
    content: '';
    position: absolute;
    top: -20px;
    left: 0;
    width: 100%;
    border-top: 2px solid #555;
    z-index: 1;
}

/* Hide horizontal line for first child's left half and last child's right half */
.children-container>.node-wrapper:first-child::after {
    left: 50%;
    width: 50%;
}

.children-container>.node-wrapper:last-child::after {
    right: 50%;
    width: 50%;
}

.children-container>.node-wrapper:only-child::after {
    display: none;
}

/* Buttons */
.btn-primary {
    background-color: #6366f1;
    border-color: #6366f1;
}

.btn-primary:hover {
    background-color: #4f46e5;
    border-color: #4f46e5;
}