/* ============================================================
   ORGANIZATION CHART - TREE DIAGRAM (HORIZONTAL CARD)
   ============================================================ */

.org-chart-container {
    width: 100%;
    overflow-x: auto;
    padding: 20px 0;
}

.org-chart {
    display: flex;
    justify-content: center;
    min-width: fit-content;
    padding: 10px;
}

/* ---------- TREE STRUCTURE ---------- */
.org-chart ul {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0;
    margin: 0;
    list-style: none;
    position: relative;
}

/* Level yang memiliki parent (bukan root) */
.org-chart ul ul {
    flex-direction: row;
    flex-wrap: nowrap;
    justify-content: center;
    align-items: stretch;
    padding-top: 20px;
    position: relative;
    gap: 20px; /* jarak antar node */
}

/* ---------- VERTICAL LINE: parent → children wrapper ---------- */
.org-chart ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #94a3b8;
    transform: translateX(-50%);
}

/* ---------- NODE (li) ---------- */
.org-chart li {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding: 0;
    flex: 0 0 auto;
}

/* ---------- CARD (horizontal) ---------- */
.node-card {
    display: flex;
    flex-direction: row;
    align-items: center;
    gap: 12px;
    background: #ffffff;
    border-radius: 12px;
    padding: 12px 20px;
    min-width: 280px;
    max-width: 280px;
    min-height: 90px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.08);
    border: 1px solid #e2e8f0;
    transition: all 0.2s ease;
    position: relative;
    z-index: 2;
}

.org-chart ul ul .node-card {
    margin-top: 20px;
}

.node-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    border-color: #3b82f6;
}

.node-avatar {
    width: 70px;
    height: 70px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid #bfdbfe;
    flex-shrink: 0;
}

.node-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.node-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
    flex: 1;
    min-width: 0;
}

.node-name {
    font-weight: 700;
    font-size: 0.95rem;
    color: #1e293b;
    line-height: 1.2;
    word-break: break-word;
}

.node-position {
    font-size: 0.8rem;
    color: #3b82f6;
    font-weight: 500;
    margin-top: 2px;
}

/* ---------- HORIZONTAL LINE: antar sibling (lurus & presisi) ---------- */
.org-chart ul ul li::before,
.org-chart ul ul li::after {
    content: '';
    position: absolute;
    top: 0;
    height: 2px;
    width: calc(50% + 10px);   /* setengah lebar node + setengah gap */
    background: #94a3b8;
}

/* Konektor ke kiri – ujung kanan di tengah node */
.org-chart ul ul li::before {
    right: 50%;
    left: auto;                /* hapus pengaruh left jika ada */
    transform: none;           /* tidak perlu translasi */
}

/* Konektor ke kanan – ujung kiri di tengah node */
.org-chart ul ul li::after {
    left: 50%;
    right: auto;
    transform: none;
}

/* ---------- HAPUS GARIS UNTUK NODE PERTAMA & TERAKHIR ---------- */
.org-chart ul ul li:first-child::before {
    display: none;
}
.org-chart ul ul li:last-child::after {
    display: none;
}
.org-chart ul ul li:only-child::before,
.org-chart ul ul li:only-child::after {
    display: none;
}

/* ---------- VERTICAL LINE: node → ke atas ---------- */
.org-chart ul ul li > .node-card::before {
    content: '';
    position: absolute;
    top: -20px;
    left: 50%;
    width: 2px;
    height: 20px;
    background: #94a3b8;
    transform: translateX(-50%);
}

/* ---------- DARK MODE ---------- */
.dark .node-card {
    background: #1e293b;
    border-color: #334155;
}
.dark .node-name {
    color: #f1f5f9;
}
.dark .node-position {
    color: #60a5fa;
}
.dark .org-chart ul ul::before,
.dark .org-chart ul ul li::before,
.dark .org-chart ul ul li::after,
.dark .org-chart ul ul li > .node-card::before {
    background: #475569;
}

/* ---------- RESPONSIVE ---------- */
@media (max-width: 768px) {
    .org-chart ul ul {
        flex-direction: column;
        flex-wrap: wrap;
        align-items: center;
        gap: 10px;
        padding-top: 10px;
    }
    .org-chart ul ul::before,
    .org-chart ul ul li::before,
    .org-chart ul ul li::after,
    .org-chart ul ul li > .node-card::before {
        display: none;
    }
    .org-chart ul ul .node-card {
        margin-top: 0;
    }
    .org-chart li {
        padding: 10px 0;
    }
    .node-card {
        min-width: 200px;
        max-width: 200px;
        padding: 10px 14px;
        flex-direction: row;
        gap: 8px;
    }
    .node-avatar {
        width: 40px;
        height: 40px;
    }
    .node-name {
        font-size: 0.8rem;
    }
    .node-position {
        font-size: 0.7rem;
    }
}