@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=Lora:ital@0;1&display=swap');

:root {
    --sppg-green:    #2d7a4f;
    --sppg-green-lt: #e8f5ee;
    --sppg-gold:     #c8962a;
    --sppg-gold-lt:  #fdf6e3;
    --sppg-bg:       #f7faf8;
    --sppg-text:     #1a2b22;
    --sppg-muted:    #6b8577;
    --sppg-border:   #b8d9c5;
    --sppg-radius:   12px;
    --sppg-shadow:   0 4px 20px rgba(45,122,79,.12);
    --sppg-line:     #7ec8a0;
}

.sppg-wrap {
    font-family: 'Plus Jakarta Sans', sans-serif;
    color: var(--sppg-text);
    background: var(--sppg-bg);
    border-radius: 16px;
    padding: 32px 24px 40px;
    max-width: 100%;
    overflow-x: auto;
}

/* ─── HEADER ─── */
.sppg-header {
    display: flex;
    align-items: center;
    gap: 16px;
    margin-bottom: 40px;
    padding-bottom: 24px;
    border-bottom: 2px solid var(--sppg-border);
    flex-wrap: wrap;
}
.sppg-logo-icon { font-size: 3rem; line-height: 1; filter: drop-shadow(0 2px 6px rgba(45,122,79,.3)); }
.sppg-header > div:nth-child(2) { flex: 1; }
.sppg-header h2 { margin: 0 0 4px; font-size: 1.6rem; font-weight: 700; color: var(--sppg-green); letter-spacing: -.5px; }
.sppg-header p  { margin: 0; font-size: .92rem; color: var(--sppg-muted); line-height: 1.5; }
.sppg-header small { font-family: 'Lora', serif; font-style: italic; font-size: .82rem; }

/* Export buttons */
.sppg-export-btns { display: flex; gap: 8px; flex-shrink: 0; }
.sppg-btn-export, .sppg-btn-print {
    background: var(--sppg-green); color: #fff;
    border: none; border-radius: 8px;
    padding: 8px 14px; font-size: .82rem; font-weight: 600;
    cursor: pointer; transition: background .2s, transform .15s;
    font-family: inherit;
}
.sppg-btn-print { background: var(--sppg-gold); }
.sppg-btn-export:hover { background: #1e5c38; transform: translateY(-1px); }
.sppg-btn-print:hover  { background: #a07520; transform: translateY(-1px); }
.sppg-btn-export:disabled { opacity: .6; cursor: wait; }

/* ─── TREE ─── */
.sppg-tree { display: flex; justify-content: center; }
.sppg-level {
    list-style: none; margin: 0; padding: 0;
    display: flex; flex-direction: column; align-items: center;
    position: relative;
}
.sppg-depth-0 { flex-direction: row; flex-wrap: wrap; gap: 0 24px; justify-content: center; }
.sppg-node {
    display: flex; flex-direction: column; align-items: center;
    position: relative; padding-top: 28px;
}
.sppg-node::before {
    content: ''; position: absolute; top: 0; left: 50%; transform: translateX(-50%);
    width: 2px; height: 28px; background: var(--sppg-line);
}
.sppg-depth-0 > .sppg-node::before { display: none; }
.sppg-level:not(.sppg-depth-0) > .sppg-node:not(:only-child)::after {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 2px; background: var(--sppg-line);
}
.sppg-level:not(.sppg-depth-0) > .sppg-node:first-child:not(:only-child)::after { left: 50%; }
.sppg-level:not(.sppg-depth-0) > .sppg-node:last-child:not(:only-child)::after  { right: 50%; }

/* ─── CARD ─── */
.sppg-card {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    background: #fff; border: 1.5px solid var(--sppg-border);
    border-radius: var(--sppg-radius); padding: 20px 16px 14px;
    width: 160px; min-height: 140px;
    box-shadow: var(--sppg-shadow);
    transition: transform .2s, box-shadow .2s;
    cursor: pointer; position: relative; overflow: hidden;
}
.sppg-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, var(--sppg-green), var(--sppg-gold));
}
.sppg-card:hover { transform: translateY(-5px); box-shadow: 0 12px 32px rgba(45,122,79,.22); }

.sppg-depth-0 > .sppg-node > .sppg-card {
    width: 190px;
    background: linear-gradient(160deg, #fff 70%, var(--sppg-gold-lt));
    border-color: var(--sppg-gold);
}
.sppg-depth-0 > .sppg-node > .sppg-card::before {
    background: linear-gradient(90deg, var(--sppg-gold), var(--sppg-green)); height: 5px;
}

/* Hint klik */
.sppg-card-hint {
    font-size: .65rem; color: var(--sppg-muted); margin-top: 6px;
    opacity: 0; transition: opacity .2s;
}
.sppg-card:hover .sppg-card-hint { opacity: 1; }

/* ─── FOTO / AVATAR ─── */
.sppg-foto { margin-bottom: 10px; }
.sppg-foto img {
    width: 64px; height: 64px; border-radius: 50%; object-fit: cover;
    border: 3px solid var(--sppg-green-lt); box-shadow: 0 2px 8px rgba(45,122,79,.2);
}
.sppg-avatar-placeholder {
    width: 64px; height: 64px; border-radius: 50%;
    background: linear-gradient(135deg, var(--sppg-green), #1a4d30);
    color: #fff; font-size: 1.6rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 10px rgba(45,122,79,.3);
}
.sppg-depth-0 > .sppg-node > .sppg-card .sppg-avatar-placeholder {
    background: linear-gradient(135deg, var(--sppg-gold), #8a6010);
    width: 74px; height: 74px; font-size: 1.9rem;
}

/* ─── INFO ─── */
.sppg-info { display: flex; flex-direction: column; gap: 3px; }
.sppg-info strong { font-size: .82rem; font-weight: 700; line-height: 1.3; color: var(--sppg-text); }
.sppg-jabatan {
    font-size: .74rem; font-weight: 600; color: var(--sppg-green);
    background: var(--sppg-green-lt); border-radius: 20px;
    padding: 2px 8px; margin-top: 2px; display: inline-block;
}

/* ─── CHILDREN ─── */
.sppg-node > .sppg-level {
    margin-top: 0; flex-direction: row; flex-wrap: wrap;
    justify-content: center; gap: 0 16px;
}

/* ─── MODAL ─── */
.sppg-modal-overlay {
    display: none; position: fixed; inset: 0;
    background: rgba(10,30,18,.6); backdrop-filter: blur(4px);
    z-index: 99999; align-items: center; justify-content: center;
    padding: 20px;
}
.sppg-modal-overlay.active { display: flex; }

.sppg-modal {
    background: #fff; border-radius: 20px;
    padding: 32px 28px 28px; max-width: 400px; width: 100%;
    box-shadow: 0 24px 60px rgba(0,0,0,.25);
    position: relative; text-align: center;
    animation: sppgModalIn .25s ease;
}
@keyframes sppgModalIn {
    from { opacity: 0; transform: scale(.92) translateY(16px); }
    to   { opacity: 1; transform: scale(1)  translateY(0); }
}

.sppg-modal-close {
    position: absolute; top: 14px; right: 16px;
    background: #f0f0f0; border: none; border-radius: 50%;
    width: 30px; height: 30px; cursor: pointer;
    font-size: 1rem; line-height: 30px; padding: 0;
    transition: background .15s;
}
.sppg-modal-close:hover { background: #e0e0e0; }

.sppg-modal-foto { margin-bottom: 16px; }
.sppg-modal-foto img {
    width: 100px; height: 100px; border-radius: 50%; object-fit: cover;
    border: 4px solid var(--sppg-green-lt); box-shadow: 0 4px 16px rgba(45,122,79,.2);
}
.sppg-modal-avatar {
    width: 100px; height: 100px; border-radius: 50%; margin: 0 auto;
    background: linear-gradient(135deg, var(--sppg-green), #1a4d30);
    color: #fff; font-size: 2.8rem; font-weight: 700;
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 4px 16px rgba(45,122,79,.25);
}

.sppg-modal-nama { margin: 0 0 6px; font-size: 1.2rem; font-weight: 700; color: var(--sppg-text); }
.sppg-modal-jabatan {
    display: inline-block; background: var(--sppg-green-lt);
    color: var(--sppg-green); font-weight: 600; font-size: .85rem;
    border-radius: 20px; padding: 3px 14px; margin-bottom: 14px;
}
.sppg-modal-ket {
    font-family: 'Lora', serif; font-style: italic;
    color: var(--sppg-muted); font-size: .9rem; margin: 0 0 14px; line-height: 1.5;
}
.sppg-modal-kontak { display: flex; flex-direction: column; gap: 6px; }
.sppg-kontak-item {
    display: block; color: var(--sppg-green); text-decoration: none;
    font-size: .87rem; font-weight: 500; padding: 6px 12px;
    background: var(--sppg-green-lt); border-radius: 8px;
    transition: background .15s;
}
.sppg-kontak-item:hover { background: #c3e8d3; }

/* ─── PRINT ─── */
@media print {
    .sppg-export-btns { display: none !important; }
    .sppg-modal-overlay { display: none !important; }
    .sppg-wrap { background: #fff; box-shadow: none; }
}

/* ─── RESPONSIVE ─── */
@media (max-width: 640px) {
    .sppg-wrap { padding: 20px 12px 28px; }
    .sppg-card { width: 130px; padding: 16px 10px 12px; min-height: 120px; }
    .sppg-depth-0 > .sppg-node > .sppg-card { width: 150px; }
    .sppg-info strong { font-size: .76rem; }
    .sppg-jabatan { font-size: .68rem; }
    .sppg-avatar-placeholder, .sppg-foto img { width: 52px; height: 52px; font-size: 1.3rem; }
    .sppg-export-btns { width: 100%; }
    .sppg-btn-export, .sppg-btn-print { flex: 1; text-align: center; }
}
