:root {
    --tree-line-color: #cbd5e1;
    --tree-node-bg: #ffffff;
    --tree-node-border: #e2e8f0;
}

.organogram-container {
    padding: 40px 0 80px;
    overflow-x: auto;
    background: #f8faff;
    min-height: 600px;
}

.tree-wrapper {
    display: inline-block;
    min-width: 100%;
    text-align: center;
}

.tree {
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    padding: 20px;
}

.tree ul {
    padding-top: 40px; 
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
}

.tree li {
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 40px 10px 0 10px;
    transition: all 0.5s;
}

/* Connectors */
.tree li::before, .tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid var(--tree-line-color);
    width: 50%;
    height: 40px;
}

.tree li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid var(--tree-line-color);
}

.tree li:only-child::after, .tree li:only-child::before {
    display: none;
}

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

.tree li:first-child::before, .tree li:last-child::after {
    border: 0 none;
}

.tree li:last-child::before {
    border-right: 2px solid var(--tree-line-color);
    border-radius: 0 10px 0 0;
}

.tree li:first-child::after {
    border-radius: 10px 0 0 0;
}

/* Vertical connector from parent */
.tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid var(--tree-line-color);
    width: 0;
    height: 40px;
}

/* Node Styles */
.tree-node {
    border: 1px solid var(--tree-node-border);
    padding: 12px 20px;
    text-decoration: none;
    color: var(--text-dark);
    font-family: 'Manrope', sans-serif;
    font-size: 14px;
    font-weight: 600;
    display: inline-flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    border-radius: 12px;
    background: var(--tree-node-bg);
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 160px;
    position: relative;
    z-index: 2;
}

.tree-node span {
    line-height: 1.4;
}

/* Node Variants */
.tree-node.root-node {
    background: var(--primary-color);
    color: white;
    border-color: var(--primary-color);
    font-size: 16px;
    padding: 18px 30px;
}

.tree-node.trust-node {
    border: 2px solid #3b82f6;
    color: #1e3a8a;
    background: #eff6ff;
}

.tree-node.leader-node {
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    background: #fff;
}

.tree-node.branch-node {
    background: #f1f5f9;
    border-color: #cbd5e1;
    color: #475569;
}

/* Arrows (using CSS shapes) */
.node-arrow {
    width: 0;
    height: 0;
    border-left: 8px solid transparent;
    border-right: 8px solid transparent;
    border-top: 10px solid var(--tree-line-color);
    margin-top: 10px;
}

/* Hover Effects */
.tree-node:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 15px -3px rgba(30, 47, 122, 0.15), 0 4px 6px -2px rgba(30, 47, 122, 0.1);
    border-color: var(--primary-color);
    color: var(--primary-color);
}

.tree-node.root-node:hover {
    color: #fff;
    background: #2a3f9d;
}

/* Branch specific colors */
.academic-branch .tree-node {
    border-left: 4px solid #10b981; /* Green for Academic */
}

.admin-branch .tree-node {
    border-left: 4px solid #f59e0b; /* Orange for Admin */
}

/* Vertical Branches (for deep trees on mobile or narrow sections) */
.vertical-branch ul {
    flex-direction: column;
    align-items: center;
    padding-top: 20px;
}

.vertical-branch li {
    padding: 20px 0 0 0;
    width: 100%;
}

.vertical-branch li::before, .vertical-branch li::after {
    display: none;
}

.vertical-branch ul::before {
    height: 20px;
}

/* Responsive */
@media (max-width: 1200px) {
    .organogram-container {
        padding-left: 20px;
        padding-right: 20px;
    }
}

@media (max-width: 768px) {
    .tree ul {
        flex-direction: column;
        align-items: center;
        padding-top: 20px;
    }
    
    .tree li {
        width: 100%;
        padding: 20px 0 0 0;
    }
    
    .tree li::before, .tree li::after, .tree ul ul::before {
        display: none;
    }
    
    /* Vertical line for mobile */
    .tree li:not(:last-child)::after {
        content: '';
        display: block;
        position: absolute;
        bottom: -20px;
        left: 50%;
        width: 2px;
        height: 20px;
        background: var(--tree-line-color);
        z-index: 1;
    }
    
    .tree-node {
        width: 240px;
    }
}
