/* ========================================
   MODERN ORGANOGRAM DESIGN
   Fresh, Clean, Professional
   ======================================== */

* {
    box-sizing: border-box;
}

:root {
    --primary-color: #2d6a4f;
    --secondary-color: #52b788;
    --accent-color: #74c69d;
    --bg-light: #d8f3dc;
    --bg-white: #ffffff;
    --text-primary: #1b4332;
    --text-secondary: #40916c;
    --border-color: #95d5b2;
    --shadow-sm: 0 2px 8px rgba(45, 106, 79, 0.08);
    --shadow-md: 0 4px 16px rgba(45, 106, 79, 0.12);
    --shadow-lg: 0 8px 24px rgba(45, 106, 79, 0.16);
}

/* CONTAINER */
.organogram-container {
    /* width: 95%;
    max-width: 95%; */
    margin: 0 auto;
    padding: 60px 20px;
    background: linear-gradient(to bottom, #f8fff9 0%, #ffffff 100%);
    min-height: calc(100vh - 86px);
    max-height: calc(100vh - 86px);
    overflow: auto;
}

/* HEADER */
.organogram-header {
    text-align: center;

}

.organogram-main-title {
    font-size: 2rem;
    font-weight: 800;
    color: var(--primary-color);
    margin: 0 0 12px 0;
    letter-spacing: -1px;
    line-height: 1.2;
}

.organogram-subtitle {
    font-size: 1.25rem;
    color: var(--text-secondary);
    font-weight: 400;
    margin: 0;
    opacity: 0.85;
}

/* CHART */
.organogram-chart {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 0;
}

/* LEVELS */
.org-level {
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.org-level-1,
.org-level-2 {
    margin-bottom: 0px;
}

.org-row {
    display: flex;
    justify-content: center;
    align-items: flex-start;
    width: 100%;
    position: relative;
}

.org-row-spaced {
    justify-content: space-evenly;
    max-width: 100%;
    width: 100%;
    padding: 0;
    gap: 2%;
}

/* COLUMNS */
.org-column {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    flex: 1;
    width: fit-content;
    margin-left: 50px;
}

.org-column:nth-child(1) {
    margin-left: 0px !important;
    width: 650px;
}

.org-card-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

.org-row-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
}

/* CARDS - Modern Design */
.org-card {
    background: linear-gradient(135deg, #ffffff 0%, #f1faee 100%);
    border: 2px solid var(--border-color);
    border-radius: 16px;
    padding: 24px 20px;
    width: 275px;
    min-height: 180px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    position: relative;
    transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: var(--shadow-sm);
    overflow: hidden;
}

.org-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    background: linear-gradient(90deg, var(--secondary-color), var(--accent-color));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.org-card:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: var(--shadow-lg);
    border-color: var(--secondary-color);
}

.org-card:hover::before {
    opacity: 1;
}

/* JS Cards - Compact */
.org-card-js {
    width: 98%;
    min-height: 160px;
    padding: 15px 10px;
}

/* Clickable Cards */
.org-card-clickable {
    cursor: pointer;
    background: linear-gradient(135deg, #ffffff 0%, #e8f5e9 100%);
    width: 100px;
    /* max-width: 200px;
    width: 100%; */
}

.org-card-clickable::after {
    content: '';
    position: absolute;
    bottom: 12px;
    right: 12px;
    width: 24px;
    height: 24px;
    background: var(--secondary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    transform: scale(0.8);
    transition: all 0.3s ease;
}

/* .org-card-clickable:hover::after {
    opacity: 1;
    transform: scale(1);
} */

/* Arrow Icon using CSS */
.org-card-clickable:hover {
    background: linear-gradient(135deg, #e8f5e9 0%, #c7f9cc 100%);
}

/* IMAGE */
.org-card-image {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    overflow: hidden;
    border: 4px solid var(--accent-color);
    background: var(--bg-white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(45, 106, 79, 0.15);
    position: relative;
    flex-shrink: 0;
}

.org-card-image::after {
    content: '';
    position: absolute;
    inset: -4px;
    border-radius: 50%;
    border: 2px solid transparent;
    background: linear-gradient(45deg, var(--secondary-color), var(--accent-color)) border-box;
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.org-card:hover .org-card-image::after {
    opacity: 1;
}

.org-card-js .org-card-image {
    width: 75px;
    height: 75px;
    border-width: 3px;
}

.org-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.org-card-image-placeholder {
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, var(--bg-light) 0%, var(--accent-color) 100%);
    color: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
}

.org-card-image-placeholder svg {
    width: 45%;
    height: 45%;
    opacity: 0.6;
}

/* CONTENT */
.org-card-content {
    text-align: center;
    width: 100%;
}

.org-card-position {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.org-card-name {
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--text-primary);
    line-height: 1.4;
}

.org-card-js .org-card-position {
    font-size: 0.75rem;
}

.org-card-js .org-card-name {
    font-size: 0.95rem;
}

/* INFO ICON */
.org-card-info-icon {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 22px;
    height: 22px;
    color: var(--secondary-color);
    opacity: 0.6;
    cursor: pointer;
    transition: all 0.3s ease;
    z-index: 10;
    pointer-events: auto;
}

.org-card-info-icon svg {
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.org-card-info-icon:hover {
    opacity: 1;
    transform: scale(1.15);
}

/* CONNECTORS - Modern Lines */
.connector-down,
.connector-down-single,
.connector-up {
    width: 2px;
    height: 40px;
    background: linear-gradient(to bottom, var(--secondary-color), var(--accent-color));
    margin: 0 auto;
}

.connector-down-branch {
    width: 2px;
    height: 70px;
    background: linear-gradient(to bottom, var(--secondary-color), var(--accent-color));
}

/* HORIZONTAL LINE */
.horizontal-line-container {
    width: 100%;
    max-width: 100%;
    height: 0px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto;
}

.horizontal-connector-line {
    position: absolute;
    top: 0;
    left: 10%;
    right: 10%;
    height: 2px;
    background: var(--secondary-color);
}

/* JS CHILDREN GROUP */
.js-children-group {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    position: relative;
    padding-top: 0;
}

/* Horizontal line for JS children */
.js-horizontal-line {
    width: 100%;
    height: 40px;
    position: relative;
    display: flex;
    align-items: flex-start;
    justify-content: space-evenly;
    gap: 2%;
}

.js-horizontal-line::before {
    content: '';
    position: absolute;
    top: 0;
    /* left: 0%;
    right: 10%; */
    height: 2px;
    background: var(--secondary-color);
    width:calc(100% - 75px);
}

/* Individual branch connectors for JS cards */
.js-branch-connector {
    flex: 1;
    height: 40px;
    background: linear-gradient(to bottom, var(--secondary-color), var(--accent-color));
    position: relative;
    z-index: 2;
    max-width: 2px;
    margin: 0 auto;
}

/* JS CARDS ROW */
.js-cards-row {
    display: flex;
    justify-content: space-evenly;
    align-items: flex-start;
    gap: 2%;
    width: 100%;
    padding: 0;
    flex-wrap: nowrap;
    position: relative;
    z-index: 2;
}

.js-cards-row .org-card-wrapper {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    max-width: 32%;
}

/* FOOTER */
.organogram-footer {
    margin-top: 60px;
    padding: 30px 20px;
    text-align: center;
    border-top: 2px solid var(--border-color);
    background: linear-gradient(to top, #f8fff9 0%, transparent 100%);
}

.organogram-footer p {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin: 0;
    font-weight: 500;
}

/* MODAL */
.modal-content {
    border-radius: 16px;
    border: none;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
    color: white;
    border-radius: 16px 16px 0 0;
    padding: 24px 30px;
}

.modal-title {
    font-weight: 700;
    font-size: 1.5rem;
}

.modal-body {
    padding: 30px;
}

.modal-body h2 {
    font-size: 1.5rem;
    color: var(--primary-color);
    margin-top: 1.5rem;
    margin-bottom: 0.75rem;
    font-weight: 700;
}

.modal-body h3 {
    font-size: 1.25rem;
    color: var(--secondary-color);
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.modal-body ul,
.modal-body ol {
    padding-left: 2rem;
    margin-bottom: 1rem;
}

.modal-body p {
    line-height: 1.7;
    color: #333;
    margin-bottom: 1rem;
}

/* DETAIL PAGE */
.organogram-detail-main {
    max-width: 1400px;
    margin: 0 auto;
    padding: 40px 20px;
}

.current-position {
    margin-bottom: 60px;
}

.children-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 30px;
    max-width: 1200px;
    margin: 0 auto;
}

/* RESPONSIVE DESIGN */
@media (max-width: 1400px) {
    .org-row-spaced {
        max-width: 1200px;
        padding: 0 30px;
        gap: 30px;
    }

    .horizontal-connector-line {
        left: calc(30px + 120px);
        right: calc(30px + 120px);
    }
}

@media (max-width: 1200px) {
    .organogram-main-title {
        font-size: 2.5rem;
    }

    .org-card {
        width: 190px;
    }

    .org-card-js {
        width: 150px;
    }

    .org-row-spaced {
        max-width: 1000px;
        gap: 25px;
    }
}

@media (max-width: 992px) {
    .organogram-container {
        padding: 40px 15px;
    }

    .org-row-spaced {
        flex-wrap: wrap;
        justify-content: center;
        gap: 40px;
        padding: 0 20px;
    }

    .horizontal-connector-line {
        display: none;
    }

    .connector-up,
    .connector-down,
    .connector-down-single,
    .connector-down-branch {
        display: none;
    }

    .org-column {
        margin-bottom: 40px;
    }
}

@media (max-width: 768px) {
    .organogram-main-title {
        font-size: 2rem;
    }

    .organogram-subtitle {
        font-size: 1.1rem;
    }

    .org-card {
        width: 180px;
        min-height: 160px;
        padding: 20px 16px;
    }

    .org-card-js {
        width: 150px;
    }

    .org-card-image {
        width: 75px;
        height: 75px;
    }

    .org-card-js .org-card-image {
        width: 65px;
        height: 65px;
    }

    .js-cards-row {
        gap: 15px;
    }
}

@media (max-width: 576px) {
    .organogram-container {
        padding: 30px 10px;
    }

    .organogram-header {
        margin-bottom: 40px;
    }

    .organogram-main-title {
        font-size: 1.75rem;
    }

    .org-card {
        width: 170px;
    }

    .org-card-js {
        width: 150px;
    }

    .org-row-spaced {
        flex-direction: column;
        align-items: center;
        gap: 30px;
    }

    .js-cards-row {
        flex-direction: column;
        align-items: center;
        gap: 20px;
    }

    .js-children-group::before {
        width: 2px;
        border: none;
        background: linear-gradient(to bottom, var(--secondary-color), var(--accent-color));
    }
}

/* ANIMATIONS */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.org-card {
    animation: fadeInUp 0.6s ease-out backwards;
}

.org-level-1 .org-card {
    animation-delay: 0.1s;
}

.org-level-2 .org-card {
    animation-delay: 0.2s;
}

.org-level-3 .org-card {
    animation-delay: 0.3s;
}

.org-level-3 {
    width: auto;
}

.org-level-3::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0%;
    right: 10%;
    height: 2px;
    background: var(--secondary-color);
    width: 100%;
}

/* ============================================
   HYBRID VIEW LAYOUT (Detail Page)
   ============================================ */

.organogram-hybrid-view {
    width: fit-content;
    padding: 0px 20px;
}

/* Root Node (Top Center) */
.hybrid-root {
    display: flex;
    justify-content: center;
    margin-bottom: 0;
}

.tree-card {
    display: inline-block;
    position: relative;
}

.tree-card .org-card {
    max-width: 320px;
    box-shadow: 0 4px 12px rgba(45, 106, 79, 0.12);
    transition: all 0.3s ease;
}

.tree-card .org-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 20px rgba(45, 106, 79, 0.2);
}

/* Hide connectors from root card and child cards - only show for DS level with children */
.hybrid-root .tree-card::before,
.hybrid-root .tree-card::after,
.column-child-item .tree-card::before,
.column-child-item .tree-card::after {
    display: none;
}

/* Hide DS connectors if no children exist */
.hybrid-column:not(:has(.column-tree-structure))>.tree-card::before,
.hybrid-column:not(:has(.column-tree-structure))>.tree-card::after {
    display: none;
}

/* Vertical Connector from Root */
.hybrid-root-connector {
    width: 3px;
    height: 60px;
    background: linear-gradient(to bottom, var(--secondary-color), var(--accent-color));
    margin: 0 auto;
}

/* Horizontal Line Container */
.hybrid-horizontal-container {
    position: relative;
    height: 40px;
    width: 100%;
    margin-bottom: 0;
    display: flex;
    justify-content: flex-start;
    margin-left: 5%;
}

.hybrid-horizontal-container::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0%;
    right: 10%;
    height: 2px;
    background: var(--secondary-color);
    width: 100%;
}

.hybrid-horizontal-line {
    /* position: absolute;
    top: 0;
    left: 15%;
    right: 15%; */
    height: 3px;
    background: linear-gradient(to right, var(--secondary-color), var(--accent-color));
    display: flex;
    justify-content: space-around;
    align-items: flex-start;
}

/* Vertical Branches Down from Horizontal Line */
.hybrid-branch-down {
    width: 3px;
    height: 60px;
    background: linear-gradient(to bottom, var(--secondary-color), var(--accent-color));
}

/* Columns Container (DS Level Cards) */
.hybrid-columns-container {
    display: flex;
    justify-content: space-between;
    gap: 2rem;
    align-items: flex-start;
    margin-left: 5%;
    /* padding: 0 15%; */
}

.hybrid-column {
    flex: 1;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
}

/* Column Tree Structure (Grandchildren with Side Connectors) */
.column-tree-structure {
    position: relative;
    width: 100%;
    margin-top: 2rem;
    padding-left: 60px;
}

/* Vertical connector from DS card down */
.hybrid-column>.tree-card::after {
    content: '';
    position: absolute;
    bottom: -2rem;
    left: 50%;
    width: 3px;
    height: 2rem;
    background: linear-gradient(to bottom, var(--secondary-color), var(--accent-color));
    transform: translateX(-50%);
}

/* Horizontal line from card center to side vertical */
.hybrid-column>.tree-card::before {
    content: '';
    position: absolute;
    bottom: -2rem;
    left: -60px;
    width: calc(50% + 60px);
    height: 3px;
    background: linear-gradient(to right, var(--secondary-color), var(--accent-color));
    z-index: -1;
}

/* Vertical Line on Left Side of Column */
.column-connector-vertical {
    position: absolute;
    left: 0;
    top: 0;
    bottom: 20px;
    width: 3px;
    background: linear-gradient(to bottom, var(--secondary-color), var(--accent-color));
    border-radius: 2px;
}

/* Children List within Column */
.column-children-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

/* Individual Child Item */
.column-child-item {
    position: relative;
    display: flex;
    align-items: center;
}

/* Horizontal Connector from Vertical Line to Card */
.column-child-connector {
    position: absolute;
    left: -50px;
    top: 50%;
    width: 50px;
    height: 3px;
    background: linear-gradient(to right, var(--secondary-color), var(--accent-color));
    transform: translateY(-50%);
}

/* Last Child - Stop Vertical Line */
/* .column-child-connector.last-child::after {
    content: '';
    position: absolute;
    left: -53px;
    top: 50%;
    bottom: -1000px;
    width: 3px;
    background: #f5f7f4;
    z-index: 1;
} */

/* Responsive Hybrid View */
@media (max-width: 1200px) {
    .hybrid-columns-container {
        gap: 1.5rem;
    }

    .hybrid-column {
        max-width: 350px;
    }
}

@media (max-width: 992px) {
    .hybrid-horizontal-line {
        left: 10%;
        right: 10%;
    }

    .hybrid-columns-container {
        flex-direction: column;
        align-items: center;
        gap: 3rem;
    }

    .hybrid-column {
        max-width: 500px;
        width: 100%;
    }

    .hybrid-horizontal-container {
        display: none;
    }

    .hybrid-root-connector {
        height: 30px;
    }
}

@media (max-width: 768px) {
    .organogram-hybrid-view {
        padding: 1rem 0.5rem;
    }

    .column-tree-structure {
        padding-left: 40px;
    }

    .hybrid-column>.tree-card::before {
        left: -40px;
        width: calc(50% + 40px);
    }

    .column-child-connector {
        width: 40px;
        left: -40px;
    }

    .column-child-connector.last-child::after {
        left: -43px;
    }

    .tree-card .org-card {
        max-width: 100%;
    }

    .hybrid-columns-container {
        gap: 2rem;
    }
}

@media (max-width: 576px) {
    .column-tree-structure {
        padding-left: 30px;
    }

    .hybrid-column>.tree-card::before {
        left: -30px;
        width: calc(50% + 30px);
    }

    .column-child-connector {
        width: 30px;
        left: -30px;
    }

    .column-child-connector.last-child::after {
        left: -33px;
    }
}