/* ==========================================================================
   Employee Workspace - header, tabs, read mode, history, checklists
   ==========================================================================

   Extends the Phase B component system. Cards, buttons, form fields, status
   pills, tables and alerts all come from components.css unchanged; what is
   added here is the vocabulary an employee record needs and an application
   screen does not.

   Load order: after components.css and reports.css, before main.css.
   Nothing here uses !important.
   ========================================================================== */

/* ==========================================================================
   1. HEADER
   ========================================================================== */

.employee-header {
  background: var(--surface-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-card);
  padding: var(--space-6) var(--space-7);
  margin-bottom: var(--space-6);
}

.employee-identity {
  display: flex;
  align-items: flex-start;
  gap: var(--space-5);
  flex-wrap: wrap;
}

/* Initials, replaced by a photograph when the employee has one (OM3.2). The
   initials are not a stopgap: they remain the rendering for every employee
   without a photo, and they are what shows while a photo is still decoding.
   The colour comes from the validated nominal categorical ramp, keyed on
   employee_id so a rename cannot recolour somebody. */
.employee-avatar {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex: none;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  color: var(--text-inverse);
  font-weight: var(--font-weight-headline);
  font-size: var(--type-card-title-size);
  letter-spacing: 0.02em;
}

.employee-avatar.is-small {
  width: 32px;
  height: 32px;
  font-size: var(--type-caption-size);
}

.avatar-slot-1 { background: var(--chart-cat-1); }
.avatar-slot-2 { background: var(--chart-cat-2); }
.avatar-slot-3 { background: var(--chart-cat-3); }
.avatar-slot-4 { background: var(--chart-cat-4); }
.avatar-slot-5 { background: var(--chart-cat-5); }
.avatar-slot-6 { background: var(--chart-cat-6); }

.employee-names {
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: var(--space-1);
  align-items: flex-start;
}

.employee-names h1 {
  margin: 0;
  overflow-wrap: anywhere;
}

.employee-legal-name,
.employee-role {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--type-body-sm-size);
}

.employee-meta {
  display: flex;
  flex-wrap: wrap;
  gap: var(--space-4) var(--space-8);
  margin-top: var(--space-5);
  padding-top: var(--space-5);
  border-top: 1px solid var(--border-default);
}

.employee-meta-item {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.employee-meta-label {
  font-size: var(--type-caption-size);
  font-weight: var(--font-weight-label);
  letter-spacing: var(--type-metric-label-tracking);
  text-transform: uppercase;
  color: var(--text-muted);
}

.employee-meta-value {
  font-size: var(--type-body-sm-size);
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.employee-meta-value a {
  color: var(--link-default);
  text-decoration: underline;
  text-underline-offset: 2px;
}

/* Where the record came from and when it last synced. In an application fed
   by import, that is part of the record. */
.employee-provenance {
  margin: var(--space-4) 0 0;
  font-size: var(--type-caption-size);
  color: var(--text-muted);
}

.employee-terminated-banner {
  margin: var(--space-5) 0 0;
}

/* ==========================================================================
   2. TABS
   ========================================================================== */

/* The tab bar is defined ONCE, in components.css, where `.workspace-tabs`
   and `.workspace-tab` are listed beside `.tab-bar`. Build 2 deleted the
   near-identical copy that used to live here: two tab treatments across
   two archetype pages is the page-specific fork this build forbids, and
   the shared one carries the frosted strip the renderings show.

   `aria-selected` was already set by employee-workspace.js, so the shared
   rule keyed on it needed no JavaScript change. */

/* ==========================================================================
   3. SECTIONS AND READ MODE
   ========================================================================== */

.employee-section {
  margin-bottom: var(--space-6);
}

.employee-section-head {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  flex-wrap: wrap;
}

.employee-section-head .card-title {
  margin: 0;
}

.employee-section-empty-count {
  font-size: var(--type-caption-size);
  color: var(--text-muted);
}

.employee-section-actions {
  margin-left: auto;
  display: flex;
  gap: var(--space-3);
}

/* Read mode is a definition list, not disabled inputs. Greyed-out controls
   read as broken rather than read-only, and they are noisier at a glance -
   which matters on a record with forty fields. */
.field-list {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: var(--space-5);
  margin: 0;
}

.field-row {
  min-width: 0;
}

.field-row-label {
  font-size: var(--type-caption-size);
  font-weight: var(--font-weight-label);
  letter-spacing: var(--type-metric-label-tracking);
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.field-row-value {
  margin: 0;
  font-size: var(--type-body-size);
  color: var(--text-primary);
  overflow-wrap: anywhere;
}

.field-row-value.is-empty {
  color: var(--text-muted);
  font-style: italic;
}

/* ==========================================================================
   4. DIRECT REPORTS
   ========================================================================== */

.direct-reports {
  list-style: none;
  margin: var(--space-4) 0 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: var(--space-3);
}

.direct-report {
  display: flex;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-3);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  min-height: 44px;
}

.direct-report:hover {
  border-color: var(--brand-primary);
  background: var(--brand-primary-subtle);
}

.direct-report-name {
  display: block;
  font-weight: var(--font-weight-label);
  color: var(--text-primary);
}

.direct-report-role {
  display: block;
  font-size: var(--type-caption-size);
  color: var(--text-muted);
}

/* ==========================================================================
   5. WORKFLOW CHECKLISTS
   ========================================================================== */

.workflow-progress {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  margin-bottom: var(--space-4);
  flex-wrap: wrap;
}

.workflow-progress-label {
  font-weight: var(--font-weight-label);
  min-width: 120px;
}

.workflow-progress-bar {
  flex: 1 1 200px;
  height: 10px;
  background: var(--surface-sunken);
  border-radius: var(--radius-pill);
  overflow: hidden;
}

.workflow-progress-fill {
  display: block;
  height: 100%;
  background: var(--brand-primary);
}

/* The count is text as well as a bar, so progress never depends on reading
   a graphic. */
.workflow-progress-count {
  font-size: var(--type-caption-size);
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}


/* ---- OM4.1: the checklist became editable ---------------------------- */


/* ---- OM4.2: the Task Center and checklist setup ---------------------- */


/* An overdue row is marked, but "Overdue" is also written into the row's
   text - never colour alone. */
/* Not prefixed with .data-table: employee.css must not redefine a shared
   component, and a test enforces it. `is-overdue` is this phase's own class,
   so scoping to the row is enough. */
tr.is-overdue td:first-child {
  box-shadow: inset 3px 0 0 var(--status-danger-text);
}

.card.is-overdue {
  border-left: 3px solid var(--status-danger-text);
}


.checklist-plan {
  margin-top: var(--space-4);
}


/* ==========================================================================
   6. HISTORY
   ========================================================================== */

.history-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  flex-wrap: wrap;
}

.history-controls {
  display: flex;
  align-items: flex-end;
  gap: var(--space-5);
  flex-wrap: wrap;
  margin: var(--space-4) 0 var(--space-6);
  padding-bottom: var(--space-5);
  border-bottom: 1px solid var(--border-default);
}

.history-view-toggle {
  display: flex;
  gap: var(--space-2);
}

.history-timeline {
  list-style: none;
  margin: 0;
  padding: 0 0 0 var(--space-6);
  border-left: 2px solid var(--border-default);
}

.history-event {
  position: relative;
  padding: 0 0 var(--space-7) var(--space-5);
}

.history-event::before {
  content: "";
  position: absolute;
  left: calc(var(--space-6) * -1 - 5px);
  top: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--brand-primary);
  border: 2px solid var(--surface-default);
}

.history-event-head {
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
}

.history-actor {
  font-weight: var(--font-weight-subhead);
  color: var(--text-primary);
}

/* A person and the importer are very different actors and must not look
   alike. The glyph carries that distinction alongside the wording. */
.history-actor-glyph {
  font-size: 0.8em;
}

.history-actor-glyph.actor-person { color: var(--brand-primary); }
.history-actor-glyph.actor-import { color: var(--chart-cat-2); }
.history-actor-glyph.actor-system { color: var(--text-muted); }
.history-actor-glyph.actor-unknown { color: var(--text-muted); }

.history-event-head time {
  font-size: var(--type-caption-size);
  color: var(--text-muted);
  cursor: help;
}

.history-event-summary {
  margin: var(--space-2) 0 0;
  font-size: var(--type-body-sm-size);
  color: var(--text-secondary);
}

.history-event-details {
  margin-top: var(--space-3);
}

.history-event-details > summary {
  cursor: pointer;
  font-size: var(--type-caption-size);
  font-weight: var(--font-weight-label);
  color: var(--brand-primary);
  min-height: 24px;
}

.history-fields {
  margin: var(--space-3) 0 0;
  padding: var(--space-4);
  background: var(--surface-sunken);
  border-radius: var(--radius-md);
}

.history-field-row {
  display: grid;
  grid-template-columns: minmax(140px, 1fr) 2fr;
  gap: var(--space-4);
  padding: var(--space-2) 0;
}

.history-field-row dt {
  font-size: var(--type-caption-size);
  font-weight: var(--font-weight-label);
  color: var(--text-muted);
}

.history-field-row dd {
  margin: 0;
  display: flex;
  align-items: baseline;
  gap: var(--space-3);
  flex-wrap: wrap;
  font-size: var(--type-body-sm-size);
}

.history-value.is-empty {
  color: var(--text-muted);
  font-style: italic;
}

.history-arrow {
  color: var(--text-muted);
}

.history-body > .btn {
  margin-top: var(--space-5);
}

/* ==========================================================================
   6B. PHOTO
   ==========================================================================

   The avatar is the same circle whether it holds initials or a face, so the
   image is sized to the circle rather than the circle to the image.
   `object-fit: cover` is what lets a 128px square render inside a 56px circle
   without stretching anybody's face.
   ========================================================================== */

.employee-avatar-image {
  display: block;
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

/* The slot colour stays underneath: it is what shows while the photo decodes,
   and it keeps a transparent source off the card surface. */
.employee-avatar.has-photo {
  overflow: hidden;
}

.photo-preview {
  display: flex;
  align-items: center;
  min-height: 160px;
  margin: var(--space-5) 0;
}

/* Square, matching the rendition's own shape - the 512px thumb is already
   cropped square by the server, so a non-square box here would letterbox it.
   Capped in width so a preview never pushes the controls off a narrow screen. */
.photo-preview-image {
  width: 256px;
  height: 256px;
  max-width: 100%;
  border: 1px solid var(--border-default);
  border-radius: var(--radius-md);
  object-fit: cover;
  background: var(--surface-sunken);
}

.photo-placeholder {
  margin: 0;
}

/* The file input is the real control and the label is only its appearance.
   The input keeps its place in the accessibility tree rather than being
   display:none, so the keyboard and assistive technology operate the input
   itself instead of a button pretending to be one. */
.photo-file-input {
  position: absolute;
  width: 1px;
  height: 1px;
  opacity: 0;
  overflow: hidden;
}

.photo-choose {
  position: relative;
  cursor: pointer;
}

/* Focus lands on the invisible input, so the visible label has to show it. */
.photo-choose:focus-within {
  outline: var(--focus-ring-width) solid var(--focus-ring);
  outline-offset: var(--focus-ring-offset);
}

.photo-choose.is-busy {
  opacity: 0.6;
  pointer-events: none;
}

/* Reserved height, so an arriving status message does not shift the buttons
   out from under the pointer. */
.photo-status {
  min-height: 1.35em;
  margin: var(--space-3) 0 0;
  color: var(--text-secondary);
}

.photo-status.is-error {
  color: var(--status-danger-text);
}


/* ==========================================================================
   6C. AVATARS IN LISTS AND ROSTERS
   ==========================================================================

   OM3.3. The same circle the Workspace header draws, at two smaller sizes:
   beside a name in a table, and above a name on a roster card. The colour
   slots and the image rule are shared with section 6B - one vocabulary, so a
   person looks the same wherever they appear.
   ========================================================================== */

/* The avatar-and-name unit is now `.identity-cell` in components.css,
   where it gained the second line the Directory rendering shows. The two
   rules that used to live here were orphaned by that move - nothing emits
   `.avatar-name` any more - and are deleted rather than left behind,
   because a dead rule is something a future page will find and use. */

.employee-avatar.is-roster {
  width: 96px;
  height: 96px;
  font-size: var(--type-section-title-size);
}

/* ------------------------------------------------------------- roster */

/* auto-fill rather than auto-fit: an office of four people should read as
   four cards at the left, not four cards stretched across a widescreen
   monitor. The track floor is what makes this responsive - the column count
   falls out of the available width with no breakpoint per size. */
.roster-grid {
  list-style: none;
  margin: 0;
  padding: 0;
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: var(--space-5);
}

.roster-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: var(--space-3);
  padding: var(--space-5) var(--space-4);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  background: var(--surface-default);
  text-align: center;
}

.roster-card-body {
  min-width: 0;
  width: 100%;
}

.roster-card-name {
  margin: 0;
  font-weight: var(--font-weight-label);
  overflow-wrap: anywhere;
}

.roster-card-title,
.roster-card-meta {
  margin: var(--space-1) 0 0;
  font-size: var(--type-body-sm-size);
  color: var(--text-muted);
  overflow-wrap: anywhere;
}


/* ==========================================================================
   6D. ROSTER SHEETS (OM3.4)
   ==========================================================================

   A sheet is the unit of layout, not a print detail. The screen stacks them,
   print breaks one per page, and image export captures one file per sheet -
   so what is on screen is what lands on a page and what lands in a file.

   The fixed 4-column grid here overrides section 6C's auto-fill grid, which
   is right for browsing search results and wrong for a page that has to
   paginate predictably at 24 cards.
   ========================================================================== */

.roster-sheet {
  background: var(--surface-default);
  border: 1px solid var(--border-default);
  border-radius: var(--radius-lg);
  padding: var(--space-6);
  margin-bottom: var(--space-6);
}

.roster-sheet-head {
  display: flex;
  align-items: baseline;
  justify-content: space-between;
  gap: var(--space-4);
  margin-bottom: var(--space-5);
  padding-bottom: var(--space-3);
  border-bottom: 1px solid var(--border-default);
}

.roster-sheet-head h2 {
  margin: 0;
  font-size: var(--type-section-title-size);
}

.roster-sheet-page {
  margin: 0;
  color: var(--text-muted);
  font-size: var(--type-body-sm-size);
}

/* 4 x 6. Fixed rather than auto-fill: the sheet must hold exactly 24 cards
   whatever the viewport, or the screen and the printed page disagree. */
.roster-sheet .roster-grid {
  grid-template-columns: repeat(4, 1fr);
}

.roster-builder .filters-bar {
  margin-bottom: var(--space-4);
}

.roster-checkbox {
  display: inline-flex;
  align-items: center;
  gap: var(--space-2);
}

.photo-status.is-error,
#rosterPrepareStatus.is-error {
  color: var(--status-danger-text);
}
/* ==========================================================================
   7. RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
  .employee-header {
    padding: var(--space-5);
  }

  .employee-avatar {
    width: 40px;
    height: 40px;
    font-size: var(--type-body-sm-size);
  }

  .employee-meta {
    gap: var(--space-4);
  }

  .employee-section-actions {
    margin-left: 0;
    width: 100%;
  }

  .employee-section-actions .btn {
    flex: 1 1 auto;
  }

  /* An audit entry is a self-contained record, not a row to compare
     against its neighbours - unlike a report table, where horizontal
     scrolling is kept precisely because column comparison IS the content.
     So here the field table stacks. No data is hidden; only the layout
     changes. */
  .history-field-row {
    grid-template-columns: 1fr;
    gap: var(--space-1);
  }

  .history-timeline {
    padding-left: var(--space-5);
  }

  .history-event {
    padding-left: var(--space-4);
  }

  .history-event::before {
    left: calc(var(--space-5) * -1 - 5px);
  }

  /* Two columns on a phone rather than one: a roster is scanned, and one
     face per screenful turns scanning into scrolling. */
  .roster-grid {
    grid-template-columns: repeat(auto-fill, minmax(132px, 1fr));
    gap: var(--space-4);
  }

  .employee-avatar.is-roster {
    width: 72px;
    height: 72px;
    font-size: var(--type-card-title-size);
  }

  /* The sheet holds 24 cards on paper regardless; on a phone the same 24
     reflow to two columns so they can be read, and the printed layout is
     restored by print.css. */
  .roster-sheet .roster-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .roster-sheet {
    padding: var(--space-4);
  }
}

/* ---------------------------------------------------------------------------
   Employee pager (UX Refresh req 7)

   Previous/next through the Directory, each naming the person it opens. At
   either end the control stays in place as disabled text rather than
   disappearing, so the row does not reflow and the boundary is stated.
   --------------------------------------------------------------------------- */

.employee-pager {
  display: flex;
  align-items: center;
  gap: var(--space-4);
  flex-wrap: wrap;
  margin-bottom: var(--space-4);
  font-size: var(--type-body-sm-size);
}

.employee-pager-link {
  color: var(--brand-primary);
  text-decoration: none;
}

.employee-pager-link:hover {
  text-decoration: underline;
}

.employee-pager-link.is-disabled {
  color: var(--text-muted);
  cursor: default;
}

.employee-pager-position {
  margin-left: auto;
  color: var(--text-muted);
}
