/* 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; }

/* ---- 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-section:not(:first-of-type) { margin-top: var(--spacingVerticalL); }
.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; }
/* The action label and the actor (an e-mail) wrap like the details, so a long label or
   address never pushes the table wider than its box. */
.pg-audit .dg td.m-name { white-space: normal; min-width: 11rem; }
.pg-audit .dg td.m-a { white-space: normal; overflow-wrap: anywhere; min-width: 9rem; }
.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; }
}

/* Rent: a bank fetch in the Bank card (admin/_rent_sync.html). The lines wrap on phones. */
.pg-rent .rent-sync { margin-top: var(--spacingVerticalS); }
.pg-rent .rent-sync .st { white-space: normal; align-items: flex-start; }
.pg-rent .rent-sync .st .i, .pg-rent .rent-sync fluent-spinner { flex: none; margin-top: 2px; }
.pg-rent .rent-sync fluent-spinner { --size: 16px; }
.pg-rent .sync-steps { list-style: none; margin: 0; padding: 0; display: grid; gap: var(--spacingVerticalXS); }
.pg-rent .sync-steps .st-none .st-word { color: var(--colorNeutralForeground3); }

/* Media of a building in a list (admin/_media.html). */
.pg-al .media-chips { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }
.pg-buildings .gridbar .bsel { flex: 0 1 240px; }

/* Rent regulation (§22): the actions stack in their cell; the deny form opens below. */
.pg-regulation .dg td.two > span { display: block; }
.pg-regulation .reg-acts { white-space: normal; max-width: 13rem; }
.pg-regulation .reg-acts > * { margin: 2px 4px 2px 0; vertical-align: middle; }
.pg-regulation .reg-deny { display: inline-block; }
.pg-regulation .reg-deny summary { cursor: pointer; padding: var(--spacingVerticalXS) var(--spacingHorizontalS); }
.pg-regulation .reg-deny[open] form { display: grid; gap: var(--spacingVerticalS); margin-top: var(--spacingVerticalS); max-width: 22rem; }
.pg-regulation .reg-later { margin: 0 0 var(--spacingVerticalXS); }
/* The total increase rows (as the economy totals) and "Gennemfør regulering" below. */
.pg-regulation .dg tfoot th { text-align: left; }
.pg-regulation .dg tfoot tr.total th, .pg-regulation .dg tfoot tr.total td {
  background: var(--colorNeutralBackground2); border-top: 1px solid var(--colorNeutralStroke1); border-bottom: 0;
  font-weight: var(--fontWeightSemibold);
}
.pg-regulation .reg-finalize { display: flex; justify-content: flex-end; }
@media (max-width: 767px) {
  /* List rows: name | new rent; unit · date | current rent; then "Gælder fra" or the
     decision (m-wide, line 3) and the actions (line 4), each across the row. No "…" column. */
  .pg-regulation .stackable.ns .dg tbody tr { grid-template-columns: auto auto minmax(0, 1fr) auto; }
  /* Narrow rows: the "Forfalden" tag goes under the date, the increase under the new rent. */
  .pg-regulation .stackable .dg td.m-b, .pg-regulation .stackable .dg td.m-val { white-space: normal; }
  .pg-regulation .stackable .dg td.m-wide .second { white-space: normal; }
  .pg-regulation .stackable .dg td.reg-acts {
    grid-column: 1 / -1; grid-row: 4; max-width: none; white-space: normal;
    display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px;
  }
  .pg-regulation .stackable .dg td.reg-acts:not(:has(*)) { display: none; }
  .pg-regulation .stackable .dg td.reg-acts > * { margin: 0; }
  .pg-regulation .stackable .reg-later, .pg-regulation .stackable .reg-deny[open] { flex-basis: 100%; }
  .pg-regulation .stackable .reg-later .st { white-space: normal; }
  .pg-regulation .stackable .reg-deny[open] form { max-width: none; }
  /* The totals: one row, label left and sum right, on the grey of the desktop total. */
  .pg-regulation .stackable .dg tfoot { display: block; }
  .pg-regulation .stackable .dg tfoot tr.total {
    display: flex; justify-content: space-between; gap: 8px; padding: 10px 12px 10px 16px;
    background: var(--colorNeutralBackground2); border-top: 1px solid var(--colorNeutralStroke1);
  }
  .pg-regulation .stackable .dg tfoot tr.total th, .pg-regulation .stackable .dg tfoot tr.total td {
    height: auto; padding: 0; border: 0; background: transparent; white-space: normal;
  }
  .pg-regulation .stackable .dg tfoot td:empty { display: none; }
}
