/**
 * 부서 조직도 — 순수 CSS 트리
 * - 769px 이상: 상단 → 하단(자식은 가로로 배치)
 * - 768px 이하: 왼쪽 → 오른쪽(자식은 세로로 배치, 가로 스크롤)
 */

.org-dept-intro {
    margin-bottom: 32px;
    max-width: 920px;
    color: #334155;
    font-size: 16px;
    line-height: 1.75;
    background: #ffffff;
    border: 1px solid #e4efe7;
    border-radius: 16px;
    padding: 24px 24px 24px 28px;
    box-shadow: 0 10px 28px rgba(15, 23, 42, 0.06);
    position: relative;
}

.org-dept-intro::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    border-radius: 16px 0 0 16px;
    background: linear-gradient(180deg, #16a34a 0%, #22c55e 100%);
}

.org-dept-intro p {
    margin: 0 0 1em;
}

.org-dept-intro p:last-child {
    margin-bottom: 0;
}

.org-dept-panel {
    margin: 0 auto 44px;
    --org-brand: #004c97;
    --org-brand-dark: #003d7a;
    --org-brand-soft: #e9f0fa;
    --org-line: #c7d5e6;
}

.org-dept-panel--admin {
    margin-bottom: 24px;
}

.org-dept-panel__hint {
    margin: 0 0 12px;
    color: #516071;
    font-size: 14px;
    line-height: 1.5;
    display: flex;
    align-items: center;
    gap: 8px;
}

.org-dept-panel__hint::before {
    content: "";
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--org-brand);
    flex: 0 0 7px;
}

/* --------------------------------------------------------------------------
 * 스크롤 영역
 * -------------------------------------------------------------------------- */
.org-dept-chart-wrap {
    position: relative;
    width: 100%;
    min-height: 210px;
    overflow: auto;
    -webkit-overflow-scrolling: touch;
    border-radius: 20px;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    box-shadow: 0 14px 34px rgba(15, 23, 42, 0.08);
    padding: 28px 22px;
}

.org-dept-chart-wrap--css {
    text-align: center;
}

/* --------------------------------------------------------------------------
 * CSS 트리 — 공통
 * -------------------------------------------------------------------------- */
.org-css-tree {
    position: relative;
    z-index: 1;
    display: inline-block;
    text-align: center;
    max-width: 100%;
}

.org-css-tree__root,
.org-css-tree__branches {
    list-style: none;
    margin: 0;
    padding: 0;
}

.org-css-tree__item {
    display: flex;
    align-items: center;
}

.org-css-tree__node {
    flex-shrink: 0;
    background: #ffffff;
    color: #1e293b;
    font-size: 16px;
    font-weight: 700;
    line-height: 1.35;
    padding: 12px 20px;
    border: 1px solid #d8e1ef;
    border-radius: 12px;
    box-shadow: 0 8px 20px rgba(15, 23, 42, 0.08);
    text-align: center;
    min-width: 100px;
    max-width: 220px;
    transition: transform 0.18s ease, box-shadow 0.18s ease, border-color 0.18s ease;
}

.org-css-tree__label {
    display: block;
    word-break: keep-all;
    overflow-wrap: break-word;
}

.org-css-tree__node--root {
    min-width: 140px;
    background: linear-gradient(135deg, var(--org-brand) 0%, var(--org-brand-dark) 100%);
    border-color: transparent;
    color: #ffffff;
}

/* --------------------------------------------------------------------------
 * 데스크톱: 위 → 아래
 * -------------------------------------------------------------------------- */
@media (min-width: 769px) {
    .org-dept-chart-wrap {
        overflow-x: hidden;
        overflow-y: visible;
    }

    .org-css-tree--responsive .org-css-tree__root {
        display: flex;
        flex-direction: row;
        justify-content: center;
        align-items: flex-start;
    }

    .org-css-tree--responsive .org-css-tree__item {
        flex-direction: column;
        position: relative;
    }

    .org-css-tree--responsive .org-css-tree__branches {
        display: flex;
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: flex-start;
        gap: 14px 20px;
        padding-top: 24px;
        border-top: none;
        position: relative;
        margin-top: 23px;
    }

    /* 1차 조직 라인은 줄바꿈 금지(마지막 항목 이탈 방지) */
    .org-css-tree--responsive .org-css-tree__root > .org-css-tree__item > .org-css-tree__branches {
        flex-wrap: nowrap;
        justify-content: space-between;
        gap: 12px;
        width: min(100%, 1200px);
        margin-left: auto;
        margin-right: auto;
    }

    .org-css-tree--responsive .org-css-tree__root > .org-css-tree__item > .org-css-tree__branches > .org-css-tree__item {
        min-width: 0;
    }

    .org-css-tree--responsive .org-css-tree__root > .org-css-tree__item > .org-css-tree__branches > .org-css-tree__item > .org-css-tree__node {
        width: 100%;
        max-width: none;
        min-width: 0;
        padding: 11px 8px;
        font-size: 16px;
    }

    /* 자식 그룹 가로 연결선(끝단 여백을 줘서 선이 덜 답답하게 보이도록 처리) */
    .org-css-tree--responsive .org-css-tree__branches::after {
        content: "";
        position: absolute;
        top: 0;
        left: 29px;
        right: 24px;
        height: 2px;
        background: var(--org-line);
        border-radius: 2px;
        margin: 0px 16px;
    }

    /* 자식이 1개인 경우 가로 연결선 숨김 */
    .org-css-tree--responsive .org-css-tree__item > .org-css-tree__branches:has(> .org-css-tree__item:only-child)::after {
        display: none;
    }

    /* 부모 ↔ 자식 연결(세로 한 줄) */
    .org-css-tree--responsive .org-css-tree__item > .org-css-tree__branches::before {
        content: "";
        position: absolute;
        top: -24px;
        left: 50%;
        width: 2px;
        height: 24px;
        margin-left: 2px;
        background: var(--org-line);
    }

    .org-css-tree--responsive .org-css-tree__branches > .org-css-tree__item {
        position: relative;
        padding-top: 0;
    }

    .org-css-tree--responsive .org-css-tree__branches > .org-css-tree__item::before {
        content: "";
        position: absolute;
        top: -24px;
        left: 50%;
        width: 2px;
        height: 24px;
        margin-left: -1px;
        background: var(--org-line);
    }

    .org-css-tree__node:hover {
        transform: translateY(-2px);
        border-color: #b9c7de;
        box-shadow: 0 12px 24px rgba(15, 23, 42, 0.12);
    }
}

/* --------------------------------------------------------------------------
 * 모바일·좁은 화면: 왼쪽 → 오른쪽
 * -------------------------------------------------------------------------- */
@media (max-width: 768px) {
    .org-dept-chart-wrap {
        min-height: 240px;
        padding: 18px 14px;
        text-align: left;
    }

    .org-css-tree {
        display: block;
        text-align: left;
        width: max-content;
        min-width: 100%;
        max-width: none;
    }

    .org-css-tree--responsive .org-css-tree__root {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
    }

    .org-css-tree--responsive .org-css-tree__item {
        flex-direction: row;
        align-items: stretch;
        gap: 12px;
    }

    .org-css-tree--responsive .org-css-tree__branches {
        display: flex;
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-top: 0;
        padding: 8px 0 8px 18px;
        border-top: none;
        border-left: 2px solid var(--org-line);
        flex: 0 1 auto;
    }

    .org-css-tree--responsive .org-css-tree__item > .org-css-tree__node {
        align-self: flex-start;
    }

    .org-css-tree__node {
        font-size: 13px;
        padding: 10px 14px;
        min-width: 100px;
        max-width: 200px;
    }

    /* 데스크톱용 세로 연결선 숨김 */
    .org-css-tree--responsive .org-css-tree__item > .org-css-tree__branches::before,
    .org-css-tree--responsive .org-css-tree__branches > .org-css-tree__item::before {
        content: none;
        display: none;
    }
}

.org-dept-empty {
    margin: 30px auto;
    padding: 24px;
    max-width: 560px;
    text-align: center;
    color: #4b5563;
    font-size: 15px;
    line-height: 1.6;
    border: 1px dashed #c9d6ea;
    border-radius: 14px;
    background: #f8fafc;
}

@media (max-width: 1024px) {
    .org-dept-chart-wrap:not(.org-dept-chart-wrap--css) {
        min-height: 420px;
    }
}

/* --------------------------------------------------------------------------
 * 회사소개 조직도 콘텐츠 페이지(content.skin.php → ctt_organization)
 * -------------------------------------------------------------------------- */
.ctt_organization .ctt_inner > header {
    text-align: center;
}

.ctt_organization .ctt_inner > header .contentTitle {
    margin-left: auto;
    margin-right: auto;
}

.ctt_organization .org-dept-panel {
    margin-left: auto;
    margin-right: auto;
    max-width: 100%;
}

.ctt_organization .org-dept-panel__hint {
    justify-content: center;
    text-align: center;
}

.ctt_organization .org-dept-chart-wrap--css {
    text-align: center;
}

@media (max-width: 768px) {
    .org-dept-intro {
        font-size: 15px;
        padding: 18px 16px 18px 20px;
    }

    .org-dept-chart-wrap {
        border-radius: 16px;
    }

    .ctt_organization .org-dept-chart-wrap--css {
        text-align: left;
    }
}
