/* Organization Page Styles */

.org-chart-container {
    margin-bottom: 80px;
    padding-top: 20px;
}

.org-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    max-width: 1000px;
    margin: 0 auto;

    .org-node {
        border: none;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s;
        font-size: 20px;
        font-weight: 700;
        width: 285px;
        height: 55px;

        /* Node Types */
        &.primary {
            background: linear-gradient(103deg, #A87AB7 -15.16%, #05607B 56.47%, #005770 81.58%);
            color: #fff;
            border-radius: 6px;
            font-size: 20px;
            z-index: 2;
            position: relative;
        }

        &.secondary {
            background-color: #1A6D83;
            color: #fff;
            border-radius: 6px;
            z-index: 2;
            position: relative;

            &.hollow {
                background-color: #E4F2F4;
                color: #1A6D83;
                border: 1px solid #1A6D83;
            }
        }

        &.light {
            width: 100%;
            height: 60px;
            background-color: #E6F3F6;
            color: #252525;
            font-weight: 700;
            border-radius: 6px;
            margin-bottom: 20px;
            z-index: 2;
            position: relative;
            font-size: 19px;
        }

        &:hover,
        &.active {
            transform: translateY(-2px);
            box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
        }
    }

    /* Layout & Lines */
    .level {
        position: relative;
        width: 100%;
        display: flex;
        justify-content: center;

        &.level-1 {
            margin-bottom: 138px;
            /* Space for line */
            z-index: 5;

            /* Vertical line from Chairman */
            &::after {
                content: '';
                position: absolute;
                bottom: -69px;
                /* Connect to next level */
                left: 50%;
                width: 1px;
                height: 72px;
                background-color: #999;
            }
        }

        &.level-2 {
            margin-bottom: 100px;
            z-index: 5;

            /* Vertical Line 1 (Chairman to Secretary) */
            .vertical-line-1 {
                position: absolute;
                top: -70px;
                left: 50%;
                width: 1px;
                height: 72px;
                background-color: #999;
            }

            /* Line from Secretary to Departments */
            &::after {
                content: '';
                position: absolute;
                bottom: -50px;
                left: 50%;
                width: 1px;
                height: 50px;
                background-color: #999;
            }
        }

        &.level-3 {
            padding-top: 0;

            .dept-container {
                display: flex;
                justify-content: space-between;
                width: 100%;
                gap: 20px;
                position: relative;

                /* Horizontal line connecting departments */
                &::before {
                    content: '';
                    position: absolute;
                    top: -50px;
                    /* Position above dept boxes */
                    left: 16.1%;
                    /* Center of first col */
                    right: 15.9%;
                    /* Center of last col */
                    height: 1px;
                    background-color: #999;
                }

                .dept-column {
                    flex: 1;
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    position: relative;

                    /* Small vertical line to each dept */
                    .dept-line-top {
                        position: absolute;
                        top: -50px;
                        left: 50%;
                        width: 1px;
                        height: 50px;
                        background-color: #999;
                    }

                    .dept-roles {
                        width: 100%;
                        background-color: #fff;
                        border: 1px solid #ccc;
                        border-radius: 6px;
                        padding: 20px 30px;

                        ul {
                            list-style: none;
                            padding: 0;
                            margin: 0;

                            li {
                                font-size: 17px;
                                color: #454545;
                                margin-bottom: 10px;
                                padding-left: 16px;
                                position: relative;
                                line-height: 1.4;
                                font-weight: 500;

                                &:last-child {
                                    margin-bottom: 0;
                                }

                                &::before {
                                    content: '';
                                    position: absolute;
                                    left: 0;
                                    top: 8px;
                                    width: 4px;
                                    height: 4px;
                                    background-color: #005770;
                                    border-radius: 50%;
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    /* Standing Member Special Layout */
    .standing-member-wrapper {
        position: absolute;
        top: 96px;
        /* Adjust based on level 1 height + spacing */
        width: 100%;
        max-width: 800px;
        /* Control width to place standing member correctly */
        display: flex;
        justify-content: flex-end;
        /* Push to right */
        padding-right: 50px;
        /* Adjust as needed */
        z-index: 1;

        /* Horizontal line to Standing Member */
        &::before {
            content: '';
            position: absolute;
            top: 50%;
            /* Center vertically relative to standing member box */
            right: 310px;
            /* Start from near the button */
            left: 50%;
            /* Connect to center vertical line */
            height: 1px;
            background-color: #999;
        }
    }
}


/* Details Section */
.org-details-section {

    .detail-content {
        display: none;

        &.active {
            display: block;
            animation: fadeIn 0.3s ease-in-out;
        }
    }

    .detail-title {
        font-size: 22px;
        font-weight: 700;
        color: #252525;
        margin-bottom: 20px;
        line-height: 1.9;
    }

    .detail-table-wrap {
        border-top: 2px solid #005770;

        .detail-table {
            width: 100%;
            border-collapse: collapse;

            th,
            td {
                border-bottom: 1px solid #BEC5C9;
                text-align: center;
                font-size: 17px;
                height: 55px;
                vertical-align: middle;
            }

            th {
                background-color: #F8FBFB;
                font-weight: 700;
                color: #474747;
            }

            td {
                color: #252525;
                font-weight: 500;
                line-height: 1.9;
                border-right: 1px solid #BEC5C9;
                padding: 17px 30px;

                &:last-of-type {
                    border-right: none;
                }
            }
        }
    }

    .empty-msg {
        text-align: center;
        padding: 50px;
        color: #888;
        background-color: #F9F9F9;
        border-radius: 6px;
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Responsive */
@media (max-width: 768px) {
    .org-chart-container {
        padding-bottom: 20px;
        overflow: visible;
    }

    .org-tree {
        min-width: 0;
        width: 100%;
        padding-right: 0;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 20px;

        /* Force hide all lines with !important */
        .level.level-1::after,
        .standing-member-wrapper::before,
        .standing-member-wrapper .standing-line,
        .vertical-line-1,
        .level.level-2::after,
        .dept-container::before,
        .dept-line-top {
            display: none !important;
        }

        .org-node {
            width: 100%;
            max-width: 100%;
            margin: 0;
            height: 50px;
            font-size: 20px;
        }

        /* 1. Chairman */
        .level.level-1 {
            width: 100%;
            margin-bottom: 0;
            display: flex;
            justify-content: center;
        }

        /* 2. Standing Member */
        .standing-member-wrapper {
            position: relative;
            width: 100%;
            max-width: 100%;
            top: auto;
            right: auto;
            left: auto;
            justify-content: center;
            padding: 0;

            .org-node {
                margin: 0;
            }
        }

        /* 3. Secretary */
        .level.level-2 {
            width: 100%;
            margin-bottom: 0;
            display: flex;
            justify-content: center;
        }

        /* 4. Departments */
        .level.level-3 {
            width: 100%;
            padding-top: 0;

            .dept-container {
                display: flex;
                flex-direction: column;
                align-items: center;
                gap: 20px;
                width: 100%;

                .dept-column {
                    display: flex;
                    flex-direction: column;
                    align-items: center;
                    width: 100%;
                    margin-bottom: 0;

                    .org-node {
                        margin-bottom: 15px;
                        border-radius: 6px;
                    }

                    .dept-roles {
                        width: 100%;
                        max-width: 100%;
                        border-radius: 6px;
                        border: 1px solid #ccc;
                        padding: 15px;
                        margin-bottom: 20px;

                        ul li {
                            margin-bottom: 5px;
                        }
                    }

                    &:last-child .dept-roles {
                        margin-bottom: 0;
                    }
                }
            }
        }
    }

    /* Details Table Mobile Styles */
    .org-details-section {
        .detail-table-wrap {
            border-top: 1px solid #005770;
            margin-top: 20px;

            .detail-table {
                display: block;
                width: 100%;

                thead {
                    display: none;
                }

                tbody,
                tr,
                td {
                    display: block;
                    width: 100%;
                    box-sizing: border-box;
                }

                tr {
                    margin-bottom: 10px;
                    border-bottom: 1px solid #eee;
                    padding-bottom: 10px;

                    &:last-child {
                        margin-bottom: 0;
                    }
                }

                td {
                    border: none;
                    padding: 5px 10px;
                    text-align: left;
                    height: auto;
                    font-size: 18px;

                    &:first-child {
                        font-weight: 700;
                        color: #005770;
                        margin-bottom: 2px;
                    }
                }
            }
        }
    }
}