/* ============================================================
   layout.css — Page skeleton, header, structural containers.
   Handles ALL layout/spacing. No colours or component styles here.
   ============================================================ */

/* ── App wrapper ── */
.app {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  gap: var(--space-md);
}

.header-left {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.header-right {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: var(--space-xs);
}

/* ── Section cards (shared shell) ── */
.card {
  background: var(--color-card);
  border: 0.5px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.section-title {
  font-size: var(--font-size-xs);
  font-weight: 500;
  color: var(--color-text-muted);
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* ── Field group ── */
.field {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.field label {
  font-size: var(--font-size-sm);
  color: var(--color-text-muted);
}

/* ── Service bar ── */
/*
  3-column grid:  [service name] [service date] [week nav arrows]
  The week nav never shrinks below its natural width.
  The name column gets all leftover space.
  The date column has a sensible min-width so it never truncates.
*/
.service-fields {
  display: grid;
  grid-template-columns: 1fr minmax(150px, auto) auto;
  gap: var(--space-sm);
  align-items: end;
}

/* Week nav: arrows + label, always inline */
.week-nav {
  display: flex;
  align-items: center;
  gap: var(--space-xs);
  flex-shrink: 0;    /* never let this compress */
}

.week-nav button {
  flex-shrink: 0;
  width: 36px;
  height: 36px;
}

.week-label {
  min-width: 48px;   /* enough for "+10w" without wrapping */
  text-align: center;
  white-space: nowrap;
}

/* ── Add-person row ── */
/*
  5 items: [name] [role] [time] [status] [button]
  Auto-flow grid — wraps cleanly at any field count via the
  responsive rules below rather than hard-coded column indices.
*/
.add-row {
  display: grid;
  grid-template-columns: 1.2fr 1.2fr 0.8fr 0.9fr auto;
  gap: var(--space-sm);
  align-items: end;
}

/* ── Roster header ── */
.roster-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 0.5px solid var(--color-border);
  flex-wrap: wrap;
  gap: var(--space-sm);
}

.roster-actions {
  display: flex;
  gap: var(--space-sm);
  align-items: center;
}

/* ── Modal overlay ── */
.modal-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 100;
}

.modal {
  width: 100%;
  max-width: 440px;
  padding: 1.5rem;
  border-radius: var(--radius-lg);
}

.modal-fields {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  margin-bottom: 1.25rem;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
}

/* ============================================================
   Responsive breakpoints
   ============================================================ */

/* ── Tablet  (≤ 700px) ── */
@media (max-width: 700px) {
  /*
    Service bar: stack name on top, date + week-nav side by side below.
    This stops the date field from being squeezed.
  */
  .service-fields {
    grid-template-columns: 1fr auto;
    grid-template-rows: auto auto;
  }

  /* Service name spans the full width on row 1 */
  .service-fields .field:first-child {
    grid-column: 1 / -1;
  }

  /* Date field sits in column 1, row 2 */
  .service-fields .field:nth-child(2) {
    grid-column: 1;
  }

  /* Week nav sits beside the date field in column 2, row 2 */
  .service-fields .week-nav {
    grid-column: 2;
    align-self: end;
  }

  /* Add-row: two fields per row, button spans full width at the end */
  .add-row {
    grid-template-columns: 1fr 1fr;
  }

  .add-row .btn {
    grid-column: 1 / -1;
  }
}

/* ── Mobile (≤ 480px) ── */
@media (max-width: 480px) {
  .app {
    padding: 1rem 0.75rem 3rem;
  }

  /* Full-stack: every field on its own row */
  .service-fields {
    grid-template-columns: 1fr;
    grid-template-rows: unset;
  }

  .service-fields .field:first-child,
  .service-fields .field:nth-child(2) {
    grid-column: 1;
  }

  /* Week nav full width, centred, with a visible label */
  .service-fields .week-nav {
    grid-column: 1;
    justify-content: center;
    padding: 0.25rem 0;
  }

  /* Add-row: everything full width, stacked */
  .add-row {
    grid-template-columns: 1fr;
  }

  .add-row .btn {
    grid-column: 1;
  }

  /* Roster actions wrap cleanly */
  .roster-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .roster-actions {
    width: 100%;
    justify-content: space-between;
  }

  .filter-input {
    flex: 1;
    width: auto;
  }
}
