/*
 * File Name    : portal-struktur-organisasi.css
 * Description  : Org chart — grid puncak 3 kolom, junction, rel Bidang; latar 10% tanpa ungu.
 * Author       : Erwin Youfilandy
 * Date         : 04/05/2026
 * Version      : 1.3.6
 *
 * Revision History :
 * Date        Comments
 * ------------------------------------------------------------------
 * 04/05/2026  Sub Bagian: stretch sel grid; kartu min/max-width + overflow-wrap agar teks di dalam kotak
 * 04/05/2026  Kolom sek: padding bawah tee + vertikal ke tengah klaster; jarak sumbu sedikit diperlebar
 * 04/05/2026  Grid cabang + jarak sumbu; klaster max-width seragam; segmen sumbu selaras variabel tee-y
 * 04/05/2026  Klaster Sekretaris di kanan sumbu; batang tengah tersegmentasi (tidak memotong kotak)
 * 04/05/2026  KJF stack (putus-putus di atas kotak); rel T Sekretaris ke dua Sub Bagian
 * 04/05/2026  Junction sekCol lebar untuk 2 Sub Bagian; klaster Sekretaris + grid 2 kolom (Sekretaris di tengah atas)
 * 04/05/2026  Kepala di kolom tengah; Subbag sejajar; okupansi 0.1; palet biru/hijau/toska (tanpa ungu)
 * 04/05/2026  Catatan: salin perubahan ke public_html/css bila deploy memakai docroot public_html (vite)
 * 04/05/2026  Initial release
 */

.portal-so-wrap {
    overflow-x: auto;
    padding-bottom: 1rem;
    -webkit-overflow-scrolling: touch;
}

.portal-so-chart {
    --so-line: rgba(15, 23, 42, 0.22);
    /* Palet non-ungu: biru gelap, toska, biru muda, biru toska (bidang), ambar (seksi) */
    --so-kepala-rgb: 12, 74, 110;
    --so-sekre-rgb: 13, 116, 106;
    --so-subbag-rgb: 7, 112, 138;
    --so-bidang-rgb: 8, 93, 112;
    --so-seksi-rgb: 180, 83, 9;
    --so-kjf-rgb: 71, 85, 105;
    --so-uptd-rgb: 5, 122, 85;
    --so-fill-opacity: 0.1;
    min-width: min(100%, 72rem);
    margin-inline: auto;
}

/* Lebar inti sama dengan tiga kolom Bidang (48rem) */
.portal-so-chart-core {
    width: 100%;
    max-width: 48rem;
    margin-inline: auto;
    position: relative;
}

/* --- Puncak: 3 kolom — Kepala di tengah (sejajar Bidang Pencatatan Sipil) --- */
.portal-so-puncak-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    max-width: 48rem;
    margin-inline: auto;
    align-items: center;
    gap: 0.5rem 0.65rem;
    margin-bottom: 0.15rem;
}

.portal-so-puncak-grid__left {
    display: flex;
    justify-content: flex-end;
    align-items: center;
    min-width: 0;
}

/* KJF: baris putus-putus di atas, kotak di bawah (bukan sejajar samping) */
.portal-so-puncak-kjfStack {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 0.5rem;
    width: 100%;
    min-width: 0;
}

.portal-so-puncak-kjfBridge {
    display: flex;
    justify-content: flex-end;
    align-items: flex-end;
    width: 100%;
    min-height: 0.35rem;
}

.portal-so-puncak-kjfBox {
    display: flex;
    justify-content: flex-end;
    width: 100%;
}

.portal-so-puncak-grid__mid {
    display: flex;
    justify-content: center;
    align-items: center;
    min-width: 0;
}

.portal-so-puncak-grid__right {
    min-height: 1px;
}

@media (max-width: 767px) {
    .portal-so-puncak-grid {
        grid-template-columns: 1fr;
    }

    .portal-so-puncak-grid__mid {
        order: -1;
    }

    .portal-so-puncak-grid__left {
        justify-content: center;
    }

    .portal-so-puncak-kjfStack {
        align-items: center;
    }

    .portal-so-puncak-kjfBridge {
        justify-content: center;
    }

    .portal-so-puncak-kjfBox {
        justify-content: center;
    }
}

.portal-so-dashed-bridge {
    width: min(100%, 11rem);
    min-width: 3rem;
    height: 0;
    border-bottom: 2px dashed rgba(71, 85, 105, 0.65);
}

.portal-so-vline {
    width: 2px;
    min-height: 0.75rem;
    margin-inline: auto;
    background: var(--so-line);
}

.portal-so-vline--spine {
    min-height: 1.1rem;
}

.portal-so-vline--spine-to-bidang {
    min-height: 1rem;
}

.portal-so-vline--under-sek {
    min-height: 0.65rem;
}

.portal-so-vline--branch {
    min-height: 0.85rem;
}

.portal-so-vline--between-seksi {
    min-height: 0.45rem;
}

/* --- Junction --- */
.portal-so-junction {
    --so-junction-spine-gap: 0.75rem;
    --so-junction-tee-y: 1.85rem;
    /* Ruang vertikal di bawah cabang horizontal sebelum konten klaster (garis tidak memotong kotak) */
    --so-sek-col-pad-top: calc(var(--so-junction-tee-y) + 0.5rem);
    --so-sek-cluster-max: 38.5rem;
    position: relative;
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
    min-height: 6rem;
    padding-bottom: 0.35rem;
}

/* Segmen atas sumbu: tepat sampai ketinggian cabang horizontal (selaras margin-top teeH) */
.portal-so-junction__lineThrough {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: 0;
    bottom: auto;
    height: calc(var(--so-junction-tee-y) + 1px);
    width: 2px;
    background: var(--so-line);
    z-index: 0;
    pointer-events: none;
}

/* Sambungan sumbu ke batang menuju Bidang (bawah junction) */
.portal-so-junction__spineStubBottom {
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    bottom: 0;
    width: 2px;
    height: 1rem;
    background: var(--so-line);
    z-index: 0;
    pointer-events: none;
}

.portal-so-junction__body {
    position: relative;
    z-index: 1;
}

/*
 * Cabang ke Sekretaris: grid dua kolom (tee | klaster). Klaster mulai di kanan sumbu + jarak (--so-junction-spine-gap).
 * teeH ditarik sedikit ke kiri agar tetap menyambung sumbu tanpa kotak menimpa garis tengah.
 */
.portal-so-junction__teeRow {
    display: grid;
    box-sizing: border-box;
    grid-template-columns: clamp(1.35rem, 5vw, 3rem) minmax(0, 1fr);
    align-items: start;
    column-gap: 0;
    margin-left: calc(50% + var(--so-junction-spine-gap));
    width: calc(50% - var(--so-junction-spine-gap));
    max-width: calc(50% - var(--so-junction-spine-gap));
    min-width: 0;
}

.portal-so-junction__teeH {
    grid-column: 1;
    grid-row: 1;
    margin-top: var(--so-junction-tee-y);
    margin-left: calc(-1 * var(--so-junction-spine-gap));
    width: calc(100% + var(--so-junction-spine-gap));
    min-width: 0;
    height: 2px;
    background: var(--so-line);
}

.portal-so-junction__sekCol {
    position: relative;
    z-index: 1;
    grid-column: 2;
    grid-row: 1;
    display: flex;
    flex-direction: column;
    align-items: stretch;
    gap: 0;
    width: 100%;
    min-width: 0;
    padding-top: var(--so-sek-col-pad-top);
    box-sizing: border-box;
}

/* Batang pendek dari cabang horizontal ke tengah atas klaster (sambungan ke «top-center» Sekretaris) */
.portal-so-junction__sekCol::before {
    content: '';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    top: calc(var(--so-junction-tee-y) + 1px);
    z-index: 0;
    width: 2px;
    height: max(0.35rem, calc(var(--so-sek-col-pad-top) - var(--so-junction-tee-y) - 2px));
    background: var(--so-line);
    pointer-events: none;
}

@media (max-width: 720px) {
    .portal-so-junction__teeRow {
        display: flex;
        flex-direction: column;
        align-items: center;
        margin-left: 0;
        width: 100%;
        max-width: 100%;
    }

    .portal-so-junction__teeH {
        margin-left: 0;
        margin-top: var(--so-junction-tee-y);
        width: clamp(2.5rem, 28vw, 4rem);
    }

    .portal-so-junction__sekCol {
        width: 100%;
        padding-top: 0;
    }

    .portal-so-junction__sekCol::before {
        content: none;
    }
}

/*
 * Klaster: lebar maks sama untuk kepala, rel T, dan Sub Bagian → pusat kartu Sekretaris = pusat celah dua Sub Bagian.
 */
.portal-so-sekretaris-cluster {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: min(100%, var(--so-sek-cluster-max, 38.5rem));
    margin-inline: auto;
}

.portal-so-sekretaris-cluster__head {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: min(100%, var(--so-sek-cluster-max, 38.5rem));
}

.portal-so-sekretaris-cluster__head > .portal-so-card-wrap {
    width: 100%;
    max-width: 18rem;
}

/* Batang dari Sekretaris + rel horizontal + turunan ke atas kartu Sub Bagian */
.portal-so-sekretaris-cluster__tee {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
    max-width: min(100%, var(--so-sek-cluster-max, 38.5rem));
}

.portal-so-sekretaris-cluster__teeRail {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    width: 100%;
}

.portal-so-sekretaris-cluster__teeRailH {
    width: 100%;
    height: 0;
    border-top: 2px solid var(--so-line);
}

.portal-so-sekretaris-cluster__teeRailCells {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    width: 100%;
}

.portal-so-sekretaris-cluster__teeRailCell {
    display: flex;
    justify-content: center;
}

.portal-so-sekretaris-cluster__teeDrop {
    display: block;
    width: 2px;
    height: 0.5rem;
    background: var(--so-line);
}

/* Sub Bagian: grid dua kolom sama lebar, kartu di tengah masing-masing sel (lebar blok = rel T di atas) */
.portal-so-subbags {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    column-gap: 0.75rem;
    row-gap: 0.75rem;
    width: 100%;
    max-width: min(100%, var(--so-sek-cluster-max, 38.5rem));
    align-items: start;
    justify-items: stretch;
}

.portal-so-subbags > .portal-so-card-wrap {
    width: 100%;
    max-width: 100%;
    min-width: 0;
}

.portal-so-subbags > .portal-so-card-wrap:only-child {
    grid-column: 1 / -1;
    justify-self: center;
}

@media (max-width: 520px) {
    .portal-so-subbags {
        grid-template-columns: 1fr;
    }
}

/* --- Rel tiga Bidang --- */
.portal-so-bidang-tier {
    width: 100%;
    max-width: 100%;
    margin-inline: auto;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.portal-so-bidang-tier__rail {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    width: 100%;
    border-top: 2px solid var(--so-line);
}

.portal-so-bidang-tier__cell {
    display: flex;
    justify-content: center;
}

.portal-so-bidang-tier__drop {
    display: block;
    width: 2px;
    height: 0.65rem;
    background: var(--so-line);
}

.portal-so-bidang-cols {
    display: grid;
    gap: 1rem 0.75rem;
    width: 100%;
    grid-template-columns: 1fr;
    padding-top: 0;
    margin-top: 0;
}

@media (min-width: 992px) {
    .portal-so-bidang-cols {
        grid-template-columns: repeat(3, minmax(0, 1fr));
        align-items: start;
    }
}

.portal-so-col {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
}

.portal-so-branch {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
}

.portal-so-stack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0;
    width: 100%;
}

.portal-so-stack__node {
    width: 100%;
    display: flex;
    justify-content: center;
}

/* --- Kotak label (KJF, UPTD) --- */
.portal-so-kotak-wrap {
    width: 100%;
    max-width: 15rem;
    display: flex;
    justify-content: center;
}

.portal-so-kotak {
    width: 100%;
    text-align: center;
    padding: 0.85rem 1rem;
    border-radius: 0.55rem;
    border: 1px solid rgba(15, 23, 42, 0.14);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}

.portal-so-kotak__label {
    display: block;
    font-size: 0.68rem;
    font-weight: 800;
    line-height: 1.35;
    letter-spacing: 0.04em;
    text-transform: uppercase;
    color: #0f172a;
}

.portal-so-kotak--kjf {
    background-color: rgba(var(--so-kjf-rgb), var(--so-fill-opacity));
    border-color: rgba(var(--so-kjf-rgb), 0.35);
}

.portal-so-kotak--uptd {
    background-color: rgba(var(--so-uptd-rgb), var(--so-fill-opacity));
    border-color: rgba(var(--so-uptd-rgb), 0.35);
}

/* --- Kartu jabatan --- */
.portal-so-card-wrap {
    width: 100%;
    max-width: 18rem;
}

.portal-so-card {
    display: flex;
    gap: 0.65rem;
    align-items: stretch;
    box-sizing: border-box;
    min-width: 0;
    max-width: 100%;
    width: 100%;
    text-decoration: none;
    color: #0f172a;
    border-radius: 0.65rem;
    padding: 0.55rem 0.65rem;
    border: 1px solid rgba(15, 23, 42, 0.12);
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    transition: border-color 0.15s ease, box-shadow 0.15s ease, transform 0.12s ease;
}

.portal-so-card:hover {
    border-color: rgba(0, 146, 213, 0.35);
    box-shadow: 0 3px 12px rgba(0, 146, 213, 0.1);
    transform: translateY(-1px);
    color: inherit;
}

.portal-so-card:focus-visible {
    outline: 2px solid var(--siak-accent-admin, #0092d5);
    outline-offset: 2px;
}

.portal-so-card--muted {
    cursor: not-allowed;
    opacity: 0.78;
}

.portal-so-card--muted:hover {
    transform: none;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.portal-so-card__muted-note {
    color: #334155;
    opacity: 0.9;
}

.portal-so-card--kepala {
    background-color: rgba(var(--so-kepala-rgb), var(--so-fill-opacity));
    border-color: rgba(var(--so-kepala-rgb), 0.32);
}

.portal-so-card--sekretaris {
    background-color: rgba(var(--so-sekre-rgb), var(--so-fill-opacity));
    border-color: rgba(var(--so-sekre-rgb), 0.32);
}

.portal-so-card--subbag {
    background-color: rgba(var(--so-subbag-rgb), var(--so-fill-opacity));
    border-color: rgba(var(--so-subbag-rgb), 0.32);
}

.portal-so-card--bidang {
    background-color: rgba(var(--so-bidang-rgb), var(--so-fill-opacity));
    border-color: rgba(var(--so-bidang-rgb), 0.32);
}

.portal-so-card--seksi {
    background-color: rgba(var(--so-seksi-rgb), var(--so-fill-opacity));
    border-color: rgba(var(--so-seksi-rgb), 0.32);
}

.portal-so-card__photo {
    flex-shrink: 0;
    width: 3.25rem;
    height: 4rem;
    border-radius: 0.35rem;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    font-size: 0.6rem;
    font-weight: 700;
    text-align: center;
    line-height: 1.15;
    padding: 0.15rem;
    background: rgba(255, 255, 255, 0.55);
    border: 1px solid rgba(15, 23, 42, 0.1);
    color: #475569;
}

.portal-so-card__photo img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.portal-so-card__body {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    overflow-wrap: anywhere;
}

.portal-so-card__jabatan {
    font-size: 0.68rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    line-height: 1.25;
    color: #0f172a;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.portal-so-card__nama {
    font-size: 0.78rem;
    font-weight: 600;
    color: #1e293b;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.portal-so-card__nama--placeholder {
    color: #64748b;
    font-weight: 500;
    font-style: italic;
}

.portal-so-card__nip {
    font-size: 0.72rem;
    color: #334155;
    overflow-wrap: anywhere;
    word-break: break-word;
}

.portal-so-page-title {
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 0.25rem;
}

.portal-so-back {
    font-size: 0.9rem;
}

.portal-so-bio {
    font-size: 0.95rem;
    line-height: 1.65;
    color: #1e293b;
}

.portal-so-bio :is(h2, h3, h4) {
    margin-top: 1rem;
    margin-bottom: 0.5rem;
    font-weight: 700;
}

.portal-so-bio p {
    margin-bottom: 0.65rem;
}

.portal-so-bio ul,
.portal-so-bio ol {
    padding-left: 1.25rem;
}

.portal-orgchart-shell {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 0.75rem;
    background: #ffffff;
    padding: 0.5rem;
}

.portal-orgchart-canvas {
    min-height: 42rem;
    width: 100%;
}
