/* Payroll (js/modules/payroll.js): the roster cards, the filter bar, the
   paycheck stub and the printable payroll register. Loaded on first use
   with ui.stylesheet(). Colors and radii come from app.css. */

/* ---------- Filters ---------- */

.pr-filters { display: flex; flex-direction: column; }
.pr-filterbar { display: flex; flex-direction: column; gap: 10px; }
.pr-chiprow { align-items: center; }
.pr-chip-divider { width: 1px; height: 22px; background: var(--line-strong); margin: 0 2px; flex-shrink: 0; }
.pr-range { font-size: 0.85rem; color: var(--text-dim); }
.pr-narrow { display: none; }

/* Phones keep the app's iPhone rows: menus and a switch. */
@media (max-width: 760px) {
  .pr-filterbar { display: none; }
  .pr-narrow { display: flex; }
}

.pr-formrow {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 8px 16px; min-height: 52px;
}
.pr-formrow > span { color: var(--ink); font-weight: 520; }
.pr-formrow .select, .pr-formrow .input { max-width: 62%; }
.pr-formrow .input { width: auto; }
.pr-info { display: flex; gap: 8px; align-items: flex-start; padding: 12px 16px; font-size: 0.86rem; color: var(--text-dim); }
.pr-info .icon { color: var(--ink); margin-top: 2px; }

/* ---------- Footers and flags ---------- */

.pr-foot { display: flex; flex-direction: column; gap: 6px; }
.pr-warn { display: flex; gap: 6px; align-items: flex-start; color: var(--orange); }
.pr-warn .icon { color: var(--ink); margin-top: 2px; }
.pr-orange { color: var(--orange) !important; }

/* ---------- Roster cards ---------- */

.pr-list { container: prlist / inline-size; }
.pr-card {
  display: flex; align-items: flex-start; gap: 12px; width: 100%; padding: 12px 16px;
  text-align: left; color: inherit; font: inherit; background: none; border: 0;
}
.pr-card.is-link { cursor: pointer; }
.pr-card.is-link:hover { background: rgba(23, 32, 51, 0.035); }
.pr-card.is-selected { background: rgba(23, 32, 51, 0.045); }
.pr-check { flex-shrink: 0; height: 40px; display: flex; align-items: center; color: var(--ink); }
.pr-chevron { align-self: center; }
.pr-body { flex: 1; min-width: 0; display: flex; align-items: flex-start; gap: 10px; }
.pr-details { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.pr-name { display: flex; align-items: center; gap: 6px; min-width: 0; }
.pr-name-text { font-weight: 620; color: var(--ink); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; min-width: 0; }
.pr-name .badge { flex-shrink: 0; }
.pr-role { font-size: 0.8rem; color: var(--text-dim); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-address { font-size: 0.74rem; color: var(--text-faint); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.pr-pay { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 6px; margin-top: 1px; }
.pr-rate { font-size: 0.8rem; font-weight: 650; color: var(--ink); white-space: nowrap; font-variant-numeric: tabular-nums; }
.pr-extras { font-size: 0.75rem; color: var(--text-dim); }
.pr-line { font-size: 0.75rem; color: var(--text-dim); }
.pr-details .pr-warn { font-size: 0.75rem; }

.pr-net { flex-shrink: 0; text-align: right; display: flex; flex-direction: column; gap: 2px; }
.pr-net-label { font-size: 0.74rem; color: var(--text-dim); }
.pr-net-amount { font-size: 1.2rem; font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pr-net-amount.is-none { color: var(--text-dim); }
.pr-net-sub { font-size: 0.74rem; color: var(--text-dim); font-variant-numeric: tabular-nums; white-space: nowrap; }

.pr-netbar {
  display: none; margin-top: 6px; padding: 7px 10px; border-radius: 10px;
  background: rgba(23, 32, 51, 0.06);
}
.pr-netbar-row { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.pr-netbar-label { font-size: 0.8rem; font-weight: 550; color: var(--text-dim); white-space: nowrap; }
.pr-netbar-amount { font-size: 1.15rem; font-weight: 750; color: var(--ink); font-variant-numeric: tabular-nums; white-space: nowrap; }
.pr-netbar-none { font-size: 0.8rem; color: var(--text-dim); }
.pr-netbar-sub { font-size: 0.8rem; color: var(--text-dim); text-align: right; font-variant-numeric: tabular-nums; }

/* The compact card (iPhone, a narrow window): who, how they're paid and
   net pay along the bottom; address and W-4 are left to the paycheck. */
@container prlist (max-width: 620px) {
  .pr-full-only { display: none !important; }
  .pr-net { display: none; }
  .pr-netbar { display: block; }
  .pr-pay .pr-extras { flex-basis: 100%; }
  .pr-details { gap: 2px; }
}

/* ---------- Export sheet ---------- */

.pr-export { display: flex; flex-direction: column; gap: 12px; }
.pr-export-summary { font-size: 0.88rem; color: var(--text-dim); }

/* ---------- Paycheck ---------- */

.pr-stub { display: flex; flex-direction: column; gap: 16px; }
.pr-box {
  display: flex; flex-direction: column; gap: 12px; padding: 16px;
  background: var(--surface); border: 1px solid var(--edge); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); min-width: 0;
}
.pr-stubcard { container: prstub / inline-size; }
.pr-hr { border: 0; border-top: 1px solid var(--line); margin: 0; }
.pr-card-title { font-size: 1.02rem; font-weight: 700; color: var(--ink); }
.pr-caption { font-size: 0.8rem; color: var(--text-dim); }

.pr-stub-head {
  display: grid; grid-template-columns: minmax(0, 1fr) auto auto; gap: 14px 24px; align-items: start;
  font-size: 0.92rem;
}
.pr-stub-side { display: contents; }
.pr-stub-emp { display: flex; flex-direction: column; gap: 2px; min-width: 0; overflow-wrap: anywhere; }
.pr-stub-name { font-weight: 700; color: var(--ink); font-size: 1rem; }
.pr-grid { display: grid; grid-template-columns: auto auto; gap: 4px 12px; margin: 0; }
.pr-grid dt { color: var(--text-dim); }
.pr-grid dd { margin: 0; color: var(--ink); font-variant-numeric: tabular-nums; }
@container prstub (max-width: 820px) {
  .pr-stub-head { grid-template-columns: minmax(0, 1fr) auto; }
  .pr-stub-side { display: flex; flex-direction: column; gap: 12px; }
}
@container prstub (max-width: 520px) {
  .pr-stub-head { grid-template-columns: minmax(0, 1fr); }
}

.pr-basis { font-size: 0.85rem; color: var(--text-dim); font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }

/* Earnings beside taxes only when both fit unwrapped (about 480px each). */
.pr-tables { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 28px; align-items: start; }
@container prstub (max-width: 980px) {
  .pr-tables { grid-template-columns: minmax(0, 1fr); gap: 20px; }
}
.pr-t { width: 100%; border-collapse: collapse; font-size: 0.9rem; font-variant-numeric: tabular-nums; }
.pr-t th {
  font-size: 0.76rem; font-weight: 650; color: var(--text-dim); text-align: right; white-space: nowrap;
  padding: 0 0 6px 12px; border-bottom: 1px solid var(--line-strong);
}
.pr-t td { padding: 5px 0 5px 12px; text-align: right; white-space: nowrap; color: var(--ink); }
.pr-t th:first-child, .pr-t td:first-child { text-align: left; padding-left: 0; }
.pr-t td:first-child { white-space: normal; min-width: 8em; }
.pr-t td.dim { color: var(--text-dim); }
.pr-t td.pr-t-note { white-space: normal; color: var(--text-dim); }
.pr-t tfoot td { font-weight: 650; border-top: 1px solid var(--line-strong); padding-top: 7px; }

.pr-netcard { display: flex; justify-content: space-between; align-items: baseline; gap: 16px; flex-wrap: wrap; }
.pr-netcard-left { display: flex; flex-direction: column; gap: 4px; }
.pr-netcard-right { display: flex; flex-direction: column; gap: 4px; align-items: flex-end; margin-left: auto; }
.pr-netcard-amount { font-size: 2rem; font-weight: 800; color: var(--ink); font-variant-numeric: tabular-nums; letter-spacing: -0.01em; }
.pr-num { font-variant-numeric: tabular-nums; }

.pr-calc { display: flex; align-items: baseline; gap: 10px; font-size: 0.92rem; color: var(--ink); }
.pr-calc.is-bold { font-weight: 650; }
.pr-calc-line { min-width: 40px; font-size: 0.78rem; color: var(--text-dim); font-variant-numeric: tabular-nums; flex-shrink: 0; }
.pr-calc-label { flex: 1; min-width: 0; overflow-wrap: anywhere; }
.pr-calc-value { text-align: right; font-variant-numeric: tabular-nums; white-space: nowrap; padding-left: 12px; }
@media (max-width: 480px) {
  .pr-calc { flex-wrap: wrap; }
  .pr-calc-value { margin-left: auto; }
}

.pr-note { display: flex; gap: 8px; align-items: flex-start; font-size: 0.86rem; color: var(--text-dim); }
.pr-note .icon { color: var(--ink); margin-top: 2px; }

/* ---------- Payroll register (the app's PDF report, as a print view) ---------- */

.pr-register {
  background: #fff; color: #000; border: 1px solid var(--edge); border-radius: var(--radius-card);
  box-shadow: var(--shadow-card); padding: 28px 30px; font-size: 0.82rem; line-height: 1.4;
  -webkit-print-color-adjust: exact; print-color-adjust: exact;
}
.pr-reg-company { font-size: 1.45rem; font-weight: 700; }
.pr-reg-title { font-size: 1rem; font-weight: 600; color: #444; margin: 2px 0 8px; }
.pr-reg-detail { font-size: 0.8rem; margin-bottom: 2px; }
.pr-reg-fine { font-size: 0.8rem; color: #808080; margin-top: 2px; }
.pr-reg-rule { border: 0; border-top: 1px solid #000; margin: 10px 0 14px; }
.pr-reg-boxes { display: grid; grid-template-columns: repeat(5, minmax(0, 1fr)); gap: 10px; margin-bottom: 20px; }
.pr-reg-box { background: #f9f9f9; border: 0.6px solid #d1d1d1; border-radius: 6px; padding: 8px 10px; min-width: 0; }
.pr-reg-box-label { font-size: 0.64rem; font-weight: 600; color: #444; letter-spacing: 0.02em; }
.pr-reg-box-value { font-size: 1.2rem; font-weight: 700; font-variant-numeric: tabular-nums; overflow-wrap: anywhere; }
.pr-reg-box-detail { font-size: 0.68rem; color: #808080; }
.pr-reg-section { margin-bottom: 18px; }
.pr-reg-h { font-size: 0.96rem; font-weight: 600; margin-bottom: 4px; color: #000; }
.pr-reg-empty { font-size: 0.78rem; color: #808080; }
.pr-reg-table { width: 100%; border-collapse: collapse; font-size: 0.72rem; font-variant-numeric: tabular-nums; }
.pr-reg-table th {
  background: #ebebeb; color: #444; font-size: 0.6rem; font-weight: 600; text-align: left;
  padding: 3.5px 4px; white-space: nowrap;
}
.pr-reg-table td { padding: 3.5px 4px; vertical-align: top; white-space: pre-line; }
.pr-reg-table .num { text-align: right; white-space: pre; }
.pr-reg-table tbody tr:nth-child(even) td { background: #f6f6f6; }
.pr-reg-table tfoot td { font-weight: 600; border-top: 0.8px solid #000; }
.pr-reg-notes { list-style: none; margin: 0; padding: 0; font-size: 0.72rem; color: #444; }
.pr-reg-notes li { margin-bottom: 3px; }
.pr-reg-foot {
  display: flex; justify-content: space-between; gap: 12px; margin-top: 14px; padding-top: 5px;
  border-top: 0.5px solid #d1d1d1; font-size: 0.66rem; color: #808080;
}

@media (max-width: 760px) {
  .pr-register { padding: 18px 16px; }
  .pr-reg-boxes { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

/* Landscape US Letter, like the app's PDF, with "Page X of Y" where the
   browser supports page-margin boxes. */
@page payroll-register {
  size: letter landscape;
  margin: 0.5in;
  @bottom-right {
    content: "Page " counter(page) " of " counter(pages);
    font-size: 7.5pt;
    color: #808080;
  }
}

@media print {
  .pr-noprint { display: none !important; }
  .pr-register {
    page: payroll-register; border: 0; border-radius: 0; box-shadow: none; padding: 0; font-size: 8.5pt;
  }
  .pr-register .table-wrap { overflow: visible; }
  .pr-reg-boxes { grid-template-columns: repeat(5, minmax(0, 1fr)); }
  .pr-reg-table thead { display: table-header-group; }
  .pr-reg-table tfoot { display: table-row-group; }
  .pr-reg-table tr { break-inside: avoid; }
  .pr-reg-keep { break-inside: avoid; }
  .pr-reg-h { break-after: avoid; }
  .pr-box { box-shadow: none; border-color: #ccc; break-inside: avoid; }
}
