﻿.org-page {
    --org-primary: #013f6e;
    --org-primary-dark: #002f53;
    --org-line: #d9a441;
    --org-border: #d9a441;
    --org-bg: #f5f8fb;
    padding: 24px 0 60px;
    background: var(--org-bg);
    font-family: inherit !important;
}

    .org-page :where( h1, h2, h3, h4, h5, h6, p, a, span, div, button, input, textarea, select, label ) {
        font-family: inherit !important;
    }

    .org-page * {
        box-sizing: border-box;
    }

/* =========================================================
   Page header
   ========================================================= */

.org-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 18px;
}

.org-page-title {
    margin: 0;
    color: var(--org-primary);
    font-size: clamp(1.25rem, 2vw, 1.7rem);
    font-weight: 800;
}

.org-page-description {
    margin: 7px 0 0;
    color: #687684;
    font-size: .86rem;
    line-height: 1.9;
}

/* =========================================================
   Chart shell and toolbar
   ========================================================= */

.org-chart-shell {
    width: 100%;
    overflow: hidden;
    background: #fff;
    border: 1px solid #e4ebf1;
    border-radius: 18px;
    box-shadow: 0 12px 36px rgba(1, 63, 110, .07);
}

.org-chart-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 12px 16px;
    color: #6b7885;
    background: #f9fbfd;
    border-bottom: 1px solid #e8eef3;
    font-size: .8rem;
}

    .org-chart-toolbar i {
        margin-left: 6px;
        color: var(--org-primary);
    }

.org-mobile-hint {
    display: none;
}

/* =========================================================
   Scroll area
   ========================================================= */

.org-chart-scroll {
    display: block;
    width: 100%;
    min-height: 520px;
    overflow-x: auto;
    overflow-y: visible;
    padding: 30px 22px 52px;
    direction: ltr;
    background: radial-gradient( circle at 1px 1px, rgba(1, 63, 110, .055) 1px, transparent 0 );
    background-size: 22px 22px;
    scrollbar-width: auto;
    scrollbar-color: rgba(1, 63, 110, .5) #edf2f6;
    -webkit-overflow-scrolling: touch;
    overscroll-behavior-x: contain;
}

    .org-chart-scroll::-webkit-scrollbar {
        height: 10px;
    }

    .org-chart-scroll::-webkit-scrollbar-track {
        background: #edf2f6;
        border-radius: 999px;
    }

    .org-chart-scroll::-webkit-scrollbar-thumb {
        background: rgba(1, 63, 110, .5);
        border-radius: 999px;
    }

/* =========================================================
   Main tree
   ========================================================= */

.org-tree {
    display: block;
    width: max-content;
    min-width: max-content;
    margin: 0 auto;
    direction: ltr;
}

    /*
   عمداً از zoom و transform: scale استفاده نشده است.
   مقیاس اعشاری باعث شکسته دیده‌شدن خطوط می‌شود.
*/

    .org-tree ul {
        position: relative;
        display: flex;
        align-items: flex-start;
        justify-content: center;
        margin: 0;
        padding: 28px 0 0;
    }

    .org-tree > ul {
        padding-top: 0;
    }

    .org-tree li {
        position: relative;
        list-style: none;
        text-align: center;
        margin: 0;
        padding: 28px 6px 0;
    }

    .org-tree > ul > li {
        padding-top: 0;
    }

    /* خطوط افقی فرزندان */

    .org-tree li::before,
    .org-tree li::after {
        content: "";
        position: absolute;
        top: 0;
        right: 50%;
        width: 50%;
        height: 28px;
        border-top: 2px solid var(--org-line);
    }

    .org-tree li::after {
        right: auto;
        left: 50%;
        border-left: 2px solid var(--org-line);
    }

    /* گره اصلی خط بالایی ندارد */

    .org-tree > ul > li::before,
    .org-tree > ul > li::after {
        display: none;
    }

    /* اتصال عمودی والد به فرزندان */

    .org-tree ul ul::before {
        content: "";
        position: absolute;
        top: 0;
        left: 50%;
        width: 0;
        height: 28px;
        border-left: 2px solid var(--org-line);
        transform: translateX(-1px);
    }

    /* اصلاح ابتدا و انتهای خط افقی */

    .org-tree li:first-child::before {
        border: 0;
    }

    .org-tree li:last-child::after {
        border: 0;
    }

    .org-tree li:last-child::before {
        border-right: 2px solid var(--org-line);
        border-radius: 0 7px 0 0;
    }

    .org-tree li:first-child::after {
        border-radius: 7px 0 0 0;
    }

    /* اگر والد فقط یک فرزند داشته باشد */

    .org-tree li:only-child::before,
    .org-tree li:only-child::after {
        display: none;
    }

    .org-tree li:only-child {
        padding-top: 0;
    }

/* =========================================================
   Cards
   ========================================================= */

.org-card {
    position: relative;
    z-index: 3;
    display: flex;
    align-items: center;
    width: 166px;
    min-height: 66px;
    margin: 0 auto;
    padding: 6px;
    gap: 6px;
    direction: rtl;
    text-align: right;
    text-decoration: none !important;
    color: #263746;
    background: #fff;
    border: 2px solid var(--org-border);
    border-radius: 9px;
    box-shadow: 0 3px 11px rgba(33, 51, 66, .06);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}

    .org-card:hover,
    .org-card:focus-visible {
        color: #263746;
        border-color: var(--org-primary);
        box-shadow: 0 8px 20px rgba(1, 63, 110, .14);
        transform: translateY(-2px);
        outline: none;
    }

.org-card--root {
    width: 190px;
    min-height: 76px;
    border-width: 2px;
    box-shadow: 0 7px 20px rgba(1, 63, 110, .1);
}

/* =========================================================
   Avatar
   ========================================================= */

.org-avatar {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    flex: 0 0 40px;
    width: 40px;
    height: 50px;
    overflow: hidden;
    color: #9aabb9;
    background: #edf3f7;
    border: 1px solid #dde6ed;
    border-radius: 7px;
}

.org-card--root .org-avatar {
    flex-basis: 46px;
    width: 46px;
    height: 58px;
}

.org-avatar img {
    display: block;
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center top;
}

.org-avatar-fallback {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    font-size: 1.35rem;
}

/* =========================================================
   Card text
   ========================================================= */

.org-card-content {
    flex: 1 1 auto;
    min-width: 0;
}

.org-fullname {
    display: block;
    margin-bottom: 2px;
    color: var(--org-primary-dark);
    font-size: .7rem;
    font-weight: 800;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.org-title {
    display: block;
    color: #4c5c6b;
    font-size: .61rem;
    font-weight: 500;
    line-height: 1.5;
    overflow-wrap: anywhere;
}

.org-card-arrow {
    position: absolute;
    left: 6px;
    bottom: 4px;
    color: rgba(1, 63, 110, .48);
    font-size: .58rem;
}

/* =========================================================
   Visual difference between branch and leaf nodes
   ========================================================= */

/* گره دارای زیرمجموعه */

.org-node--has-children > .org-card {
    border-color: var(--org-primary);
    box-shadow: 0 3px 11px rgba(1, 63, 110, .09), inset 0 -3px 0 rgba(1, 63, 110, .07);
}

    /* نشان کوچک گره دارای زیرمجموعه */

    .org-node--has-children > .org-card::after {
        content: "";
        position: absolute;
        right: 50%;
        bottom: -5px;
        width: 8px;
        height: 8px;
        background: var(--org-primary);
        border: 2px solid #fff;
        border-radius: 50%;
        transform: translateX(50%);
    }

/* گره نهایی */

.org-node--leaf > .org-card {
    border-color: var(--org-border);
    box-shadow: 0 3px 10px rgba(33, 51, 66, .05);
}

/* =========================================================
   Compact leaf children
   ========================================================= */

/*
 * ردیف اصلی فرزندان همچنان افقی است.
 * گره‌های شاخه‌دار دقیقاً چیدمان قبلی را حفظ می‌کنند.
 */
.org-children--compact {
    position: relative;
    display: flex !important;
    flex-direction: row !important;
    align-items: flex-start;
    justify-content: center;
    margin: 0;
    padding: 28px 0 0;
}

    /*
 * تمام فرزندان نهایی یک والد،
 * فقط به‌اندازه یک ستون در ردیف اصلی جا می‌گیرند.
 *
 * خطوط اتصال این li توسط قوانین عمومی فعلی درخت رسم می‌شوند؛
 * بنابراین اینجا pseudo-element اضافی تعریف نمی‌کنیم.
 */
    .org-children--compact > .org-node--leaf-stack {
        position: relative;
        width: 200px;
        min-width: 200px;
        margin: 0;
        padding: 28px 5px 0;
        list-style: none;
        text-align: left;
    }

        /*
 * اگر ستون برگ‌ها تنها فرزند والد باشد،
 * خط مستقیم عمومی والد حفظ می‌شود.
 */
        .org-children--compact > .org-node--leaf-stack:only-child {
            padding-top: 0 !important;
        }

/* =========================================================
   Leaf side rail
   ========================================================= */

.org-leaf-stack {
    position: relative;
    width: 190px;
    min-width: 190px;
    margin: 0 auto;
    padding: 0;
}

    /*
 * ریل عمودی فقط از مرکز اولین کارت
 * تا مرکز آخرین کارت ادامه دارد.
 *
 * به همین دلیل هیچ خطی زیر آخرین گره ایجاد نمی‌شود.
 */
    .org-leaf-stack::before {
        content: "";
        position: absolute;
        z-index: 0;
        top: 38px;
        bottom: 38px;
        left: 8px;
        width: 2px;
        background: var(--org-line);
        pointer-events: none;
    }

    /*
 * اتصال مرکز ستون به ریل کناری.
 * این مسیر فقط یک بار رسم می‌شود.
 */
    .org-leaf-stack::after {
        content: "";
        position: absolute;
        z-index: 0;
        top: 0;
        left: 24px;
        width: calc(50% - 24px);
        height: 38px;
        border-right: 2px solid var(--org-line);
        border-bottom: 2px solid var(--org-line);
        pointer-events: none;
    }

/*
 * هر فرزند نهایی یک ردیف مستقل است.
 */
.org-leaf-stack-item {
    position: relative;
    display: flex;
    align-items: center;
    width: 190px;
    height: 76px;
    margin: 0;
    padding: 5px 0;
    text-align: left;
}

    /*
 * شاخه افقی هر فرزند از ریل تا کارت.
 */
    .org-leaf-stack-item::before {
        content: "";
        position: absolute;
        z-index: 1;
        top: 50%;
        left: 8px;
        width: 16px;
        height: 2px;
        background: var(--org-line);
        transform: translateY(-1px);
        pointer-events: none;
    }


    /*
 * کارت‌های نهایی با همان ابعاد اصلی نمایش داده می‌شوند.
 */
    .org-leaf-stack-item > .org-card {
        position: relative;
        z-index: 2;
        width: 166px;
        height: 66px;
        min-height: 66px;
        margin: 0 0 0 24px;
    }

        /*
 * کارت‌های این ستون زیرمجموعه یکدیگر نیستند؛
 * بنابراین زیر هیچ کارتی نقطه یا خط اضافه رسم نمی‌شود.
 */
        .org-leaf-stack-item > .org-card::after {
            content: none !important;
            display: none !important;
        }

/* =========================================================
   Empty state
   ========================================================= */

.org-empty {
    padding: 70px 20px;
    text-align: center;
    color: #768491;
}

    .org-empty i {
        display: block;
        margin-bottom: 16px;
        color: #b6c3ce;
        font-size: 3rem;
    }

/* =========================================================
   Desktop
   ========================================================= */

@media (min-width: 992px) {
    .org-chart-scroll {
        min-height: 500px;
        overflow-x: auto;
        overflow-y: visible;
        padding: 28px 18px 48px;
    }

    .org-tree {
        width: max-content;
        min-width: max-content;
        margin: 0 auto;
        /* استفاده از zoom در این قسمت ممنوع است. */
        zoom: 1;
        transform: none;
    }

        .org-tree li {
            padding-right: 5px;
            padding-left: 5px;
        }
}

/* =========================================================
   Tablet
   ========================================================= */

@media (min-width: 768px) and (max-width: 991.98px) {
    .org-chart-scroll {
        padding: 28px 18px 50px;
        overflow-x: auto;
        overflow-y: visible;
    }

    .org-tree {
        width: max-content;
        min-width: max-content;
        margin: 0 auto;
    }
}

/* =========================================================
   Mobile
   ========================================================= */

@media (max-width: 767.98px) {
    .org-page {
        padding-top: 20px;
    }

    .org-page-header {
        display: block;
        padding: 0 4px;
    }

    .org-page-description {
        font-size: .82rem;
    }

    .org-chart-toolbar {
        padding: 11px 13px;
    }

    .org-mobile-hint {
        display: inline-flex;
        align-items: center;
    }

    .org-desktop-hint {
        display: none;
    }

    .org-chart-scroll {
        display: block;
        width: 100%;
        min-height: 500px;
        overflow-x: auto;
        overflow-y: visible;
        padding: 28px 16px 50px;
    }

    .org-tree {
        width: max-content;
        min-width: max-content;
        margin: 0 auto;
        zoom: 1;
        transform: none;
    }

        .org-tree li {
            padding-right: 5px;
            padding-left: 5px;
        }

    .org-card {
        width: 166px;
    }

    .org-card--root {
        width: 190px;
    }
}

/* =========================================================
   Compact organization chart
   ========================================================= */

/*
 * کارت معمولی:
 * عرض قبلی: 166px
 * ارتفاع قبلی: 66px
 */
.org-card {
    width: 132px;
    height: 52px;
    min-height: 52px;
    padding: 4px;
    gap: 5px;
    border-radius: 7px;
}

/*
 * کارت گره اصلی:
 * عرض قبلی: 190px
 * ارتفاع قبلی: 76px
 */
.org-card--root {
    width: 150px;
    height: 60px;
    min-height: 60px;
}

/* کاهش فاصله افقی بین شاخه‌ها */
.org-tree li {
    padding-right: 3px;
    padding-left: 3px;
}

/*
 * تصویر کارت معمولی:
 * اندازه قبلی: 40 × 50
 */
.org-avatar {
    flex: 0 0 32px;
    width: 32px;
    height: 40px;
    border-radius: 6px;
}

/*
 * تصویر کارت ریشه:
 * اندازه قبلی: 46 × 58
 */
.org-card--root .org-avatar {
    flex-basis: 36px;
    width: 36px;
    height: 46px;
}

/* اندازه آیکون جایگزین تصویر */
.org-avatar-fallback {
    font-size: 1rem;
}

/* متن نام */
.org-fullname {
    margin-bottom: 1px;
    font-size: .61rem;
    line-height: 1.4;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* متن عنوان شغلی */
.org-title {
    display: -webkit-box;
    overflow: hidden;
    font-size: .53rem;
    line-height: 1.35;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
}

/* فلش پایین کارت */
.org-card-arrow {
    left: 4px;
    bottom: 3px;
    font-size: .48rem;
}

/* نقطه اتصال گره‌های دارای فرزند */
.org-node--has-children > .org-card::after {
    bottom: -4px;
    width: 7px;
    height: 7px;
}

/* =========================================================
   Compact leaf stack
   ========================================================= */

/*
 * عرض ستون کارشناسان:
 * مقدار قبلی: 200px
 */
.org-children--compact > .org-node--leaf-stack {
    width: 158px;
    min-width: 158px;
    padding-right: 3px;
    padding-left: 3px;
}

/*
 * عرض فضای داخلی ستون:
 * مقدار قبلی: 190px
 */
.org-leaf-stack {
    width: 152px;
    min-width: 152px;
}

/*
 * ارتفاع هر ردیف:
 * مقدار قبلی: 76px
 */
.org-leaf-stack-item {
    width: 152px;
    height: 60px;
    padding: 4px 0;
}

/* ریل عمودی از مرکز اولین کارت تا مرکز آخرین کارت */
.org-leaf-stack::before {
    top: 30px;
    bottom: 30px;
    left: 6px;
}

/* اتصال والد به اولین کارت */
.org-leaf-stack::after {
    left: 20px;
    width: calc(50% - 20px);
    height: 30px;
}

/* شاخه افقی هر کارت */
.org-leaf-stack-item::before {
    left: 6px;
    width: 14px;
}

/*
 * کارت‌های داخل ستون کارشناسان:
 * مقدار قبلی: 166 × 66
 */
.org-leaf-stack-item > .org-card {
    width: 132px;
    height: 52px;
    min-height: 52px;
    margin-left: 20px;
}

/* تثبیت اندازه‌ها در موبایل */
@media (max-width: 767.98px) {
    .org-card {
        width: 132px;
    }

    .org-card--root {
        width: 150px;
    }
}

/* =========================================================
   Print
   ========================================================= */

@media print {
    .main-header,
    .main-footer,
    .org-chart-toolbar {
        display: none !important;
    }

    .org-page {
        padding: 0;
        background: #fff;
    }

    .org-chart-shell {
        overflow: visible;
        border: 0;
        box-shadow: none;
    }

    .org-chart-scroll {
        overflow: visible;
        min-height: 0;
        padding: 10px;
        background: #fff;
    }

    .org-tree {
        zoom: 1;
        transform: none;
    }
}
