/* The admin lists and forms (docs/DESIGN.md "File ownership"): Boliger, Lejere, Gateways,
   Installationer, Fundne enheder, Afkodningsfejl, Revisionslog, API-nøgler, Administratorer,
   Brugere, Ejendomme, Importer målere, form pages and the secret-once pages.
   Every rule is scoped under .pg-al (shared by all of them) or the screen's own page class
   (.pg-units, .pg-tenants, …); the shared components live in components.css. */

/* ---- Data grids ------------------------------------------------------------ */
/* Row menu cell: the "…" button at the end of the row */
.pg-al .dg .menu-col, .pg-al .dg .menu-cell { width: 48px; padding-left: 0; padding-right: 8px; text-align: right; }
.pg-al .dg .menu-cell { overflow: visible; }
/* Secondary lines may wrap where the text is the content (messages, details) */
.pg-al .dg td.wrap { white-space: normal; padding-top: 8px; padding-bottom: 8px; }
.pg-al .dg td.wrap .second { white-space: normal; max-width: none; overflow: visible; text-overflow: clip; }
.pg-al .dg .mono-cell { font-family: var(--fontFamilyMonospace); font-size: var(--fontSizeBase200); }
.pg-al .dg tr.revoked td { color: var(--colorNeutralForeground3); }
.pg-al .dg tr.revoked .primary { color: var(--colorNeutralForeground3); font-weight: var(--fontWeightRegular); }
.pg-al .dg td .muted { color: var(--colorNeutralForeground3); }
.pg-al .dg .st { vertical-align: middle; }
.pg-al .dg .med { vertical-align: middle; }
.pg-al .page-head + * { margin-top: var(--spacingVerticalL); }
.pg-al .dg .line { display: block; line-height: 20px; }
.pg-al .card > .table-wrap:first-child { border-top: 0; border-radius: var(--borderRadiusXLarge) var(--borderRadiusXLarge) 0 0; }

/* The "…" menu: a native popover anchored to its button (the implicit anchor of the invoker;
   anchor() needs a named anchor, position-area does not). Without anchor positioning it opens
   where it sits in the cell. */
.pg-al .rowmenu { min-width: 220px; }
@supports (position-area: bottom) {
  .pg-al .rowmenu { position-area: bottom span-left; margin: 4px 0; position-try-fallbacks: flip-block; }
}

/* ---- Forms ----------------------------------------------------------------- */
.pg-form .form-card { max-width: 640px; }
.pg-form .form-card .card-body { padding: 20px; }
.pg-al .admin-form:not(.inline) { display: grid; gap: var(--spacingVerticalL); }
.pg-al .admin-form:not(.inline) .field { max-width: none; }
.pg-al .admin-form:not(.inline) > fluent-button[type="submit"] { justify-self: start; }
.pg-al .admin-form .form-error {
  padding: 8px 12px; border-radius: var(--borderRadiusMedium);
  background: var(--colorStatusDangerBackground1); color: var(--colorStatusDangerForeground1);
  border: 1px solid var(--colorStatusDangerBorder1);
}
.pg-al .form-actions { display: flex; align-items: center; gap: 8px; margin-top: var(--spacingVerticalXS); }
.pg-al .field-hint { margin-top: 2px; }

@media (max-width: 767px) {
  .pg-form .form-card .card-body { padding: 16px; }
  .pg-form .form-card { max-width: none; }
  .pg-al .form-actions fluent-button, .pg-al .form-actions fluent-anchor-button { flex: 1; }

  /* List rows (components.css "stackable"): status icon | name + second line | value | "…" */
  .pg-al .stackable .dg tbody tr { grid-template-columns: 20px auto auto minmax(0, 1fr) auto 32px; }
  .pg-al .stackable .dg td.m-a .second, .pg-al .stackable .dg td.m-st .second { display: none; }
  .pg-al .stackable .dg td.chev, .pg-al .stackable .dg td.menu-cell { display: block; grid-column: 6; grid-row: 1 / span 2; align-self: center; text-align: right; }
  .pg-al .stackable .dg td.menu-cell .iconbtn { margin-right: -4px; }
  /* A full-width third line (messages, details); a second-line cell without a partner has no separator */
  .pg-al .stackable .dg td.m-wide { grid-column: 1 / -1; grid-row: 3; white-space: normal; margin-top: 2px; }
  .pg-al .stackable .dg tr.group td { height: auto; }
  .pg-al .stackable .dg td.solo::after { content: none; }
  .pg-audit .stackable .dg td.m-name, .pg-decode .stackable .dg td.m-name { white-space: normal; }
  /* Lists without a status column: the name starts at the edge */
  .pg-al .stackable.ns .dg tbody tr { grid-template-columns: auto auto minmax(0, 1fr) auto 32px; }
  .pg-al .stackable.ns .dg td.m-name { grid-column: 1 / 4; }
  .pg-al .stackable.ns .dg td.m-a { grid-column: 1; }
  .pg-al .stackable.ns .dg td.m-b { grid-column: 2; }
  .pg-al .stackable.ns .dg td.m-val { grid-column: 4; }
  .pg-al .stackable.ns .dg td.m-seen { grid-column: 4; }
  .pg-al .stackable.ns .dg td.chev, .pg-al .stackable.ns .dg td.menu-cell { grid-column: 5; }
}

/* ---- Search box in a grid bar (Brugere) ------------------------------------ */
.pg-al .gridbar .searchbox { flex: 0 1 320px; }

/* ---- Import ------------------------------------------------------------------ */
.pg-import .stack { grid-template-columns: minmax(0, 1fr); max-width: 760px; }
.pg-import .form-card { max-width: none; }
.pg-import .example .t-body1s { margin-bottom: 8px; }
.pg-import pre {
  margin: 0; padding: 12px 16px; overflow-x: auto; border-radius: var(--borderRadiusMedium);
  background: var(--colorNeutralBackground3); color: var(--colorNeutralForeground1);
}
.pg-import .dg td code { color: var(--colorNeutralForeground2); }

/* ---- Pager (grid footer) ------------------------------------------------------ */
.pg-al .pager { justify-content: space-between; }
.pg-al .pager-page { margin: 0 auto; }
.pg-al .pager-link {
  display: inline-flex; align-items: center; gap: 4px; height: 32px; padding: 0 12px; border-radius: var(--borderRadiusMedium);
  border: 1px solid var(--colorNeutralStroke1); background: var(--colorNeutralBackground1); color: var(--colorNeutralForeground1);
}
.pg-al .pager-link:hover { background: var(--colorNeutralBackground1Hover); text-decoration: none; color: var(--colorNeutralForeground1); }

/* ---- Audit details and secret-once pages --------------------------------------- */
.pg-audit .audit-details { font-size: var(--fontSizeBase200); line-height: 16px; min-width: 12rem; }
.pg-audit .audit-details li { overflow-wrap: anywhere; }
.pg-audit .wrap-code { overflow-wrap: anywhere; color: var(--colorNeutralForeground2); }
.pg-audit .dg td.wrap:has(.wrap-code) { min-width: 10rem; }
.pg-decode .dg td.m-name { white-space: normal; min-width: 12rem; }
.pg-decode .dg td.m-wide { min-width: 10rem; }
.pg-secret .card-body { display: grid; gap: var(--spacingVerticalL); padding-top: 20px; }
.pg-secret .secret-once { max-width: 720px; border-left: 3px solid var(--colorStatusWarningBorderActive); }
.pg-secret .facts { display: grid; grid-template-columns: max-content minmax(0, 1fr); gap: 12px 24px; }
.pg-secret .facts dt { color: var(--colorNeutralForeground3); }
.pg-secret .facts code { font-size: var(--fontSizeBase300); overflow-wrap: anywhere; }
.pg-secret code.secret { user-select: all; padding: 2px 6px; border-radius: var(--borderRadiusSmall); background: var(--colorNeutralBackground3); }
@media (max-width: 599px) {
  .pg-secret .facts { grid-template-columns: minmax(0, 1fr); gap: 2px; }
  .pg-secret .facts dd { margin-bottom: 10px; }
}
@media (max-width: 767px) {
  .pg-al .gridbar .searchbox { flex: 1 1 180px; width: auto; }
}
