/**
 * UNCM Org Chart - Frontend Styles
 * Fully Scoped & Isolated to prevent conflicts with WordPress / Divi themes
 */

.uncm-wrapper {
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif !important;
    background: #ffffff;
    padding: 28px 20px;
    margin: 20px auto;
    max-width: 1350px;
    border-radius: 16px;
    box-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
    border: 1px solid #e2e8f0;
    box-sizing: border-box;
    color: #0f172a;
    position: relative;
}

.uncm-wrapper * {
    box-sizing: border-box;
}

/* HEADER */
.uncm-header {
    text-align: center;
    margin-bottom: 24px;
}

.uncm-tag {
    display: inline-block;
    font-size: 11px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    padding: 4px 14px;
    border-radius: 9999px;
    background: #eff6ff;
    color: #1d4ed8;
    border: 1px solid #dbeafe;
    margin-bottom: 8px;
}

.uncm-title {
    font-size: 24px !important;
    font-weight: 800 !important;
    color: #0f2c4d !important;
    letter-spacing: -0.01em;
    margin: 0 0 6px 0 !important;
    text-transform: uppercase;
    line-height: 1.2 !important;
}

.uncm-subtitle {
    font-size: 14px !important;
    font-weight: 600 !important;
    color: #475569 !important;
    margin: 0 !important;
}

/* TOOLBAR */
.uncm-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 18px;
    padding: 12px 18px;
    background: #f8fafc;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
}

.uncm-status {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #0f766e;
}

.uncm-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #0d9488;
    display: inline-block;
}

/* ZOOM CONTROLS */
.uncm-zoom-controls {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #ffffff;
    padding: 4px 8px;
    border-radius: 8px;
    border: 1px solid #cbd5e1;
}

.uncm-zoom-level {
    font-size: 12px;
    font-weight: 700;
    min-width: 44px;
    text-align: center;
    color: #1e293b;
}

.uncm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 7px 12px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 7px;
    border: 1px solid #cbd5e1;
    background: #ffffff;
    color: #1e293b;
    cursor: pointer;
    transition: all 0.15s ease;
    line-height: 1;
}

.uncm-btn:hover {
    background: #f1f5f9;
    border-color: #94a3b8;
}

.uncm-btn-icon {
    width: 26px;
    height: 26px;
    padding: 0;
}

.uncm-btn-sm {
    padding: 5px 8px;
    font-size: 11px;
}

.uncm-btn-primary {
    background: #0f2c4d;
    border-color: #0f2c4d;
    color: #ffffff;
}

.uncm-btn-primary:hover {
    background: #1e3a5f;
    border-color: #1e3a5f;
    color: #ffffff;
}

/* TABS BAR */
.uncm-tabs-bar {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid #e2e8f0;
}

.uncm-tab-btn {
    padding: 8px 16px;
    font-size: 12.5px;
    font-weight: 600;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    background: #f8fafc;
    color: #475569;
    cursor: pointer;
    transition: all 0.15s ease;
}

.uncm-tab-btn:hover {
    background: #f1f5f9;
    color: #0f2c4d;
}

.uncm-tab-btn.active {
    background: #0f2c4d;
    color: #ffffff;
    border-color: #0f2c4d;
    box-shadow: 0 2px 6px rgba(15, 44, 77, 0.2);
}

/* CANVAS CONTAINER */
.uncm-canvas-outer {
    width: 100%;
    overflow: auto;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    padding: 24px;
    -webkit-overflow-scrolling: touch;
    cursor: grab;
    user-select: none;
    position: relative;
    min-height: 480px;
}

.uncm-canvas-outer.is-dragging {
    cursor: grabbing;
}

.uncm-canvas-viewport {
    transform-origin: 50% 0;
    transition: transform 0.1s ease-out;
    display: flex;
    flex-direction: column;
    gap: 40px;
    min-width: 1050px;
}

/* SECTION HEADINGS */
.uncm-section {
    display: none;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.uncm-section.active {
    display: flex;
}

.uncm-section-title-wrap {
    text-align: center;
    margin-bottom: 24px;
    padding-bottom: 10px;
    border-bottom: 2px solid #e2e8f0;
    width: 100%;
    max-width: 800px;
}

.uncm-sec-title {
    font-size: 18px !important;
    font-weight: 800 !important;
    color: #0f2c4d !important;
    margin: 0 0 4px 0 !important;
    letter-spacing: 0.04em;
}

.uncm-sec-sub {
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
}

/* =========================================================================
   CARD DESIGN (Vector Crisp)
   ========================================================================= */
.uncm-card-node {
    width: 190px;
    background: #ffffff;
    border: 1.5px solid var(--card-accent, #0f2c4d);
    border-radius: 10px;
    box-shadow: 0 3px 10px rgba(15, 23, 42, 0.05);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    text-align: center;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    margin: 0 auto;
}

.uncm-card-node:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.1);
}

.uncm-card-header {
    background: var(--card-accent, #0f2c4d);
    color: #ffffff;
    padding: 5px 8px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    min-height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1.2;
}

.uncm-card-body {
    padding: 8px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    background: #fafbfc;
}

.uncm-avatar-wrapper {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    overflow: hidden;
    border: 2px solid #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.12);
    background: #e2e8f0;
    flex-shrink: 0;
}

.uncm-avatar-img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover !important;
    display: block !important;
}

.uncm-card-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    width: 100%;
}

.uncm-card-name {
    font-size: 11.5px;
    font-weight: 700;
    color: #1e293b;
    line-height: 1.25;
    word-break: break-word;
}

.uncm-card-empty .uncm-card-name {
    color: #94a3b8;
    font-style: italic;
    font-weight: 500;
}

.uncm-card-badge {
    font-size: 9.5px;
    font-weight: 600;
    color: #64748b;
    line-height: 1.1;
}

/* =========================================================================
   TREE HIERARCHY (Vector Connectors with pure CSS)
   ========================================================================= */
.uncm-tree-wrap {
    width: 100%;
    display: flex;
    justify-content: center;
}

.uncm-tree ul {
    padding-top: 24px;
    position: relative;
    transition: all 0.5s;
    display: flex;
    justify-content: center;
    margin: 0;
    padding-left: 0;
    list-style: none;
}

.uncm-tree li {
    float: left;
    text-align: center;
    list-style-type: none;
    position: relative;
    padding: 24px 8px 0 8px;
    transition: all 0.5s;
}

/* Horizontal connectors */
.uncm-tree li::before, .uncm-tree li::after {
    content: '';
    position: absolute;
    top: 0;
    right: 50%;
    border-top: 2px solid #0f2c4d;
    width: 50%;
    height: 24px;
}

.uncm-tree li::after {
    right: auto;
    left: 50%;
    border-left: 2px solid #0f2c4d;
}

/* Remove connectors from only child / extremities */
.uncm-tree li:only-child::after, .uncm-tree li:only-child::before {
    display: none;
}

.uncm-tree li:only-child {
    padding-top: 0;
}

.uncm-tree li:first-child::before, .uncm-tree li:last-child::after {
    border: 0 none;
}

.uncm-tree li:last-child::before {
    border-right: 2px solid #0f2c4d;
    border-radius: 0 6px 0 0;
}

.uncm-tree li:first-child::after {
    border-radius: 6px 0 0 0;
}

/* Down connectors from parents */
.uncm-tree ul ul::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    border-left: 2px solid #0f2c4d;
    width: 0;
    height: 24px;
}

.uncm-branch-label {
    display: inline-block;
    padding: 3px 8px;
    font-size: 10px;
    font-weight: 700;
    background: #f1f5f9;
    color: #475569;
    border-radius: 4px;
    margin-bottom: 8px;
    border: 1px solid #e2e8f0;
}

.uncm-subgroup-row {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.uncm-subgroup-col {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.uncm-subgroup-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    justify-content: center;
    max-width: 900px;
}

.uncm-unit-card-box {
    display: flex;
    flex-direction: column;
    gap: 6px;
    width: 175px;
}

.uncm-unit-card-box .uncm-card-node {
    width: 100%;
}

/* =========================================================================
   FAKULTAS SECTION
   ========================================================================= */
.uncm-fakultas-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
    width: 100%;
    max-width: 1000px;
    margin: 0 auto;
}

.uncm-fakultas-column {
    background: #f8fafc;
    border: 1px solid #cbd5e1;
    border-radius: 12px;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

.uncm-fakultas-banner {
    padding: 10px;
    border-radius: 8px;
    color: #ffffff;
    font-weight: 800;
    font-size: 13.5px;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

.uncm-banner-fkip {
    background: #003595;
}

.uncm-banner-fst {
    background: #004ed6;
}

.uncm-fakultas-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.uncm-pair-row {
    display: flex;
    gap: 10px;
}

.uncm-pair-row .uncm-card-node {
    flex: 1;
}

/* =========================================================================
   PROGRAM STUDI SECTION
   ========================================================================= */
.uncm-prodi-grid {
    display: grid;
    grid-template-columns: repeat(6, 1fr);
    gap: 12px;
    width: 100%;
}

@media (max-width: 1200px) {
    .uncm-prodi-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

.uncm-prodi-column {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.uncm-prodi-header {
    padding: 8px 6px;
    text-align: center;
    color: #ffffff;
}

.uncm-header-fkip {
    background: #003595;
}

.uncm-header-fst {
    background: #004ed6;
}

.uncm-prodi-badge {
    display: inline-block;
    padding: 2px 6px;
    background: rgba(255, 255, 255, 0.25);
    border-radius: 4px;
    font-size: 9.5px;
    font-weight: 700;
    margin-bottom: 2px;
}

.uncm-prodi-header h5 {
    font-size: 11px !important;
    font-weight: 800 !important;
    margin: 0 !important;
    color: #ffffff !important;
    line-height: 1.2 !important;
}

.uncm-prodi-cards {
    padding: 10px 6px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.uncm-prodi-cards .uncm-card-node {
    width: 100%;
}

/* =========================================================================
   PEGAWAI STRUKTURAL TANPA JABATAN
   ========================================================================= */
.uncm-tanpa-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(185px, 1fr));
    gap: 16px;
    width: 100%;
    max-width: 1100px;
    margin: 0 auto;
}

/* LEGENDA LUAR */
.uncm-legend-bar {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 20px;
    margin-top: 24px;
    padding: 12px 18px;
    background: #f8fafc;
    border-radius: 10px;
    border: 1px solid #edf2f7;
}

.uncm-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #334155;
}

.uncm-legend-line {
    width: 28px;
    height: 2.5px;
    background: #0f2c4d;
    position: relative;
}

.uncm-legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.uncm-dot-pimpinan {
    background: #0f2c4d;
}

.uncm-dot-fakultas {
    background: #004ed6;
}

.uncm-dot-upt {
    background: #4338ca;
}
