// Custom "HR" app pages (Leave List / Leave Approval), styled after
// XENHR's own Leaves / My Team Leaves screens.

// Core clips both .o_action_manager and .o_action with overflow:hidden
// (webclient_layout.scss), assuming each view provides its own scroll
// region -- these custom client-action pages (Leave List/Approval) can
// run taller than one screen, so anchor to the viewport directly rather
// than fight that ancestor chain. Same technique/fix as xeno_hr_dashboard's
// dashboard.scss (.o_xeno_dashboard) for the same underlying issue.
$xeno-topbar-height: 48px;
$xeno-sidebar-width: 238px; // keep in sync with xeno_theme_slate's sidebar width

.o_xeno_hr_page {
    padding: 24px 32px;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: auto;

    @media (min-width: 768px) {
        position: fixed;
        top: $xeno-topbar-height;
        left: $xeno-sidebar-width;
        right: 0;
        bottom: 0;
        transition: left 0.2s ease;
    }

    h1 {
        font-size: 1.6rem;
        font-weight: 700;
        margin-bottom: 2px;
    }
}

// Being position:fixed (see the file-top comment for why) means this page
// sits outside .o_action_manager entirely, so it doesn't pick up that
// element's own margin-left/left collapse handling for free -- same fix as
// xeno_hr_dashboard's dashboard.scss (.o_xeno_dashboard), same breakpoint/
// value xeno_theme_slate's own .xeno_topbar and .o_action_manager use for
// the same toggle. Covers all four o_xeno_hr_page pages: Leave List,
// Leave Balances, Leave Approval (Team Leave), Approver Configuration.
body.xeno_sidebar_collapsed .o_xeno_hr_page {
    @media (min-width: 768px) {
        left: 64px;
    }
}

.o_xeno_hr_subtitle {
    color: #8a8a8a;
    font-size: 0.9rem;
    margin-bottom: 0;
}

.o_xeno_hr_header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.o_xeno_hr_header_actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.o_xeno_hr_card {
    // Hardcoded, not the --o-view-background-color variable: this page
    // is deliberately always light (see note near the bottom of this
    // file), and that variable can resolve dark in contexts where the
    // rest of this custom client-action page stays light regardless.
    background: #fff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    border-radius: 10px;
    padding: 16px 20px 8px;
    // Without this, a table wider than the card (e.g. Leave List's
    // Approval Chain column, whose steps don't wrap) visually spills past
    // the card's own rounded border onto the page background instead of
    // scrolling inside it.
    overflow-x: auto;
}

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

.o_xeno_pill_tabs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.o_xeno_pill_tab {
    border: 1px solid rgba(0, 0, 0, 0.12);
    background: transparent;
    color: #6b6b6b;
    border-radius: 999px;
    padding: 6px 16px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: background-color 0.15s, color 0.15s;

    &.active {
        background: #3b7dec;
        border-color: #3b7dec;
        color: #fff;
    }

    &:not(.active):hover {
        background: rgba(0, 0, 0, 0.04);
    }
}

.o_xeno_department_filter,
.o_xeno_employee_filter,
.o_xeno_leave_type_filter {
    max-width: 220px;
}

.o_xeno_deduction_check {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    color: #495057;
    white-space: nowrap;
    cursor: pointer;
}

.o_xeno_hr_table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.88rem;

    thead th {
        text-align: left;
        text-transform: uppercase;
        letter-spacing: 0.04em;
        font-size: 0.72rem;
        color: #9a9a9a;
        font-weight: 600;
        border-bottom: 1px solid rgba(0, 0, 0, 0.08);
        padding: 10px 8px;
        white-space: nowrap;
    }

    tbody td {
        padding: 14px 8px;
        border-bottom: 1px solid rgba(0, 0, 0, 0.06);
        vertical-align: middle;
    }

    tbody tr:hover {
        background: rgba(59, 125, 236, 0.03);
    }
}

.o_xeno_reason_cell {
    max-width: 220px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

// My Team Leaves only (leave_approval_templates.xml) -- susu wants the
// full reason readable there, not truncated like Pending My Approval's own
// reason cell (untouched, keeps the ellipsis above).
.o_xeno_reason_cell_wrap {
    overflow: visible;
    text-overflow: clip;
    white-space: normal;
    word-break: break-word;
}

.o_xeno_employee_cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.o_xeno_avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    color: #fff;
    font-weight: 700;
    font-size: 0.9rem;
    flex-shrink: 0;
}

.o_xeno_pill {
    display: inline-block;
    padding: 3px 12px;
    border-radius: 999px;
    font-size: 0.78rem;
    font-weight: 600;
}

.o_xeno_pill_pending { background: #fdf0cc; color: #8a6d1d; }
.o_xeno_pill_approved { background: #d9f2e3; color: #206b45; }
.o_xeno_pill_rejected { background: #fbdfe4; color: #a33a49; }
.o_xeno_pill_muted { background: #ececec; color: #7a7a7a; }

.o_xeno_chain {
    display: flex;
    align-items: flex-start;
}

.o_xeno_chain_step {
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 92px;
    text-align: center;
    flex-shrink: 0;
}

.o_xeno_chain_icon {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 2px solid #d6d6d6;
    color: #9a9a9a;
    font-size: 0.8rem;
    margin-bottom: 4px;
}

.o_xeno_chain_icon_approved {
    border-color: #34a866;
    color: #34a866;
    background: #eafaf1;
}

.o_xeno_chain_icon_rejected {
    border-color: #d4534f;
    color: #d4534f;
    background: #fdeceb;
}

.o_xeno_chain_label {
    font-size: 0.75rem;
    font-weight: 600;
    color: #4a4a4a;
    line-height: 1.2;
}

.o_xeno_chain_approver {
    font-size: 0.7rem;
    color: #9a9a9a;
    line-height: 1.2;
}

.o_xeno_chain_decided {
    font-size: 0.66rem;
    font-style: italic;
    color: #b0b0b0;
    line-height: 1.2;
    margin-top: 2px;
}

// Field-widget context (the Leave form's Approval Chain section) needs
// a bit more per-step width than the Leave List table cell does, since
// it also carries the Decided At line.
.o_xeno_chain_field .o_xeno_chain_step {
    width: 130px;
}

.o_xeno_chain_connector {
    height: 2px;
    background: #e0e0e0;
    flex: 1 1 24px;
    margin-top: 15px;
    min-width: 16px;
}

.o_xeno_actions {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: 0.82rem;

    a {
        color: #3b7dec;
        text-decoration: none;
        white-space: nowrap;

        &:hover { text-decoration: underline; }
    }

    .o_xeno_action_warn { color: #b5790a; }
    .o_xeno_action_danger { color: #c8383f; }
}

.o_xeno_actions_pair {
    display: flex;
    align-items: center;
    gap: 4px;
}

.o_xeno_actions_sep {
    color: #adb5bd;
}

.o_xeno_section_title {
    font-size: 1.15rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
}

.o_xeno_count_badge {
    background: #fdf0cc;
    color: #8a6d1d;
    border-radius: 999px;
    font-size: 0.72rem;
    font-weight: 700;
    padding: 2px 9px;
}

.o_xeno_pill_step_current {
    background: #dce8fd;
    color: #2b5fc4;
}

.o_xeno_full_chain {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    max-width: 220px;
}

.o_xeno_chain_pill {
    font-weight: 500;
}

.o_xeno_approval_buttons {
    display: flex;
    gap: 6px;
}

.o_xeno_btn_approve {
    background: #eafaf1;
    color: #206b45;
    border: 1px solid #bfe8cf;

    &:hover { background: #d9f2e3; color: #206b45; }
}

.o_xeno_btn_reject {
    background: #fdeceb;
    color: #a33a49;
    border: 1px solid #f6cdd1;

    &:hover { background: #fbdfe4; color: #a33a49; }
}

// Approve/Reject confirmation dialog (Leave Approval page)
.o_xeno_chain_dialog_arrow {
    color: #b0b0b0;
    font-size: 0.75rem;
    margin: 0 6px;
}

.o_xeno_reason_box {
    background: #f8f9fa;
    border: 1px solid #e9ecef;
    border-radius: 0.4rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.88rem;
    color: #495057;
}

// Approve/Reject decision dialog's advisory checklist -- never blocks the
// decision, just flags patterns (frequency/pace/balance/bridging) worth a
// second look before the approver clicks through.
.o_xeno_analysis_row {
    display: flex;
    align-items: baseline;
    gap: 6px;
    font-size: 0.82rem;
    padding: 3px 0;
    color: #495057;
}

.o_xeno_analysis_icon {
    flex-shrink: 0;
    font-size: 0.78rem;
}

.o_xeno_analysis_ok .o_xeno_analysis_icon {
    color: #16a34a;
}

.o_xeno_analysis_flagged {
    color: #92400e;

    .o_xeno_analysis_icon {
        color: #d97706;
    }
}

.o_xeno_analysis_label {
    font-weight: 600;
    white-space: nowrap;
}

// Leave List page pager
.o_xeno_pager {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 4px 4px;
    font-size: 0.85rem;
    color: #6c757d;
}

.o_xeno_pager_nav {
    display: flex;
    gap: 8px;
}

// Briefly marks the row the user just came back from viewing/editing, so
// they don't have to re-scan the whole page to find it again after
// Pending/All + page position are restored.
.o_xeno_row_highlight {
    animation: xeno-row-highlight-fade 2s ease-out;
}

@keyframes xeno-row-highlight-fade {
    0% { background-color: #fff3cd; }
    100% { background-color: transparent; }
}

// "Employee's summary" grouped by leave type -- used both by core's own
// LeaveStatsComponent (patched, leave form sidebar) and the Leave
// Approval decision dialog's own summary section. One rowspan'd cell per
// leave type, one row per leave under it.
.o_xeno_summary_table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.82rem;

    td {
        border: 1px solid #dee2e6;
        padding: 5px 10px;
        vertical-align: middle;
    }

    .o_xeno_summary_type {
        width: 150px;
    }

    .o_xeno_summary_dates {
        color: #6c757d;
        white-space: nowrap;
    }

    .o_xeno_summary_days {
        // Left-aligned, not right: this table sits in the leave form's
        // sidebar, where a cancel/approve corner ribbon clips the top-right
        // corner and would otherwise cover right-aligned text there.
        text-align: left;
        white-space: nowrap;
    }
}
