/* ============================================================
   ORG CHART COMPONENT
   .oc-*  - desktop tree + flat grid + shared node card
   .ocm-* - mobile indented list
   ============================================================ */

/* ── Loading state ─────────────────────────────────────────── */
.oc-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 12px;
    padding: 80px 2rem;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.oc-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--color-border);
    border-top-color: var(--color-accent);
    border-radius: 50%;
    animation: oc-spin 0.7s linear infinite;
}

@keyframes oc-spin {
    to { transform: rotate(360deg); }
}

/* ── Empty state ───────────────────────────────────────────── */
.oc-empty {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 80px 2rem;
    color: var(--color-text-secondary);
    font-size: var(--font-size-sm);
}

.oc-empty p {
    margin: 0;
}

/* ── Tree container (desktop) ─────────────────────────────── */
.oc-tree {
    display: flex;
    flex-direction: column;
    align-items: center;
    overflow-x: auto;
    padding: 32px 16px;
    min-height: 400px;
}

/* Multiple roots: lay them side by side with breathing room */
.oc-tree-roots {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 48px;
}

/* ── Tree level - wraps one node + its children subtree ────── */
.oc-level {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* ── Children row ─────────────────────────────────────────── */
.oc-children {
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    justify-content: center;
    gap: 24px;
    position: relative;
    padding-top: 32px;
}

/* Vertical connector from parent node down to the horizontal bar */
.oc-children::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 32px;
    background: var(--color-border);
    transform: translateX(-50%);
}

/* Horizontal bar at the bottom of the vertical drop, spanning all siblings */
.oc-children::after {
    content: '';
    position: absolute;
    top: 32px;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--color-border);
}

/* Hide horizontal bar when there is only one child */
.oc-children.oc-single-child::after {
    display: none;
}

/* ── Per-child wrapper ────────────────────────────────────── */
.oc-child {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    padding-top: 32px;
}

/* Vertical connector from horizontal bar down to the child node */
.oc-child::before {
    content: '';
    position: absolute;
    top: 0;
    left: 50%;
    width: 1px;
    height: 32px;
    background: var(--color-border);
    transform: translateX(-50%);
}

/* ── Node card ─────────────────────────────────────────────── */
.oc-node {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 10px;
    padding: 12px 16px;
    min-width: 160px;
    max-width: 200px;
    cursor: pointer;
    transition: border-color 150ms ease, box-shadow 150ms ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    user-select: none;
}

.oc-node:hover {
    border-color: var(--color-accent);
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.07);
}

.oc-node--selected {
    border-color: var(--color-accent);
    background: var(--color-accent-subtle);
}

/* ── Node avatar ───────────────────────────────────────────── */
.oc-node-avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    background: var(--color-accent);
    color: #fff;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.oc-node-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}

/* ── Node text block ───────────────────────────────────────── */
.oc-node-info {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    min-width: 0;
    width: 100%;
}

.oc-node-name {
    font-size: 13px;
    font-weight: 600;
    color: var(--color-text-primary);
    line-height: 1.3;
    word-break: break-word;
}

.oc-node-role {
    font-size: 11px;
    color: var(--color-accent);
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    word-break: break-word;
}

.oc-node-dept {
    font-size: 11px;
    color: var(--color-text-secondary);
    word-break: break-word;
}

/* ── Flat grid (when no hierarchy is defined) ─────────────── */
.oc-flat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 16px;
    padding: 24px 0;
}

.oc-flat-hint {
    text-align: center;
    color: var(--color-text-secondary);
    font-size: 13px;
    margin-top: 16px;
}

/* ── Mobile list (.ocm-*) ─────────────────────────────────── */
.oc-mobile-list {
    padding: 16px 0;
}

/* .ocm-node padding-left is set dynamically via style= for depth */

.ocm-node-card {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    cursor: pointer;
    transition: background-color var(--transition-fast);
    border-radius: var(--radius-md);
    margin: 2px 0;
}

.ocm-node-card:hover {
    background: var(--color-background);
}

.ocm-node-card--selected {
    background: var(--color-accent-subtle);
}

.ocm-avatar {
    width: 36px;
    height: 36px;
    border-radius: var(--radius-full);
    background: var(--color-accent);
    color: #fff;
    font-size: 13px;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    overflow: hidden;
}

.ocm-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    border-radius: var(--radius-full);
}

.ocm-info {
    flex: 1;
    min-width: 0;
}

.ocm-name {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--color-text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ocm-role {
    font-size: var(--font-size-xs);
    color: var(--color-text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ocm-chevron {
    color: var(--color-text-secondary);
    flex-shrink: 0;
}
