/* Organization Chart Styles */
.org-chart-container {
    padding: 60px 0;
    background-color: white;
    overflow-x: auto;
    /* Allow scrolling on small screens */
    width: 100%;
}

.tree {
    width: max-content;
    /* Ensure wide enough */
    margin: 0 auto;
    padding-top: 20px;
}

.tree ul {
    padding-top: 20px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
    margin: 0;
}

.tree li {
    float: left;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 20px 5px 0 5px;
    transition: all 0.5s;
}

/* We will use ::before and ::after to draw the connectors */
.tree li::before,
.tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 1px solid var(--color-border);
    width: 50%;
    height: 20px;
    z-index: 1;
}

.tree li::after {
    right: auto;
    left: 50%;
    border-left: 1px solid var(--color-border);
}

/* We need to remove left-right connectors from elements without any siblings */
.tree li:only-child::after,
.tree li:only-child::before {
    display: none;
}

/* Remove space from the top of single children */
.tree li:only-child {
    padding-top: 0;
}

/* Remove left connector from first child and right connector from last child */
.tree li:first-child::before,
.tree li:last-child::after {
    border: 0 none;
}

/* Adding back the vertical connector to the last nodes */
.tree li:last-child::before {
    border-right: 1px solid var(--color-border);
    border-radius: 0 5px 0 0;
}

.tree li:first-child::after {
    border-radius: 5px 0 0 0;
}

/* Time to add downward connectors from parents */
.tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 1px solid var(--color-border);
    width: 0;
    height: 20px;
    z-index: 1;
}

.tree .member-card {
    border: 1px solid #ccc;
    padding: 10px 15px;
    text-decoration: none;
    color: #333;
    font-family: var(--font-heading);
    font-size: 0.85rem;
    font-weight: 600;
    display: inline-block;
    border-radius: 4px;
    transition: all 0.5s;
    background: #fff;
    min-width: 120px;
    position: relative;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.tree .member-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

/* Role Coding based on Diagram Key - Legend Indicators */

/* Base Card Style Update */
.tree .member-card {
    background: #fff;
    color: #000;
    border: 1px solid #ccc;
    padding: 10px 15px;
    display: inline-flex;
    /* Use flex to align square and text */
    align-items: center;
    justify-content: center;
    min-width: 120px;
    position: relative;
    z-index: 2;
    border-radius: 4px;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Indicator Square Logic */
.tree .member-card::before {
    content: '';
    display: inline-block;
    width: 12px;
    height: 12px;
    margin-right: 8px;
    flex-shrink: 0;
    border: 1px solid #ddd;
}

/* HM - Dark Green */
.cat-hm::before {
    background-color: #4CAF50;
}

/* MM 1-1 - Mid Green */
.cat-mm::before {
    background-color: #8BC34A;
}

/* AR-1 - Light Green */
.cat-ar::before {
    background-color: #C8E6C9;
}

/* JM - Bright Green */
.cat-jm::before {
    background-color: #4CAF50;
}

/* MA-4 - Red */
.cat-ma4::before {
    background-color: #FF5252;
}

/* MA-3 - Pale Green/Yellow */
.cat-ma3::before {
    background-color: #DCEDC8;
}

/* MA 1-1 - Blue */
.cat-ma1::before {
    background-color: #B2EBF2;
}

/* MA 2-1 - Yellow */
.cat-ma2::before {
    background-color: #FFF176;
}

/* PL-3 - Magenta/Pink */
.cat-pl3::before {
    background-color: #E040FB;
}

/* PL-1 - Grey */
.cat-pl1::before {
    background-color: #BDBDBD;
}

/* Clean up old border classes overriding */
.cat-hm,
.cat-mm,
.cat-ar,
.cat-jm,
.cat-ma4,
.cat-ma3,
.cat-ma1,
.cat-ma2,
.cat-pl3,
.cat-pl1 {
    border-top-color: transparent;
    /* Reset */
    border-top-width: 0;
}

/* -- Legacy Classes Mapped -- */
.bg-green-bright {
    border-top-color: #61b329;
}

/* Chart Title helper */
.chart-title {
    text-align: center;
    margin-bottom: 40px;
    font-family: var(--font-heading);
    color: var(--color-maroon);
}

/* Vertical Stacking helper for leaf nodes */
.vertical-branch>ul {
    flex-direction: column;
    align-items: center;
    padding-top: 0;
}

.vertical-branch>ul>li {
    padding: 10px 0 0 0;
}

.vertical-branch>ul>li::before,
.vertical-branch>ul>li::after {
    display: none;
    /* Disable standard tree lines for vertical */
}

/* Custom vertical line */
.vertical-branch>ul::before {
    display: none;
}

.vertical-branch>ul>li {
    position: relative;
}

.vertical-branch>ul>li::before {
    display: block;
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    width: 1px;
    height: 10px;
    background: var(--color-border);
    border: none;
}