/* ============================================================
   The provider pages: the directory (/providers), credential verifications,
   availability windows, staff affiliations and the staff program map. Every
   one is built from design-system components; this sheet only places them.
   Structure in @layer layout, paint in @layer design.

   Each rule hangs on its page's domain-concept class and reads --t-* / --c-*
   tokens only. See frontend/app/README.md.
   ============================================================ */

@layer layout {
  /* ── /providers: the directory ── */
  .providers .controls { display: grid; gap: var(--t-space-3); }
  .providers .search,
  .providers .sort { display: flex; flex-wrap: wrap; align-items: end;
                     gap: var(--t-space-3); margin: 0; }
  .providers .search .field { flex: 1; min-inline-size: 12rem; }
  .providers .sort .field { min-inline-size: 12rem; }
  .providers .divider { align-self: stretch; min-block-size: 1.5rem;
                        border-inline-start-width: 1px; }

  /* The directory fills the content area for everyone. .app-screen caps a
     page outside the desk shell, which a participant's page is, to a phone
     column. */
  .providers { max-width: none; }
  .providers .bulk-form { display: grid; gap: var(--t-space-3); }
  .providers .bulk-bar { padding: var(--t-space-3) var(--t-space-4); border-radius: var(--t-radius-lg); }

  /* One card per provider, as width allows. */
  .providers .provider-list { display: grid; gap: var(--t-space-4); margin: 0; padding: 0;
                              list-style: none; grid-template-columns: 1fr; }
  @container (min-width: 38rem) { .providers .provider-list { grid-template-columns: repeat(2, 1fr); } }
  @container (min-width: 60rem) { .providers .provider-list { grid-template-columns: repeat(3, 1fr); } }

  .providers .provider-card > .body { gap: var(--t-space-2); }
  .providers .badges { display: flex; flex-wrap: wrap; gap: var(--t-space-1);
                       margin: 0; padding: 0; list-style: none; }
  .providers .provider-actions { display: flex; flex-wrap: wrap; gap: var(--t-space-2);
                                  margin-block-start: var(--t-space-1); }
  .providers .capacity { margin: 0; }
  .providers .capacity-meta { display: flex; align-items: center; justify-content: space-between;
                              gap: var(--t-space-2); margin: 0; }
  .providers .capacity-meta,
  .providers .capacity-label { font-size: var(--t-font-size-sm); }
  .providers .capacity-value,
  .providers .capacity-pct { font-weight: var(--t-font-weight-semibold); }
  .providers .capacity-detail { display: grid; gap: var(--t-space-2); }
  .providers .capacity-label { margin: 0; }
  .providers .programs { margin: 0; padding-inline-start: var(--t-space-4); }
  .providers .status { margin: 0; }
  .providers .blank-slate { padding: var(--t-space-8) var(--t-space-4); }

  /* The edit and add forms: two columns, with the long fields spanning both. */
  .providers .provider-form { display: grid; grid-template-columns: repeat(2, 1fr);
                              gap: var(--t-space-3); margin: 0; }
  .providers .provider-form .full { grid-column: 1 / -1; }
  @container (max-width: 30rem) { .providers .provider-form { grid-template-columns: 1fr; } }

  /* ── Credential verifications ── */
  .provider-verifications header { display: grid; gap: var(--t-space-3); }
  .provider-verifications header .back { justify-self: start; }

  /* ── Availability ── */
  .provider-availability .picker { display: flex; flex-wrap: wrap; align-items: end;
                                    gap: var(--t-space-3); }
  .provider-availability .picker .field { min-inline-size: 18rem; }
  .provider-availability .add-form { display: grid; gap: var(--t-space-3); }
  .provider-availability .deactivate { margin: 0; }

  /* ── Staff affiliations ── */
  .provider-staff-affiliations .grant-form,
  .provider-staff-affiliations .direct-form { display: grid; gap: var(--t-space-3); }
  .provider-staff-affiliations .direct-form { margin-block-start: var(--t-space-3); }
  .provider-staff-affiliations .revoke { margin-block-start: var(--t-space-3); }
  .provider-staff-affiliations .picker { display: grid; gap: var(--t-space-2); }
  /* The staff cards stack with a gap, so one card's edge never meets the next. */
  .provider-staff-affiliations .affiliation-list { display: grid; gap: var(--t-space-4); }

  /* ── Program map ── */
  .provider-map .map img { display: block; max-inline-size: 100%; block-size: auto; }
  .provider-map .filters { display: flex; flex-wrap: wrap; align-items: end;
                           gap: var(--t-space-3); }
  .provider-map .filters .field { min-inline-size: 12rem; }
  .provider-map .set-address-form,
  .provider-map .restrictions-form { display: grid; gap: var(--t-space-3); }
  .provider-map .restrictions { display: grid; gap: var(--t-space-2); }
  .provider-map .hint { margin: 0; font-size: var(--t-font-size-sm); }

  /* ── /admin/providers: the program-requirements editor ── */
  .admin-providers { display: grid; gap: var(--t-space-6); align-content: start; }
  .admin-providers .intro { display: flex; flex-wrap: wrap; align-items: flex-start;
                            justify-content: space-between; gap: var(--t-space-3); }

  .admin-providers .settings-form { display: grid; gap: var(--t-space-4); }

  /* Each capability is its own card; the section around them names the group. */
  .admin-providers .programs { display: grid; gap: var(--t-space-4); }

  /* The collapsible requirement matrix: one group of codes per disclosure. */
  .admin-providers .requirement-group { display: grid; gap: var(--t-space-3); }
  .admin-providers .requirement-group > summary { cursor: pointer;
                                                  font-weight: var(--t-font-weight-semibold); }

  .admin-providers .external-ref { margin: 0; font-size: var(--t-font-size-sm); }
}

@layer design {
  .providers .divider { border-inline-start-style: solid;
                        border-inline-start-color: var(--t-border); }

  /* Card details read as secondary text; the capacity figure stands out, and
     a load past the line is the error ink. */
  .providers .provider-card > .body > p { color: var(--c-surface-text-color-muted); }
  .providers .capacity-meta,
  .providers .capacity-label { color: var(--c-surface-text-color-muted); }
  .providers .capacity-value,
  .providers .capacity-pct { color: var(--c-surface-text-color-base); }
  .providers .capacity-value.high,
  .providers .capacity-pct.high { color: var(--c-surface-text-color-error); }

  .provider-map .hint { color: var(--c-surface-text-color-muted); }
}
