/* ==========================================================================
   Productivity / Performance Report module
   Reuses the Schedule chrome classes for toolbar/footer/tabs but adds the
   bits that differ: red-accented landing header, KPI tile, action rail,
   inline bar cells, drawers (Applied Filters, Group By).
   ========================================================================== */
:root {
  --prod-red:        #e11d48;   /* rose-600 — matches chart bars */
  --prod-red-soft:   #fb7185;   /* rose-400 — gradient stop */
  --prod-teal:       #14b8a6;   /* teal-500 — KPI baseline + earned pills */
  --prod-teal-soft:  #5eead4;   /* teal-300 */
  --prod-indigo:     #6366f1;   /* indigo-500 — JTD baseline line + slider */
  --prod-bg:         #f3f5f7;
  --prod-link:       #1d4ed8;
}

/* Productivity landing — navy/grey hero band identical in shape to the
   Schedule landing but with the KBR mark on the right and the red accent
   border the screenshots show. */
.productivity-landing-shell .schedule-landing-header {
  background: linear-gradient(135deg, #1c3a5e 0%, #0f2342 100%);
}
.productivity-landing-shell .schedule-landing-header h1 { color: #fff; }
.productivity-landing-shell .schedule-navigate-btn {
  background: linear-gradient(180deg, #1c3a5e 0%, #0f2a44 100%);
  border-color: #1c3a5e;
}
.productivity-landing-shell .schedule-navigate-btn:not(:disabled):hover {
  background: linear-gradient(180deg, #2a4d72 0%, #1c3a5e 100%);
}

/* Productivity portfolio table — wider numeric columns, no critical cluster. */
.productivity-portfolio-table thead .col-row th { font-size: 11px; }
.productivity-portfolio-table tbody td.num { text-align: right; font-variant-numeric: tabular-nums; }
.productivity-portfolio-table .portfolio-cell { font-weight: 500; }

/* Actual cell pill — red when < 1 (underperforming), teal when >= 1. */
.productivity-portfolio-table .actual-pill {
  display: inline-block;
  padding: 2px 10px;
  border-radius: 4px;
  font-weight: 600;
  font-variant-numeric: tabular-nums;
  min-width: 48px;
  text-align: center;
}
.productivity-portfolio-table .actual-pill.actual-bad  { background: #fde2e2; color: var(--prod-red);  }
.productivity-portfolio-table .actual-pill.actual-good { background: #ccfbf1; color: var(--prod-teal); }

/* CPI / Variance arrows */
.productivity-portfolio-table .arrow,
.productivity-details-table .arrow { font-size: 10px; margin-left: 4px; }
.arrow.up      { color: #15803d; }
.arrow.down    { color: var(--prod-red); }
.arrow.neutral { color: #f59e0b; }

/* Inline cell bar for Earned % / Expended % — teal fill, value over it. */
.cell-bar {
  position: relative;
  background: linear-gradient(90deg, rgba(13,148,136,0.18) var(--pct, 0%), transparent var(--pct, 0%));
  padding: 2px 6px;
  border-radius: 3px;
  text-align: right;
  font-variant-numeric: tabular-nums;
}
.cell-bar.earned   { background: #b8e3da; }   /* approximation of the screenshot */
.cell-bar.expended { background: #6fb8ac; color: #fff; }

/* ---- Productivity overview / details shells ---------------------------- */
.productivity-shell { padding-bottom: 14px; }
.productivity-toolbar { padding-bottom: 6px; }
.productivity-toolbar .report-tag { color: var(--prod-link); }

/* KPI tile — Baseline (teal) + Actual (red) stacked rows, navy title bar. */
.productivity-kpi-card {
  width: 260px;
  border: 1px solid #cbd5e1;
  border-radius: 6px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 1px 2px rgba(15,23,42,0.06);
}
.productivity-kpi-card .productivity-kpi-title {
  background: #1c3a5e;
  color: #fff;
  font-weight: 600;
  font-size: 13px;
  text-align: center;
  padding: 6px 8px;
}
.productivity-kpi-row {
  display: flex;
  align-items: stretch;
  border-top: 1px solid #e2e8f0;
}
.productivity-kpi-row .kpi-label {
  flex: 0 0 92px;
  padding: 6px 12px;
  font-size: 12px;
  color: #475569;
  display: flex; align-items: center;
}
.productivity-kpi-row .kpi-value {
  flex: 1 1 auto;
  padding: 6px 14px;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  display: flex; align-items: center; justify-content: flex-start;
  color: #fff;
}
.productivity-kpi-row .kpi-baseline { background: var(--prod-teal); }
.productivity-kpi-row .kpi-actual   { background: var(--prod-red);  }

/* Productivity Graph panel — header bar with title centered + period inline */
.productivity-graph-panel { position: relative; }
.productivity-graph-header {
  display: flex; align-items: center; justify-content: space-between;
  gap: 16px;
  margin-bottom: 6px;
}
.productivity-graph-header h4 {
  margin: 0 auto;
  font-size: 14px;
  font-weight: 600;
  color: var(--sched-text);
  letter-spacing: -0.005em;
}
.productivity-period-slider .period-box {
  display: inline-flex; align-items: center; gap: 6px;
  border: 1px solid #cbd5e1;
  border-radius: 4px;
  padding: 4px 8px;
  background: #fff;
  font-size: 12px;
}
.productivity-period-slider .period-box label { color: #475569; font-weight: 600; margin: 0; }
.productivity-period-slider .period-box input[type="date"] { border: none; outline: none; font-size: 12px; }
.productivity-body .card-panel .chart-box.tall { height: 360px; }

/* Action rail — vertical column of icon buttons, sits at the right edge */
.productivity-action-rail {
  position: absolute;
  top: 80px; right: 16px;
  display: flex; flex-direction: column; gap: 8px;
  z-index: 5;
}
.productivity-action-rail .rail-btn {
  width: 32px; height: 32px;
  border-radius: 6px;
  border: 1px solid #cbd5e1;
  background: #fff;
  color: var(--sched-link);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 150ms ease, border-color 150ms ease, color 150ms ease, transform 120ms ease;
}
.productivity-action-rail .rail-btn:hover {
  background: #eff6ff; border-color: var(--sched-link-soft); transform: translateY(-1px);
}

/* Applied-Filters drawer (Overview) and Group-By drawer (Details) */
.productivity-applied-drawer,
.productivity-groupby-drawer {
  position: fixed; top: 0; right: -320px; height: 100%; width: 280px;
  background: #fff;
  box-shadow: -2px 0 10px rgba(0,0,0,0.10);
  z-index: 1040;
  transition: right .2s ease;
  display: flex; flex-direction: column;
}
.productivity-applied-drawer.open,
.productivity-groupby-drawer.open { right: 0; }
.productivity-applied-drawer .drawer-header,
.productivity-groupby-drawer .drawer-header {
  padding: 10px 14px;
  border-bottom: 1px solid #e2e8f0;
  display: flex; align-items: center; justify-content: space-between;
}
.productivity-applied-drawer .drawer-header h5 { margin: 0; color: var(--sched-link); font-size: 14px; font-weight: 700; }
.productivity-applied-drawer .drawer-close,
.productivity-groupby-drawer .drawer-close {
  background: transparent; border: none; font-size: 22px; line-height: 1;
  color: #1e2a38; cursor: pointer;
}
.productivity-applied-drawer .drawer-body,
.productivity-groupby-drawer .drawer-body { padding: 12px 14px; overflow-y: auto; }

/* Applied Filters list (read-only) — key/value rows */
.productivity-applied-drawer .applied-item {
  padding: 6px 0;
  border-bottom: 1px solid #eef1f5;
}
.productivity-applied-drawer .applied-item:last-child { border-bottom: none; }
.productivity-applied-drawer .applied-key {
  font-size: 11px;
  font-weight: 600;
  color: var(--sched-muted);
  letter-spacing: 0.03em;
}
.productivity-applied-drawer .applied-val {
  font-size: 13px;
  color: var(--sched-text);
  font-weight: 500;
  margin-top: 2px;
}
.productivity-applied-drawer .applied-empty {
  font-size: 12px;
  color: var(--sched-muted);
  font-style: italic;
  padding: 8px 0;
}

/* Group-by pills mirror the Power BI button list from the screenshot */
.groupby-pill {
  display: block;
  width: 100%;
  background: linear-gradient(180deg, #2a4d72 0%, #1c3a5e 100%);
  color: #fff;
  border: none;
  padding: 8px 12px;
  margin-bottom: 6px;
  border-radius: 16px;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 150ms ease, transform 120ms ease;
}
.groupby-pill:hover { filter: brightness(1.1); transform: translateY(-1px); }
.groupby-pill.active { background: linear-gradient(180deg, #1c3a5e 0%, #0f2342 100%); box-shadow: 0 0 0 2px #cbd5e1; }

/* Productivity details table — same chrome as schedule details but more numeric */
.productivity-details-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.productivity-details-table thead {
  background: linear-gradient(180deg, #2a4d72 0%, #1c3a5e 100%);
  color: #fff;
}
.productivity-details-table thead th {
  padding: 8px 8px;
  text-align: right;
  font-weight: 600;
  border: 1px solid #3b5cc9;
  font-size: 11px;
}
.productivity-details-table thead th:first-child { text-align: left; }
.productivity-details-table tbody td {
  padding: 6px 8px;
  border-bottom: 1px solid #eef1f5;
  background: #fff;
  font-variant-numeric: tabular-nums;
}
.productivity-details-table tbody td.num { text-align: right; }
.productivity-details-table tbody tr:nth-child(even) td { background: #f8fafc; }
.productivity-details-table tbody tr:hover td { background: #eef4fa; }
.productivity-details-table tbody tr.details-total-row td {
  font-weight: 700;
  background: #f1f5f9 !important;
  border-top: 2px solid #cbd5e1;
}

/* Productivity Details Tabulator — mirrors PAF Details (#tblDetails) for
   cross-module consistency. Soft-gray header, white rows, thin dividers. */
#tblProductivityDetails.tabulator {
  font-size: 12px;
  color: #1f2937;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 6px;
}
#tblProductivityDetails .tabulator-header {
  background: #f3f4f6;
  border-bottom: 1px solid #e5e7eb;
}
#tblProductivityDetails .tabulator-header .tabulator-col {
  background: transparent;
  border-right: 1px solid #e5e7eb;
  padding: 6px 10px;
}
#tblProductivityDetails .tabulator-header .tabulator-col:last-child { border-right: none; }
#tblProductivityDetails .tabulator-header .tabulator-col-content { padding: 0; }
#tblProductivityDetails .tabulator-header .tabulator-col-title {
  font-size: 12px;
  font-weight: 600;
  color: #374151;
}
#tblProductivityDetails .tabulator-col-sorter { right: 6px; }
#tblProductivityDetails .tabulator-col-sorter .tabulator-arrow {
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 5px solid #cbd5e1;
}
#tblProductivityDetails .tabulator-col[aria-sort="ascending"] .tabulator-arrow {
  border-bottom-color: #111827;
}
#tblProductivityDetails .tabulator-col[aria-sort="descending"] .tabulator-arrow {
  border-bottom: none;
  border-top: 5px solid #111827;
}
#tblProductivityDetails .tabulator-tableholder { background: #fff; }
#tblProductivityDetails .tabulator-row {
  background: #fff;
  border-bottom: 1px solid #f1f5f9;
  min-height: 36px;
}
#tblProductivityDetails .tabulator-row.tabulator-row-even { background: #fff; }
#tblProductivityDetails .tabulator-row:hover { background: #f9fafb; }
#tblProductivityDetails .tabulator-row .tabulator-cell {
  padding: 8px 10px;
  border-right: none;
  color: #1f2937;
  font-variant-numeric: tabular-nums;
}

/* Group By + Columns dropdowns — match the visual weight of the other
   filter combos used in PAF Details / Cost Status Report. */
#groupByHost .cols-btn,
#columnsHost .cols-btn {
  background: #fff;
  border: 1px solid #d6dde7;
  border-radius: 6px;
  padding: 6px 28px 6px 10px;
  font-size: 13px;
  color: var(--kbr-navy);
  min-height: 34px;
}
#groupByHost .cols-btn:hover,
#columnsHost .cols-btn:hover { border-color: #bfc7d1; }
#groupByHost .cols-dropdown { right: auto; left: 0; min-width: 220px; }

/* Footer for Productivity — same chrome class set as Schedule's */
.productivity-footer { gap: 12px; }
.productivity-footer .footer-item.end { margin-left: auto; }

/* Productivity slicer — modernized track with a sky→indigo gradient fill,
   brighter thumbs, and tick labels positioned far enough below the track
   that the thumbs can't sit on top of them. */
.productivity-range-slicer { margin: 4px 0 24px; padding: 6px 24px 0; position: relative; }
.productivity-range-slicer .range-slicer-track { height: 24px; }
.productivity-range-slicer .rs-rail {
  height: 6px; top: 9px;
  background: #e2e8f0; border-radius: 3px;
}
.productivity-range-slicer .rs-fill {
  height: 6px; top: 9px;
  background: linear-gradient(90deg, #0ea5e9 0%, #6366f1 100%);
  border-radius: 3px;
  box-shadow: 0 1px 2px rgba(99,102,241,0.25);
}
.productivity-range-slicer input[type="range"]::-webkit-slider-thumb {
  width: 20px; height: 20px;
  background: #fff;
  border: 3px solid #6366f1;
  box-shadow: 0 2px 6px rgba(99,102,241,0.35);
}
.productivity-range-slicer input[type="range"]::-moz-range-thumb {
  width: 20px; height: 20px;
  background: #fff;
  border: 3px solid #6366f1;
  box-shadow: 0 2px 6px rgba(99,102,241,0.35);
}
.productivity-range-slicer .rs-ticks {
  display: flex; justify-content: space-between;
  font-size: 11px; font-weight: 600; color: #475569;
  margin-top: 8px;
  padding: 0;
}
/* Pin the first and last tick labels so they sit inside the panel padding,
   never clipped or hidden behind the slider thumbs. */
.productivity-range-slicer .rs-ticks span:first-child { transform: translateX(-12px); }
.productivity-range-slicer .rs-ticks span:last-child  { transform: translateX(12px); }

/* Chart→table view, rendered in place of the canvas when btnToggleView active.
   `.as-table` is toggled on the .chart-box by overview.js so the otherwise
   fixed-height container becomes a vertical scroll surface — keeps the long
   per-period table from overflowing into the page footer. */
.productivity-body .card-panel .chart-box.as-table {
  overflow-y: auto;
  padding-right: 4px;
}
.productivity-graph-table { width: 100%; border-collapse: collapse; font-size: 12px; }
.productivity-graph-table th, .productivity-graph-table td {
  padding: 5px 10px; border-bottom: 1px solid #eef1f5;
  font-variant-numeric: tabular-nums;
}
.productivity-graph-table th {
  color: var(--sched-link); font-weight: 600; text-align: left;
  position: sticky; top: 0;            /* stays visible while the body scrolls */
  background: #fff;
  z-index: 1;
}
.productivity-graph-table .num { text-align: right; }
.productivity-graph-table .total-row td { background: #f1f5f9; border-top: 2px solid #cbd5e1; }

/* Responsive */
@media (max-width: 991px) {
  .productivity-action-rail { position: static; flex-direction: row; margin-top: 8px; justify-content: flex-end; }
}
@media (max-width: 768px) {
  .productivity-kpi-card { width: 100%; }
  .productivity-body .card-panel .chart-box.tall { height: 280px; }
}

/* ==========================================================================
   Cross-module responsive — covers gaps left by the per-module @media blocks.
   Applies to the Staffing chrome (page-toolbar / page-footer / kpi-strips),
   the hub home, and any wide tables that need horizontal scrolling.
   ========================================================================== */

/* Tablet landscape — toolbars and footers wrap, KPI strips relax */
@media (max-width: 991px) {
  /* Staffing top toolbar: stack the tab nav and reporting-date box */
  .page-toolbar {
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 14px;
  }
  .tab-nav { flex-wrap: wrap; gap: 12px; }
  .tab-link { font-size: 14px; padding: 6px 2px 8px; }
  .reporting-date-box { min-width: 0; flex: 1 1 220px; }

  /* Staffing page body padding */
  .page-body { padding: 12px 14px 18px; }

  /* KPI strips become 3-up or 2-up. The .three variant collapses to 2-col
     on narrow screens to keep each tile readable. */
  .kpi-strip { grid-template-columns: repeat(3, 1fr); }
  .kpi-strip.three { grid-template-columns: repeat(2, 1fr); }

  /* Staffing page footer wraps so it never overflows */
  .page-footer {
    flex-wrap: wrap;
    gap: 8px;
    padding: 10px 14px;
    font-size: 12px;
  }

  /* Inline filter/toggle clusters wrap */
  .date-range-box, .toggle-group, .toggle-rect { flex-wrap: wrap; }

  /* Hub mini row (OPSR / ePCSR / Monthly / Client / Project Data Hub) wraps */
  .hub-mini-row { flex-wrap: wrap; gap: 8px; }
}

/* Tablet portrait — single-column tiles, smaller chart heights, wrap tabs */
@media (max-width: 768px) {
  .kbr-header { padding: 14px 16px; }
  .kbr-header .kbr-meta { position: static; text-align: left; margin-top: 8px; }
  .kbr-header h1 { display: block; margin: 8px 0 0 0; font-size: 20px; }

  .hub-shell { padding: 24px 16px; }
  .hub-title { font-size: 26px; }

  /* Staffing chart panels shrink */
  .page-body .card-panel .chart-box.tall { height: 280px; }

  /* Staffing KPI strip drops to 2-up across all variants */
  .kpi-strip,
  .kpi-strip.three { grid-template-columns: repeat(2, 1fr); }

  /* Wide tables: enable horizontal scroll if not already wrapped */
  .data-table-wrap,
  .schedule-portfolio-wrap,
  .productivity-portfolio-wrap { -webkit-overflow-scrolling: touch; }
  .schedule-portfolio-table,
  .productivity-portfolio-table { min-width: 880px; }
  .productivity-details-table,
  .schedule-details-table { min-width: 780px; }

  /* Productivity graph header — let the title and period box stack */
  .productivity-graph-header { flex-direction: column; align-items: stretch; gap: 6px; }
  .productivity-graph-header h4 { margin: 0; text-align: left; }
  .productivity-period-slider .period-box { width: 100%; justify-content: space-between; }

  /* Productivity action rail already horizontal at 991px; tighten gap */
  .productivity-action-rail { gap: 6px; }
}

/* Phone — single-column KPI strips, smaller fonts, wider drawers */
@media (max-width: 575px) {
  .page-body { padding: 10px 10px 16px; }
  .page-toolbar { padding: 8px 10px; }

  .tab-nav { gap: 10px; }
  .tab-link { font-size: 13px; }

  /* Single-column KPI tiles on phones */
  .kpi-strip,
  .kpi-strip.three { grid-template-columns: 1fr; }

  /* Footers stack vertically on phones */
  .page-footer { flex-direction: column; align-items: flex-start; }
  .schedule-shell .schedule-footer { flex-direction: column; align-items: flex-start; }
  .schedule-footer .footer-item.end,
  .productivity-footer .footer-item.end { margin-left: 0; }

  /* Filter slide-in drawers become near-full-width on phones */
  .filter-panel,
  .schedule-filter-panel,
  .productivity-applied-drawer,
  .productivity-groupby-drawer { width: 92vw; right: -100vw; }
  .filter-panel.open,
  .schedule-filter-panel.open,
  .productivity-applied-drawer.open,
  .productivity-groupby-drawer.open { right: 0; }

  /* Chart heights shrink further on phones */
  .page-body .card-panel .chart-box.tall,
  .productivity-body .card-panel .chart-box.tall { height: 240px; }

  /* Productivity KPI tile fills the screen */
  .productivity-kpi-card { width: 100%; }
}

