// Organization Chart page (xeno_org_chart's own custom, reorderable tree --
// distinct from core's native web_hierarchy view styled in
// native_hierarchy.scss). .o_xeno_hr_page/_header/_card/_toolbar classes
// come from xeno_leave/static/src/scss/leave_hr_app.scss (already loaded
// globally in web.assets_backend, and xeno_org_chart depends on
// xeno_leave) -- this file only replaces the page shell + tree styling to
// match Xenoptics' circular-avatar / colored-ring reference layout.

.o_xeno_org_page {
    background: #fff;
    padding: 24px 28px 40px;
    // Core wraps every client action in .o_action_manager > .o_action,
    // both height:100% + overflow:hidden, relying on each view's own
    // inner .o_content to scroll (see xeno_app_dashboard.scss's identical
    // fix). This page renders a bare div with no such inner scroller, so
    // a tree taller than the viewport was silently clipped with no
    // scrollbar at all -- give this root a definite height and its own
    // vertical scroll; horizontal scroll of the tree itself stays scoped
    // to .o_xeno_org_tree below.
    height: 100%;
    overflow-y: auto;
    overflow-x: hidden;
}

.o_xeno_org_header {
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    margin-bottom: 24px;
}

.o_xeno_org_company {
    background: #f1f2f4;
    border: 1px solid #dee2e6;
    border-radius: 24px;
    padding: 10px 28px;
    font-weight: 700;
    font-size: 0.95rem;
    text-align: center;
    color: #212529;
}

.o_xeno_org_logo {
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%);
    max-height: 40px;
    max-width: 140px;
    object-fit: contain;
}

.o_xeno_org_controls {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 20px;
}

.o_xeno_org_filter {
    max-width: 240px;
}

.o_xeno_org_legend {
    display: flex;
    align-items: center;
    gap: 18px;
    flex-wrap: wrap;
}

.o_xeno_org_zoom {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}

.o_xeno_org_zoom_btn {
    width: 26px;
    height: 26px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    border-radius: 50%;
    font-size: 0.72rem;
    cursor: pointer;

    &:hover:not(:disabled) {
        background: #f1f3f5;
        color: #212529;
    }

    &:disabled {
        opacity: 0.4;
        cursor: default;
    }
}

.o_xeno_org_zoom_label {
    min-width: 38px;
    text-align: center;
    font-size: 0.75rem;
    color: #868e96;
}

// CSS `zoom` (not `transform: scale`) is used deliberately -- transform
// only rescales what's already painted and leaves the pre-zoom layout
// footprint behind (so "zooming out" would still need the same amount of
// scrolling as before, defeating the point); zoom actually shrinks the
// element's own layout box, so the tree's scrollable area shrinks together
// with what's drawn.
.o_xeno_org_zoom_wrap {
    zoom: 1;
}

.o_xeno_org_legend_item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.78rem;
    color: #495057;
}

.o_xeno_org_legend_dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #fff;
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px #ced4da;
    display: inline-block;

    &.role_manager { box-shadow: 0 0 0 2px rgba(224, 32, 32, 0.64); }
    &.role_senior { box-shadow: 0 0 0 2px rgb(22, 193, 45); }
    &.role_supervisor { box-shadow: 0 0 0 2px #0064c9; }
    &.role_management { box-shadow: 0 0 0 2px #f1f1f1; }
}

.o_xeno_org_loading {
    color: #868e96;
    text-align: center;
    padding: 32px 0;
}

// justify-content: center on the scrolling container itself was the bug:
// when the centered content is wider than the viewport, browsers center
// it by pushing the "start" half off-screen with a negative offset --
// and clip that overflow instead of leaving it scrollable, so the
// scrollbar could never reach the tree's actual left/right edges. Centering
// via margin: auto on the (shrink-wrapped) content instead centers only
// when it fits, and simply starts flush at the left edge once it
// overflows -- nothing is ever pushed into unreachable negative space.
.o_xeno_org_tree {
    overflow-x: auto;
    overflow-y: hidden;
    padding: 12px 4px 24px;
}

.o_xeno_org_level {
    display: flex;
    list-style: none;
    margin: 0;
    padding: 0;
    // column-gap (same-row spacing) moved to .o_xeno_org_node's own
    // padding below -- a flex `gap` leaves a bare space between adjacent
    // <li>s that neither node's own connector-line segment covers,
    // breaking the horizontal line into visibly disconnected pieces.
    // row-gap (space between wrapped lines on .o_xeno_org_root, which can
    // wrap onto multiple rows) isn't part of that problem, so it stays.
    row-gap: 28px;
}

.o_xeno_org_root {
    display: inline-flex;
    flex-wrap: wrap;
    justify-content: center;
    margin: 0 auto;
}

.o_xeno_org_node {
    display: flex;
    flex-direction: column;
    align-items: center;
    position: relative;
    // Replaces .o_xeno_org_level's old column-gap (28px total, 14px each
    // side here) -- keeps the same visual spacing between cards while
    // letting adjacent nodes' connector-line segments below butt up
    // against each other with no bare gap in between.
    padding: 0 14px;
}

// L-shaped connectors: a vertical stub down out of the parent card
// (.o_xeno_org_vline, rendered by the template between a parent and its
// children level), plus a horizontal segment + vertical stub per child
// card -- plain borders read as a clean right-angled tree without any
// hand-drawn SVG paths.
//
// The horizontal line is drawn PER CHILD (each node's own ::after,
// trimmed to a half for the first/last child), not once as a single bar
// on the row (<ul>) inset by a fixed guess at "half a card's width": a
// node whose own subtree is expanded grows its <li> far wider than one
// card, which moves that card's true center well past any fixed inset,
// producing a dangling excess line that only happened to look right when
// every sibling was still exactly one plain card wide. Since each node
// draws only its OWN width's worth of line, the combined line across a
// row always starts/ends exactly at the outermost cards' centers no
// matter how wide any individual sibling's own expanded subtree gets.
.o_xeno_org_level:not(.o_xeno_org_root) {
    padding-top: 18px;
}

.o_xeno_org_level:not(.o_xeno_org_root) > .o_xeno_org_node {
    &::before {
        content: "";
        position: absolute;
        top: -18px;
        left: 50%;
        width: 1px;
        height: 18px;
        background: #ced4da;
    }

    &::after {
        content: "";
        position: absolute;
        top: -18px;
        left: 0;
        right: 0;
        height: 1px;
        background: #ced4da;
    }

    &:first-child::after { left: 50%; }
    &:last-child::after { right: 50%; }
    &:only-child::after { display: none; }
}

.o_xeno_org_team_label {
    background: #eef1f5;
    border: 1px solid #dee2e6;
    border-radius: 16px;
    padding: 4px 16px;
    font-size: 0.75rem;
    font-weight: 700;
    color: #495057;
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}

.o_xeno_org_card {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    background: #fff;
    border-radius: 10px;
    padding: 10px 14px 8px;
    min-width: 130px;
    max-width: 150px;
    cursor: grab;
    position: relative;
    transition: box-shadow 0.15s ease;

    &:hover {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    }

    &:active {
        cursor: grabbing;
    }
}

.o_xeno_org_depth_0 .o_xeno_org_avatar {
    width: 76px;
    height: 76px;
}

.o_xeno_org_avatar {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-color: #e9ecef;
    flex-shrink: 0;
    box-sizing: border-box;
    // Soft two-tone ring (white inner border + a tinted outer halo via
    // box-shadow) instead of one flat, saturated border -- reads as a
    // deliberate frame rather than a harsh solid-color outline, while
    // still keeping each role visually distinct. No box-shadow at all
    // for a card with no matching role (plain border only).
    border: 3px solid #fff;

    &.role_manager { box-shadow: 0 0 0 3px rgba(224, 32, 32, 0.64); }
    &.role_senior { box-shadow: 0 0 0 3px rgb(22, 193, 45); }
    &.role_supervisor { box-shadow: 0 0 0 3px #0064c9; }
    &.role_management { box-shadow: 0 0 0 5px #f1f1f1; }
}

.o_xeno_org_avatar_initial {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
}

.o_xeno_org_name {
    font-weight: 700;
    font-size: 0.82rem;
    text-align: center;
    color: #212529;
    line-height: 1.2;
}

.o_xeno_org_title {
    font-size: 0.72rem;
    color: #868e96;
    text-align: center;
    line-height: 1.2;
}

.o_xeno_org_toggle {
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 22px;
    height: 22px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #dee2e6;
    background: #fff;
    color: #495057;
    border-radius: 50%;
    cursor: pointer;
    font-size: 0.7rem;
    z-index: 1;

    &:hover {
        background: #f1f3f5;
        color: #212529;
    }
}

.o_xeno_org_toggle_count {
    position: absolute;
    top: -6px;
    right: -6px;
    background: #495057;
    color: #fff;
    border-radius: 8px;
    font-size: 0.6rem;
    line-height: 1;
    padding: 2px 4px;
}

.o_xeno_org_collapsed_hint {
    margin-top: 14px;
    font-size: 0.7rem;
    color: #adb5bd;
    font-style: italic;
    text-align: center;
}

.o_xeno_org_hint {
    text-align: center;
    color: #adb5bd;
    font-size: 0.78rem;
    margin-top: 20px;
}

// The vertical connector stub rendered between a parent card and its
// children (see the template's .o_xeno_org_vline divs) -- centers itself
// under the parent by living inside the parent <li>'s flex column.
.o_xeno_org_vline {
    width: 1px;
    height: 18px;
    background: #ced4da;
}
