/* --- VARIABLES & PALETTE --- */
:root {
    /* Primary Brand Colors */
    --color-inviso-green: #54B848;
    --color-deep-forest: #1A2B18;
    
    /* Secondary & Accent */
    --color-social-red: #EE352E;
    
    /* Neutrals */
    --color-heading-grey: #959595;
    --color-body-grey: #707070;
    --color-shadow-blue: #D3D9E3;
    --color-bg: #f8f9fa;
    --color-white: #ffffff;
}

body {
    background-color: var(--color-bg);
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    color: var(--color-body-grey);
}

/* Typography Overrides */
.text-dark-green { color: var(--color-deep-forest); }
.text-heading { color: var(--color-heading-grey); }

/* Button Styles */
.btn-outline-inviso {
    color: var(--color-inviso-green);
    border-color: var(--color-inviso-green);
}
.btn-outline-inviso:hover {
    background-color: var(--color-inviso-green);
    color: white;
}

.org-chart-wrapper {
    padding: 20px 10px;
    overflow-x: auto;
}

/* --- BASE TREE STRUCTURE (MOBILE FIRST - VERTICAL) --- */
.tree ul {
    padding-left: 20px;
    list-style: none;
    position: relative;
}

.tree li {
    position: relative;
    padding-left: 20px;
    padding-bottom: 20px;
    box-sizing: border-box;
}

/* Vertical line connector (Left side) */
.tree li::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    bottom: 0;
    width: 2px;
    background-color: var(--color-shadow-blue);
}

/* Horizontal line connector (To Card) */
.tree li::after {
    content: '';
    position: absolute;
    top: 30px; /* Approx center of top card part */
    left: 0;
    width: 20px;
    height: 2px;
    background-color: var(--color-shadow-blue);
}

/* Remove bottom line for last child */
.tree li:last-child::before {
    height: 30px; /* Stop at the connector */
}

/* Root node specific reset */
.tree > ul {
    padding-left: 0;
}
.tree > ul > li {
    padding-left: 0;
}
.tree > ul > li::before,
.tree > ul > li::after {
    display: none;
}

/* --- NODE / CARD STYLING --- */
.node {
    background: var(--color-white);
    border-radius: 8px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.05), 0 1px 3px rgba(0,0,0,0.1);
    border: 1px solid var(--color-shadow-blue);
    transition: all 0.3s ease;
    cursor: pointer;
    position: relative;
    width: 100%;
    max-width: 400px; /* Reasonable max width on mobile */
}

.node:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.1);
    border-color: var(--color-inviso-green);
}

/* Icon Box */
.node .icon-box {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background-color: #f0f0f0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    color: var(--color-heading-grey);
    flex-shrink: 0;
}

/* Text Details */
.node .details {
    flex-grow: 1;
}

.node .name {
    display: block;
    font-weight: 700;
    font-size: 1rem;
    color: var(--color-deep-forest);
    line-height: 1.2;
}

.node .role {
    display: block;
    font-size: 0.85rem;
    color: var(--color-body-grey);
    margin-top: 4px;
}

/* --- LEVEL SPECIFIC STYLING --- */

/* Level 1: DSI (Root) */
.node-level-1 {
    background-color: var(--color-deep-forest);
    border-color: var(--color-deep-forest);
    color: white;
}
.node-level-1 .name { color: var(--color-inviso-green); } /* Highlight Name */
.node-level-1 .role { color: #ccc; }
.node-level-1 .icon-box {
    background-color: var(--color-inviso-green);
    color: white;
}

/* Level 2: Directors */
.node-level-2 {
    border-left: 5px solid var(--color-inviso-green);
}
.node-level-2 .icon-box { color: var(--color-inviso-green); }

/* Level 3: Managers */
.node-level-3 {
    border-left: 5px solid var(--color-heading-grey);
}

/* Level 4: Staff */
.node-staff {
    padding: 8px 12px;
    font-size: 0.9rem;
    border: 1px solid #eee;
    box-shadow: none;
    background-color: #fdfdfd;
    max-width: 250px;
}
.node-staff:hover {
    background-color: white;
    border-color: var(--color-inviso-green);
}

/* Collapse/Expand Indicators */
.node.has-children::after {
    content: '\f078'; /* Chevron Down */
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    margin-left: auto;
    color: var(--color-heading-grey);
    transition: transform 0.3s;
}
.collapsed .node.has-children::after {
    transform: rotate(-90deg);
}

/* Collapsed State */
.collapsed > ul {
    display: none;
}

/* --- SPECIAL NODES --- */

/* Contact Card */
.node-contact {
    flex-direction: column;
    text-align: center;
    border: 2px solid var(--color-social-red);
    background-color: #fffcfc;
}

.node-contact .contact-message {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--color-deep-forest);
}

/* Contact Buttons */
.btn-contact-email {
    color: var(--color-social-red);
    border-color: var(--color-social-red);
}
.btn-contact-email:hover {
    background-color: var(--color-social-red);
    color: white;
}

.btn-contact-phone {
    color: var(--color-body-grey);
    border-color: var(--color-body-grey);
}
.btn-contact-phone:hover {
    background-color: var(--color-body-grey);
    color: white;
}

.btn-contact-wa {
    color: #25D366; /* WhatsApp Brand Color */
    border-color: #25D366;
}
.btn-contact-wa:hover {
    background-color: #25D366;
    color: white;
}

/* --- DESKTOP VIEW (HORIZONTAL TREE) --- */
@media (min-width: 992px) {
    .org-chart-wrapper {
        display: flex;
        justify-content: center;
        padding-bottom: 50px;
    }

    /* Reset Vertical Styles */
    .tree ul {
        padding-left: 0;
        display: flex;
        justify-content: center;
        padding-top: 20px;
    }

    .tree li {
        float: left;
        text-align: center;
        padding: 20px 10px 0 10px;
        padding-left: 10px; /* Reset */
        padding-bottom: 0; /* Reset */
    }

    /* Connectors: Top Lines */
    .tree li::before, .tree li::after {
        top: 0;
        right: 50%;
        width: 50%;
        height: 20px;
        border-top: 2px solid var(--color-shadow-blue);
        background: none; /* Reset vertical line bg */
        left: auto; /* Reset */
        bottom: auto; /* Reset */
    }

    .tree li::after {
        right: auto;
        left: 50%;
        border-left: 2px solid var(--color-shadow-blue);
        height: 20px;
        width: 50%;
    }

    /* Connectors: Downward Line from Parent */
    .tree ul ul::before {
        content: '';
        position: absolute;
        top: 0;
        left: 50%;
        border-left: 2px solid var(--color-shadow-blue);
        width: 0;
        height: 20px;
    }

    /* Remove connectors for root/single */
    .tree li:only-child::after, .tree li:only-child::before { display: none; }
    .tree li:only-child { padding-top: 0; }
    
    /* First/Last child connector fixes */
    .tree li:first-child::before, .tree li:last-child::after { border: 0 none; }
    .tree li:last-child::before {
        border-right: 2px solid var(--color-shadow-blue);
        border-radius: 0 5px 0 0;
    }
    .tree li:first-child::after {
        border-radius: 5px 0 0 0;
    }

    /* Node Styling Adjustments for Desktop */
    .node {
        display: inline-flex; /* Keep flex but inline */
        flex-direction: column; /* Stack icon and text */
        text-align: center;
        justify-content: center;
        min-width: 180px;
        max-width: 220px;
        padding: 20px 10px;
    }

    .node .icon-box {
        margin-bottom: 10px;
    }
    
    .node.has-children::after {
        position: absolute;
        bottom: -20px;
        left: 50%;
        margin-left: -5px;
        margin-top: 0;
        content: '\f078'; /* Chevron Down */
        font-size: 12px;
        color: var(--color-shadow-blue);
    }
    
    .collapsed .node.has-children::after {
        content: '\f054'; /* Right chevron doesn't make sense here, stick to plus/minus or opacity */
        transform: rotate(0);
        color: var(--color-inviso-green);
    }

    /* Staff Grouping - Vertical stack under manager */
    .staff-group {
        display: flex;
        flex-direction: column !important;
        align-items: center;
    }
    .staff-group li {
        padding: 5px 0 !important;
        float: none;
    }
    .staff-group li::before, .staff-group li::after {
        display: none; /* No tree lines for simple staff list under manager */
    }
    /* Add a small connector for staff stack */
    .staff-group::before {
        height: 10px;
    }
}

