﻿/*
 * Projects dashboard.
 *
 * Palette and the shared primitives (status pills, percent cells, burn bar, .hours-over)
 * come from css/projects/shared.css. This file lays out the page: KPI band, pulse strip,
 * portfolio Gantt, chart grid, scorecard and attention list.
 *
 * The Gantt block deliberately reuses the same class names as the project-detail Gantt in
 * css/projects/project/index.css. The two never load together — a dashboard page does not
 * load the detail stylesheet — so there is no collision, and keeping the names identical is
 * what stops the two timelines drifting into different-looking components.
 */

.projects-dashboard {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* ============================ KPI band ============================ */

.kpi-band {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 16px;
}

@media (max-width: 1200px) {
    .kpi-band { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 620px) {
    .kpi-band { grid-template-columns: 1fr; }
}

.stat-card {
    background: #fff;
    border: 1px solid var(--proj-border);
    border-radius: 8px;
    padding: 16px;
}

/* Affordance for the drillable cards. drilldown.js adds .is-drillable. */
.stat-card.is-drillable {
    cursor: pointer;
    transition: box-shadow 0.15s ease, transform 0.15s ease;
}

.stat-card.is-drillable:hover {
    box-shadow: 0 4px 12px rgba(15, 23, 42, 0.10);
    transform: translateY(-1px);
}

.stat-card.is-drillable:focus-visible {
    outline: 2px solid var(--proj-green);
    outline-offset: 2px;
}

.stat-header { display: flex; justify-content: space-between; margin-bottom: 10px; }

.stat-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 15px;
}

.stat-icon.navy { background-color: var(--proj-navy); }
.stat-icon.green { background-color: var(--proj-done); }
.stat-icon.teal { background-color: var(--proj-green); }
.stat-icon.red { background-color: var(--proj-over); }
.stat-icon.amber { background-color: var(--proj-blocked); }
.stat-icon.slate { background-color: var(--proj-notstarted); }

.stat-label {
    font-size: 13px;
    font-weight: 600;
    color: var(--proj-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.stat-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--proj-navy);
    font-variant-numeric: tabular-nums;
    line-height: 1.2;
}

/* Two lines of room, so a card whose sub-line wraps does not sit taller than its
   neighbours and break the band's alignment. */
.stat-sub {
    font-size: 12px;
    color: var(--proj-muted);
    min-height: 30px;
    line-height: 1.3;
}

.stat-sub-link {
    color: var(--proj-over);
    font-weight: 600;
    text-decoration: none;
}

/* The neutral variant: a sub-line that is information rather than a warning. */
.stat-sub-link.stat-sub-neutral { color: var(--proj-muted); font-weight: 600; }

.stat-sub-link:hover { text-decoration: underline; }

/* ============================ Pulse strip ============================ */

.pulse-band {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

@media (max-width: 1000px) {
    .pulse-band { grid-template-columns: 1fr; }
}

.pulse-card {
    background: #fff;
    border: 1px solid var(--proj-border);
    border-radius: 8px;
    padding: 16px;
}

.pulse-head {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    margin-bottom: 10px;
}

.pulse-title {
    font-size: 13px;
    font-weight: 600;
    color: var(--proj-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.pulse-figure {
    font-size: 20px;
    font-weight: 700;
    color: var(--proj-navy);
    font-variant-numeric: tabular-nums;
}

.pulse-figure.is-over { color: var(--proj-over); }

.pulse-note {
    font-size: 12px;
    color: var(--proj-muted);
    margin-top: 8px;
    min-height: 16px;
    line-height: 1.4;
}

.meter-track {
    height: 10px;
    background-color: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.meter-fill {
    height: 100%;
    background-color: var(--proj-navy);
    border-radius: 999px;
    transition: width 0.3s ease;
}

.split-track {
    display: flex;
    height: 10px;
    background-color: #e2e8f0;
    border-radius: 999px;
    overflow: hidden;
}

.split-seg { height: 100%; }

.pulse-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 10px;
}

.pulse-legend-item {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 12px;
    color: var(--proj-muted);
    text-decoration: none;
}

.pulse-legend-item:hover { text-decoration: underline; }

.pulse-legend-item strong {
    color: var(--proj-navy);
    font-variant-numeric: tabular-nums;
}

.legend-dot {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 999px;
}

/* ============================ Panels ============================ */

.dash-panel {
    background: #fff;
    border: 1px solid var(--proj-border);
    border-radius: 8px;
    padding: 16px;
}

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

.panel-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--proj-navy);
    margin: 0;
}

.panel-title i { margin-right: 6px; color: var(--proj-notstarted); }

.panel-sub {
    font-size: 12px;
    color: var(--proj-muted);
    margin: 4px 0 0;
}

.panel-note { font-size: 12px; color: var(--proj-muted); }

.panel-tools {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.panel-tools .filter-input { max-width: 230px; }

/* ============================ Chart grid ============================ */

.chart-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
}

.split-grid {
    display: grid;
    grid-template-columns: 1.15fr 1fr;
    gap: 20px;
}

@media (max-width: 1100px) {
    .chart-grid,
    .split-grid { grid-template-columns: 1fr; }
}

/* A fixed height is what makes maintainAspectRatio:false safe — without it Chart.js and a
   flex parent grow each other on every resize. */
.chart-wrapper {
    position: relative;
    height: 300px;
}

/* Only the horizontal bar chart needs the extra room — ten project rows plus an axis. The
   two doughnuts stay at the base height so they read as the same component. */
.chart-wrapper.tall { height: 340px; }

/* ============================ Portfolio Gantt ============================ */

.zoom-group {
    display: inline-flex;
    border: 1px solid var(--proj-border);
    border-radius: 6px;
    overflow: hidden;
    background: #fff;
}

.zoom-btn {
    border: none;
    background: transparent;
    padding: 6px 12px;
    font-size: 13px;
    font-weight: 600;
    color: var(--proj-muted);
    cursor: pointer;
    border-left: 1px solid var(--proj-border);
}

.zoom-btn:first-child { border-left: none; }
.zoom-btn:hover { background-color: #f1f5f9; }

.zoom-btn.active {
    background-color: var(--proj-navy);
    color: #fff;
}

.range-group {
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.range-label {
    font-size: 12px;
    color: var(--proj-muted);
    min-width: 190px;
    text-align: center;
}

.gantt-legend {
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
    font-size: 12px;
    color: var(--proj-muted);
    margin-bottom: 8px;
}

.legend-swatch {
    display: inline-block;
    width: 14px;
    height: 8px;
    border-radius: 2px;
    margin-right: 4px;
}

.swatch-plan { background-color: #cbd5e1; }
.swatch-actual { background-color: var(--proj-green); }
.swatch-over { background-color: var(--proj-over); }

/* The overdue marker is a cap, not a bar, so its swatch is drawn in the cap's shape. Both
   it and the over-budget swatch are red; the shape is what tells them apart. */
.swatch-late {
    background-color: var(--proj-over);
    width: 5px;
    height: 14px;
    vertical-align: -3px;
}

/* Horizontal scroll lives out here and only engages on a narrow screen — the timeline
   columns are sized in percentages, so at normal widths there is nothing to scroll. */
.gantt-scroll { overflow-x: auto; }

.gantt {
    border: 1px solid var(--proj-border);
    border-radius: 8px;
    overflow: hidden;
    background: #fff;
    min-width: 900px;
}

/* Head and body are rows, each split into the same two panes. One vertical scroller (the
   body) under one frozen header — the two sides cannot drift out of alignment because they
   are inside the same scrollport. */
.gantt-head-row,
.gantt-body { display: flex; }

.gantt-body {
    max-height: 560px;
    overflow-y: auto;
}

.gantt-left {
    flex: 0 0 380px;
    min-width: 0;
    border-right: 1px solid var(--proj-border);
}

.gantt-right { flex: 1; min-width: 0; }

.gantt-head,
.gantt-row {
    display: flex;
    align-items: center;
    height: 44px;
    border-bottom: 1px solid #f1f5f9;
    font-size: 13px;
}

.gantt-head {
    font-weight: 600;
    color: var(--proj-muted);
    background: #f8fafc;
    font-size: 12px;
    text-transform: uppercase;
    height: 34px;
}

.gantt-row .col-name,
.gantt-head .col-name {
    flex: 1;
    padding-left: 8px;
    display: flex;
    align-items: center;
    gap: 4px;
    overflow: hidden;
}

/* flex:1 with min-width:0 is what actually lets the ellipsis clip — a flex child defaults
   to min-width:auto and refuses to shrink below its own content. */
.gantt-row .row-name {
    flex: 1;
    min-width: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: block;
}

.gantt-row .row-link {
    color: var(--proj-navy);
    text-decoration: none;
}

.gantt-row .row-link:hover { text-decoration: underline; }

.gantt-row .row-number {
    font-weight: 700;
    font-variant-numeric: tabular-nums;
}

.row-sub {
    display: block;
    font-size: 11px;
    font-weight: 400;
    color: var(--proj-muted);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.gantt-row .col-hours,
.gantt-head .col-hours {
    flex: 0 0 58px;
    text-align: right;
    padding-right: 10px;
    font-variant-numeric: tabular-nums;
}

.gantt-row.level-project { font-weight: 600; color: var(--proj-navy); }
.gantt-row.level-phase { background: #f8fafc; font-size: 12px; }
.gantt-row.level-phase .col-name { padding-left: 26px; }
.gantt-row.is-over { background-color: var(--proj-over-tint); }
.gantt-row-empty .row-name { font-style: italic; }

.late-icon { color: var(--proj-over); }

.gantt-toggle {
    border: none;
    background: transparent;
    color: var(--proj-muted);
    cursor: pointer;
    width: 18px;
    padding: 0;
    flex: 0 0 18px;
}

.gantt-toggle:hover { color: var(--proj-navy); }

.gantt-toggle-spacer { display: inline-block; width: 18px; flex: 0 0 18px; }

.gantt-timeline-head {
    display: flex;
    height: 34px;
    background: #f8fafc;
    border-bottom: 1px solid var(--proj-border);
}

.gantt-col-head {
    flex: 0 0 auto;
    font-size: 11px;
    color: var(--proj-muted);
    text-align: center;
    line-height: 34px;
    border-left: 1px solid #f1f5f9;
    overflow: hidden;
    white-space: nowrap;
}

.gantt-bar-row {
    position: relative;
    height: 44px;
    border-bottom: 1px solid #f1f5f9;
}

.gantt-bar-row.level-phase { background: #f8fafc; }

.gantt-grid { position: absolute; inset: 0; }

.gantt-grid-col {
    position: absolute;
    top: 0;
    bottom: 0;
    border-left: 1px solid #f1f5f9;
}

/* Dashed today line, drawn over the grid but under the bars. */
.gantt-today {
    position: absolute;
    top: 0;
    bottom: 0;
    width: 0;
    border-left: 2px dashed var(--proj-over);
    z-index: 1;
}

.bar {
    position: absolute;
    border-radius: 3px;
    z-index: 2;
}

/* The plan bar is the full-height track; the completion fill sits inside it so the
   proportion reads as a fill rather than as two unrelated bars. */
.bar-plan {
    top: 15px;
    height: 14px;
    background-color: #cbd5e1;
}

.bar-actual {
    top: 17px;
    height: 10px;
    background-color: var(--proj-green);
    z-index: 3;
}

/* Hung off the end of the plan rather than inside it: the overrun is time the plan never
   accounted for, and drawing it inside would hide it behind the fill. */
.bar-over {
    top: 17px;
    height: 10px;
    background-color: var(--proj-over);
    z-index: 3;
}

.bar-late-cap {
    top: 11px;
    height: 22px;
    background-color: var(--proj-over);
    border-radius: 1px;
    z-index: 4;
}

.bar-phase {
    top: 18px;
    height: 8px;
    background-color: #e2e8f0;
}

.bar-phase-fill {
    top: 18px;
    height: 8px;
    background-color: var(--proj-notstarted);
    opacity: 0.85;
    z-index: 3;
}

/* A bar continuing past the visible window loses its cap on that side, so the user can
   tell "runs off the edge" from "ends here". */
.bar.clipped-left { border-top-left-radius: 0; border-bottom-left-radius: 0; }
.bar.clipped-right { border-top-right-radius: 0; border-bottom-right-radius: 0; }

/* A project with no dates at all still gets a row and says so, rather than rendering an
   empty lane that reads as a loading failure. */
.bar-missing {
    position: absolute;
    left: 8px;
    top: 14px;
    font-size: 11px;
    color: var(--proj-muted);
    font-style: italic;
    background: #f8fafc;
    border: 1px dashed var(--proj-border);
    border-radius: 3px;
    padding: 1px 8px;
}

/* ============================ Scorecard ============================ */

#scorecard-table td { vertical-align: middle; }

.drill-row { cursor: pointer; }
.drill-row:hover > td { background-color: #f8fafc; }

.unassigned-icon { color: var(--proj-blocked); margin-right: 4px; }

.flags-cell { white-space: nowrap; text-align: right; }

.flag {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    margin-left: 4px;
}

.flag i { font-size: 10px; }

.flag-late { background-color: #fee2e2; color: #991b1b; }
.flag-over { background-color: #fee2e2; color: #991b1b; }
.flag-risk { background-color: #fef3c7; color: #92400e; }
.flag-clear { background-color: #dcfce7; color: #166534; }

/* ============================ Attention list ============================ */

.attention-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.attention-row {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border: 1px solid var(--proj-border);
    border-radius: 6px;
    text-decoration: none;
    color: inherit;
    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.attention-row:hover {
    background-color: #f8fafc;
    border-color: #cbd5e1;
}

.severity-dot {
    flex: 0 0 8px;
    width: 8px;
    height: 8px;
    border-radius: 999px;
    margin-top: 6px;
}

.severity-critical .severity-dot { background-color: var(--proj-over); }
.severity-warning .severity-dot { background-color: var(--proj-blocked); }

/* min-width:0 is what lets the ellipsis inside actually clip — a flex child defaults to
   min-width:auto and refuses to shrink below its content. */
.attention-body { flex: 1; min-width: 0; }

.attention-title {
    display: block;
    font-size: 13px;
    color: var(--proj-navy);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attention-reason {
    display: block;
    font-size: 12px;
    color: #475569;
    margin-top: 2px;
    line-height: 1.4;
}

.severity-critical .attention-reason { color: #991b1b; }

.attention-meta {
    display: block;
    font-size: 11px;
    color: var(--proj-muted);
    margin-top: 3px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.attention-chevron {
    color: var(--proj-notstarted);
    font-size: 11px;
    margin-top: 5px;
}

.attention-clear {
    text-align: center;
    padding: 28px 16px;
    color: var(--proj-muted);
}

.attention-clear i {
    font-size: 28px;
    color: var(--proj-done);
    margin-bottom: 8px;
}

.attention-clear p { margin: 0; font-size: 13px; }
