/*
 * Block of Hours (BoH) Project views: the Burn-down panel, the Hours Used vs Remaining side panel
 * and the BoH Plan list.
 *
 * Only theme variables are used, so light and dark themes both read correctly. Chart heights and
 * text sizes are fixed px: only the width stretches with the page.
 *
 * Referenced by:
 *   - src/views/project/record/boh/burn-down.js (template res/templates/project/record/boh/burn-down.tpl)
 *   - src/views/project/record/panels/boh-hours.js (template res/templates/project/record/panels/boh-hours.tpl)
 *   - src/views/project/record/plan.js (adds .boh-plan)
 *
 * Registered in Resources/metadata/app/client.json "cssList".
 */

/* ── Panels ──────────────────────────────────────────────────────────── */

/* The Burn-down is a normal panel at the top of the record's main column, and Hours Used vs
   Remaining a normal side panel, so both take their frame, width and spacing from the theme like
   the panels around them. Only the heading gains a right-aligned note: the period or the total. */
/* No flex gap: the side-panel frame puts an empty actions container before the title, and a gap
   beside it would push the title out of line with the other side panels. */
.boh-panel > .panel-heading {
    display: flex;
    align-items: baseline;
}

.boh-panel-meta {
    margin-left: auto;
    padding-left: 12px;
    font-size: 12px;
    color: var(--text-muted-color);
    text-align: right;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* Remaining at or past the warning / danger threshold (the project's totalRemainingHoursLevel). */
.record .panel.boh-hours.boh-level-warning {
    border: 1px solid var(--brand-warning);
}

.record .panel.boh-hours.boh-level-danger {
    border: 1px solid var(--brand-danger);
}

/* ── Burn-down ───────────────────────────────────────────────────────── */

/* Legend: 16×2 line swatch for Remaining, 10×10 square for monthly hours. */
.boh-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 4px 16px;
    margin-bottom: 12px;
    font-size: 12px;
    color: var(--text-muted-color);
}

.boh-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.boh-swatch-line {
    width: 16px;
    height: 2px;
    background: var(--brand-warning);
}

.boh-swatch-bar {
    width: 10px;
    height: 10px;
    background: var(--brand-primary);
}

/* Each plot is a fixed-height box; its SVG fills it and stretches only horizontally. Labels are
   positioned over it in percentages, so they keep their size at any width. */
.boh-plot {
    position: relative;
}

.boh-plot > svg {
    display: block;
    width: 100%;
    height: 100%;
    overflow: visible;
}

.boh-plot-remaining {
    height: 150px;
}

.boh-plot-bars {
    height: 44px;
}

.boh-grid {
    stroke: var(--default-border-color);
    stroke-width: 1;
}

.boh-grid-base {
    stroke: var(--text-muted-color);
}

.boh-line {
    fill: none;
    stroke: var(--brand-warning);
    stroke-width: 2;
    stroke-linejoin: round;
}

.boh-bar {
    fill: var(--brand-primary);
}

/* 8px dot on the last point, with its value just above and to the left. */
.boh-end-dot {
    position: absolute;
    width: 8px;
    height: 8px;
    margin: -4px 0 0 -4px;
    border-radius: 50%;
    background: var(--brand-warning);
}

.boh-end-label {
    position: absolute;
    transform: translate(-100%, -100%);
    padding: 0 6px 4px 0;
    font-size: 12px;
    font-weight: 500;
    white-space: nowrap;
    font-variant-numeric: tabular-nums;
}

/* "Per Month", 14px above the bars. */
.boh-per-month {
    margin: 10px 0 14px;
    font-size: 11px;
    color: var(--text-muted-color);
}

/* The bar axis maximum, top-left of the bar plot. */
.boh-bar-max {
    position: absolute;
    top: -14px;
    left: 0;
    font-size: 11px;
    color: var(--text-muted-color);
    font-variant-numeric: tabular-nums;
}

/* One equal column per month slot, aligned with the plots above; the year sits under the first
   month of each year. */
.boh-x-labels {
    display: grid;
    grid-template-columns: repeat(var(--boh-slots), minmax(0, 1fr));
    margin-top: 6px;
    font-size: 11px;
    color: var(--text-muted-color);
    text-align: center;
}

.boh-x-label {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    white-space: nowrap;
}

.boh-x-year {
    font-size: 11px;
}

/* ── Hours Used vs Remaining (side panel) ────────────────────────────── */

.boh-hours-body {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

/* 172px donut, radius 66, stroke 20; used arc from 12 o'clock over the remaining colour. */
.boh-donut {
    position: relative;
    width: 172px;
    height: 172px;
    flex: none;
}

.boh-donut circle {
    fill: none;
    stroke-width: 20;
}

.boh-donut-remaining {
    stroke: var(--brand-warning);
}

.boh-donut-used {
    stroke: var(--brand-primary);
}

.boh-donut-centre {
    position: absolute;
    inset: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.boh-donut-percent {
    font-size: 24px;
    font-weight: 500;
    line-height: 1.1;
    font-variant-numeric: tabular-nums;
}

.boh-donut-caption {
    font-size: 12px;
    color: var(--text-muted-color);
}

/* Compact figures: one 22px line each, colour square, muted label, tabular value on the right. */
.boh-figures {
    width: 100%;
    margin: 0;
    padding: 0;
    list-style: none;
}

.boh-figure {
    display: flex;
    align-items: center;
    gap: 8px;
    line-height: 22px;
}

.boh-figure-swatch {
    width: 8px;
    height: 8px;
    flex: none;
}

.boh-figure-used .boh-figure-swatch {
    background: var(--brand-primary);
}

.boh-figure-remaining .boh-figure-swatch {
    background: var(--brand-warning);
}

/* Total: a top rule and an outlined square. */
.boh-figure-total {
    border-top: 1px solid var(--default-border-color);
    margin-top: 2px;
    padding-top: 2px;
}

.boh-figure-total .boh-figure-swatch {
    border: 1px solid var(--text-muted-color);
}

/* Excluded (over task limits): staff only, a muted hollow square under the Total rule. */
.boh-figure-excluded .boh-figure-swatch {
    border: 1px dashed var(--text-muted-color);
}

.boh-figure-excluded .boh-figure-label {
    font-style: italic;
}

.boh-figure-label {
    flex: 1;
    font-size: 13px;
    color: var(--text-muted-color);
}

.boh-figure-value {
    font-size: 14px;
    font-variant-numeric: tabular-nums;
}

/* ── BoH Plan ─────────────────────────────────────────────────────────── */

/* Task names stay on one line with an ellipsis; the link's title shows the full name. */
.boh-plan [data-role="group"] td.cell[data-name="name"] {
    max-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Below ~820px each group scrolls sideways instead of squeezing its columns. */
.boh-plan [data-role="group"] .list {
    overflow-x: auto;
}

.boh-plan [data-role="group"] .list > table {
    min-width: 820px;
}
