/* @udf/views — record management surfaces.
   Only what the components need; the design tokens come from @udf/ui. */

/* The workspace sizes itself from the space it is given, never from the
   viewport: an embedded view and a chat message are narrow containers on a wide
   screen, and a media query would get both wrong. */
.udf-record-workspace {
  display: grid;
  grid-template-columns: minmax(0, 1.15fr) minmax(0, 1fr);
  gap: 16px;
  align-items: start;
  min-width: 0;
  container-type: inline-size;
  container-name: udf-record;
}

.udf-toolbar {
  display: flex;
  gap: 8px;
  align-items: center;
  margin-bottom: 8px;
}

.udf-toolbar__spacer { flex: 1; }

.udf-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-bottom: 8px;
}

.udf-filters__item {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  color: var(--udf-muted, #667085);
}

.udf-filters__select {
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid var(--udf-border, #d0d5dd);
  background: var(--udf-surface, #fff);
  font-size: 12px;
}

.udf-records { display: flex; flex-direction: column; gap: 8px; min-width: 0; }

.udf-pager {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 8px;
  font-size: 12px;
}

.udf-record__header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding-bottom: 8px;
  border-bottom: 1px solid var(--udf-border, #eaecf0);
}

.udf-record__heading { display: flex; flex-direction: column; gap: 4px; min-width: 0; }

.udf-record__title {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  /* The title wraps: a record name is never truncated to an ellipsis in the
     space that exists to show it. Table cells ellipsise, headers do not. */
  overflow-wrap: anywhere;
}

.udf-details dd { overflow-wrap: anywhere; }

.udf-record__actions { display: flex; flex-wrap: wrap; gap: 6px; }

.udf-record__nav { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }

.udf-status {
  align-self: flex-start;
  padding: 1px 8px;
  border-radius: 999px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  background: var(--udf-chip, #f2f4f7);
  color: var(--udf-muted, #475467);
}

.udf-status--active { background: #e7f6ec; color: #14663a; }
.udf-status--draft { background: #fff6e5; color: #8a5b00; }
.udf-status--archived, .udf-status--retired { background: #f2f4f7; color: #667085; }
.udf-status--dormant { background: #eef2ff; color: #3538cd; }

.udf-sections { display: flex; flex-direction: column; gap: 14px; margin-top: 10px; }

.udf-section__title {
  margin: 0 0 6px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--udf-muted, #667085);
}

.udf-record-form { display: flex; flex-direction: column; gap: 10px; }

/* ── surfaces ─────────────────────────────────────────────────────────────── */
.udf-overlay {
  position: fixed;
  inset: 0;
  z-index: 60;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(16, 24, 40, 0.45);
}

.udf-overlay--drawer { justify-content: flex-end; }

.udf-surface {
  background: var(--udf-surface, #fff);
  border-radius: 12px;
  box-shadow: 0 24px 48px rgba(16, 24, 40, 0.18);
  width: min(560px, 94vw);
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.udf-surface--drawer {
  height: 100vh;
  max-height: 100vh;
  width: min(480px, 94vw);
  border-radius: 0;
}

.udf-surface__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--udf-border, #eaecf0);
}

.udf-surface__title { margin: 0; font-size: 15px; font-weight: 600; }

.udf-surface__body { padding: 16px; overflow: auto; }

.udf-page { display: flex; flex-direction: column; gap: 12px; height: 100%; }

.udf-page__header { display: flex; align-items: center; gap: 12px; }

.udf-page__title { margin: 0; font-size: 16px; font-weight: 600; }

@container udf-record (max-width: 720px) {
  .udf-record-workspace { grid-template-columns: minmax(0, 1fr); }
}

/* ── embedded and conversational contexts ───────────────────────────────────
   Same components, same behaviour: a detail replaces the list instead of
   sitting beside it, and the paddings shrink so a message can carry a record
   without taking the whole transcript. No fixed width or height is declared:
   the host owns the box. */
.udf-record-workspace--embedded,
.udf-record-workspace--message {
  grid-template-columns: minmax(0, 1fr);
  gap: 10px;
}

.udf-record-workspace--message .udf-panel { padding: 10px; }
.udf-record-workspace--message .udf-toolbar { margin-bottom: 6px; }
.udf-record-workspace--message .udf-record__header { gap: 8px; padding-bottom: 6px; }
.udf-record-workspace--message .udf-sections { gap: 10px; margin-top: 6px; }
.udf-record-workspace--message .udf-pager { justify-content: space-between; }

/* An inline surface is part of the host's flow: no overlay, no shadow, no
   backdrop and no minimum height. */
.udf-surface--inline {
  border: 1px solid var(--udf-border, #eaecf0);
  border-radius: 10px;
  background: inherit;
  box-shadow: none;
  width: auto;
  max-height: none;
  display: flex;
  flex-direction: column;
}

.udf-surface--inline .udf-surface__body { padding: 10px; }
